ImportKeys: Refactoring CardView
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
@@ -58,6 +56,8 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class DecryptFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
public static final int LOADER_ID_UNIFIED = 0;
|
||||
@@ -319,7 +319,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
mSignatureEmail.setText(userIdSplit.email);
|
||||
} else {
|
||||
mSignatureEmail.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(
|
||||
getActivity(), mSignatureResult.getKeyId()));
|
||||
mSignatureResult.getKeyId()));
|
||||
}
|
||||
|
||||
// NOTE: Don't use revoked and expired fields from database, they don't show
|
||||
@@ -429,7 +429,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
mSignatureEmail.setText(userIdSplit.email);
|
||||
} else {
|
||||
mSignatureEmail.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(
|
||||
getActivity(), mSignatureResult.getKeyId()));
|
||||
mSignatureResult.getKeyId()));
|
||||
}
|
||||
|
||||
switch (mSignatureResult.getResult()) {
|
||||
|
||||
@@ -225,7 +225,8 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
||||
|
||||
// get key id from MASTER_KEY_ID
|
||||
long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
|
||||
getSupportActionBar().setSubtitle(KeyFormattingUtils.beautifyKeyIdWithPrefix(this, masterKeyId));
|
||||
String formattedKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(masterKeyId);
|
||||
getSupportActionBar().setSubtitle(formattedKeyId);
|
||||
|
||||
mHasSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
|
||||
boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0;
|
||||
|
||||
@@ -237,7 +237,8 @@ public class ViewKeyAdvCertsFragment extends LoaderFragment implements
|
||||
TextView wSignerName = (TextView) view.findViewById(R.id.signerName);
|
||||
TextView wSignStatus = (TextView) view.findViewById(R.id.signStatus);
|
||||
|
||||
String signerKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(getActivity(), cursor.getLong(mIndexSignerKeyId));
|
||||
String signerKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(
|
||||
cursor.getLong(mIndexSignerKeyId));
|
||||
OpenPgpUtils.UserId userId = KeyRing.splitUserId(cursor.getString(mIndexSignerUserId));
|
||||
if (userId.name != null) {
|
||||
wSignerName.setText(userId.name);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
@@ -25,6 +26,7 @@ import android.support.v7.widget.RecyclerView;
|
||||
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.Constants;
|
||||
@@ -115,12 +117,18 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public ImportKeysListItemBinding binding;
|
||||
public ImportKeysListItemBinding b;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
binding = DataBindingUtil.bind(view);
|
||||
binding.setNonInteractive(mNonInteractive);
|
||||
b = DataBindingUtil.bind(view);
|
||||
|
||||
b.setNonInteractive(mNonInteractive);
|
||||
|
||||
Resources resources = mActivity.getResources();
|
||||
b.setStandardColor(FormattingUtils.getColorFromAttr(mActivity, R.attr.colorText));
|
||||
b.setRevokedExpiredColor(resources.getColor(R.color.key_flag_gray));
|
||||
b.setSecretColor(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,27 +142,18 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, final int position) {
|
||||
final ImportKeysListItemBinding b = holder.binding;
|
||||
final ImportKeysListItemBinding b = holder.b;
|
||||
final ImportKeysListEntry entry = mData.get(position);
|
||||
|
||||
Resources resources = mActivity.getResources();
|
||||
Highlighter highlighter = new Highlighter(mActivity, entry.getQuery());
|
||||
b.setStandardColor(FormattingUtils.getColorFromAttr(mActivity, R.attr.colorText));
|
||||
b.setRevokedExpiredColor(resources.getColor(R.color.key_flag_gray));
|
||||
b.setSecretColor(Color.RED);
|
||||
b.setHighlighter(highlighter);
|
||||
|
||||
b.setSecret(entry.isSecretKey());
|
||||
b.setExpired(entry.isExpired());
|
||||
b.setRevoked(entry.isRevoked());
|
||||
|
||||
String userId = entry.getPrimaryUserId();
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
|
||||
b.setAlgorithm(entry.getAlgorithm());
|
||||
b.setEntry(entry);
|
||||
b.setUserId(userIdSplit.name);
|
||||
b.setUserIdEmail(userIdSplit.email);
|
||||
b.setKeyId(KeyFormattingUtils.beautifyKeyIdWithPrefix(mActivity, entry.getKeyIdHex()));
|
||||
|
||||
if (entry.isRevoked()) {
|
||||
KeyFormattingUtils.setStatusImage(mActivity, b.status, null,
|
||||
@@ -208,6 +207,11 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
b.extraContainer.setVisibility(showed ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@BindingAdapter("app:keyId")
|
||||
public static void setKeyId(TextView textView, String keyId) {
|
||||
textView.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(keyId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData != null ? mData.size() : 0;
|
||||
|
||||
@@ -312,12 +312,12 @@ public class KeyFormattingUtils {
|
||||
return beautifyKeyId(convertKeyIdToHex(keyId));
|
||||
}
|
||||
|
||||
public static String beautifyKeyIdWithPrefix(Context context, String idHex) {
|
||||
public static String beautifyKeyIdWithPrefix(String idHex) {
|
||||
return "Key ID: " + beautifyKeyId(idHex);
|
||||
}
|
||||
|
||||
public static String beautifyKeyIdWithPrefix(Context context, long keyId) {
|
||||
return beautifyKeyIdWithPrefix(context, convertKeyIdToHex(keyId));
|
||||
public static String beautifyKeyIdWithPrefix(long keyId) {
|
||||
return beautifyKeyIdWithPrefix(convertKeyIdToHex(keyId));
|
||||
}
|
||||
|
||||
public static SpannableStringBuilder colorizeFingerprint(String fingerprint) {
|
||||
|
||||
@@ -19,6 +19,7 @@ public class ImportUserIdsView extends LinearLayout {
|
||||
|
||||
public ImportUserIdsView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
setOrientation(VERTICAL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user