add a preference option to select an external directory
This commit is contained in:
parent
72ad36c6ba
commit
47ffaf99bd
6 changed files with 36 additions and 3 deletions
|
@ -33,6 +33,7 @@ dependencies {
|
||||||
compile 'org.apache.commons:commons-io:1.3.2'
|
compile 'org.apache.commons:commons-io:1.3.2'
|
||||||
compile 'com.jayway.android.robotium:robotium-solo:5.3.1'
|
compile 'com.jayway.android.robotium:robotium-solo:5.3.1'
|
||||||
compile 'com.melnykov:floatingactionbutton:1.2.0'
|
compile 'com.melnykov:floatingactionbutton:1.2.0'
|
||||||
|
compile 'net.rdrei.android.dirchooser:library:2.1@aar'
|
||||||
compile group: 'com.google.guava', name: 'guava', version: '18.0'
|
compile group: 'com.google.guava', name: 'guava', version: '18.0'
|
||||||
}
|
}
|
||||||
tasks.findAll { // make all tasks whose name starts with 'assemble'...
|
tasks.findAll { // make all tasks whose name starts with 'assemble'...
|
||||||
|
|
|
@ -30,9 +30,12 @@
|
||||||
<meta-data android:name="android.support.PARENT_ACTIVITY"
|
<meta-data android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="com.zeapo.pwdstore.PasswordStore" />
|
android:value="com.zeapo.pwdstore.PasswordStore" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="net.rdrei.android.dirchooser.DirectoryChooserActivity" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -19,6 +20,8 @@ import com.zeapo.pwdstore.crypto.PgpHandler;
|
||||||
import com.zeapo.pwdstore.git.GitActivity;
|
import com.zeapo.pwdstore.git.GitActivity;
|
||||||
import com.zeapo.pwdstore.utils.PasswordRepository;
|
import com.zeapo.pwdstore.utils.PasswordRepository;
|
||||||
|
|
||||||
|
import net.rdrei.android.dirchooser.DirectoryChooserActivity;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.openintents.openpgp.util.OpenPgpKeyPreference;
|
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 IMPORT_PGP_KEY = 2;
|
||||||
private final static int EDIT_GIT_INFO = 3;
|
private final static int EDIT_GIT_INFO = 3;
|
||||||
private OpenPgpKeyPreference mKey;
|
private OpenPgpKeyPreference mKey;
|
||||||
|
private final static int SELECT_GIT_DIRECTORY = 4;
|
||||||
|
|
||||||
public static class PrefsFragment extends PreferenceFragment {
|
public static class PrefsFragment extends PreferenceFragment {
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,6 +112,22 @@ public class UserPreference extends AppCompatActivity {
|
||||||
callingActivity.mKey.setOpenPgpProvider((String) o);
|
callingActivity.mKey.setOpenPgpProvider((String) o);
|
||||||
return false;
|
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);
|
startActivityForResult(intent, IMPORT_SSH_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void copySshKey(Uri uri) throws IOException {
|
private void copySshKey(Uri uri) throws IOException {
|
||||||
InputStream sshKey = this.getContentResolver().openInputStream(uri);
|
InputStream sshKey = this.getContentResolver().openInputStream(uri);
|
||||||
byte[] privateKey = IOUtils.toByteArray(sshKey);
|
byte[] privateKey = IOUtils.toByteArray(sshKey);
|
||||||
|
|
5
app/src/main/res/color/text_color.xml
Normal file
5
app/src/main/res/color/text_color.xml
Normal file
|
@ -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>
|
|
@ -6,7 +6,7 @@
|
||||||
<item name="colorPrimaryDark">@color/blue_grey_500</item>
|
<item name="colorPrimaryDark">@color/blue_grey_500</item>
|
||||||
<item name="android:windowBackground">@color/blue_grey_50</item>
|
<item name="android:windowBackground">@color/blue_grey_50</item>
|
||||||
<item name="android:textColorPrimary">@color/teal_900</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>
|
<item name="actionModeStyle">@style/ActionMode</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,12 @@
|
||||||
<PreferenceCategory android:title="@string/pref_git_title">
|
<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_edit_server_info" android:key="git_server_info"/>
|
||||||
<Preference android:title="@string/pref_ssh_title" android:key="ssh_key" />
|
<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>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/pref_crypto_title">
|
<PreferenceCategory android:title="@string/pref_crypto_title">
|
||||||
|
|
Loading…
Reference in a new issue