diff options
author | knuthy <knuthy@gmail.com> | 2014-09-23 00:23:55 +0200 |
---|---|---|
committer | knuthy <knuthy@gmail.com> | 2014-09-23 00:23:55 +0200 |
commit | da8ec72655f3009df83ec0a5c0945f8735863e4e (patch) | |
tree | d4613498e79dbbdd46f720135fb129b6c96f2f99 /app | |
parent | 9d338955691ec3fe7b9abb6c065e85b93a0cd463 (diff) |
Take into account subdirectories
Fix #9
Diffstat (limited to 'app')
-rw-r--r-- | app/app-release.apk | bin | 1717723 -> 1717230 bytes | |||
-rw-r--r-- | app/build.gradle | 4 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/GitHandler.java | 5 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java | 25 |
5 files changed, 19 insertions, 16 deletions
diff --git a/app/app-release.apk b/app/app-release.apk Binary files differindex 25ec5480..0937a8f1 100644 --- a/app/app-release.apk +++ b/app/app-release.apk diff --git a/app/build.gradle b/app/build.gradle index c2842999..a78291ca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.zeapo.pwdstore" minSdkVersion 15 targetSdkVersion 19 - versionCode 11 - versionName "1.1-b5" + versionCode 12 + versionName "1.1-b6" } buildTypes { release { diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java index cbb816c1..c487ce0f 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java @@ -2,12 +2,10 @@ package com.zeapo.pwdstore; import android.app.Activity; import android.app.AlertDialog; -import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.text.InputType; @@ -34,9 +32,6 @@ import org.apache.commons.io.FileUtils; import org.eclipse.jgit.api.GitCommand; import org.eclipse.jgit.api.PullCommand; import org.eclipse.jgit.api.PushCommand; -import org.eclipse.jgit.api.errors.InvalidRemoteException; -import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.api.errors.TransportException; import org.eclipse.jgit.errors.UnsupportedCredentialItem; import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialsProvider; diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 71954859..4fadb65e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -215,6 +215,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI } private void checkLocalRepository(File localDir) { + Log.d("PASS", localDir.getAbsolutePath()); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java index eda32b0a..289f9f43 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -1,6 +1,9 @@ package com.zeapo.pwdstore.utils; +import android.util.Log; + import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.FileFilterUtils; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.lib.Repository; @@ -10,7 +13,10 @@ import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.URIish; import java.io.File; +import java.io.FileFilter; +import java.lang.reflect.Array; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; @@ -115,7 +121,10 @@ public class PasswordRepository { public static ArrayList<File> getFilesList(File path){ if (!path.exists()) return new ArrayList<File>(); - List<File> files = (List<File>) FileUtils.listFiles(path, new String[] {"gpg"}, true); + Log.d("REPO", path.getAbsolutePath()); + ArrayList<File> files = new ArrayList<File>(Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()))); + files.addAll( new ArrayList<File>((List<File>)FileUtils.listFiles(path, new String[] {"gpg"}, false))); + return new ArrayList<File>(files); } @@ -129,15 +138,13 @@ public class PasswordRepository { ArrayList<PasswordItem> passwordList = new ArrayList<PasswordItem>(); for (File file : passList) { - String fileName = file.getAbsolutePath().replace(path.getAbsolutePath() + "/", ""); - - String[] parts = fileName.split("/"); - if (parts.length == 1) { - passwordList.add(PasswordItem.newPassword(parts[0], file)); + if (file.isFile()) { + passwordList.add(PasswordItem.newPassword(file.getName(), file)); } else { - if (!passwordList.contains(PasswordItem.newCategory(parts[0], file.getParentFile()))) { - passwordList.add(PasswordItem.newCategory(parts[0], file.getParentFile())); - } + // ignore .git directory + if (file.getName().equals(".git")) + continue; + passwordList.add(PasswordItem.newCategory(file.getName(), file)); } } sort(passwordList); |