Fix bad behavior with unhidden items in menu
This commit is contained in:
parent
bf207a77be
commit
7d8157c5e2
|
@ -1506,7 +1506,7 @@ public class Helper {
|
||||||
*/
|
*/
|
||||||
public static void changeUser(Activity activity, String userID, String instance, boolean notificationIntent) {
|
public static void changeUser(Activity activity, String userID, String instance, boolean notificationIntent) {
|
||||||
|
|
||||||
|
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
|
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
|
||||||
navigationView.getMenu().clear();
|
navigationView.getMenu().clear();
|
||||||
MainActivity.lastNotificationId = null;
|
MainActivity.lastNotificationId = null;
|
||||||
|
@ -1519,13 +1519,7 @@ public class Helper {
|
||||||
//Can happen when an account has been deleted and there is a click on an old notification
|
//Can happen when an account has been deleted and there is a click on an old notification
|
||||||
if( account == null)
|
if( account == null)
|
||||||
return;
|
return;
|
||||||
//Locked account can see follow request
|
|
||||||
if (account.isLocked()) {
|
|
||||||
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
|
|
||||||
} else {
|
|
||||||
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
|
|
||||||
}
|
|
||||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
if( !account.getToken().equals(token)){
|
if( !account.getToken().equals(token)){
|
||||||
FragmentManager fm = activity.getFragmentManager();
|
FragmentManager fm = activity.getFragmentManager();
|
||||||
|
@ -1533,6 +1527,7 @@ public class Helper {
|
||||||
fm.popBackStack();
|
fm.popBackStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
|
@ -2918,6 +2913,27 @@ public class Helper {
|
||||||
if( navigationView.getMenu().findItem(R.id.nav_follow_request) != null)
|
if( navigationView.getMenu().findItem(R.id.nav_follow_request) != null)
|
||||||
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
|
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
|
||||||
}
|
}
|
||||||
|
MenuItem news = navigationView.getMenu().findItem(R.id.nav_news);
|
||||||
|
if( news != null){
|
||||||
|
boolean display_news = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEWS_FROM_FEDILAB, true);
|
||||||
|
if( ! display_news ){
|
||||||
|
news.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
||||||
|
MenuItem adminItem = navigationView.getMenu().findItem(R.id.nav_administration);
|
||||||
|
if( adminItem != null){
|
||||||
|
adminItem.setVisible(false);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
boolean display_admin_menu = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_MENU + userID + instance, false);
|
||||||
|
if( !display_admin_menu){
|
||||||
|
MenuItem adminItem = navigationView.getMenu().findItem(R.id.nav_administration);
|
||||||
|
if( adminItem != null){
|
||||||
|
adminItem.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION + userID + instance, null);
|
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION + userID + instance, null);
|
||||||
|
|
Loading…
Reference in New Issue