1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-22 12:22:08 +01:00

Go to login page instead of podpage

This commit is contained in:
Gregor Santner 2016-10-07 04:29:32 +02:00
parent 64a9d02e7c
commit a2508e4df5
4 changed files with 49 additions and 36 deletions

View file

@ -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;
@ -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,6 +246,7 @@ 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
*/ */
@ -281,6 +282,7 @@ 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) {
@ -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)
@ -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());

View file

@ -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();
} }
} }

View file

@ -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

View file

@ -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);
} }