mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-06 17:25:05 -05:00
key view is working
This commit is contained in:
parent
c740d409c4
commit
face67d64b
@ -1,22 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="3dip"
|
||||
android:paddingRight="?android:attr/scrollbarSize"
|
||||
@ -63,7 +47,7 @@
|
||||
<TextView
|
||||
android:id="@+id/keyId"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="BBBBBBBB"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:typeface="monospace" />
|
||||
|
@ -1,20 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -1,133 +1,216 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="?android:attr/scrollbarSize"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" >
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_master_key" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:stretchColumns="1" >
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_keyId"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_key_id" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="0000 0000"
|
||||
android:typeface="monospace" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_algorithm" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="Name" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_creation"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_creation" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/creation"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_expiry"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_expiry" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/expiry"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_user_ids" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/user_ids"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_keys" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/keys"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_actions" />
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/action_encrypt"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/key_view_action_encrypt"
|
||||
bootstrapbutton:bb_icon_left="fa-lock"
|
||||
bootstrapbutton:bb_type="info" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="?android:attr/scrollbarSize"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" >
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_master_user_id" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:stretchColumns="1" >
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_email" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/email"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_comment" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_master_key" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:stretchColumns="1" >
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_key_id" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/key_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text=""
|
||||
android:typeface="monospace" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_algorithm" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_creation" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/creation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_expiry" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/expiry"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dip"
|
||||
android:text="@string/label_fingerprint" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fingerprint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:typeface="monospace" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_user_ids" />
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/user_ids"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_keys" />
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/keys"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/section_actions" />
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/action_encrypt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/key_view_action_encrypt"
|
||||
bootstrapbutton:bb_icon_left="fa-lock"
|
||||
bootstrapbutton:bb_type="info" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -4,7 +4,6 @@
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:layout_marginRight="?android:attr/scrollbarSize"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="36dip"
|
||||
android:singleLine="true" >
|
||||
|
||||
<TextView
|
||||
|
@ -55,6 +55,7 @@
|
||||
<string name="section_defaults">Defaults</string>
|
||||
<string name="section_advanced">Advanced</string>
|
||||
<string name="section_master_key">Master Key</string>
|
||||
<string name="section_master_user_id">Master User ID</string>
|
||||
<string name="section_actions">Actions</string>
|
||||
|
||||
<!-- button -->
|
||||
@ -137,6 +138,7 @@
|
||||
<string name="label_comment">Comment</string>
|
||||
<string name="label_email">Email</string>
|
||||
<string name="label_send_key">Send Key to Server?</string>
|
||||
<string name="label_fingerprint">Fingerprint</string>
|
||||
<string name="no_keys_selected">Select</string>
|
||||
<string name="one_key_selected">1 Selected</string>
|
||||
<string name="n_keys_selected">Selected</string>
|
||||
|
@ -79,23 +79,4 @@ public class OtherHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits userId string into naming part and email part
|
||||
*
|
||||
* @param userId
|
||||
* @return array with naming (0) and email (1)
|
||||
*/
|
||||
public static String[] splitUserId(String userId) {
|
||||
String[] output = new String[2];
|
||||
|
||||
String chunks[] = userId.split(" <", 2);
|
||||
userId = chunks[0];
|
||||
if (chunks.length > 1) {
|
||||
output[1] = "<" + chunks[1];
|
||||
}
|
||||
output[0] = userId;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||
import org.spongycastle.openpgp.PGPPublicKey;
|
||||
@ -524,4 +526,32 @@ public class PgpKeyHelper {
|
||||
return (Long.parseLong(s1, 16) << 32) | Long.parseLong(s2, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits userId string into naming part, email part, and comment part
|
||||
*
|
||||
* @param userId
|
||||
* @return array with naming (0), email (1), comment (2)
|
||||
*/
|
||||
public static String[] splitUserId(String userId) {
|
||||
String[] result = new String[] { "", "", "" };
|
||||
|
||||
Pattern withComment = Pattern.compile("^(.*) \\((.*)\\) <(.*)>$");
|
||||
Matcher matcher = withComment.matcher(userId);
|
||||
if (matcher.matches()) {
|
||||
result[0] = matcher.group(1);
|
||||
result[1] = matcher.group(3);
|
||||
result[2] = matcher.group(2);
|
||||
return result;
|
||||
}
|
||||
|
||||
Pattern withoutComment = Pattern.compile("^(.*) <(.*)>$");
|
||||
matcher = withoutComment.matcher(userId);
|
||||
if (matcher.matches()) {
|
||||
result[0] = matcher.group(1);
|
||||
result[1] = matcher.group(2);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ public class KeychainContract {
|
||||
|
||||
public static final String CONTENT_AUTHORITY = Constants.PACKAGE_NAME + ".provider";
|
||||
|
||||
private static final Uri BASE_CONTENT_URI_INTERNAL = Uri.parse("content://"
|
||||
+ CONTENT_AUTHORITY);
|
||||
private static final Uri BASE_CONTENT_URI_INTERNAL = Uri
|
||||
.parse("content://" + CONTENT_AUTHORITY);
|
||||
|
||||
public static final String BASE_KEY_RINGS = "key_rings";
|
||||
public static final String BASE_DATA = "data";
|
||||
@ -185,6 +185,14 @@ public class KeychainContract {
|
||||
return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(keyRingRowId)
|
||||
.appendPath(PATH_KEYS).appendPath(keyRowId).build();
|
||||
}
|
||||
|
||||
public static Uri buildKeysUri(Uri keyRingUri) {
|
||||
return keyRingUri.buildUpon().appendPath(PATH_KEYS).build();
|
||||
}
|
||||
|
||||
public static Uri buildKeysUri(Uri keyRingUri, String keyRowId) {
|
||||
return keyRingUri.buildUpon().appendPath(PATH_KEYS).appendPath(keyRowId).build();
|
||||
}
|
||||
}
|
||||
|
||||
public static class UserIds implements UserIdsColumns, BaseColumns {
|
||||
@ -216,6 +224,14 @@ public class KeychainContract {
|
||||
return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(keyRingRowId)
|
||||
.appendPath(PATH_USER_IDS).appendPath(userIdRowId).build();
|
||||
}
|
||||
|
||||
public static Uri buildUserIdsUri(Uri keyRingUri) {
|
||||
return keyRingUri.buildUpon().appendPath(PATH_USER_IDS).build();
|
||||
}
|
||||
|
||||
public static Uri buildUserIdsUri(Uri keyRingUri, String userIdRowId) {
|
||||
return keyRingUri.buildUpon().appendPath(PATH_USER_IDS).appendPath(userIdRowId).build();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ApiApps implements ApiAppsColumns, BaseColumns {
|
||||
|
@ -51,7 +51,6 @@ public class KeyListSecretFragment extends SherlockListFragment implements
|
||||
LoaderManager.LoaderCallbacks<Cursor>, OnItemClickListener {
|
||||
|
||||
private KeyListSecretActivity mKeyListSecretActivity;
|
||||
|
||||
private KeyListSecretAdapter mAdapter;
|
||||
|
||||
/**
|
||||
@ -146,7 +145,7 @@ public class KeyListSecretFragment extends SherlockListFragment implements
|
||||
setListShown(false);
|
||||
|
||||
// Create an empty adapter we will use to display the loaded data.
|
||||
mAdapter = new KeyListSecretAdapter(mKeyListSecretActivity, null, Id.type.secret_key);
|
||||
mAdapter = new KeyListSecretAdapter(mKeyListSecretActivity, null, 0);
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
// Prepare the loader. Either re-connect with an existing one,
|
||||
@ -157,8 +156,7 @@ public class KeyListSecretFragment extends SherlockListFragment implements
|
||||
// These are the rows that we will retrieve.
|
||||
static final String[] PROJECTION = new String[] { KeyRings._ID, KeyRings.MASTER_KEY_ID,
|
||||
UserIds.USER_ID };
|
||||
|
||||
static final String SORT_ORDER = UserIds.USER_ID + " ASC";
|
||||
static final String SORT_ORDER = UserIds.USER_ID + " COLLATE LOCALIZED ASC";
|
||||
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
// This is called when a new Loader needs to be created. This
|
||||
@ -169,8 +167,7 @@ public class KeyListSecretFragment extends SherlockListFragment implements
|
||||
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
// creating a Cursor for the data being displayed.
|
||||
return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, UserIds.USER_ID
|
||||
+ " COLLATE LOCALIZED ASC");
|
||||
return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, SORT_ORDER);
|
||||
}
|
||||
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
* Copyright (C) 2013-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
* Copyright (C) 2013 Bahtiar 'kalkin' Gadimov
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -20,8 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.spongycastle.openpgp.PGPPublicKey;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
@ -31,7 +29,12 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||
import org.sufficientlysecure.keychain.helper.ExportHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.ShareQrCodeDialogFragment;
|
||||
@ -39,6 +42,7 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.nfc.NdefMessage;
|
||||
import android.nfc.NdefRecord;
|
||||
@ -50,6 +54,9 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@ -64,7 +71,7 @@ import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class ViewKeyActivity extends SherlockFragmentActivity implements CreateNdefMessageCallback,
|
||||
OnNdefPushCompleteCallback {
|
||||
OnNdefPushCompleteCallback, LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
ExportHelper mExportHelper;
|
||||
|
||||
@ -72,10 +79,14 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
||||
|
||||
private PGPPublicKey mPublicKey;
|
||||
|
||||
private TextView mName;
|
||||
private TextView mEmail;
|
||||
private TextView mComment;
|
||||
private TextView mAlgorithm;
|
||||
private TextView mFingerint;
|
||||
private TextView mKeyId;
|
||||
private TextView mExpiry;
|
||||
private TextView mCreation;
|
||||
private TextView mFingerprint;
|
||||
private BootstrapButton mActionEncrypt;
|
||||
|
||||
private ListView mUserIds;
|
||||
@ -86,6 +97,12 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
||||
private byte[] mSharedKeyringBytes;
|
||||
private static final int NFC_SENT = 1;
|
||||
|
||||
private static final int LOADER_ID_KEYRING = 0;
|
||||
private static final int LOADER_ID_USER_IDS = 1;
|
||||
private static final int LOADER_ID_KEYS = 2;
|
||||
private ViewKeyUserIdsAdapter mUserIdsAdapter;
|
||||
private ViewKeyKeysAdapter mKeysAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -93,14 +110,19 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
||||
mExportHelper = new ExportHelper(this);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setIcon(android.R.color.transparent);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
|
||||
setContentView(R.layout.view_key_activity);
|
||||
|
||||
mFingerint = (TextView) findViewById(R.id.fingerprint);
|
||||
mExpiry = (TextView) findViewById(R.id.expiry);
|
||||
mCreation = (TextView) findViewById(R.id.creation);
|
||||
mName = (TextView) findViewById(R.id.name);
|
||||
mEmail = (TextView) findViewById(R.id.email);
|
||||
mComment = (TextView) findViewById(R.id.comment);
|
||||
mKeyId = (TextView) findViewById(R.id.key_id);
|
||||
mAlgorithm = (TextView) findViewById(R.id.algorithm);
|
||||
mCreation = (TextView) findViewById(R.id.creation);
|
||||
mExpiry = (TextView) findViewById(R.id.expiry);
|
||||
mFingerprint = (TextView) findViewById(R.id.fingerprint);
|
||||
mActionEncrypt = (BootstrapButton) findViewById(R.id.action_encrypt);
|
||||
mUserIds = (ListView) findViewById(R.id.user_ids);
|
||||
mKeys = (ListView) findViewById(R.id.keys);
|
||||
@ -128,6 +150,11 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
Intent homeIntent = new Intent(this, KeyListPublicActivity.class);
|
||||
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(homeIntent);
|
||||
return true;
|
||||
case R.id.menu_key_view_update:
|
||||
updateFromKeyserver(mDataUri);
|
||||
return true;
|
||||
@ -173,16 +200,23 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
||||
}
|
||||
|
||||
private void loadData(Uri dataUri) {
|
||||
// TODO: don't use pubkey object, use database!!!
|
||||
|
||||
PGPPublicKeyRing ring = (PGPPublicKeyRing) ProviderHelper.getPGPKeyRing(this, dataUri);
|
||||
mPublicKey = ring.getPublicKey();
|
||||
|
||||
mFingerint.setText(PgpKeyHelper.shortifyFingerprint(PgpKeyHelper
|
||||
mKeyId.setText(PgpKeyHelper.shortifyFingerprint(PgpKeyHelper
|
||||
.convertFingerprintToHex(mPublicKey.getFingerprint())));
|
||||
String[] mainUserId = splitUserId("");
|
||||
|
||||
String fingerprint = PgpKeyHelper.convertFingerprintToHex(mPublicKey.getFingerprint());
|
||||
fingerprint = fingerprint.replace(" ", "\n");
|
||||
mFingerprint.setText(fingerprint);
|
||||
|
||||
// TODO: get image with getUserAttributes() on key and then PGPUserAttributeSubpacketVector
|
||||
|
||||
Date expiryDate = PgpKeyHelper.getExpiryDate(mPublicKey);
|
||||
if (expiryDate == null) {
|
||||
mExpiry.setText("");
|
||||
mExpiry.setText(R.string.none);
|
||||
} else {
|
||||
mExpiry.setText(DateFormat.getDateFormat(getApplicationContext()).format(expiryDate));
|
||||
}
|
||||
@ -203,32 +237,117 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
|
||||
mUserIdsAdapter = new ViewKeyUserIdsAdapter(this, null, 0);
|
||||
|
||||
mUserIds.setAdapter(mUserIdsAdapter);
|
||||
// mUserIds.setEmptyView(findViewById(android.R.id.empty));
|
||||
// mUserIds.setClickable(true);
|
||||
// mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
// @Override
|
||||
// public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
|
||||
// }
|
||||
// });
|
||||
|
||||
mKeysAdapter = new ViewKeyKeysAdapter(this, null, 0);
|
||||
|
||||
mKeys.setAdapter(mKeysAdapter);
|
||||
|
||||
// Prepare the loader. Either re-connect with an existing one,
|
||||
// or start a new one.
|
||||
getSupportLoaderManager().initLoader(LOADER_ID_KEYRING, null, this);
|
||||
getSupportLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this);
|
||||
getSupportLoaderManager().initLoader(LOADER_ID_KEYS, null, this);
|
||||
}
|
||||
|
||||
static final String[] KEYRING_PROJECTION = new String[] { KeyRings._ID, KeyRings.MASTER_KEY_ID,
|
||||
UserIds.USER_ID };
|
||||
|
||||
static final String[] USER_IDS_PROJECTION = new String[] { UserIds._ID, UserIds.USER_ID,
|
||||
UserIds.RANK, };
|
||||
// not the main user id
|
||||
static final String USER_IDS_SELECTION = UserIds.RANK + " > 0 ";
|
||||
static final String USER_IDS_SORT_ORDER = UserIds.USER_ID + " COLLATE LOCALIZED ASC";
|
||||
|
||||
static final String[] KEYS_PROJECTION = new String[] { Keys._ID, Keys.KEY_ID,
|
||||
Keys.IS_MASTER_KEY, Keys.ALGORITHM, Keys.KEY_SIZE, Keys.CAN_CERTIFY, Keys.CAN_SIGN,
|
||||
Keys.CAN_ENCRYPT, };
|
||||
static final String KEYS_SORT_ORDER = Keys.RANK + " ASC";
|
||||
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
switch (id) {
|
||||
case LOADER_ID_KEYRING: {
|
||||
Uri baseUri = mDataUri;
|
||||
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
// creating a Cursor for the data being displayed.
|
||||
return new CursorLoader(this, baseUri, KEYRING_PROJECTION, null, null, null);
|
||||
}
|
||||
case LOADER_ID_USER_IDS: {
|
||||
Uri baseUri = UserIds.buildUserIdsUri(mDataUri);
|
||||
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
// creating a Cursor for the data being displayed.
|
||||
return new CursorLoader(this, baseUri, USER_IDS_PROJECTION, USER_IDS_SELECTION, null,
|
||||
USER_IDS_SORT_ORDER);
|
||||
}
|
||||
case LOADER_ID_KEYS: {
|
||||
Uri baseUri = Keys.buildKeysUri(mDataUri);
|
||||
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
// creating a Cursor for the data being displayed.
|
||||
return new CursorLoader(this, baseUri, KEYS_PROJECTION, null, null, KEYS_SORT_ORDER);
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
// Swap the new cursor in. (The framework will take care of closing the
|
||||
// old cursor once we return.)
|
||||
switch (loader.getId()) {
|
||||
case LOADER_ID_KEYRING:
|
||||
if (data.moveToFirst()) {
|
||||
String[] mainUserId = PgpKeyHelper.splitUserId(data.getString(2));
|
||||
setTitle(mainUserId[0]);
|
||||
mName.setText(mainUserId[0]);
|
||||
mEmail.setText(mainUserId[1]);
|
||||
mComment.setText(mainUserId[2]);
|
||||
}
|
||||
|
||||
break;
|
||||
case LOADER_ID_USER_IDS:
|
||||
mUserIdsAdapter.swapCursor(data);
|
||||
break;
|
||||
case LOADER_ID_KEYS:
|
||||
mKeysAdapter.swapCursor(data);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: does this duplicate functionality from elsewhere? put in helper!
|
||||
* This is called when the last Cursor provided to onLoadFinished() above is about to be closed.
|
||||
* We need to make sure we are no longer using it.
|
||||
*/
|
||||
private String[] splitUserId(String userId) {
|
||||
String[] result = new String[] { "", "", "" };
|
||||
Log.v("UserID", userId);
|
||||
|
||||
Pattern withComment = Pattern.compile("^(.*) [(](.*)[)] <(.*)>$");
|
||||
Matcher matcher = withComment.matcher(userId);
|
||||
if (matcher.matches()) {
|
||||
result[0] = matcher.group(1);
|
||||
result[1] = matcher.group(2);
|
||||
result[2] = matcher.group(3);
|
||||
return result;
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
switch (loader.getId()) {
|
||||
case LOADER_ID_KEYRING:
|
||||
// TODO?
|
||||
break;
|
||||
case LOADER_ID_USER_IDS:
|
||||
mUserIdsAdapter.swapCursor(null);
|
||||
break;
|
||||
case LOADER_ID_KEYS:
|
||||
mKeysAdapter.swapCursor(null);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Pattern withoutComment = Pattern.compile("^(.*) <(.*)>$");
|
||||
matcher = withoutComment.matcher(userId);
|
||||
if (matcher.matches()) {
|
||||
result[0] = matcher.group(1);
|
||||
result[1] = matcher.group(2);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void uploadToKeyserver(Uri dataUri) {
|
||||
|
@ -1,279 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.database.MergeCursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CursorTreeAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class KeyListAdapterOLD extends CursorTreeAdapter {
|
||||
private Context mContext;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
protected int mKeyType;
|
||||
|
||||
private static final int CHILD_KEY = 0;
|
||||
private static final int CHILD_USER_ID = 1;
|
||||
private static final int CHILD_FINGERPRINT = 2;
|
||||
|
||||
public KeyListAdapterOLD(Context context, Cursor groupCursor, int keyType) {
|
||||
super(groupCursor, context);
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mKeyType = keyType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflate new view for group items
|
||||
*/
|
||||
@Override
|
||||
public View newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup parent) {
|
||||
return mInflater.inflate(R.layout.key_list_item, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds TextViews from group view to results from database group cursor.
|
||||
*/
|
||||
@Override
|
||||
protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) {
|
||||
int userIdIndex = cursor.getColumnIndex(UserIds.USER_ID);
|
||||
|
||||
TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
|
||||
mainUserId.setText(R.string.unknown_user_id);
|
||||
TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
|
||||
mainUserIdRest.setText("");
|
||||
|
||||
String userId = cursor.getString(userIdIndex);
|
||||
if (userId != null) {
|
||||
String[] userIdSplit = OtherHelper.splitUserId(userId);
|
||||
|
||||
if (userIdSplit[1] != null) {
|
||||
mainUserIdRest.setText(userIdSplit[1]);
|
||||
}
|
||||
mainUserId.setText(userIdSplit[0]);
|
||||
}
|
||||
|
||||
if (mainUserId.getText().length() == 0) {
|
||||
mainUserId.setText(R.string.unknown_user_id);
|
||||
}
|
||||
|
||||
if (mainUserIdRest.getText().length() == 0) {
|
||||
mainUserIdRest.setVisibility(View.GONE);
|
||||
} else {
|
||||
mainUserIdRest.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Inflate new view for child items
|
||||
// */
|
||||
// @Override
|
||||
// public View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) {
|
||||
// return mInflater.inflate(R.layout.key_list_child_item, null);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Bind TextViews from view of childs based on query results
|
||||
*/
|
||||
@Override
|
||||
protected void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild) {
|
||||
// LinearLayout keyLayout = (LinearLayout) view.findViewById(R.id.keyLayout);
|
||||
// LinearLayout userIdLayout = (LinearLayout) view.findViewById(R.id.userIdLayout);
|
||||
|
||||
// first entry is fingerprint
|
||||
if (cursor.getPosition() == 0) {
|
||||
// show only userId layout
|
||||
// keyLayout.setVisibility(View.GONE);
|
||||
// userIdLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
String fingerprint = PgpKeyHelper.getFingerPrint(context,
|
||||
cursor.getLong(cursor.getColumnIndex(Keys.KEY_ID)));
|
||||
fingerprint = fingerprint.replace(" ", "\n");
|
||||
|
||||
TextView userId = (TextView) view.findViewById(R.id.userId);
|
||||
if (userId == null) {
|
||||
Log.d(Constants.TAG, "userId is null!");
|
||||
}
|
||||
userId.setText(context.getString(R.string.fingerprint) + "\n" + fingerprint);
|
||||
} else {
|
||||
// differentiate between keys and userIds in MergeCursor
|
||||
if (cursor.getColumnIndex(Keys.KEY_ID) != -1) {
|
||||
// keyLayout.setVisibility(View.VISIBLE);
|
||||
// userIdLayout.setVisibility(View.GONE);
|
||||
|
||||
String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(cursor
|
||||
.getColumnIndex(Keys.KEY_ID)));
|
||||
String algorithmStr = PgpKeyHelper.getAlgorithmInfo(
|
||||
cursor.getInt(cursor.getColumnIndex(Keys.ALGORITHM)),
|
||||
cursor.getInt(cursor.getColumnIndex(Keys.KEY_SIZE)));
|
||||
|
||||
TextView keyId = (TextView) view.findViewById(R.id.keyId);
|
||||
keyId.setText(keyIdStr);
|
||||
|
||||
TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails);
|
||||
keyDetails.setText("(" + algorithmStr + ")");
|
||||
|
||||
ImageView masterKeyIcon = (ImageView) view.findViewById(R.id.ic_masterKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.IS_MASTER_KEY)) != 1) {
|
||||
masterKeyIcon.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
masterKeyIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
ImageView certifyIcon = (ImageView) view.findViewById(R.id.ic_certifyKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.CAN_CERTIFY)) != 1) {
|
||||
certifyIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
certifyIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.CAN_ENCRYPT)) != 1) {
|
||||
encryptIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
encryptIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.CAN_SIGN)) != 1) {
|
||||
signIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
signIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
// keyLayout.setVisibility(View.GONE);
|
||||
// userIdLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
String userIdStr = cursor.getString(cursor.getColumnIndex(UserIds.USER_ID));
|
||||
|
||||
TextView userId = (TextView) view.findViewById(R.id.userId);
|
||||
userId.setText(userIdStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the group cursor, we start cursors for a fingerprint, keys, and userIds, which are
|
||||
* merged together and build the child cursor
|
||||
*/
|
||||
@Override
|
||||
protected Cursor getChildrenCursor(Cursor groupCursor) {
|
||||
final long keyRingRowId = groupCursor.getLong(groupCursor.getColumnIndex(BaseColumns._ID));
|
||||
|
||||
Cursor fingerprintCursor = getChildCursor(keyRingRowId, CHILD_FINGERPRINT);
|
||||
Cursor keyCursor = getChildCursor(keyRingRowId, CHILD_KEY);
|
||||
Cursor userIdCursor = getChildCursor(keyRingRowId, CHILD_USER_ID);
|
||||
|
||||
MergeCursor mergeCursor = new MergeCursor(new Cursor[] { fingerprintCursor, keyCursor,
|
||||
userIdCursor });
|
||||
Log.d(Constants.TAG, "mergeCursor:" + DatabaseUtils.dumpCursorToString(mergeCursor));
|
||||
|
||||
return mergeCursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* This builds a cursor for a specific type of children
|
||||
*
|
||||
* @param keyRingRowId
|
||||
* foreign row id of the keyRing
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private Cursor getChildCursor(long keyRingRowId, int type) {
|
||||
Uri uri = null;
|
||||
String[] projection = null;
|
||||
String sortOrder = null;
|
||||
String selection = null;
|
||||
|
||||
switch (type) {
|
||||
case CHILD_FINGERPRINT:
|
||||
projection = new String[] { Keys._ID, Keys.KEY_ID, Keys.IS_MASTER_KEY, Keys.ALGORITHM,
|
||||
Keys.KEY_SIZE, Keys.CAN_CERTIFY, Keys.CAN_SIGN, Keys.CAN_ENCRYPT, };
|
||||
sortOrder = Keys.RANK + " ASC";
|
||||
|
||||
// use only master key for fingerprint
|
||||
selection = Keys.IS_MASTER_KEY + " = 1 ";
|
||||
|
||||
if (mKeyType == Id.type.public_key) {
|
||||
uri = Keys.buildPublicKeysUri(String.valueOf(keyRingRowId));
|
||||
} else {
|
||||
uri = Keys.buildSecretKeysUri(String.valueOf(keyRingRowId));
|
||||
}
|
||||
break;
|
||||
|
||||
case CHILD_KEY:
|
||||
projection = new String[] { Keys._ID, Keys.KEY_ID, Keys.IS_MASTER_KEY, Keys.ALGORITHM,
|
||||
Keys.KEY_SIZE, Keys.CAN_CERTIFY, Keys.CAN_SIGN, Keys.CAN_ENCRYPT, };
|
||||
sortOrder = Keys.RANK + " ASC";
|
||||
|
||||
if (mKeyType == Id.type.public_key) {
|
||||
uri = Keys.buildPublicKeysUri(String.valueOf(keyRingRowId));
|
||||
} else {
|
||||
uri = Keys.buildSecretKeysUri(String.valueOf(keyRingRowId));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CHILD_USER_ID:
|
||||
projection = new String[] { UserIds._ID, UserIds.USER_ID, UserIds.RANK, };
|
||||
sortOrder = UserIds.RANK + " ASC";
|
||||
|
||||
// not the main user id
|
||||
selection = UserIds.RANK + " > 0 ";
|
||||
|
||||
if (mKeyType == Id.type.public_key) {
|
||||
uri = UserIds.buildPublicUserIdsUri(String.valueOf(keyRingRowId));
|
||||
} else {
|
||||
uri = UserIds.buildSecretUserIdsUri(String.valueOf(keyRingRowId));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
return mContext.getContentResolver().query(uri, projection, selection, null, sortOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View newChildView(Context context, Cursor cursor, boolean isLastChild,
|
||||
ViewGroup parent) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -19,11 +19,13 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
@ -69,7 +71,7 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea
|
||||
|
||||
String userId = cursor.getString(userIdIndex);
|
||||
if (userId != null) {
|
||||
String[] userIdSplit = OtherHelper.splitUserId(userId);
|
||||
String[] userIdSplit = PgpKeyHelper.splitUserId(userId);
|
||||
|
||||
if (userIdSplit[1] != null) {
|
||||
mainUserIdRest.setText(userIdSplit[1]);
|
||||
|
@ -21,7 +21,7 @@ import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@ -57,7 +57,7 @@ public class KeyListSecretAdapter extends CursorAdapter {
|
||||
|
||||
String userId = cursor.getString(userIdIndex);
|
||||
if (userId != null) {
|
||||
String[] userIdSplit = OtherHelper.splitUserId(userId);
|
||||
String[] userIdSplit = PgpKeyHelper.splitUserId(userId);
|
||||
|
||||
if (userIdSplit[1] != null) {
|
||||
mainUserIdRest.setText(userIdSplit[1]);
|
||||
|
@ -18,11 +18,10 @@
|
||||
package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
@ -78,7 +77,7 @@ public class SelectKeyCursorAdapter extends CursorAdapter {
|
||||
|
||||
String userId = cursor.getString(cursor.getColumnIndex(UserIds.USER_ID));
|
||||
if (userId != null) {
|
||||
String[] userIdSplit = OtherHelper.splitUserId(userId);
|
||||
String[] userIdSplit = PgpKeyHelper.splitUserId(userId);
|
||||
|
||||
if (userIdSplit[1] != null) {
|
||||
mainUserIdRest.setText(userIdSplit[1]);
|
||||
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ViewKeyKeysAdapter extends CursorAdapter {
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
public ViewKeyKeysAdapter(Context context, Cursor c, int flags) {
|
||||
super(context, c, flags);
|
||||
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(cursor
|
||||
.getColumnIndex(Keys.KEY_ID)));
|
||||
String algorithmStr = PgpKeyHelper.getAlgorithmInfo(
|
||||
cursor.getInt(cursor.getColumnIndex(Keys.ALGORITHM)),
|
||||
cursor.getInt(cursor.getColumnIndex(Keys.KEY_SIZE)));
|
||||
|
||||
TextView keyId = (TextView) view.findViewById(R.id.keyId);
|
||||
keyId.setText(keyIdStr);
|
||||
|
||||
TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails);
|
||||
keyDetails.setText("(" + algorithmStr + ")");
|
||||
|
||||
ImageView masterKeyIcon = (ImageView) view.findViewById(R.id.ic_masterKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.IS_MASTER_KEY)) != 1) {
|
||||
masterKeyIcon.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
masterKeyIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
ImageView certifyIcon = (ImageView) view.findViewById(R.id.ic_certifyKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.CAN_CERTIFY)) != 1) {
|
||||
certifyIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
certifyIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.CAN_ENCRYPT)) != 1) {
|
||||
encryptIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
encryptIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey);
|
||||
if (cursor.getInt(cursor.getColumnIndex(Keys.CAN_SIGN)) != 1) {
|
||||
signIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
signIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
return mInflater.inflate(R.layout.view_key_keys_item, null);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -17,17 +17,11 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -47,35 +41,15 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
int userIdIndex = cursor.getColumnIndex(UserIds.USER_ID);
|
||||
|
||||
TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
|
||||
mainUserId.setText(R.string.unknown_user_id);
|
||||
TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
|
||||
mainUserIdRest.setText("");
|
||||
String userIdStr = cursor.getString(userIdIndex);
|
||||
|
||||
String userId = cursor.getString(userIdIndex);
|
||||
if (userId != null) {
|
||||
String[] userIdSplit = OtherHelper.splitUserId(userId);
|
||||
|
||||
if (userIdSplit[1] != null) {
|
||||
mainUserIdRest.setText(userIdSplit[1]);
|
||||
}
|
||||
mainUserId.setText(userIdSplit[0]);
|
||||
}
|
||||
|
||||
if (mainUserId.getText().length() == 0) {
|
||||
mainUserId.setText(R.string.unknown_user_id);
|
||||
}
|
||||
|
||||
if (mainUserIdRest.getText().length() == 0) {
|
||||
mainUserIdRest.setVisibility(View.GONE);
|
||||
} else {
|
||||
mainUserIdRest.setVisibility(View.VISIBLE);
|
||||
}
|
||||
TextView userId = (TextView) view.findViewById(R.id.userId);
|
||||
userId.setText(userIdStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
return mInflater.inflate(R.layout.key_list_item, null);
|
||||
return mInflater.inflate(R.layout.view_key_userids_item, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
package org.sufficientlysecure.keychain.ui.widget;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ListView;
|
||||
|
||||
/**
|
||||
* Automatically calculate height of listview based on contained items. This enables to put this
|
||||
* ListView into a ScrollView without messing up.
|
||||
*
|
||||
* from
|
||||
* http://stackoverflow.com/questions/2419246/how-do-i-create-a-listview-thats-not-in-a-scrollview-
|
||||
* or-has-the-scrollview-dis
|
||||
*/
|
||||
public class FixedListView extends ListView {
|
||||
|
||||
public FixedListView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public FixedListView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public FixedListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// Calculate height of the entire list by providing a very large
|
||||
// height hint. But do not use the highest 2 bits of this integer;
|
||||
// those are reserved for the MeasureSpec mode.
|
||||
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
|
||||
super.onMeasure(widthMeasureSpec, expandSpec);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user