aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohamed Zenadi <mohamed@zenadi.com>2015-05-03 13:10:53 +0200
committerMohamed Zenadi <mohamed@zenadi.com>2015-05-17 18:54:28 +0200
commit4975dfdcfaef453f564eb2dadca7580e47a3d2a6 (patch)
tree09051af478db9773e8d2141ed97078ee14fbe9ac
parent4e5c64913d41397df46fef5aed23c0bb9b8bb5bd (diff)
force the selection of directory until the welcome screen is implemented
-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