Fix account change
This commit is contained in:
parent
2652827971
commit
282dc59a30
|
@ -148,7 +148,6 @@ import static fr.gouv.etalab.mastodon.asynctasks.ManageFiltersAsyncTask.action.G
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.ADD_USER_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.ADD_USER_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.BACKUP_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.BACKUP_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.BACK_TO_SETTINGS;
|
import static fr.gouv.etalab.mastodon.helper.Helper.BACK_TO_SETTINGS;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_USER_INTENT;
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.INSTANCE_NAME;
|
import static fr.gouv.etalab.mastodon.helper.Helper.INSTANCE_NAME;
|
||||||
|
@ -708,7 +707,9 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
tabLayout.addTab(tabHome);
|
tabLayout.addTab(tabHome);
|
||||||
tabLayout.addTab(tabNotif);
|
tabLayout.addTab(tabNotif);
|
||||||
tabPosition.put("home",0);
|
tabPosition.put("home",0);
|
||||||
|
typePosition.put(0, RetrieveFeedsAsyncTask.Type.HOME);
|
||||||
tabPosition.put("notifications",1);
|
tabPosition.put("notifications",1);
|
||||||
|
typePosition.put(1, RetrieveFeedsAsyncTask.Type.NOTIFICATION);
|
||||||
int i = 2;
|
int i = 2;
|
||||||
if( display_direct) {
|
if( display_direct) {
|
||||||
tabLayout.addTab(tabDirect);
|
tabLayout.addTab(tabDirect);
|
||||||
|
@ -1790,14 +1791,6 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
navigationView.setCheckedItem(R.id.nav_settings);
|
navigationView.setCheckedItem(R.id.nav_settings);
|
||||||
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
||||||
toolbarTitle.setText(R.string.settings);
|
toolbarTitle.setText(R.string.settings);
|
||||||
}else if( extras.getInt(INTENT_ACTION) == CHANGE_USER_INTENT){
|
|
||||||
unCheckAllMenuItems(navigationView);
|
|
||||||
if( tabLayout.getTabAt(0) != null)
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
tabLayout.getTabAt(0).select();
|
|
||||||
if( !toolbar_search.isIconified() ) {
|
|
||||||
toolbar_search.setIconified(true);
|
|
||||||
}
|
|
||||||
}else if (extras.getInt(INTENT_ACTION) == ADD_USER_INTENT){
|
}else if (extras.getInt(INTENT_ACTION) == ADD_USER_INTENT){
|
||||||
this.recreate();
|
this.recreate();
|
||||||
}else if( extras.getInt(INTENT_ACTION) == BACKUP_INTENT){
|
}else if( extras.getInt(INTENT_ACTION) == BACKUP_INTENT){
|
||||||
|
@ -2407,8 +2400,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
return notificationsFragment;
|
return notificationsFragment;
|
||||||
}else {
|
}else {
|
||||||
statusFragment = new DisplayStatusFragment();
|
statusFragment = new DisplayStatusFragment();
|
||||||
bundle.putSerializable("type", Helper.timelineType(position));
|
bundle.putSerializable("type", typePosition.get(position));
|
||||||
if( Helper.timelineType(position) == RetrieveFeedsAsyncTask.Type.TAG){
|
if( typePosition.get(position) == RetrieveFeedsAsyncTask.Type.TAG){
|
||||||
if( tabLayout.getTabAt(position) != null && tabLayout.getTabAt(position).getText() != null) {
|
if( tabLayout.getTabAt(position) != null && tabLayout.getTabAt(position).getText() != null) {
|
||||||
bundle.putString("tag", tabLayout.getTabAt(position).getText().toString());
|
bundle.putString("tag", tabLayout.getTabAt(position).getText().toString());
|
||||||
tagFragment.put(tabLayout.getTabAt(position).getText().toString(), statusFragment);
|
tagFragment.put(tabLayout.getTabAt(position).getText().toString(), statusFragment);
|
||||||
|
|
|
@ -74,7 +74,8 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
CACHE_BOOKMARKS_PEERTUBE,
|
CACHE_BOOKMARKS_PEERTUBE,
|
||||||
CACHE_STATUS,
|
CACHE_STATUS,
|
||||||
REMOTE_INSTANCE,
|
REMOTE_INSTANCE,
|
||||||
ART
|
ART,
|
||||||
|
NOTIFICATION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1263,12 +1263,11 @@ public class Helper {
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
editor.putString(Helper.PREF_INSTANCE, account.getInstance().trim());
|
editor.putString(Helper.PREF_INSTANCE, account.getInstance().trim());
|
||||||
editor.commit();
|
editor.commit();
|
||||||
activity.recreate();
|
Intent changeAccount = new Intent(activity, MainActivity.class);
|
||||||
if( checkItem ) {
|
changeAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
Intent intent = new Intent(activity, MainActivity.class);
|
activity.finish();
|
||||||
intent.putExtra(INTENT_ACTION, CHANGE_USER_INTENT);
|
activity.startActivity(changeAccount);
|
||||||
activity.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2638,9 +2637,12 @@ public class Helper {
|
||||||
allTabCount -=1;
|
allTabCount -=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int i = countInitialTab;
|
||||||
if( searches != null) {
|
if( searches != null) {
|
||||||
for (String search : searches) {
|
for (String search : searches) {
|
||||||
addTab(tableLayout, pagerAdapter, search);
|
addTab(tableLayout, pagerAdapter, search);
|
||||||
|
BaseMainActivity.typePosition.put(i, RetrieveFeedsAsyncTask.Type.TAG);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
if( searches.size() > 0 ){
|
if( searches.size() > 0 ){
|
||||||
tableLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
tableLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
||||||
|
@ -3089,13 +3091,6 @@ public class Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RetrieveFeedsAsyncTask.Type timelineType(int position){
|
|
||||||
if(MainActivity.typePosition.size() > position)
|
|
||||||
return MainActivity.typePosition.get(position);
|
|
||||||
else
|
|
||||||
return RetrieveFeedsAsyncTask.Type.TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean containsCaseInsensitive(String s, List<String> l){
|
public static boolean containsCaseInsensitive(String s, List<String> l){
|
||||||
for (String string : l){
|
for (String string : l){
|
||||||
if (string.equalsIgnoreCase(s)){
|
if (string.equalsIgnoreCase(s)){
|
||||||
|
|
Loading…
Reference in New Issue