Add some toast

This commit is contained in:
Alexander Bakker 2017-11-27 21:06:23 +01:00
parent ca68f0525d
commit daf81e02e6
4 changed files with 22 additions and 17 deletions

View file

@ -86,7 +86,7 @@ public class CustomAuthenticatedSlide extends Fragment implements FingerprintUiH
if (_storeHandle == null) {
_storeHandle = new KeyStoreHandle();
}
// TODO: consider regenerating the key if it exists
// TODO: consider regenerating the key here if it already exists
if (!_storeHandle.keyExists()) {
key = _storeHandle.generateKey(true);
} else {

View file

@ -18,7 +18,6 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import me.impy.aegis.helpers.ItemTouchHelperAdapter;

View file

@ -81,7 +81,8 @@ public class MainActivity extends AppCompatActivity {
Intent intro = new Intent(this, IntroActivity.class);
startActivityForResult(intro, CODE_DO_INTRO);
} catch (Exception e) {
// TODO: feedback
e.printStackTrace();
Toast.makeText(this, "An error occurred while trying to deserialize the database", Toast.LENGTH_LONG).show();
throw new UndeclaredThrowableException(e);
}
}
@ -213,7 +214,7 @@ public class MainActivity extends AppCompatActivity {
_db.addKey(entry);
} catch (Exception e) {
e.printStackTrace();
// TODO: feedback
Toast.makeText(this, "An error occurred while trying to add an entry", Toast.LENGTH_SHORT).show();
return;
}
@ -235,8 +236,10 @@ public class MainActivity extends AppCompatActivity {
_db.setMasterKey(key);
}
} catch (Exception e) {
// TODO: feedback
throw new UndeclaredThrowableException(e);
e.printStackTrace();
Toast.makeText(this, "An error occurred while trying to load/decrypt the database", Toast.LENGTH_LONG).show();
recreate();
return;
}
loadKeyProfiles();
@ -247,8 +250,10 @@ public class MainActivity extends AppCompatActivity {
try {
_db.setMasterKey(key);
} catch (Exception e) {
// TODO: feedback
throw new UndeclaredThrowableException(e);
e.printStackTrace();
Toast.makeText(this, "An error occurred while trying to decrypt the database", Toast.LENGTH_LONG).show();
recreate();
return;
}
loadKeyProfiles();
@ -315,14 +320,13 @@ public class MainActivity extends AppCompatActivity {
_db.removeKey(profile.getEntry());
} catch (Exception e) {
e.printStackTrace();
//TODO: feedback
Toast.makeText(this, "An error occurred while trying to delete an entry", Toast.LENGTH_SHORT).show();
return;
}
_keyProfiles.remove(_clickedItemPosition);
_keyProfileAdapter.notifyItemRemoved(_clickedItemPosition);
})
.setNegativeButton(android.R.string.no, (dialog, which) -> {
})
.setNegativeButton(android.R.string.no, null)
.show();
}
@ -420,8 +424,8 @@ public class MainActivity extends AppCompatActivity {
try {
_db.save();
} catch (Exception e) {
//TODO: feedback
throw new UndeclaredThrowableException(e);
e.printStackTrace();
Toast.makeText(this, "An error occurred while trying to save the database", Toast.LENGTH_LONG).show();
}
}
@ -432,14 +436,16 @@ public class MainActivity extends AppCompatActivity {
for (DatabaseEntry entry : _db.getKeys()) {
_keyProfiles.add(new KeyProfile(entry));
}
_keyProfileAdapter.notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "An error occurred while trying to load database entries", Toast.LENGTH_SHORT).show();
return;
}
Collections.sort(_keyProfiles, (p1, p2) -> {
return p1.getEntry().getOrder() >= p2.getEntry().getOrder() ? 1 : -1;
});
_keyProfileAdapter.notifyDataSetChanged();
}
private void updateLockIcon() {

View file

@ -40,16 +40,16 @@ public class Database {
}
}
public void addKey(DatabaseEntry entry) throws Exception {
public void addKey(DatabaseEntry entry) {
entry.setID(_entries.size() + 1);
_entries.add(entry);
}
public void removeKey(DatabaseEntry entry) throws Exception {
public void removeKey(DatabaseEntry entry) {
_entries.remove(entry);
}
public List<DatabaseEntry> getKeys() throws Exception {
public List<DatabaseEntry> getKeys() {
return _entries;
}
}