ImportKeys: Use CardView for the list and change layout
This commit is contained in:
@@ -19,12 +19,12 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -58,6 +58,8 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public View container;
|
||||
|
||||
public TextView mainUserId;
|
||||
public TextView mainUserIdRest;
|
||||
public TextView keyId;
|
||||
@@ -66,10 +68,10 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
public ImageView status;
|
||||
public View userIdsDivider;
|
||||
public LinearLayout userIdsList;
|
||||
public CheckBox checkBox;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
public ViewHolder(View container) {
|
||||
super(container);
|
||||
this.container = container;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +125,6 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
vh.status = (ImageView) v.findViewById(R.id.import_item_status);
|
||||
vh.userIdsDivider = v.findViewById(R.id.import_item_status_divider);
|
||||
vh.userIdsList = (LinearLayout) v.findViewById(R.id.import_item_user_ids_list);
|
||||
vh.checkBox = (CheckBox) v.findViewById(R.id.import_item_selected);
|
||||
|
||||
return vh;
|
||||
}
|
||||
@@ -263,12 +264,15 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
}
|
||||
}
|
||||
|
||||
holder.checkBox.setChecked(entry.isSelected());
|
||||
holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
int defaultColor = ContextCompat.getColor(mContext, R.color.cardview_light_background);
|
||||
int selectedColor = ContextCompat.getColor(mContext, R.color.primaryLight);
|
||||
holder.container.setBackgroundColor(entry.isSelected() ? selectedColor : defaultColor);
|
||||
holder.container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
public void onClick(View v) {
|
||||
if (!mNonInteractive) {
|
||||
entry.setSelected(isChecked);
|
||||
entry.setSelected(!entry.isSelected());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:scrollbars="vertical"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
@@ -1,36 +1,29 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="4dp"
|
||||
android:singleLine="true">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/import_item_selected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="top|center"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingTop="2dp" />
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginTop="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="24dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="24dp">
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dip"
|
||||
android:id="@+id/import_item_header_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toLeftOf="@+id/import_item_status"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@@ -44,6 +37,7 @@
|
||||
android:id="@+id/import_item_user_id_email"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="alice@example.com"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
@@ -56,39 +50,23 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
<ImageView
|
||||
android:id="@+id/import_item_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="4dp">
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/status_signature_revoked_cutout_24dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/import_item_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/status_signature_revoked_cutout_24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/import_item_algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="RSA"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/import_item_status_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
android:gravity="right" />
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/import_item_user_ids_list"
|
||||
@@ -104,6 +82,14 @@
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:typeface="monospace" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/import_item_algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="RSA"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
|
||||
<color name="primary">#7bad45</color>
|
||||
<color name="primaryLight">#e5f0da</color>
|
||||
|
||||
<color name="icons">#ffffff</color>
|
||||
<color name="transparent">#00ffffff</color>
|
||||
|
||||
Reference in New Issue
Block a user