summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorknuthy <knuthy@gmail.com>2014-09-23 00:23:55 +0200
committerknuthy <knuthy@gmail.com>2014-09-23 00:23:55 +0200
commitda8ec72655f3009df83ec0a5c0945f8735863e4e (patch)
treed4613498e79dbbdd46f720135fb129b6c96f2f99 /app/src/main/java
parent9d338955691ec3fe7b9abb6c065e85b93a0cd463 (diff)
Take into account subdirectories
Fix #9
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/GitHandler.java5
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java25
3 files changed, 17 insertions, 14 deletions
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);