Do not show splash screen when signed in

This commit is contained in:
Torsten Grote
2018-02-26 15:46:51 -03:00
parent 6fbaae0e5e
commit 9f02bbbba1
5 changed files with 19 additions and 18 deletions

View File

@@ -94,6 +94,7 @@ public class AppModule {
@Override
public boolean databaseExists() {
// FIXME should not run on UiThread #620
if (!dir.isDirectory()) return false;
File[] files = dir.listFiles();
return files != null && files.length > 0;

View File

@@ -17,4 +17,7 @@ public interface ConfigController {
void deleteAccount(Context ctx);
boolean accountExists();
boolean accountSignedIn();
}

View File

@@ -52,4 +52,10 @@ public class ConfigControllerImpl implements ConfigController {
String hex = getEncryptedDatabaseKey();
return hex != null && databaseConfig.databaseExists();
}
@Override
public boolean accountSignedIn() {
return databaseConfig.getEncryptionKey() != null;
}
}

View File

@@ -46,8 +46,6 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static android.os.Build.MANUFACTURER;
import static android.os.Build.VERSION.SDK_INT;
import static android.support.v4.app.FragmentManager.POP_BACK_STACK_INCLUSIVE;
import static android.support.v4.view.GravityCompat.START;
import static android.support.v4.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
@@ -214,18 +212,6 @@ public class NavDrawerActivity extends BriarActivity implements
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(START)) {
drawerLayout.closeDrawer(START);
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
getSupportFragmentManager()
.findFragmentByTag(ContactListFragment.TAG) != null) {
if (SDK_INT == 19 && MANUFACTURER.equalsIgnoreCase("Samsung")) {
// workaround for #1116 causes splash screen to show again
super.onBackPressed();
} else {
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
getSupportFragmentManager()
.findFragmentByTag(ContactListFragment.TAG) == null) {

View File

@@ -43,10 +43,15 @@ public class SplashScreenActivity extends BaseActivity {
setContentView(R.layout.splash);
new Handler().postDelayed(() -> {
startNextActivity();
supportFinishAfterTransition();
}, 500);
if (configController.accountSignedIn()) {
startActivity(new Intent(this, NavDrawerActivity.class));
finish();
} else {
new Handler().postDelayed(() -> {
startNextActivity();
supportFinishAfterTransition();
}, 500);
}
}
@Override