Cleanup keyspinner layout, key id typeface monospace

This commit is contained in:
Dominik Schürmann 2014-08-31 20:39:36 +02:00
parent bdf0436c94
commit 9258fbfb74
2 changed files with 45 additions and 42 deletions

View File

@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui.widget;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader; import android.support.v4.content.Loader;
@ -140,9 +139,9 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader
@Override @Override
public void bindView(View view, Context context, Cursor cursor) { public void bindView(View view, Context context, Cursor cursor) {
String[] userId = KeyRing.splitUserId(cursor.getString(mIndexUserId)); String[] userId = KeyRing.splitUserId(cursor.getString(mIndexUserId));
((TextView) view.findViewById(android.R.id.title)).setText(userId[2] == null ? userId[0] : (userId[0] + " (" + userId[2] + ")")); ((TextView) view.findViewById(R.id.keyspinner_key_name)).setText(userId[2] == null ? userId[0] : (userId[0] + " (" + userId[2] + ")"));
((TextView) view.findViewById(android.R.id.text1)).setText(userId[1]); ((TextView) view.findViewById(R.id.keyspinner_key_email)).setText(userId[1]);
((TextView) view.findViewById(android.R.id.text2)).setText(PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId))); ((TextView) view.findViewById(R.id.keyspinner_key_id)).setText(PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId)));
} }
@Override @Override
@ -194,7 +193,7 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
try { try {
View v = getDropDownView(position, convertView, parent); View v = getDropDownView(position, convertView, parent);
v.findViewById(android.R.id.text1).setVisibility(View.GONE); v.findViewById(R.id.keyspinner_key_email).setVisibility(View.GONE);
return v; return v;
} catch (NullPointerException e) { } catch (NullPointerException e) {
// This is for the preview... // This is for the preview...
@ -211,13 +210,13 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader
} else { } else {
v = convertView; v = convertView;
} }
((TextView) v.findViewById(android.R.id.title)).setText("None"); ((TextView) v.findViewById(R.id.keyspinner_key_name)).setText("None");
v.findViewById(android.R.id.text1).setVisibility(View.GONE); v.findViewById(R.id.keyspinner_key_email).setVisibility(View.GONE);
v.findViewById(android.R.id.text2).setVisibility(View.GONE); v.findViewById(R.id.keyspinner_key_id).setVisibility(View.GONE);
} else { } else {
v = inner.getView(position - 1, convertView, parent); v = inner.getView(position - 1, convertView, parent);
v.findViewById(android.R.id.text1).setVisibility(View.VISIBLE); v.findViewById(R.id.keyspinner_key_email).setVisibility(View.VISIBLE);
v.findViewById(android.R.id.text2).setVisibility(View.VISIBLE); v.findViewById(R.id.keyspinner_key_id).setVisibility(View.VISIBLE);
} }
return v; return v;
} }

View File

@ -1,35 +1,39 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:padding="4dp" android:padding="4dp"
android:minHeight="24dp" android:minHeight="24dp"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView android:id="@android:id/title"
android:textColor="?android:attr/textColorSecondary" <TextView
android:textSize="18sp" android:id="@+id/keyspinner_key_name"
android:layout_width="wrap_content" android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content" android:textSize="18sp"
android:singleLine="true" android:layout_width="wrap_content"
android:ellipsize="end" android:layout_height="wrap_content"
/> android:singleLine="true"
<TextView android:id="@android:id/text1" android:ellipsize="end" />
android:textColor="?android:attr/textColorTertiary"
android:textSize="14sp" <TextView
android:layout_width="wrap_content" android:id="@+id/keyspinner_key_email"
android:layout_height="wrap_content" android:textColor="?android:attr/textColorTertiary"
android:singleLine="true" android:textSize="14sp"
android:ellipsize="end" android:layout_width="wrap_content"
android:layout_marginTop="-4dip" android:layout_height="wrap_content"
android:text=".com"/> android:singleLine="true"
<TextView android:id="@android:id/text2" android:ellipsize="end"
android:textColor="?android:attr/textColorTertiary" android:layout_marginTop="-4dip"
android:textSize="14sp" android:text="alice@example.com" />
android:layout_width="wrap_content"
android:layout_height="wrap_content" <TextView
android:singleLine="true" android:id="@+id/keyspinner_key_id"
android:ellipsize="end" android:textColor="?android:attr/textColorTertiary"
android:layout_marginTop="-4dip" android:textSize="14sp"
/> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:typeface="monospace"
android:layout_marginTop="-4dip" />
</LinearLayout> </LinearLayout>