From 58d93d757d30e45a740f9797ef15766c6db01bee Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Wed, 12 Aug 2015 22:33:48 +0200 Subject: show the full category of the password with a small style revamp --- app/app-release.apk | Bin 3200227 -> 3209627 bytes app/build.gradle | 1 + .../java/com/zeapo/pwdstore/PasswordFragment.java | 19 ++++---- .../java/com/zeapo/pwdstore/PasswordStore.java | 5 +- .../com/zeapo/pwdstore/utils/PasswordItem.java | 24 ++++++---- .../pwdstore/utils/PasswordRecyclerAdapter.java | 23 +++------ .../zeapo/pwdstore/utils/PasswordRepository.java | 10 ++-- app/src/main/res/layout/password_recycler_view.xml | 4 +- app/src/main/res/layout/password_row_layout.xml | 53 +++++++++++++-------- app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 10 ++-- 11 files changed, 80 insertions(+), 70 deletions(-) (limited to 'app') diff --git a/app/app-release.apk b/app/app-release.apk index b72b4ace..6efda333 100644 Binary files a/app/app-release.apk and b/app/app-release.apk differ diff --git a/app/build.gradle b/app/build.gradle index cd51da05..dac5fbf6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,6 +31,7 @@ android { dependencies { compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.android.support:recyclerview-v7:22.2.1' + compile 'com.android.support:cardview-v7:22.2.1' compile 'com.android.support:design:22.2.1' compile 'org.sufficientlysecure:openpgp-api:7.0' compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r' diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index fed557fa..72636043 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -60,7 +60,8 @@ public class PasswordFragment extends Fragment{ passListStack = new Stack>(); scrollPosition = new Stack(); pathStack = new Stack(); - recyclerAdapter = new PasswordRecyclerAdapter((PasswordStore) getActivity(), mListener, PasswordRepository.getPasswords(new File(path))); + recyclerAdapter = new PasswordRecyclerAdapter((PasswordStore) getActivity(), mListener, + PasswordRepository.getPasswords(new File(path), PasswordRepository.getRepositoryDirectory(getActivity()))); } @Override @@ -98,8 +99,8 @@ public class PasswordFragment extends Fragment{ if (item.getType() == PasswordItem.TYPE_CATEGORY) { // push the current password list (non filtered plz!) passListStack.push(pathStack.isEmpty() ? - PasswordRepository.getPasswords() : - PasswordRepository.getPasswords(pathStack.peek())); + PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(activity)) : + PasswordRepository.getPasswords(pathStack.peek(), PasswordRepository.getRepositoryDirectory(activity))); //push the category were we're going pathStack.push(item.getFile()); @@ -107,7 +108,7 @@ public class PasswordFragment extends Fragment{ recyclerView.scrollToPosition(0); recyclerAdapter.clear(); - recyclerAdapter.addAll(PasswordRepository.getPasswords(item.getFile())); + recyclerAdapter.addAll(PasswordRepository.getPasswords(item.getFile(), PasswordRepository.getRepositoryDirectory(activity))); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } else { @@ -140,7 +141,7 @@ public class PasswordFragment extends Fragment{ pathStack.clear(); scrollPosition.clear(); recyclerAdapter.clear(); - recyclerAdapter.addAll(PasswordRepository.getPasswords()); + recyclerAdapter.addAll(PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(getActivity()))); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); } @@ -151,8 +152,8 @@ public class PasswordFragment extends Fragment{ public void refreshAdapter() { recyclerAdapter.clear(); recyclerAdapter.addAll(pathStack.isEmpty() ? - PasswordRepository.getPasswords() : - PasswordRepository.getPasswords(pathStack.peek())); + PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(getActivity())) : + PasswordRepository.getPasswords(pathStack.peek(), PasswordRepository.getRepositoryDirectory(getActivity()))); } /** @@ -177,8 +178,8 @@ public class PasswordFragment extends Fragment{ private void recursiveFilter(String filter, File dir) { // on the root the pathStack is empty ArrayList passwordItems = dir == null ? - PasswordRepository.getPasswords() : - PasswordRepository.getPasswords(dir); + PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(getActivity())) : + PasswordRepository.getPasswords(dir, PasswordRepository.getRepositoryDirectory(getActivity())); boolean rec = settings.getBoolean("filter_recursively", true); for (PasswordItem item : passwordItems) { diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 3d17ce10..e51ef201 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -34,7 +34,6 @@ import java.io.File; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import java.util.TreeSet; public class PasswordStore extends AppCompatActivity { private static final String TAG = "PwdStrAct"; @@ -226,7 +225,7 @@ public class PasswordStore extends AppCompatActivity { File dir = new File(settings.getString("git_external_repo", null)); if (dir.exists() && dir.isDirectory() && !FileUtils.listFiles(dir, null, true).isEmpty() && - !PasswordRepository.getPasswords(dir).isEmpty()) { + !PasswordRepository.getPasswords(dir, PasswordRepository.getRepositoryDirectory(this)).isEmpty()) { PasswordRepository.closeRepository(); checkLocalRepository(); return; // if not empty, just show me the passwords! @@ -468,7 +467,7 @@ public class PasswordStore extends AppCompatActivity { dir.exists() && dir.isDirectory() && !FileUtils.listFiles(dir, null, true).isEmpty() && - !PasswordRepository.getPasswords(dir).isEmpty()) { + !PasswordRepository.getPasswords(dir, PasswordRepository.getRepositoryDirectory(this)).isEmpty()) { PasswordRepository.closeRepository(); checkLocalRepository(); return; // if not empty, just show me the passwords! diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java index 4f129851..7fa88085 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java @@ -11,6 +11,7 @@ public class PasswordItem implements Comparable{ private String name; private PasswordItem parent; private File file; + private String fullPathName; public boolean selected = false; /** Create a password item @@ -20,11 +21,12 @@ public class PasswordItem implements Comparable{ * @param parent * @param type */ - protected PasswordItem(String name, PasswordItem parent, char type, File file) { + protected PasswordItem(String name, PasswordItem parent, char type, File file, File rootDir) { this.name = name; this.parent = parent; this.type = type; this.file = file; + this.fullPathName = file.getAbsolutePath().replace(rootDir.getAbsolutePath(), "").replace(file.getName(), ""); } /** Create a new Category item @@ -33,8 +35,8 @@ public class PasswordItem implements Comparable{ * @param parent * @return */ - public static PasswordItem newCategory(String name, File file, PasswordItem parent) { - return new PasswordItem(name, parent, TYPE_CATEGORY, file); + public static PasswordItem newCategory(String name, File file, PasswordItem parent, File rootDir) { + return new PasswordItem(name, parent, TYPE_CATEGORY, file, rootDir); } /** Create a new parentless category item @@ -42,8 +44,8 @@ public class PasswordItem implements Comparable{ * @param name * @return */ - public static PasswordItem newCategory(String name, File file) { - return new PasswordItem(name, null, TYPE_CATEGORY, file); + public static PasswordItem newCategory(String name, File file, File rootDir) { + return new PasswordItem(name, null, TYPE_CATEGORY, file, rootDir); } /** Create a new password item @@ -52,8 +54,8 @@ public class PasswordItem implements Comparable{ * @param parent * @return */ - public static PasswordItem newPassword(String name, File file, PasswordItem parent) { - return new PasswordItem(name, parent, TYPE_PASSWORD, file); + public static PasswordItem newPassword(String name, File file, PasswordItem parent, File rootDir) { + return new PasswordItem(name, parent, TYPE_PASSWORD, file, rootDir); } /** Create a new parentless password item @@ -61,8 +63,8 @@ public class PasswordItem implements Comparable{ * @param name * @return */ - public static PasswordItem newPassword(String name, File file) { - return new PasswordItem(name, null, TYPE_PASSWORD, file); + public static PasswordItem newPassword(String name, File file, File rootDir) { + return new PasswordItem(name, null, TYPE_PASSWORD, file, rootDir); } public char getType(){ @@ -81,6 +83,10 @@ public class PasswordItem implements Comparable{ return this.file; } + public String getFullPathName() { + return this.fullPathName; + } + @Override public String toString(){ return this.getName().replace(".gpg", ""); diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java index 4bf9cb98..208ec2eb 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java @@ -1,6 +1,7 @@ package com.zeapo.pwdstore.utils; import android.support.v7.view.ActionMode; +import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.Menu; @@ -31,12 +32,14 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter getPasswords() { - return getPasswords(repository.getWorkTree()); + public static ArrayList getPasswords(File rootDir) { + return getPasswords(rootDir, rootDir); } public static File getWorkTree() { @@ -183,7 +183,7 @@ public class PasswordRepository { * @param path the directory path * @return a list of password items */ - public static ArrayList getPasswords(File path) { + public static ArrayList getPasswords(File path, File rootDir) { //We need to recover the passwords then parse the files ArrayList passList = getFilesList(path); @@ -193,12 +193,12 @@ public class PasswordRepository { for (File file : passList) { if (file.isFile()) { - passwordList.add(PasswordItem.newPassword(file.getName(), file)); + passwordList.add(PasswordItem.newPassword(file.getName(), file, rootDir)); } else { // ignore .git directory if (file.getName().equals(".git")) continue; - passwordList.add(PasswordItem.newCategory(file.getName(), file)); + passwordList.add(PasswordItem.newCategory(file.getName(), file, rootDir)); } } sort(passwordList); diff --git a/app/src/main/res/layout/password_recycler_view.xml b/app/src/main/res/layout/password_recycler_view.xml index 1b922a17..c49e4e45 100644 --- a/app/src/main/res/layout/password_recycler_view.xml +++ b/app/src/main/res/layout/password_recycler_view.xml @@ -25,8 +25,8 @@ android:layout_gravity="bottom|end" app:elevation="6dp" app:pressedTranslationZ="12dp" - app:backgroundTint="@color/blue_grey_500" - app:rippleColor="@color/blue_grey_50" + app:backgroundTint="@color/indigo_A700" + app:rippleColor="@color/blue_500" app:borderWidth="0dp" android:layout_margin="@dimen/fab_compat_margin" android:layout_alignParentBottom="true" diff --git a/app/src/main/res/layout/password_row_layout.xml b/app/src/main/res/layout/password_row_layout.xml index 99ee58eb..1e694f87 100644 --- a/app/src/main/res/layout/password_row_layout.xml +++ b/app/src/main/res/layout/password_row_layout.xml @@ -1,30 +1,41 @@ - - - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 75d5bb51..3a3d4061 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -152,5 +152,6 @@ Control the visibility of the passwords once decrypted, this does not disable the password copy Password copied into the clipboard Generate + "Category: " diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 3fffef42..9f610b68 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -2,15 +2,15 @@ -- cgit v1.2.3