Filter key list by certified keys

This commit is contained in:
Dominik Schürmann 2014-10-08 14:42:56 +02:00
parent 678265483a
commit adcc07ca65
4 changed files with 81 additions and 4 deletions

View File

@ -49,9 +49,11 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView.MultiChoiceModeListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
@ -68,8 +70,10 @@ import org.sufficientlysecure.keychain.ui.util.Highlighter;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.ui.util.Notify;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
@ -85,10 +89,13 @@ public class KeyListFragment extends LoaderFragment
private KeyListAdapter mAdapter;
private StickyListHeadersListView mStickyList;
private ListAwareSwipeRefreshLayout mSwipeRefreshLayout;
private Spinner mFilterSpinner;
// saves the mode object for multiselect, needed for reset at some point
private ActionMode mActionMode = null;
private boolean mShowAllKeys = false;
private String mQuery;
private SearchView mSearchView;
// empty list layout
@ -213,6 +220,42 @@ public class KeyListFragment extends LoaderFragment
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mFilterSpinner = (Spinner) getActivity().findViewById(R.id.key_list_filter_spinner);
List<String> list = new ArrayList<String>();
list.add(getString(R.string.key_list_filter_show_certified));
list.add(getString(R.string.key_list_filter_show_all));
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
(getActivity(), android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
mFilterSpinner.setAdapter(dataAdapter);
mFilterSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0: {
mShowAllKeys = false;
getLoaderManager().restartLoader(0, null, KeyListFragment.this);
break;
}
case 1: {
mShowAllKeys = true;
getLoaderManager().restartLoader(0, null, KeyListFragment.this);
break;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
mStickyList.setOnItemClickListener(this);
mStickyList.setAreHeadersSticky(true);
mStickyList.setDrawingListUnderStickyHeader(false);
@ -355,6 +398,14 @@ public class KeyListFragment extends LoaderFragment
whereArgs[i] = "%" + words[i] + "%";
}
}
if (!mShowAllKeys) {
if (where == null) {
where = "";
} else {
where += " AND ";
}
where += KeyRings.VERIFIED + " != 0";
}
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.

View File

@ -6,17 +6,42 @@
<include layout="@layout/notify_area" />
<FrameLayout
<LinearLayout
android:id="@+id/content_frame"
android:layout_marginLeft="@dimen/drawer_content_padding"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:background="@color/holo_gray_bright"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="@+id/key_list_filter_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
</LinearLayout>
<fragment
android:id="@+id/key_list_fragment"
android:name="org.sufficientlysecure.keychain.ui.KeyListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

View File

@ -147,7 +147,6 @@
android:id="@+id/view_key_action_update"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:layout_marginBottom="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -489,6 +489,8 @@
<string name="key_list_empty_text3">"or"</string>
<string name="key_list_empty_button_create">"creating your own key"</string>
<string name="key_list_empty_button_import">"importing an existing key."</string>
<string name="key_list_filter_show_all">"Show all keys"</string>
<string name="key_list_filter_show_certified">"Show certified keys only"</string>
<!-- Key view -->
<string name="key_view_action_edit">"Edit key"</string>