aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml3
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.java21
-rw-r--r--app/src/main/res/color/text_color.xml5
-rw-r--r--app/src/main/res/values/styles.xml2
-rw-r--r--app/src/main/res/xml/preference.xml7
5 files changed, 35 insertions, 3 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cc21dc54..e3e0837e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -30,9 +30,12 @@
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="com.zeapo.pwdstore.PasswordStore" />
</activity>
+
+ <activity android:name="net.rdrei.android.dirchooser.DirectoryChooserActivity" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
index 0b7f3640..e8bacad5 100644
--- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
+++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
@@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Environment;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
@@ -19,6 +20,8 @@ import com.zeapo.pwdstore.crypto.PgpHandler;
import com.zeapo.pwdstore.git.GitActivity;
import com.zeapo.pwdstore.utils.PasswordRepository;
+import net.rdrei.android.dirchooser.DirectoryChooserActivity;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.openintents.openpgp.util.OpenPgpKeyPreference;
@@ -34,6 +37,7 @@ public class UserPreference extends AppCompatActivity {
private final static int IMPORT_PGP_KEY = 2;
private final static int EDIT_GIT_INFO = 3;
private OpenPgpKeyPreference mKey;
+ private final static int SELECT_GIT_DIRECTORY = 4;
public static class PrefsFragment extends PreferenceFragment {
@Override
@@ -108,6 +112,22 @@ public class UserPreference extends AppCompatActivity {
callingActivity.mKey.setOpenPgpProvider((String) o);
return false;
});
+
+ findPreference("pref_select_external").setOnPreferenceClickListener((Preference pref) -> {
+ Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath());
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(selectedUri);
+
+ if (intent.resolveActivity(callingActivity.getPackageManager()) != null) {
+ startActivityForResult(Intent.createChooser(intent, "Open folder"), SELECT_GIT_DIRECTORY);
+ } else {
+ intent = new Intent(callingActivity, DirectoryChooserActivity.class);
+ intent.putExtra(DirectoryChooserActivity.EXTRA_NEW_DIR_NAME, "DirChooserSample");
+
+ startActivityForResult(intent, SELECT_GIT_DIRECTORY);
+ }
+ return true;
+ });
}
}
@@ -150,7 +170,6 @@ public class UserPreference extends AppCompatActivity {
startActivityForResult(intent, IMPORT_SSH_KEY);
}
-
private void copySshKey(Uri uri) throws IOException {
InputStream sshKey = this.getContentResolver().openInputStream(uri);
byte[] privateKey = IOUtils.toByteArray(sshKey);
diff --git a/app/src/main/res/color/text_color.xml b/app/src/main/res/color/text_color.xml
new file mode 100644
index 00000000..9e70185e
--- /dev/null
+++ b/app/src/main/res/color/text_color.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android" >
+ <item android:state_enabled="false" android:color="@color/grey_500"/>
+ <item android:color="@color/blue_grey_900"/>
+</selector> \ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 556da8f2..a183f724 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -6,7 +6,7 @@
<item name="colorPrimaryDark">@color/blue_grey_500</item>
<item name="android:windowBackground">@color/blue_grey_50</item>
<item name="android:textColorPrimary">@color/teal_900</item>
- <item name="android:textColor">@color/blue_grey_900</item>
+ <item name="android:textColor">@color/text_color</item>
<item name="actionModeStyle">@style/ActionMode</item>
</style>
diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml
index 1d81f987..b3bed289 100644
--- a/app/src/main/res/xml/preference.xml
+++ b/app/src/main/res/xml/preference.xml
@@ -3,7 +3,12 @@
<PreferenceCategory android:title="@string/pref_git_title">
<Preference android:title="@string/pref_edit_server_info" android:key="git_server_info"/>
<Preference android:title="@string/pref_ssh_title" android:key="ssh_key" />
- <Preference android:title="@string/pref_git_delete_repo" android:key="git_delete_repo"/>
+ <Preference android:title="@string/pref_git_delete_repo" android:key="git_delete_repo"
+ android:summary="Deletes local repository"/>
+ <CheckBoxPreference android:title="External repository" android:key="git_external"
+ android:summary="Use an external password repository"/>
+ <Preference android:title="Select external repository" android:key="pref_select_external"
+ android:dependency="git_external"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_crypto_title">