Browse Source

Fixed setup closing on config change

main
M66B 6 years ago
parent
commit
fec647a7ee
2 changed files with 16 additions and 9 deletions
  1. +16
    -1
      app/src/main/java/eu/faircode/email/ActivitySetup.java
  2. +0
    -8
      app/src/main/java/eu/faircode/email/FragmentSetup.java

+ 16
- 1
app/src/main/java/eu/faircode/email/ActivitySetup.java View File

@ -26,11 +26,16 @@ import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem; import android.view.MenuItem;
import java.util.List;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
public class ActivitySetup extends ActivityBase implements FragmentManager.OnBackStackChangedListener { public class ActivitySetup extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
boolean hasAccount;
static final String ACTION_EDIT_ACCOUNT = BuildConfig.APPLICATION_ID + ".EDIT_ACCOUNT"; static final String ACTION_EDIT_ACCOUNT = BuildConfig.APPLICATION_ID + ".EDIT_ACCOUNT";
static final String ACTION_EDIT_IDENTITY = BuildConfig.APPLICATION_ID + ".EDIT_IDENTITY"; static final String ACTION_EDIT_IDENTITY = BuildConfig.APPLICATION_ID + ".EDIT_IDENTITY";
@ -48,6 +53,13 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
fragmentTransaction.replace(R.id.content_frame, new FragmentSetup()).addToBackStack("setup"); fragmentTransaction.replace(R.id.content_frame, new FragmentSetup()).addToBackStack("setup");
fragmentTransaction.commit(); fragmentTransaction.commit();
} }
DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
@Override
public void onChanged(List<EntityAccount> accounts) {
hasAccount = (accounts != null && accounts.size() > 0);
}
});
} }
@Override @Override
@ -79,8 +91,11 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
@Override @Override
public void onBackStackChanged() { public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0)
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
if (hasAccount)
startActivity(new Intent(this, ActivityView.class).putExtra("setup", true));
finish(); finish();
}
} }
BroadcastReceiver receiver = new BroadcastReceiver() { BroadcastReceiver receiver = new BroadcastReceiver() {


+ 0
- 8
app/src/main/java/eu/faircode/email/FragmentSetup.java View File

@ -21,7 +21,6 @@ package eu.faircode.email;
import android.Manifest; import android.Manifest;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
@ -208,13 +207,6 @@ public class FragmentSetup extends FragmentEx {
}); });
} }
@Override
public void onDestroy() {
if (tvAccountDone.getVisibility() == View.VISIBLE)
startActivity(new Intent(getContext(), ActivityView.class).putExtra("setup", true));
super.onDestroy();
}
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
boolean has = (grantResults.length > 0); boolean has = (grantResults.length > 0);


Loading…
Cancel
Save