Start the intro if the database file was not found

This commit is contained in:
Alexander Bakker 2017-11-26 19:27:03 +01:00
parent 41bafba596
commit f09d227378
2 changed files with 13 additions and 8 deletions

View file

@ -159,7 +159,6 @@ public class IntroActivity extends AppIntro {
setResult(RESULT_OK, result); setResult(RESULT_OK, result);
// skip the intro from now on // skip the intro from now on
// TODO: show the intro if we can't find any database files
SharedPreferences prefs = this.getSharedPreferences("me.impy.aegis", Context.MODE_PRIVATE); SharedPreferences prefs = this.getSharedPreferences("me.impy.aegis", Context.MODE_PRIVATE);
prefs.edit().putBoolean("passedIntro", true).apply(); prefs.edit().putBoolean("passedIntro", true).apply();
finish(); finish();

View file

@ -26,6 +26,7 @@ import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.UndeclaredThrowableException; import java.lang.reflect.UndeclaredThrowableException;
import java.util.ArrayList; import java.util.ArrayList;
@ -69,10 +70,6 @@ public class MainActivity extends AppCompatActivity {
} else { } else {
try { try {
_db.load(); _db.load();
} catch (Exception e) {
// TODO: feedback
throw new UndeclaredThrowableException(e);
}
if (!_db.isDecrypted()) { if (!_db.isDecrypted()) {
Intent intent = new Intent(this, AuthActivity.class); Intent intent = new Intent(this, AuthActivity.class);
intent.putExtra("slots", _db.getFile().getSlots()); intent.putExtra("slots", _db.getFile().getSlots());
@ -80,6 +77,15 @@ public class MainActivity extends AppCompatActivity {
} else { } else {
loadKeyProfiles(); loadKeyProfiles();
} }
} catch (FileNotFoundException e) {
// start the intro if the db file was not found
Toast.makeText(this, "Database file not found, starting over...", Toast.LENGTH_SHORT).show();
Intent intro = new Intent(this, IntroActivity.class);
startActivityForResult(intro, CODE_DO_INTRO);
} catch (Exception e) {
// TODO: feedback
throw new UndeclaredThrowableException(e);
}
} }
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);