From e9be4bf8d0c4441c0ddf1fe638bd1bb73402a104 Mon Sep 17 00:00:00 2001 From: Zeapo Date: Sun, 27 Jul 2014 23:07:53 +0100 Subject: [PATCH] get absolute path to a file from the name so that we can read it. --- .../java/com/zeapo/pwdstore/PasswordRepository.java | 4 ++++ .../main/java/com/zeapo/pwdstore/PasswordStore.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/PasswordRepository.java index 75e65144..cdbcb3b0 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordRepository.java @@ -60,6 +60,10 @@ public class PasswordRepository { return mainPasswordMap; } + public static File getFile(String name) { + return new File(repository.getWorkTree() + "/" + name); + } + public static ArrayList getFilesList(File path){ List files = (List) FileUtils.listFiles(path, new String[] {"gpg"}, true); ArrayList filePaths = new ArrayList(); diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 9e45b38a..8bbdcb4e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -31,6 +31,7 @@ import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.util.Collection; import java.util.List; @@ -115,7 +116,15 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI /* If an item is clicked in the list of passwords, this will be triggered */ @Override public void onFragmentInteraction(String id) { - System.out.println(id + " Clicked"); + + try { + for (String l : (List) FileUtils.readLines(PasswordRepository.getFile(id), null)) { + System.out.println(l); + } + } catch (IOException e) { + //TODO handle problems + e.printStackTrace(); + } } }