Added preference to disable recursive filtering

This commit is contained in:
zeapo
2014-12-06 18:03:43 +01:00
parent c0b0ec10fc
commit 3f1caf89aa
3 changed files with 14 additions and 3 deletions

View File

@@ -2,9 +2,11 @@ package com.zeapo.pwdstore;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.app.Fragment; import android.app.Fragment;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.support.v7.internal.widget.AdapterViewCompat; import android.support.v7.internal.widget.AdapterViewCompat;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
@@ -47,6 +49,7 @@ public class PasswordFragment extends Fragment{
private RecyclerView recyclerView; private RecyclerView recyclerView;
private RecyclerView.LayoutManager mLayoutManager; private RecyclerView.LayoutManager mLayoutManager;
private OnFragmentInteractionListener mListener; private OnFragmentInteractionListener mListener;
private SharedPreferences settings;
/** /**
* Mandatory empty constructor for the fragment manager to instantiate the * Mandatory empty constructor for the fragment manager to instantiate the
@@ -60,6 +63,7 @@ public class PasswordFragment extends Fragment{
String path = getArguments().getString("Path"); String path = getArguments().getString("Path");
settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
passListStack = new Stack<ArrayList<PasswordItem>>(); passListStack = new Stack<ArrayList<PasswordItem>>();
scrollPosition = new Stack<Integer>(); scrollPosition = new Stack<Integer>();
pathStack = new Stack<File>(); pathStack = new Stack<File>();
@@ -175,8 +179,9 @@ public class PasswordFragment extends Fragment{
PasswordRepository.getPasswords() : PasswordRepository.getPasswords() :
PasswordRepository.getPasswords(dir); PasswordRepository.getPasswords(dir);
boolean rec = settings.getBoolean("filter_recursively", true);
for (PasswordItem item : passwordItems) { for (PasswordItem item : passwordItems) {
if (item.getType() == PasswordItem.TYPE_CATEGORY) { if (item.getType() == PasswordItem.TYPE_CATEGORY && rec) {
recursiveFilter(filter, item.getFile()); recursiveFilter(filter, item.getFile());
} }
boolean matches = item.toString().toLowerCase().contains(filter.toLowerCase()); boolean matches = item.toString().toLowerCase().contains(filter.toLowerCase());

View File

@@ -109,7 +109,9 @@
<string name="pref_copy_title">Automatically Copy Password</string> <string name="pref_copy_title">Automatically Copy Password</string>
<string name="pref_copy_dialog_title">Automatically copy the password to the clipboard after decryption was successful.</string> <string name="pref_copy_dialog_title">Automatically copy the password to the clipboard after decryption was successful.</string>
<string name="ssh_key_error_dialog_title">Error while trying to import the ssh-key</string> <string name="ssh_key_error_dialog_title">Error while trying to import the ssh-key</string>
<string name="ssh_key_error_dialog_text">Message : /n</string> <string name="ssh_key_error_dialog_text">Message : \n</string>
<string name="pref_recursive_filter">Recursive filtering</string>
<string name="pref_recursive_filter_hint">Recursively find passwords of the current directory.</string>
<!-- Misc --> <!-- Misc -->
<string name="dialog_ok">OK</string> <string name="dialog_ok">OK</string>

View File

@@ -22,10 +22,14 @@
<EditTextPreference android:title="@string/pref_password_title" <EditTextPreference android:title="@string/pref_password_title"
android:dialogTitle="@string/pref_password_dialog_title" android:dialogTitle="@string/pref_password_dialog_title"
android:summary="@string/pref_password_dialog_title" android:summary="@string/pref_password_dialog_title"
android:hint="45" android:key="general_show_time" /> android:defaultValue="45" android:key="general_show_time"
android:inputType="number" />
<CheckBoxPreference android:title="@string/pref_copy_title" <CheckBoxPreference android:title="@string/pref_copy_title"
android:dialogTitle="@string/pref_copy_dialog_title" android:dialogTitle="@string/pref_copy_dialog_title"
android:summary="@string/pref_copy_dialog_title" android:summary="@string/pref_copy_dialog_title"
android:key="copy_on_decrypt" android:defaultValue="true" /> android:key="copy_on_decrypt" android:defaultValue="true" />
<CheckBoxPreference android:title="@string/pref_recursive_filter"
android:summary="@string/pref_recursive_filter_hint"
android:key="filter_recursively" android:defaultValue="true"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>