nicer list items

This commit is contained in:
Dominik Schürmann 2014-02-04 17:52:17 +01:00
parent c434c426e7
commit 99ec57aeaa
5 changed files with 34 additions and 26 deletions

View File

@ -24,7 +24,6 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.util.Log;
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
@ -37,6 +36,7 @@ import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
@ -91,29 +91,43 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea
TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
TextView revoked = (TextView) view.findViewById(R.id.revoked);
mainUserId.setText(R.string.user_id_no_name);
mainUserIdRest.setText("");
revoked.setVisibility(View.GONE);
String userId = cursor.getString(mIndexUserId);
String[] userIdSplit = PgpKeyHelper.splitUserId(userId);
if (userIdSplit[0] != null) {
mainUserId.setText(userIdSplit[0]);
} else {
mainUserId.setText(R.string.user_id_no_name);
}
if (userIdSplit[1] != null) {
mainUserIdRest.setText(userIdSplit[1]);
mainUserIdRest.setVisibility(View.VISIBLE);
// disable centering of main user id field
RelativeLayout.LayoutParams layoutParams =
(RelativeLayout.LayoutParams) mainUserId.getLayoutParams();
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0);
mainUserId.setLayoutParams(layoutParams);
} else {
mainUserIdRest.setVisibility(View.INVISIBLE);
// center main user id field
RelativeLayout.LayoutParams layoutParams =
(RelativeLayout.LayoutParams) mainUserId.getLayoutParams();
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mainUserId.setLayoutParams(layoutParams);
}
boolean isRevoked = cursor.getInt(mIndexIsRevoked) > 0;
if (isRevoked) {
revoked.setVisibility(View.VISIBLE);
} else {
revoked.setVisibility(View.GONE);
}
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return mInflater.inflate(R.layout.key_list_item, null);
return mInflater.inflate(R.layout.key_list_public_item, null);
}
/**

View File

@ -88,7 +88,7 @@ public class KeyListSecretAdapter extends CursorAdapter {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return mInflater.inflate(R.layout.key_list_item, null);
return mInflater.inflate(R.layout.key_list_secret_item, null);
}
/** -------------------------- MULTI-SELECTION METHODS -------------- */

View File

@ -1,14 +1,13 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:gravity="left"
android:orientation="horizontal" >
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingBottom="4dp">
<ImageView
android:id="@+id/api_apps_adapter_item_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
@ -22,7 +21,7 @@
android:layout_toRightOf="@+id/api_apps_adapter_item_icon"
android:gravity="center_vertical"
android:orientation="vertical"
android:text="Set in-code!"
android:text="Application Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>

View File

@ -2,17 +2,21 @@
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<fragment
android:id="@+id/key_list_secret_fragment"
android:name="org.sufficientlysecure.keychain.ui.KeyListSecretFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:scrollbarStyle="outsideOverlay" />
</FrameLayout>
<include layout="@layout/drawer_list" />

View File

@ -4,6 +4,8 @@
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_marginRight="?android:attr/scrollbarSize"
android:paddingLeft="8dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:singleLine="true">
<TextView
@ -26,15 +28,4 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/revoked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/revoked"
android:textColor="#e00"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>