mirror of
https://github.com/gsantner/dandelion
synced 2024-11-25 22:02:08 +01:00
Go to login page instead of podpage
This commit is contained in:
parent
64a9d02e7c
commit
a2508e4df5
4 changed files with 49 additions and 36 deletions
|
@ -60,7 +60,6 @@ import android.widget.Toast;
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
import com.github.dfa.diaspora_android.R;
|
import com.github.dfa.diaspora_android.R;
|
||||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||||
import com.github.dfa.diaspora_android.data.DiasporaPodList;
|
|
||||||
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||||
import com.github.dfa.diaspora_android.fragment.BrowserFragment;
|
import com.github.dfa.diaspora_android.fragment.BrowserFragment;
|
||||||
import com.github.dfa.diaspora_android.fragment.CustomFragment;
|
import com.github.dfa.diaspora_android.fragment.CustomFragment;
|
||||||
|
@ -179,7 +178,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!appSettings.hasPod()) {
|
if (!appSettings.hasPod()) {
|
||||||
AppLog.d(this, "We have no pod. Show PodSelectionFragment");
|
AppLog.d(this, "We have no pod. Show PodSelectionFragment");
|
||||||
showFragment(getFragment(PodSelectionFragment.TAG));
|
showFragment(getFragment(PodSelectionFragment.TAG));
|
||||||
} else {
|
} else {
|
||||||
|
@ -233,6 +232,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show DiasporaStreamFragment if necessary and load URL url
|
* Show DiasporaStreamFragment if necessary and load URL url
|
||||||
|
*
|
||||||
* @param url URL to load in the DiasporaStreamFragment
|
* @param url URL to load in the DiasporaStreamFragment
|
||||||
*/
|
*/
|
||||||
public void openDiasporaUrl(String url) {
|
public void openDiasporaUrl(String url) {
|
||||||
|
@ -246,12 +246,13 @@ public class MainActivity extends AppCompatActivity
|
||||||
* Get an instance of the CustomFragment with the tag fragmentTag.
|
* Get an instance of the CustomFragment with the tag fragmentTag.
|
||||||
* If there was no instance so far, create a new one and add it to the FragmentManagers pool.
|
* If there was no instance so far, create a new one and add it to the FragmentManagers pool.
|
||||||
* If there is no Fragment with the corresponding Tag, return null.
|
* If there is no Fragment with the corresponding Tag, return null.
|
||||||
|
*
|
||||||
* @param fragmentTag tag
|
* @param fragmentTag tag
|
||||||
* @return corresponding Fragment
|
* @return corresponding Fragment
|
||||||
*/
|
*/
|
||||||
protected CustomFragment getFragment(String fragmentTag) {
|
protected CustomFragment getFragment(String fragmentTag) {
|
||||||
CustomFragment fragment = (CustomFragment) fm.findFragmentByTag(fragmentTag);
|
CustomFragment fragment = (CustomFragment) fm.findFragmentByTag(fragmentTag);
|
||||||
if(fragment != null) {
|
if (fragment != null) {
|
||||||
return fragment;
|
return fragment;
|
||||||
} else {
|
} else {
|
||||||
switch (fragmentTag) {
|
switch (fragmentTag) {
|
||||||
|
@ -272,8 +273,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
fm.beginTransaction().add(psf, fragmentTag).commit();
|
fm.beginTransaction().add(psf, fragmentTag).commit();
|
||||||
return psf;
|
return psf;
|
||||||
default:
|
default:
|
||||||
AppLog.e(this,"Invalid Fragment Tag: "+fragmentTag
|
AppLog.e(this, "Invalid Fragment Tag: " + fragmentTag
|
||||||
+"\nAdd Fragments Tag to getFragment()'s switch case.");
|
+ "\nAdd Fragments Tag to getFragment()'s switch case.");
|
||||||
return getTopFragment();
|
return getTopFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,12 +282,13 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the Fragment fragment in R.id.fragment_container. If the fragment was already visible, do nothing.
|
* Show the Fragment fragment in R.id.fragment_container. If the fragment was already visible, do nothing.
|
||||||
|
*
|
||||||
* @param fragment Fragment to show
|
* @param fragment Fragment to show
|
||||||
*/
|
*/
|
||||||
protected void showFragment(CustomFragment fragment) {
|
protected void showFragment(CustomFragment fragment) {
|
||||||
AppLog.v(this, "showFragment()");
|
AppLog.v(this, "showFragment()");
|
||||||
CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container);
|
CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container);
|
||||||
if(currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
|
if (currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
|
||||||
AppLog.v(this, "Fragment was not visible. Replace it.");
|
AppLog.v(this, "Fragment was not visible. Replace it.");
|
||||||
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
@ -344,21 +346,6 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set visibility
|
|
||||||
Menu navMenu = navView.getMenu();
|
|
||||||
navMenu.findItem(R.id.nav_exit).setVisible(appSettings.isVisibleInNavExit());
|
|
||||||
navMenu.findItem(R.id.nav_activities).setVisible(appSettings.isVisibleInNavActivities());
|
|
||||||
navMenu.findItem(R.id.nav_aspects).setVisible(appSettings.isVisibleInNavAspects());
|
|
||||||
navMenu.findItem(R.id.nav_commented).setVisible(appSettings.isVisibleInNavCommented());
|
|
||||||
navMenu.findItem(R.id.nav_followed_tags).setVisible(appSettings.isVisibleInNavFollowed_tags());
|
|
||||||
navMenu.findItem(R.id.nav_about).setVisible(appSettings.isVisibleInNavHelp_license());
|
|
||||||
navMenu.findItem(R.id.nav_liked).setVisible(appSettings.isVisibleInNavLiked());
|
|
||||||
navMenu.findItem(R.id.nav_mentions).setVisible(appSettings.isVisibleInNavMentions());
|
|
||||||
navMenu.findItem(R.id.nav_profile).setVisible(appSettings.isVisibleInNavProfile());
|
|
||||||
navMenu.findItem(R.id.nav_public).setVisible(appSettings.isVisibleInNavPublic_activities());
|
|
||||||
// Hide all pod related options if no pod is selected
|
|
||||||
navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), appSettings.getPod() != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.main__topbar)
|
@OnClick(R.id.main__topbar)
|
||||||
|
@ -396,7 +383,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
loadUrl = intent.getDataString();
|
loadUrl = intent.getDataString();
|
||||||
AppLog.v(this, "Intent has a delicious URL for us: "+loadUrl);
|
AppLog.v(this, "Intent has a delicious URL for us: " + loadUrl);
|
||||||
}
|
}
|
||||||
} else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
|
} else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
|
||||||
AppLog.v(this, "Reset pod data and show PodSelectionFragment");
|
AppLog.v(this, "Reset pod data and show PodSelectionFragment");
|
||||||
|
@ -435,7 +422,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
AppLog.v(this, "onActivityResult(): "+requestCode);
|
AppLog.v(this, "onActivityResult(): " + requestCode);
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +440,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
private CustomFragment getTopFragment() {
|
private CustomFragment getTopFragment() {
|
||||||
Fragment top = fm.findFragmentById(R.id.fragment_container);
|
Fragment top = fm.findFragmentById(R.id.fragment_container);
|
||||||
if(top != null) {
|
if (top != null) {
|
||||||
return (CustomFragment) top;
|
return (CustomFragment) top;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -467,12 +454,12 @@ public class MainActivity extends AppCompatActivity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CustomFragment top = getTopFragment();
|
CustomFragment top = getTopFragment();
|
||||||
if(top != null) {
|
if (top != null) {
|
||||||
AppLog.v(this, "Top Fragment is not null");
|
AppLog.v(this, "Top Fragment is not null");
|
||||||
if(!top.onBackPressed()) {
|
if (!top.onBackPressed()) {
|
||||||
AppLog.v(this, "Top Fragment.onBackPressed was false");
|
AppLog.v(this, "Top Fragment.onBackPressed was false");
|
||||||
AppLog.v(this, "BackStackEntryCount: "+fm.getBackStackEntryCount());
|
AppLog.v(this, "BackStackEntryCount: " + fm.getBackStackEntryCount());
|
||||||
if(fm.getBackStackEntryCount()>0) {
|
if (fm.getBackStackEntryCount() > 0) {
|
||||||
fm.popBackStack();
|
fm.popBackStack();
|
||||||
} else {
|
} else {
|
||||||
snackbarExitApp.show();
|
snackbarExitApp.show();
|
||||||
|
@ -528,9 +515,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
toolbarBottom.setVisibility(View.VISIBLE);
|
toolbarBottom.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
CustomFragment top = getTopFragment();
|
CustomFragment top = getTopFragment();
|
||||||
if(top != null) {
|
if (top != null) {
|
||||||
//Are we displaying a Fragment other than PodSelectionFragment?
|
//Are we displaying a Fragment other than PodSelectionFragment?
|
||||||
if(!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
if (!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
||||||
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
||||||
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
|
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
|
||||||
top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
|
top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
|
||||||
|
@ -548,6 +535,21 @@ public class MainActivity extends AppCompatActivity
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
MenuItem item;
|
MenuItem item;
|
||||||
|
|
||||||
|
Menu navMenu = navView.getMenu();
|
||||||
|
navMenu.findItem(R.id.nav_exit).setVisible(appSettings.isVisibleInNavExit());
|
||||||
|
navMenu.findItem(R.id.nav_activities).setVisible(appSettings.isVisibleInNavActivities());
|
||||||
|
navMenu.findItem(R.id.nav_aspects).setVisible(appSettings.isVisibleInNavAspects());
|
||||||
|
navMenu.findItem(R.id.nav_commented).setVisible(appSettings.isVisibleInNavCommented());
|
||||||
|
navMenu.findItem(R.id.nav_followed_tags).setVisible(appSettings.isVisibleInNavFollowed_tags());
|
||||||
|
navMenu.findItem(R.id.nav_about).setVisible(appSettings.isVisibleInNavHelp_license());
|
||||||
|
navMenu.findItem(R.id.nav_liked).setVisible(appSettings.isVisibleInNavLiked());
|
||||||
|
navMenu.findItem(R.id.nav_mentions).setVisible(appSettings.isVisibleInNavMentions());
|
||||||
|
navMenu.findItem(R.id.nav_profile).setVisible(appSettings.isVisibleInNavProfile());
|
||||||
|
navMenu.findItem(R.id.nav_public).setVisible(appSettings.isVisibleInNavPublic_activities());
|
||||||
|
if (appSettings.getPod() == null) {
|
||||||
|
navMenu.setGroupVisible(navView.getMenu().findItem(R.id.nav_exit).getGroupId(), false);
|
||||||
|
}
|
||||||
|
|
||||||
if ((item = menu.findItem(R.id.action_notifications)) != null) {
|
if ((item = menu.findItem(R.id.action_notifications)) != null) {
|
||||||
LayerDrawable icon = (LayerDrawable) item.getIcon();
|
LayerDrawable icon = (LayerDrawable) item.getIcon();
|
||||||
BadgeDrawable.setBadgeCount(this, icon, podUserProfile.getNotificationCount());
|
BadgeDrawable.setBadgeCount(this, icon, podUserProfile.getNotificationCount());
|
||||||
|
@ -757,8 +759,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCustomTabsConnected() {
|
public void onCustomTabsConnected() {
|
||||||
if(customTabsSession == null) {
|
if (customTabsSession == null) {
|
||||||
AppLog.i(this, "CustomTabs warmup: "+customTabActivityHelper.warmup(0));
|
AppLog.i(this, "CustomTabs warmup: " + customTabActivityHelper.warmup(0));
|
||||||
customTabsSession = customTabActivityHelper.getSession();
|
customTabsSession = customTabActivityHelper.getSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,6 @@ public class PodSelectionFragment extends CustomFragment implements SearchView.O
|
||||||
public void onPodSelectionDialogResult(DiasporaPod pod, boolean accepted) {
|
public void onPodSelectionDialogResult(DiasporaPod pod, boolean accepted) {
|
||||||
System.out.println(accepted + ": " + pod.toString());
|
System.out.println(accepted + ": " + pod.toString());
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
//TODO: Rework for new pod url system ;)
|
|
||||||
app.getSettings().setPod(pod);
|
app.getSettings().setPod(pod);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -232,7 +231,10 @@ public class PodSelectionFragment extends CustomFragment implements SearchView.O
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
((MainActivity) getActivity()).openDiasporaUrl(new DiasporaUrlHelper(appSettings).getPodUrl());
|
MainActivity mainActivity = (MainActivity) getActivity();
|
||||||
|
DiasporaUrlHelper urlHelper = new DiasporaUrlHelper(appSettings);
|
||||||
|
mainActivity.openDiasporaUrl(urlHelper.getSignInUrl());
|
||||||
|
mainActivity.invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class DiasporaUrlHelper {
|
||||||
public static final String SUBURL_STATISTICS = "/statistics";
|
public static final String SUBURL_STATISTICS = "/statistics";
|
||||||
public static final String SUBURL_PERSONAL_SETTINGS = "/user/edit";
|
public static final String SUBURL_PERSONAL_SETTINGS = "/user/edit";
|
||||||
public static final String SUBURL_MANAGE_TAGS = "/tag_followings/manage";
|
public static final String SUBURL_MANAGE_TAGS = "/tag_followings/manage";
|
||||||
|
public static final String SUBURL_SIGN_IN = "/users/sign_in";
|
||||||
public static final String SUBURL_MANAGE_CONTACTS = "/contacts";
|
public static final String SUBURL_MANAGE_CONTACTS = "/contacts";
|
||||||
public static final String URL_BLANK = "about:blank";
|
public static final String URL_BLANK = "about:blank";
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ public class DiasporaUrlHelper {
|
||||||
public String getPodUrl() {
|
public String getPodUrl() {
|
||||||
DiasporaPod pod = settings.getPod();
|
DiasporaPod pod = settings.getPod();
|
||||||
if (pod != null){
|
if (pod != null){
|
||||||
return settings.getPod().getPodUrl().getBaseUrl();
|
return pod.getPodUrl().getBaseUrl();
|
||||||
}
|
}
|
||||||
return "http://127.0.0.1";
|
return "http://127.0.0.1";
|
||||||
|
|
||||||
|
@ -220,6 +221,14 @@ public class DiasporaUrlHelper {
|
||||||
return getPodUrl() + SUBURL_STATISTICS;
|
return getPodUrl() + SUBURL_STATISTICS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a url that points to the sign in page of the pod.
|
||||||
|
* @return https://(pod-domain.tld)/users/sign_in
|
||||||
|
*/
|
||||||
|
public String getSignInUrl() {
|
||||||
|
return getPodUrl() + SUBURL_SIGN_IN;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a url that points to the personal settings page of the pod.
|
* Return a url that points to the personal settings page of the pod.
|
||||||
* @return https://(pod-domain.tld)/user/edit
|
* @return https://(pod-domain.tld)/user/edit
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class DiasporaStreamWebChromeClient extends FileUploadWebChromeClient {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(WebView wv, int progress) {
|
public void onProgressChanged(WebView wv, int progress) {
|
||||||
super.onProgressChanged(wv, progress);
|
super.onProgressChanged(wv, progress);
|
||||||
if (progress > 0 && progress <= 60) {
|
if (progress > 10 && progress <= 60) {
|
||||||
WebHelper.getUserProfile(wv);
|
WebHelper.getUserProfile(wv);
|
||||||
WebHelper.optimizeMobileSiteLayout(wv);
|
WebHelper.optimizeMobileSiteLayout(wv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue