Take into account subdirectories

Fix #9
This commit is contained in:
knuthy
2014-09-23 00:23:55 +02:00
parent 9d33895569
commit da8ec72655
5 changed files with 19 additions and 16 deletions

Binary file not shown.

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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();

View File

@@ -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);