From 7ee5ff76ba3468467a2b0396704e5c21962ba046 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Sat, 21 Nov 2015 04:18:07 -0500 Subject: default to reasonable external directory --- app/build.gradle | 6 +++++- app/src/main/AndroidManifest.xml | 6 ++++-- app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 2 +- .../main/java/com/zeapo/pwdstore/UserPreference.java | 17 ++++++++++++++--- .../main/java/com/zeapo/pwdstore/git/GitActivity.java | 2 +- build.gradle | 1 + 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 13a92edb..db9fa9c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,8 @@ android { packagingOptions { exclude '.readme' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/NOTICE.txt' } // @@ -67,7 +69,9 @@ dependencies { compile 'com.jcraft:jsch:0.1.53' compile 'org.apache.commons:commons-io:1.3.2' compile 'com.jayway.android.robotium:robotium-solo:5.3.1' - compile 'net.rdrei.android.dirchooser:library:2.1@aar' + compile ('net.rdrei.android.dirchooser:library:3.0@aar') { + transitive = true; + } compile group: 'com.google.guava', name: 'guava', version: '18.0' } tasks.findAll { // make all tasks whose name starts with 'assemble'... diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0789fd33..404a5138 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + xmlns:tools="http://schemas.android.com/tools" + package="com.zeapo.pwdstore"> @@ -8,7 +9,8 @@ + android:label="@string/app_name" android:theme="@style/AppTheme" + tools:replace="android:theme"> diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 33b6bd29..83a21266 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -495,7 +495,7 @@ public class PasswordStore extends AppCompatActivity { PasswordRepository.closeRepository(); new AlertDialog.Builder(this) - .setTitle("Repositiory location") + .setTitle("Repository location") .setMessage("Select where to create or clone your password repository.") .setPositiveButton("External", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 8f8e8d66..7313ffb3 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -8,6 +8,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.os.Environment; import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.PreferenceFragment; @@ -29,6 +30,7 @@ import com.zeapo.pwdstore.git.GitActivity; import com.zeapo.pwdstore.utils.PasswordRepository; import net.rdrei.android.dirchooser.DirectoryChooserActivity; +import net.rdrei.android.dirchooser.DirectoryChooserConfig; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -124,7 +126,8 @@ public class UserPreference extends AppCompatActivity { public boolean onPreferenceClick(Preference preference) { new AlertDialog.Builder(callingActivity). setTitle(R.string.pref_dialog_delete_title). - setMessage(R.string.pref_dialog_delete_msg). + setMessage(getResources().getString(R.string.dialog_delete_msg) + + " " + PasswordRepository.getWorkTree().toString()). setCancelable(false). setPositiveButton(R.string.dialog_delete, new DialogInterface.OnClickListener() { @Override @@ -265,8 +268,16 @@ public class UserPreference extends AppCompatActivity { public void selectExternalGitRepository() { Intent intent = new Intent(this, DirectoryChooserActivity.class); - intent.putExtra(DirectoryChooserActivity.EXTRA_NEW_DIR_NAME, - "passwordstore"); + File dir = new File(Environment.getExternalStorageDirectory() + "/PasswordStore"); + if (!dir.exists()) { + dir.mkdir(); + } + DirectoryChooserConfig config = DirectoryChooserConfig.builder() + .newDirectoryName("PasswordStore") + .allowNewDirectoryNameModification(true) + .initialDirectory(Environment.getExternalStorageDirectory() + "/PasswordStore") + .build(); + intent.putExtra(DirectoryChooserActivity.EXTRA_CONFIG, config); startActivityForResult(intent, SELECT_GIT_DIRECTORY); } diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java index 00d5be35..d5cba03e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java @@ -481,7 +481,7 @@ public class GitActivity extends AppCompatActivity { if (localDir.exists() && localDir.listFiles().length != 0) { new AlertDialog.Builder(this). setTitle(R.string.dialog_delete_title). - setMessage(R.string.dialog_delete_msg). + setMessage(getResources().getString(R.string.dialog_delete_msg) + " " + localDir.toString()). setCancelable(false). setPositiveButton(R.string.dialog_delete, new DialogInterface.OnClickListener() { diff --git a/build.gradle b/build.gradle index 9cbebcf6..6fed505e 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ allprojects { repositories { jcenter() mavenCentral() + maven { url 'http://guardian.github.com/maven/repo-releases' } } } -- cgit v1.2.3