ditch ViewCertActivity and cert fragment in AdvKeyView

This commit is contained in:
Vincent Breitmoser
2018-06-19 14:22:08 +02:00
parent de708288fb
commit f3ef530b96
13 changed files with 4 additions and 1023 deletions

View File

@@ -168,15 +168,6 @@
<data android:mimeType="vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key" />
</intent-filter>
</activity>
<activity
android:name=".ui.ViewCertActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_view_cert"
android:parentActivityName=".ui.keyview.ViewKeyActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.keyview.ViewKeyActivity" />
</activity>
<activity
android:name=".ui.SafeSlingerActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"

View File

@@ -295,17 +295,6 @@ public class KeychainContract {
return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_CERTS).build();
}
public static Uri buildCertsSpecificUri(long masterKeyId, long rank, long certifier) {
return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId))
.appendPath(PATH_CERTS).appendPath(Long.toString(rank))
.appendPath(Long.toString(certifier)).build();
}
public static Uri buildCertsUri(Uri uri) {
return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1))
.appendPath(PATH_CERTS).build();
}
public static Uri buildLinkedIdCertsUri(Uri uri, int rank) {
return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1))
.appendPath(PATH_LINKED_IDS).appendPath(Integer.toString(rank))

View File

@@ -65,7 +65,6 @@ public class KeychainProvider extends ContentProvider implements SimpleContentRe
private static final int KEY_RING_USER_IDS = 202;
private static final int KEY_RING_PUBLIC = 203;
private static final int KEY_RING_CERTS = 205;
private static final int KEY_RING_CERTS_SPECIFIC = 206;
private static final int KEY_RING_LINKED_IDS = 207;
private static final int KEY_RING_LINKED_ID_CERTS = 208;
@@ -165,9 +164,6 @@ public class KeychainProvider extends ContentProvider implements SimpleContentRe
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/"
+ KeychainContract.PATH_CERTS,
KEY_RING_CERTS);
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/"
+ KeychainContract.PATH_CERTS + "/*/*",
KEY_RING_CERTS_SPECIFIC);
matcher.addURI(authority, KeychainContract.BASE_KEY_SIGNATURES, KEY_SIGNATURES);
@@ -565,7 +561,6 @@ public class KeychainProvider extends ContentProvider implements SimpleContentRe
}
case KEY_RING_CERTS:
case KEY_RING_CERTS_SPECIFIC:
case KEY_RING_LINKED_ID_CERTS: {
HashMap<String, String> projectionMap = new HashMap<>();
projectionMap.put(Certs._ID, Tables.CERTS + ".oid AS " + Certs._ID);
@@ -599,12 +594,6 @@ public class KeychainProvider extends ContentProvider implements SimpleContentRe
qb.appendWhere(Tables.CERTS + "." + Certs.MASTER_KEY_ID + " = ");
qb.appendWhereEscapeString(uri.getPathSegments().get(1));
if(match == KEY_RING_CERTS_SPECIFIC) {
qb.appendWhere(" AND " + Tables.CERTS + "." + Certs.RANK + " = ");
qb.appendWhereEscapeString(uri.getPathSegments().get(3));
qb.appendWhere(" AND " + Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER+ " = ");
qb.appendWhereEscapeString(uri.getPathSegments().get(4));
}
if (match == KEY_RING_LINKED_ID_CERTS) {
qb.appendWhere(" AND " + Tables.USER_PACKETS + "."

View File

@@ -1,221 +0,0 @@
/*
* Copyright (C) 2017 Schürmann & Breitmoser GbR
*
* 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;
import java.util.Date;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.NavUtils;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.app.ActionBar;
import android.text.format.DateFormat;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import timber.log.Timber;
public class ViewCertActivity extends BaseActivity
implements LoaderManager.LoaderCallbacks<Cursor> {
// These are the rows that we will retrieve.
static final String[] PROJECTION = new String[]{
Certs.MASTER_KEY_ID,
Certs.USER_ID,
Certs.TYPE,
Certs.CREATION,
Certs.KEY_ID_CERTIFIER,
Certs.SIGNER_UID,
Certs.DATA,
};
private static final int INDEX_MASTER_KEY_ID = 0;
private static final int INDEX_USER_ID = 1;
private static final int INDEX_TYPE = 2;
private static final int INDEX_CREATION = 3;
private static final int INDEX_KEY_ID_CERTIFIER = 4;
private static final int INDEX_SIGNER_UID = 5;
private static final int INDEX_DATA = 6;
private Uri mDataUri;
private long mCertifierKeyId;
private TextView mSigneeKey, mSigneeUid, mAlgorithm, mType, mReason, mCreation;
private TextView mCertifierKey, mCertifierUid, mStatus;
private View mRowReason;
private View mViewCertifierButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
mSigneeKey = findViewById(R.id.signee_key);
mSigneeUid = findViewById(R.id.signee_uid);
mAlgorithm = findViewById(R.id.algorithm);
mType = findViewById(R.id.signature_type);
mReason = findViewById(R.id.reason);
mCreation = findViewById(R.id.creation);
mCertifierKey = findViewById(R.id.signer_key_id);
mCertifierUid = findViewById(R.id.signer_uid);
mRowReason = findViewById(R.id.row_reason);
mViewCertifierButton = findViewById(R.id.view_cert_view_cert_key);
mDataUri = getIntent().getData();
if (mDataUri == null) {
Timber.e("Intent data missing. Should be Uri of key!");
finish();
return;
}
getSupportLoaderManager().initLoader(0, null, this);
}
@Override
protected void initLayout() {
setContentView(R.layout.view_cert_activity);
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.
return new CursorLoader(this, mDataUri, PROJECTION, null, null, null);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (data.moveToFirst()) {
mSigneeKey.setText(KeyFormattingUtils.beautifyKeyId(data.getLong(INDEX_MASTER_KEY_ID)));
String signeeUid = data.getString(INDEX_USER_ID);
mSigneeUid.setText(signeeUid);
Date creationDate = new Date(data.getLong(INDEX_CREATION) * 1000);
mCreation.setText(DateFormat.getDateFormat(getApplicationContext()).format(creationDate));
mCertifierKeyId = data.getLong(INDEX_KEY_ID_CERTIFIER);
mCertifierKey.setText(KeyFormattingUtils.beautifyKeyId(mCertifierKeyId));
String certifierUid = data.getString(INDEX_SIGNER_UID);
if (certifierUid != null) {
mCertifierUid.setText(certifierUid);
} else {
mCertifierUid.setText(R.string.unknown_uid);
}
WrappedSignature sig = WrappedSignature.fromBytes(data.getBlob(INDEX_DATA));
String algorithmStr = KeyFormattingUtils.getAlgorithmInfo(this, sig.getKeyAlgorithm(), null, null);
mAlgorithm.setText(algorithmStr);
mRowReason.setVisibility(View.GONE);
switch (data.getInt(INDEX_TYPE)) {
case WrappedSignature.DEFAULT_CERTIFICATION:
mType.setText(R.string.cert_default);
break;
case WrappedSignature.NO_CERTIFICATION:
mType.setText(R.string.cert_none);
break;
case WrappedSignature.CASUAL_CERTIFICATION:
mType.setText(R.string.cert_casual);
break;
case WrappedSignature.POSITIVE_CERTIFICATION:
mType.setText(R.string.cert_positive);
break;
case WrappedSignature.CERTIFICATION_REVOCATION: {
mType.setText(R.string.cert_revoke);
if (sig.isRevocation()) {
try {
String reason = sig.getRevocationReason();
if (reason != null) {
mReason.setText(reason);
} else {
mReason.setText(R.string.none);
}
} catch(PgpGeneralException e) {
mReason.setText(R.string.none);
}
}
mRowReason.setVisibility(View.VISIBLE);
break;
}
}
}
// can't do this before the data is initialized
mViewCertifierButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent viewIntent = new Intent(ViewCertActivity.this, ViewKeyActivity.class);
try {
KeyRepository keyRepository =
KeyRepository.create(ViewCertActivity.this);
long signerMasterKeyId = keyRepository.getCachedPublicKeyRing(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mCertifierKeyId)).getMasterKeyId();
viewIntent.setData(KeyRings.buildGenericKeyRingUri(signerMasterKeyId));
startActivity(viewIntent);
} catch (PgpKeyNotFoundException e) {
// TODO notify user of this, maybe offer download?
Timber.e(e, "key not found!");
}
}
});
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: {
Intent viewIntent = NavUtils.getParentActivityIntent(this);
viewIntent.setData(KeyRings.buildGenericKeyRingUri(mDataUri));
NavUtils.navigateUpTo(this, viewIntent);
return true;
}
}
return super.onOptionsItemSelected(item);
}
}

View File

@@ -126,7 +126,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
mViewPager.setAdapter(mTabAdapter);
// keep track which of these are action mode enabled!
mTabsWithActionMode = new boolean[5];
mTabsWithActionMode = new boolean[4];
mTabAdapter.addTab(ViewKeyAdvStartFragment.class,
null, getString(R.string.key_view_tab_start));
@@ -150,12 +150,6 @@ public class ViewKeyAdvActivity extends BaseActivity implements
keysBundle, getString(R.string.key_view_tab_keys));
mTabsWithActionMode[3] = true;
Bundle certsBundle = new Bundle();
certsBundle.putParcelable(ViewKeyAdvCertsFragment.ARG_DATA_URI, dataUri);
mTabAdapter.addTab(ViewKeyAdvCertsFragment.class,
certsBundle, getString(R.string.key_view_tab_certs));
mTabsWithActionMode[4] = false;
// update layout after operations
mSlidingTabLayout.setViewPager(mViewPager);
mSlidingTabLayout.setOnPageChangeListener(this);

View File

@@ -1,129 +0,0 @@
/*
* Copyright (C) 2017 Schürmann & Breitmoser GbR
*
* 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;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import com.tonicartos.superslim.LayoutManager;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.ui.adapter.CertSectionedListAdapter;
import org.sufficientlysecure.keychain.ui.base.RecyclerFragment;
import timber.log.Timber;
public class ViewKeyAdvCertsFragment extends RecyclerFragment<CertSectionedListAdapter>
implements LoaderManager.LoaderCallbacks<Cursor>, CertSectionedListAdapter.CertListListener {
public static final String ARG_DATA_URI = "data_uri";
private Uri mDataUriCerts;
/**
* Creates new instance of this fragment
*/
public static ViewKeyAdvCertsFragment newInstance(Uri dataUri) {
ViewKeyAdvCertsFragment frag = new ViewKeyAdvCertsFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_DATA_URI, dataUri);
frag.setArguments(args);
return frag;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.view_key_adv_certs_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
hideList(false);
Uri dataUri = getArguments().getParcelable(ARG_DATA_URI);
if (dataUri == null) {
Timber.e("Data missing. Should be Uri of key!");
getActivity().finish();
return;
} else {
mDataUriCerts = KeychainContract.Certs.buildCertsUri(dataUri);
}
CertSectionedListAdapter adapter = new CertSectionedListAdapter(getActivity(), null);
adapter.setCertListListener(this);
setAdapter(adapter);
setLayoutManager(new LayoutManager(getActivity()));
getLoaderManager().initLoader(0, null, this);
}
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.
return new CursorLoader(getActivity(), mDataUriCerts,
CertSectionedListAdapter.CertCursor.CERTS_PROJECTION, null, null,
CertSectionedListAdapter.CertCursor.CERTS_SORT_ORDER);
}
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
// Avoid NullPointerExceptions, if we get an empty result set.
if (data.getCount() == 0) {
return;
}
// Swap the new cursor in. (The framework will take care of closing the
// old cursor once we return.)
getAdapter().swapCursor(CertSectionedListAdapter.CertCursor.wrap(data));
if (isResumed()) {
showList(true);
} else {
showList(false);
}
}
/**
* 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.
*/
public void onLoaderReset(Loader<Cursor> loader) {
getAdapter().swapCursor(null);
}
@Override
public void onClick(long masterKeyId, long signerKeyId, long rank) {
if(masterKeyId != 0L) {
Intent viewIntent = new Intent(getActivity(), ViewCertActivity.class);
viewIntent.setData(KeychainContract.Certs.buildCertsSpecificUri(
masterKeyId, rank, signerKeyId));
startActivity(viewIntent);
}
}
}

View File

@@ -1,259 +0,0 @@
/*
* Copyright (C) 2017 Schürmann & Breitmoser GbR
*
* 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 android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.openintents.openpgp.util.OpenPgpUtils;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.ui.adapter.CertSectionedListAdapter.CertCursor;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter;
import org.sufficientlysecure.keychain.ui.util.adapter.SectionCursorAdapter;
import java.util.ArrayList;
import java.util.Arrays;
public class CertSectionedListAdapter extends SectionCursorAdapter<CertCursor, String,
CertSectionedListAdapter.CertItemViewHolder, CertSectionedListAdapter.CertSectionViewHolder> {
private CertListListener mListener;
public CertSectionedListAdapter(Context context, CertCursor cursor) {
super(context, CertCursor.wrap(cursor), 0);
}
public void setCertListListener(CertListListener listener) {
mListener = listener;
}
@Override
public long getIdFromCursor(CertCursor cursor) {
return cursor.getKeyId();
}
@Override
protected String getSectionFromCursor(CertCursor cursor) throws IllegalStateException {
return cursor.getRawSignerUserId();
}
@Override
protected CertSectionViewHolder onCreateSectionViewHolder(ViewGroup parent, int viewType) {
return new CertSectionViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.view_key_adv_certs_header, parent, false));
}
@Override
protected CertItemViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
return new CertItemViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.view_key_adv_certs_item, parent, false));
}
@Override
protected void onBindSectionViewHolder(CertSectionViewHolder holder, String section) {
holder.bind(section);
}
@Override
protected void onBindItemViewHolder(CertItemViewHolder holder, CertCursor cursor) {
holder.bind(cursor);
}
class CertItemViewHolder extends SectionCursorAdapter.ViewHolder
implements View.OnClickListener {
private TextView mSignerKeyId;
private TextView mSignerName;
private TextView mSignStatus;
public CertItemViewHolder(View itemView) {
super(itemView);
itemView.setClickable(true);
itemView.setOnClickListener(this);
mSignerName = itemView.findViewById(R.id.signerName);
mSignStatus = itemView.findViewById(R.id.signStatus);
mSignerKeyId = itemView.findViewById(R.id.signerKeyId);
}
public void bind(CertCursor cursor) {
String signerKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(
cursor.getCertifierKeyId());
OpenPgpUtils.UserId userId = cursor.getSignerUserId();
if (userId.name != null) {
mSignerName.setText(userId.name);
} else {
mSignerName.setText(R.string.user_id_no_name);
}
mSignerKeyId.setText(signerKeyId);
switch (cursor.getType()) {
case WrappedSignature.DEFAULT_CERTIFICATION: // 0x10
mSignStatus.setText(R.string.cert_default);
break;
case WrappedSignature.NO_CERTIFICATION: // 0x11
mSignStatus.setText(R.string.cert_none);
break;
case WrappedSignature.CASUAL_CERTIFICATION: // 0x12
mSignStatus.setText(R.string.cert_casual);
break;
case WrappedSignature.POSITIVE_CERTIFICATION: // 0x13
mSignStatus.setText(R.string.cert_positive);
break;
case WrappedSignature.CERTIFICATION_REVOCATION: // 0x30
mSignStatus.setText(R.string.cert_revoke);
break;
}
}
@Override
public void onClick(View v) {
if(mListener != null) {
int index = getCursorPositionWithoutSections(getAdapterPosition());
if (moveCursor(index)) {
CertCursor cursor = getCursor();
mListener.onClick(
cursor.getKeyId(),
cursor.getCertifierKeyId(),
cursor.getRank()
);
}
}
}
}
static class CertSectionViewHolder extends SectionCursorAdapter.ViewHolder {
private TextView mHeaderText;
public CertSectionViewHolder(View itemView) {
super(itemView);
mHeaderText = itemView.findViewById(R.id.stickylist_header_text);
}
public void bind(String text) {
mHeaderText.setText(text);
}
}
public static class CertCursor extends CursorAdapter.SimpleCursor {
public static final String[] CERTS_PROJECTION;
static {
ArrayList<String> projection = new ArrayList<>();
projection.addAll(Arrays.asList(SimpleCursor.PROJECTION));
projection.addAll(Arrays.asList(
KeychainContract.Certs.MASTER_KEY_ID,
KeychainContract.Certs.VERIFIED,
KeychainContract.Certs.TYPE,
KeychainContract.Certs.RANK,
KeychainContract.Certs.KEY_ID_CERTIFIER,
KeychainContract.Certs.USER_ID,
KeychainContract.Certs.SIGNER_UID
));
CERTS_PROJECTION = projection.toArray(new String[projection.size()]);
}
public static final String CERTS_SORT_ORDER =
KeychainDatabase.Tables.CERTS + "." + KeychainContract.Certs.RANK + " ASC, "
+ KeychainContract.Certs.VERIFIED + " DESC, "
+ KeychainDatabase.Tables.CERTS + "." + KeychainContract.Certs.TYPE + " DESC, "
+ KeychainContract.Certs.SIGNER_UID + " ASC";
public static CertCursor wrap(Cursor cursor) {
if(cursor != null) {
return new CertCursor(cursor);
} else {
return null;
}
}
private CertCursor(Cursor cursor) {
super(cursor);
}
public long getKeyId() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.MASTER_KEY_ID);
return getLong(index);
}
public boolean isVerified() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.VERIFIED);
return getInt(index) > 0;
}
public int getType() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.TYPE);
return getInt(index);
}
public long getRank() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.RANK);
return getLong(index);
}
public long getCertifierKeyId() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.KEY_ID_CERTIFIER);
return getLong(index);
}
public String getRawUserId() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.USER_ID);
return getString(index);
}
public String getRawSignerUserId() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.SIGNER_UID);
return getString(index);
}
public String getName() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.NAME);
return getString(index);
}
public String getEmail() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.EMAIL);
return getString(index);
}
public String getComment() {
int index = getColumnIndexOrThrow(KeychainContract.Certs.COMMENT);
return getString(index);
}
public OpenPgpUtils.UserId getSignerUserId() {
return KeyRing.splitUserId(getRawSignerUserId());
}
}
public interface CertListListener {
void onClick(long masterKeyId, long signerKeyId, long rank);
}
}

View File

@@ -99,8 +99,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
private int lidRank;
private long certifyKeyId;
public static LinkedIdViewFragment newInstance(Uri dataUri, int rank,
boolean isSecret, long masterKeyId) throws IOException {
public static LinkedIdViewFragment newInstance(Uri dataUri, int rank, boolean isSecret, long masterKeyId) {
LinkedIdViewFragment frag = new LinkedIdViewFragment();
Bundle args = new Bundle();

View File

@@ -114,14 +114,8 @@ public class IdentitiesPresenter implements Observer<List<IdentityInfo>> {
}
private void showLinkedId(final LinkedIdInfo info) {
final LinkedIdViewFragment frag;
try {
Uri dataUri = UserPackets.buildLinkedIdsUri(KeyRings.buildGenericKeyRingUri(masterKeyId));
frag = LinkedIdViewFragment.newInstance(dataUri, info.getRank(), isSecret, masterKeyId);
} catch (IOException e) {
Timber.e(e, "IOException");
return;
}
Uri dataUri = UserPackets.buildLinkedIdsUri(KeyRings.buildGenericKeyRingUri(masterKeyId));
LinkedIdViewFragment frag = LinkedIdViewFragment.newInstance(dataUri, info.getRank(), isSecret, masterKeyId);
viewKeyMvpView.switchToFragment(frag, "linked_id");
}

View File

@@ -1,226 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_include"
layout="@layout/toolbar_standalone" />
<ScrollView
android:layout_below="@id/toolbar_include"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView
style="@style/SectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginTop="14dp"
android:text="@string/section_cert" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:stretchColumns="1">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_key_id" />
<TextView
android:id="@+id/signee_key"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingRight="5dip"
android:typeface="monospace" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_user_id" />
<TextView
android:id="@+id/signee_uid"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingRight="5dip" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_algorithm" />
<TextView
android:id="@+id/algorithm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingRight="5dip" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_cert_type" />
<TextView
android:id="@+id/signature_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingRight="5dip" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/row_reason">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_revocation" />
<TextView
android:id="@+id/reason"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingRight="5dip" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_creation" />
<TextView
android:id="@+id/creation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingRight="5dip" />
</TableRow>
</TableLayout>
<TextView
style="@style/SectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginTop="14dp"
android:text="@string/section_certifier_id" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginBottom="4dp"
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/signer_key_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
android:typeface="monospace" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/label_algorithm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_user_id" />
<TextView
android:id="@+id/signer_uid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip" />
</TableRow>
</TableLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/view_cert_view_cert_key"
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"
android:minHeight="?android:attr/listPreferredItemHeight"
android:clickable="true"
android:background="?android:selectableItemBackground"
android:text="@string/btn_view_cert_key"
android:layout_weight="1"
android:drawableRight="@drawable/ic_person_grey_24dp"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
</LinearLayout>
</ScrollView>
</RelativeLayout>

View File

@@ -1,71 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/colorButtonRow"
android:padding="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/certs_text"
android:gravity="center_horizontal" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider"
android:id="@+id/view_key_status_divider" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@android:id/progress"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" />
</LinearLayout>
<RelativeLayout
android:id="@android:id/widget_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<android.support.v7.widget.RecyclerView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:clipToPadding="false" />
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/empty_certs"
android:visibility="gone"
android:layout_gravity="center" />
</RelativeLayout>
</FrameLayout>
</LinearLayout>

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground">
<TextView
android:id="@+id/stickylist_header_text"
style="@style/SectionHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|left"
tools:text="header text" />
</RelativeLayout>

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:maxLines="1"
android:descendantFocusability="blocksDescendants"
android:background="?attr/selectableItemBackground"
android:focusable="false">
<TextView
android:id="@+id/signerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
tools:text="signer name" />
<TextView
android:id="@+id/signerKeyId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_below="@+id/signerName"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
tools:text="&lt;user@example.com>" />
<TextView
android:id="@+id/signStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="visible"
android:layout_above="@+id/signerKeyId"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
tools:text="status" />
</RelativeLayout>