summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java13
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.java25
2 files changed, 26 insertions, 12 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index 146b9906..a08e7d88 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -50,16 +50,19 @@ public class PasswordStore extends ActionBarActivity {
File dir = null;
if (settings.getBoolean("git_external", false)) {
- if (settings.getString("git_external_repo", null) == null)
- {
- // todo: show the main screen
- } else {
+ if (settings.getString("git_external_repo", null) != null) {
dir = new File(settings.getString("git_external_repo", null));
}
} else {
dir = new File(getFilesDir() + "/store");
}
- assert dir != null;
+ // temp for debug
+ if (dir == null) {
+ Intent intent = new Intent(this, UserPreference.class);
+ intent.putExtra("operation", "git_external");
+ startActivity(intent);
+ return;
+ }
// uninitialize the repo if the dir does not exist or is absolutely empty
if (!dir.exists() || !dir.isDirectory()) {
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
index 2280019d..fbdc7d3d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
+++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
@@ -111,11 +111,7 @@ public class UserPreference extends AppCompatActivity {
});
findPreference("pref_select_external").setOnPreferenceClickListener((Preference pref) -> {
- Intent intent = new Intent(callingActivity, DirectoryChooserActivity.class);
- intent.putExtra(DirectoryChooserActivity.EXTRA_NEW_DIR_NAME,
- "passwordstore");
-
- startActivityForResult(intent, SELECT_GIT_DIRECTORY);
+ callingActivity.selectExternalGitRepository();
return true;
});
}
@@ -125,8 +121,15 @@ public class UserPreference extends AppCompatActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent() != null) {
- if ((getIntent().getStringExtra("operation") != null) && (getIntent().getStringExtra("operation").equals("get_ssh_key"))) {
- getSshKey();
+ if (getIntent().getStringExtra("operation") != null) {
+ switch (getIntent().getStringExtra("operation")) {
+ case "get_ssh_key":
+ getSshKey();
+ break;
+ case "git_external":
+ selectExternalGitRepository();
+ break;
+ }
}
}
@@ -136,6 +139,14 @@ public class UserPreference extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
+ public void selectExternalGitRepository() {
+ Intent intent = new Intent(this, DirectoryChooserActivity.class);
+ intent.putExtra(DirectoryChooserActivity.EXTRA_NEW_DIR_NAME,
+ "passwordstore");
+
+ startActivityForResult(intent, SELECT_GIT_DIRECTORY);
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will