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" applicationId "com.zeapo.pwdstore"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 19 targetSdkVersion 19
versionCode 11 versionCode 12
versionName "1.1-b5" versionName "1.1-b6"
} }
buildTypes { buildTypes {
release { release {

View File

@@ -2,12 +2,10 @@ package com.zeapo.pwdstore;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.InputType; 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.GitCommand;
import org.eclipse.jgit.api.PullCommand; import org.eclipse.jgit.api.PullCommand;
import org.eclipse.jgit.api.PushCommand; 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.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider; 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) { private void checkLocalRepository(File localDir) {
Log.d("PASS", localDir.getAbsolutePath());
FragmentManager fragmentManager = getFragmentManager(); FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

View File

@@ -1,6 +1,9 @@
package com.zeapo.pwdstore.utils; package com.zeapo.pwdstore.utils;
import android.util.Log;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
@@ -10,7 +13,10 @@ import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import java.io.File; import java.io.File;
import java.io.FileFilter;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -115,7 +121,10 @@ public class PasswordRepository {
public static ArrayList<File> getFilesList(File path){ public static ArrayList<File> getFilesList(File path){
if (!path.exists()) return new ArrayList<File>(); 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); return new ArrayList<File>(files);
} }
@@ -129,15 +138,13 @@ public class PasswordRepository {
ArrayList<PasswordItem> passwordList = new ArrayList<PasswordItem>(); ArrayList<PasswordItem> passwordList = new ArrayList<PasswordItem>();
for (File file : passList) { for (File file : passList) {
String fileName = file.getAbsolutePath().replace(path.getAbsolutePath() + "/", ""); if (file.isFile()) {
passwordList.add(PasswordItem.newPassword(file.getName(), file));
String[] parts = fileName.split("/");
if (parts.length == 1) {
passwordList.add(PasswordItem.newPassword(parts[0], file));
} else { } else {
if (!passwordList.contains(PasswordItem.newCategory(parts[0], file.getParentFile()))) { // ignore .git directory
passwordList.add(PasswordItem.newCategory(parts[0], file.getParentFile())); if (file.getName().equals(".git"))
} continue;
passwordList.add(PasswordItem.newCategory(file.getName(), file));
} }
} }
sort(passwordList); sort(passwordList);