mirror of
https://github.com/gsantner/dandelion
synced 2024-11-25 05:42:10 +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.R;
|
||||
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.fragment.BrowserFragment;
|
||||
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
|
||||
*
|
||||
* @param url URL to load in the DiasporaStreamFragment
|
||||
*/
|
||||
public void openDiasporaUrl(String url) {
|
||||
|
@ -246,6 +246,7 @@ public class MainActivity extends AppCompatActivity
|
|||
* 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 is no Fragment with the corresponding Tag, return null.
|
||||
*
|
||||
* @param fragmentTag tag
|
||||
* @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.
|
||||
*
|
||||
* @param fragment Fragment to show
|
||||
*/
|
||||
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)
|
||||
|
@ -548,6 +535,21 @@ public class MainActivity extends AppCompatActivity
|
|||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
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) {
|
||||
LayerDrawable icon = (LayerDrawable) item.getIcon();
|
||||
BadgeDrawable.setBadgeCount(this, icon, podUserProfile.getNotificationCount());
|
||||
|
|
|
@ -215,7 +215,6 @@ public class PodSelectionFragment extends CustomFragment implements SearchView.O
|
|||
public void onPodSelectionDialogResult(DiasporaPod pod, boolean accepted) {
|
||||
System.out.println(accepted + ": " + pod.toString());
|
||||
if (accepted) {
|
||||
//TODO: Rework for new pod url system ;)
|
||||
app.getSettings().setPod(pod);
|
||||
|
||||
try {
|
||||
|
@ -232,7 +231,10 @@ public class PodSelectionFragment extends CustomFragment implements SearchView.O
|
|||
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_PERSONAL_SETTINGS = "/user/edit";
|
||||
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 URL_BLANK = "about:blank";
|
||||
|
||||
|
@ -68,7 +69,7 @@ public class DiasporaUrlHelper {
|
|||
public String getPodUrl() {
|
||||
DiasporaPod pod = settings.getPod();
|
||||
if (pod != null){
|
||||
return settings.getPod().getPodUrl().getBaseUrl();
|
||||
return pod.getPodUrl().getBaseUrl();
|
||||
}
|
||||
return "http://127.0.0.1";
|
||||
|
||||
|
@ -220,6 +221,14 @@ public class DiasporaUrlHelper {
|
|||
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 https://(pod-domain.tld)/user/edit
|
||||
|
|
|
@ -21,7 +21,7 @@ public class DiasporaStreamWebChromeClient extends FileUploadWebChromeClient {
|
|||
@Override
|
||||
public void onProgressChanged(WebView wv, int progress) {
|
||||
super.onProgressChanged(wv, progress);
|
||||
if (progress > 0 && progress <= 60) {
|
||||
if (progress > 10 && progress <= 60) {
|
||||
WebHelper.getUserProfile(wv);
|
||||
WebHelper.optimizeMobileSiteLayout(wv);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue