aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2019-06-07 12:13:14 +0530
committerHarsh Shandilya <msfjarvis@gmail.com>2019-07-28 12:07:04 +0530
commit699007c53b3b29bf798088254abd107ce6bae549 (patch)
tree17ddc51c62cae740c6a99915a34e7e2c63e67c23 /app/src/main
parente37ea38f014f16cc7353c47913ae97470ea23123 (diff)
PasswordStore: Clear some lint warnings and deprecated API
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index 6bf52d2f..44182602 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -175,7 +175,7 @@ public class PasswordStore extends AppCompatActivity {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_menu, menu);
searchItem = menu.findItem(R.id.action_search);
- searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
+ searchView = (SearchView) searchItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
@@ -304,16 +304,21 @@ public class PasswordStore extends AppCompatActivity {
PasswordRepository.initialize(this);
}
- File localDir = PasswordRepository.getRepositoryDirectory(getApplicationContext());
-
- localDir.mkdir();
+ final File localDir = PasswordRepository.getRepositoryDirectory(getApplicationContext());
try {
+ if (!localDir.mkdir())
+ throw new IllegalStateException("Failed to create directory!");
PasswordRepository.createRepository(localDir);
- new File(localDir.getAbsolutePath() + "/.gpg-id").createNewFile();
- settings.edit().putBoolean("repository_initialized", true).apply();
+ if (new File(localDir.getAbsolutePath() + "/.gpg-id").createNewFile()) {
+ settings.edit().putBoolean("repository_initialized", true).apply();
+ } else {
+ throw new IllegalStateException("Failed to initialize repository state.");
+ }
} catch (Exception e) {
e.printStackTrace();
- localDir.delete();
+ if (!localDir.delete()) {
+ Log.d(TAG, "Failed to delete local repository");
+ }
return;
}
checkLocalRepository();