summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java2
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordRepository.java (renamed from app/src/main/java/com/zeapo/pwdstore/GitRepo.java)24
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java11
-rw-r--r--app/src/main/res/layout/fragment_password_list.xml5
4 files changed, 22 insertions, 20 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
index f6a2d822..2f9f655b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
@@ -47,7 +47,7 @@ public class PasswordFragment extends Fragment implements AbsListView.OnItemClic
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mAdapter = new PasswordAdapter(getActivity(), new ArrayList<String>());
+ mAdapter = new PasswordAdapter(getActivity(), PasswordRepository.getFilesList());
}
@Override
diff --git a/app/src/main/java/com/zeapo/pwdstore/GitRepo.java b/app/src/main/java/com/zeapo/pwdstore/PasswordRepository.java
index 34757b88..5861d229 100644
--- a/app/src/main/java/com/zeapo/pwdstore/GitRepo.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordRepository.java
@@ -1,5 +1,7 @@
package com.zeapo.pwdstore;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.Repository;
@@ -8,15 +10,14 @@ import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
-/**
- * Created by zeapo on 7/27/14.
- */
-public class GitRepo {
+public class PasswordRepository {
private static Repository repository;
- protected GitRepo(){ }
+ protected PasswordRepository(){ }
public static Repository getRepository(File localDir) {
if (repository == null) {
@@ -38,4 +39,17 @@ public class GitRepo {
public static void closeRepository() {
repository.close();
}
+
+ public static ArrayList<String> getFilesList(){
+ return getFilesList(repository.getWorkTree());
+ }
+
+ public static ArrayList<String> getFilesList(File path){
+ List<File> files = (List<File>) FileUtils.listFiles(path, new String[] {"gpg"}, true);
+ ArrayList<String> filePaths = new ArrayList<String>();
+ for (File file : files) {
+ filePaths.add(file.getAbsolutePath().replace(repository.getWorkTree().getAbsolutePath(), ""));
+ }
+ return filePaths;
+ }
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index 8b047626..a31fa50e 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -48,9 +48,10 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
super.onResume();
// re-check that there was no change with the repository state
checkLocalRepository();
+ Repository repository = PasswordRepository.getRepository(new File(getFilesDir() + "/store/.git"));
+ PasswordRepository.getFilesList();
}
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
@@ -115,12 +116,4 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
}
}
- public void addItem(View view) {
- ListView l = (ListView) findViewById(R.id.pass_list);
-
- PasswordAdapter pad = (PasswordAdapter) l.getAdapter();
-
- pad.add("Something");
- }
-
}
diff --git a/app/src/main/res/layout/fragment_password_list.xml b/app/src/main/res/layout/fragment_password_list.xml
index e3f04ece..a2091272 100644
--- a/app/src/main/res/layout/fragment_password_list.xml
+++ b/app/src/main/res/layout/fragment_password_list.xml
@@ -11,10 +11,5 @@
android:layout_height="match_parent"
android:dividerHeight="8dp"
android:divider="@android:color/transparent"/>
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="Add!"
- android:onClick="addItem"/>
</FrameLayout>