Browse Source

Fixed home/toggle eula

main
M66B 6 years ago
parent
commit
553a467ca0
1 changed files with 13 additions and 9 deletions
  1. +13
    -9
      app/src/main/java/eu/faircode/email/ActivityView.java

+ 13
- 9
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -31,7 +31,6 @@ import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
@ -135,6 +134,14 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
Log.i(Helper.TAG, "View post create"); Log.i(Helper.TAG, "View post create");
super.onPostCreate(savedInstanceState); super.onPostCreate(savedInstanceState);
drawerToggle.syncState(); drawerToggle.syncState();
syncState();
}
private void syncState() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean eula = prefs.getBoolean("eula", false);
int count = getSupportFragmentManager().getBackStackEntryCount();
drawerToggle.setDrawerIndicatorEnabled(count == 1 && eula);
} }
@Override @Override
@ -175,8 +182,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
Log.i(Helper.TAG, "View configuration changed"); Log.i(Helper.TAG, "View configuration changed");
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
drawerToggle.onConfigurationChanged(newConfig); drawerToggle.onConfigurationChanged(newConfig);
int count = getSupportFragmentManager().getBackStackEntryCount();
drawerToggle.setDrawerIndicatorEnabled(count == 1);
syncState();
} }
@Override @Override
@ -200,7 +206,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
int count = getSupportFragmentManager().getBackStackEntryCount(); int count = getSupportFragmentManager().getBackStackEntryCount();
if (count == 0) if (count == 0)
finish(); finish();
drawerToggle.setDrawerIndicatorEnabled(count == 1);
syncState();
} }
@Override @Override
@ -246,6 +252,8 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getBoolean("eula", false)) { if (prefs.getBoolean("eula", false)) {
getSupportFragmentManager().popBackStack(); // eula
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("folder", -1); args.putLong("folder", -1);
@ -256,10 +264,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("unified"); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("unified");
fragmentTransaction.commit(); fragmentTransaction.commit();
Fragment eula = getSupportFragmentManager().findFragmentByTag("eula");
if (eula != null)
getSupportFragmentManager().beginTransaction().remove(eula).commit();
DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() { DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
@Override @Override
public void onChanged(@Nullable List<EntityAccount> accounts) { public void onChanged(@Nullable List<EntityAccount> accounts) {
@ -271,7 +275,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}); });
} else { } else {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentEula(), "eula");
fragmentTransaction.replace(R.id.content_frame, new FragmentEula()).addToBackStack("eula");
fragmentTransaction.commit(); fragmentTransaction.commit();
} }
} }


Loading…
Cancel
Save