trustid: show intent icon for trust ids
This commit is contained in:
@@ -21,7 +21,9 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
@@ -31,10 +33,12 @@ import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiTrustIdentity;
|
||||
|
||||
@@ -59,16 +63,35 @@ public class TrustIdsAdapter extends CursorAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
String packageName = cursor.getString(INDEX_PACKAGE_NAME);
|
||||
String trustId = cursor.getString(INDEX_TRUST_ID);
|
||||
public void bindView(View view, final Context context, Cursor cursor) {
|
||||
final String packageName = cursor.getString(INDEX_PACKAGE_NAME);
|
||||
final String trustId = cursor.getString(INDEX_TRUST_ID);
|
||||
|
||||
TextView vTrustId = (TextView) view.findViewById(R.id.trust_id_name);
|
||||
ImageView vAppIcon = (ImageView) view.findViewById(R.id.trust_id_app_icon);
|
||||
ImageView vActionIcon = (ImageView) view.findViewById(R.id.trust_id_action);
|
||||
|
||||
Drawable drawable = getDrawableForPackageName(packageName);
|
||||
vTrustId.setText(trustId);
|
||||
vAppIcon.setImageDrawable(drawable);
|
||||
vActionIcon.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
launchTrustIdActivity(packageName, trustId, context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void launchTrustIdActivity(String packageName, String trustId, Context context) {
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(packageName + ".TRUST_ID_ACTION");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_TRUST_IDENTITY, trustId);
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
// can't help it
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable getDrawableForPackageName(String packageName) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM6,9h12v2L6,11L6,9zM14,14L6,14v-2h8v2zM18,8L6,8L6,6h12v2z"/>
|
||||
</vector>
|
||||
@@ -27,4 +27,14 @@
|
||||
tools:text="alice@example.com"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="8dp"
|
||||
android:id="@+id/trust_id_action"
|
||||
android:background="?selectableItemBackground"
|
||||
android:src="@drawable/ic_chat_black_24dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user