add "show unknown signatures" button

This commit is contained in:
Vincent Breitmoser 2014-03-11 03:19:12 +01:00
parent 8b4a63d5c4
commit 3ed93b7671
4 changed files with 56 additions and 21 deletions

View File

@ -88,7 +88,8 @@ public class KeychainProvider extends ContentProvider {
private static final int CERTS_BY_KEY_ID = 402;
private static final int CERTS_BY_ROW_ID = 403;
private static final int CERTS_BY_KEY_ROW_ID = 404;
private static final int CERTS_BY_CERTIFIER_ID = 405;
private static final int CERTS_BY_KEY_ROW_ID_ALL = 405;
private static final int CERTS_BY_CERTIFIER_ID = 406;
// private static final int DATA_STREAM = 401;
@ -256,6 +257,8 @@ public class KeychainProvider extends ContentProvider {
matcher.addURI(authority, KeychainContract.BASE_CERTS + "/#", CERTS_BY_ROW_ID);
matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
+ KeychainContract.PATH_BY_KEY_ROW_ID + "/#", CERTS_BY_KEY_ROW_ID);
matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
+ KeychainContract.PATH_BY_KEY_ROW_ID + "/#/all", CERTS_BY_KEY_ROW_ID_ALL);
matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
+ KeychainContract.PATH_BY_KEY_ID + "/#", CERTS_BY_KEY_ID);
matcher.addURI(authority, KeychainContract.BASE_CERTS + "/"
@ -717,6 +720,7 @@ public class KeychainProvider extends ContentProvider {
break;
case CERTS_BY_KEY_ROW_ID:
case CERTS_BY_KEY_ROW_ID_ALL:
qb.setTables(Tables.CERTS
+ " JOIN " + Tables.USER_IDS + " ON ("
+ Tables.CERTS + "." + Certs.KEY_RING_ROW_ID + " = "
@ -725,9 +729,10 @@ public class KeychainProvider extends ContentProvider {
+ Tables.CERTS + "." + Certs.RANK + " = "
+ Tables.USER_IDS + "." + UserIds.RANK
// noooooooot sure about this~ database design
+ ") LEFT JOIN " + Tables.KEYS + " ON ("
+ Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER + " = "
+ Tables.KEYS + "." + Keys.KEY_ID
+ ")" + (match == CERTS_BY_KEY_ROW_ID_ALL ? " LEFT" : "")
+ " JOIN " + Tables.KEYS + " ON ("
+ Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER + " = "
+ Tables.KEYS + "." + Keys.KEY_ID
+ ") LEFT JOIN " + Tables.USER_IDS + " AS signer ON ("
+ Tables.KEYS + "." + Keys.KEY_RING_ROW_ID + " = "
+ "signer." + UserIds.KEY_RING_ROW_ID

View File

@ -19,9 +19,7 @@ package org.sufficientlysecure.keychain.ui;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -32,22 +30,17 @@ import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.beardedhen.androidbootstrap.BootstrapButton;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.util.Log;
import java.nio.ByteBuffer;
import java.util.HashMap;
import se.emilsjolander.stickylistheaders.ApiLevelTooLowException;
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
@ -75,10 +68,12 @@ public class ViewKeyCertsFragment extends Fragment
public static final String ARG_KEYRING_ROW_ID = "row_id";
private StickyListHeadersListView mStickyList;
private CheckBox mShowUnknown;
private CertListAdapter mAdapter;
private boolean mUnknownShown = false;
private Uri mDataUri;
private Uri mBaseUri, mDataUri;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -87,10 +82,26 @@ public class ViewKeyCertsFragment extends Fragment
return view;
}
private void toggleShowUnknown(boolean shown) {
if(shown)
mDataUri = mBaseUri.buildUpon().appendPath("all").build();
else
mDataUri = mBaseUri;
getLoaderManager().restartLoader(0, null, this);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mShowUnknown = (CheckBox) getActivity().findViewById(R.id.showUnknown);
mShowUnknown.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
toggleShowUnknown(b);
}
});
mStickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list);
if (!getArguments().containsKey(ARG_KEYRING_ROW_ID)) {
@ -100,7 +111,7 @@ public class ViewKeyCertsFragment extends Fragment
}
long rowId = getArguments().getLong(ARG_KEYRING_ROW_ID);
mDataUri = KeychainContract.Certs.buildCertsByKeyRowIdUri(Long.toString(rowId));
mBaseUri = KeychainContract.Certs.buildCertsByKeyRowIdUri(Long.toString(rowId));
mStickyList.setAreHeadersSticky(true);
mStickyList.setDrawingListUnderStickyHeader(false);
@ -121,6 +132,7 @@ public class ViewKeyCertsFragment extends Fragment
// Prepare the loader. Either re-connect with an existing one,
// or start a new one.
mDataUri = mBaseUri;
getLoaderManager().initLoader(0, null, this);
}

View File

@ -4,18 +4,35 @@
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
android:orientation="vertical">
<view
android:layout_width="match_parent"
android:layout_height="match_parent"
class="se.emilsjolander.stickylistheaders.StickyListHeadersListView"
android:id="@+id/list" />
</LinearLayout>
android:id="@+id/list"
android:layout_alignParentTop="true"
android:layout_above="@+id/showUnknown"
android:paddingRight="32dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingLeft="16dp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_unknown_signatures"
android:id="@+id/showUnknown"
android:enabled="true"
android:layout_alignParentBottom="true"
android:layout_alignEnd="@+id/list"
android:singleLine="false"
android:layout_alignParentRight="true"
android:layout_marginRight="16dp" />
</RelativeLayout>
</ScrollView>

View File

@ -442,5 +442,6 @@
<string name="label_secret_key">Secret Key</string>
<string name="secret_key_yes">available</string>
<string name="secret_key_no">unavailable</string>
<string name="show_unknown_signatures">Show unknown signatures</string>
</resources>