ImportKeys: Make the design more usable

- Make card clickable
- Move import button in expanded part of the card
This commit is contained in:
Andrea Torlaschi
2016-08-23 16:22:12 +02:00
parent 89dcb2535d
commit 9b2e899f4f
6 changed files with 149 additions and 162 deletions

View File

@@ -35,8 +35,8 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.databinding.ImportKeysListBasicItemBinding;
import org.sufficientlysecure.keychain.databinding.ImportKeysListFragmentBinding; import org.sufficientlysecure.keychain.databinding.ImportKeysListFragmentBinding;
import org.sufficientlysecure.keychain.databinding.ImportKeysListItemBasicBinding;
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.keyimport.processing.AsyncTaskResultWrapper; import org.sufficientlysecure.keychain.keyimport.processing.AsyncTaskResultWrapper;
import org.sufficientlysecure.keychain.keyimport.processing.BytesLoaderState; import org.sufficientlysecure.keychain.keyimport.processing.BytesLoaderState;
@@ -69,7 +69,7 @@ public class ImportKeysListFragment extends Fragment implements
private ImportKeysListener mListener; private ImportKeysListener mListener;
private ImportKeysListFragmentBinding mBinding; private ImportKeysListFragmentBinding mBinding;
private ImportKeysListItemBasicBinding mBindingBasic; private ImportKeysListBasicItemBinding mBindingBasic;
private ParcelableProxy mParcelableProxy; private ParcelableProxy mParcelableProxy;
private ImportKeysAdapter mAdapter; private ImportKeysAdapter mAdapter;

View File

@@ -126,14 +126,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
final boolean downloaded = keyState.mDownloaded; final boolean downloaded = keyState.mDownloaded;
final boolean showed = keyState.mShowed; final boolean showed = keyState.mShowed;
b.importKey.setOnClickListener(new View.OnClickListener() { b.card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getKey(entry, false);
}
});
b.expand.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
mCurrent = position; mCurrent = position;
@@ -145,15 +138,12 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
} }
}); });
float rotation = showed ? 180 : 0; b.extra.importKey.setOnClickListener(new View.OnClickListener() {
if (!keyState.mAnimated) { @Override
keyState.mAnimated = true; public void onClick(View v) {
float oldRotation = !showed ? 180 : 0; getKey(entry, false);
b.expand.setRotation(oldRotation); }
b.expand.animate().rotation(rotation).start(); });
} else {
b.expand.setRotation(rotation);
}
b.extraContainer.setVisibility(showed ? View.VISIBLE : View.GONE); b.extraContainer.setVisibility(showed ? View.VISIBLE : View.GONE);
} }
@@ -234,13 +224,11 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
private class KeyState { private class KeyState {
public boolean mDownloaded = false; public boolean mDownloaded = false;
public boolean mShowed = false; public boolean mShowed = false;
public boolean mAnimated = true;
} }
private void changeState(int position, boolean showed) { private void changeState(int position, boolean showed) {
KeyState keyState = mKeyStates[position]; KeyState keyState = mKeyStates[position];
keyState.mShowed = showed; keyState.mShowed = showed;
keyState.mAnimated = true;
notifyItemChanged(position); notifyItemChanged(position);
} }

View File

@@ -49,7 +49,7 @@
<include <include
android:id="@+id/basic" android:id="@+id/basic"
layout="@layout/import_keys_list_item_basic" /> layout="@layout/import_keys_list_basic_item" />
</LinearLayout> </LinearLayout>

View File

@@ -7,9 +7,11 @@
<variable name="nonInteractive" type="boolean" /> <variable name="nonInteractive" type="boolean" />
<variable name="entry" type="ImportKeysListEntry" /> <variable name="entry" type="ImportKeysListEntry" />
<variable name="expanded" type="boolean" />
</data> </data>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
@@ -20,102 +22,82 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="24dp"> android:paddingBottom="8dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="16dp" android:paddingBottom="16dp"
android:paddingLeft="16dp" android:paddingTop="24dp">
android:paddingRight="16dp">
<RelativeLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:orientation="horizontal">
android:layout_toLeftOf="@+id/status"
android:orientation="vertical">
<TextView <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/status"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
app:keyRevokedOrExpired="@{entry.revokedOrExpired}"
app:keySecret="@{entry.secretKey}"
app:keyUserId="@{entry.primaryUserId.name}"
app:query="@{entry.query}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAppearance="?android:attr/textAppearanceSmall"
app:keyRevokedOrExpired="@{entry.revokedOrExpired}"
app:keyUserEmail="@{entry.primaryUserId.email}"
app:query="@{entry.query}" />
</LinearLayout>
<ImageView
android:id="@+id/status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_alignParentRight="true"
app:keyRevokedOrExpired="@{entry.revokedOrExpired}" android:layout_centerVertical="true"
app:keySecret="@{entry.secretKey}" android:visibility="@{entry.revokedOrExpired ? V.VISIBLE : V.GONE}"
app:keyUserId="@{entry.primaryUserId.name}" app:keyExpired="@{entry.expired}"
app:query="@{entry.query}" /> app:keyRevoked="@{entry.revoked}" />
<TextView </RelativeLayout>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAppearance="?android:attr/textAppearanceSmall"
app:keyRevokedOrExpired="@{entry.revokedOrExpired}"
app:keyUserEmail="@{entry.primaryUserId.email}"
app:query="@{entry.query}" />
</LinearLayout> </LinearLayout>
<ImageView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="@{entry.revokedOrExpired ? V.VISIBLE : V.GONE}"
app:keyExpired="@{entry.expired}"
app:keyRevoked="@{entry.revoked}" />
</RelativeLayout>
</LinearLayout> </LinearLayout>
<RelativeLayout <FrameLayout
android:id="@+id/extra_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:animateLayoutChanges="true"
android:visibility="@{nonInteractive ? V.GONE : V.VISIBLE}"> android:orientation="vertical"
android:visibility="gone">
<Button <include
android:id="@+id/import_key" android:id="@+id/extra"
style="@style/CardViewActionButton" layout="@layout/import_keys_list_item_extra"
android:text="@string/btn_import" /> app:entry="@{entry}" />
<ImageButton
android:id="@+id/expand"
style="@style/CardViewActionButton"
android:layout_alignParentRight="true"
android:src="@drawable/ic_expand_more_black_24dp" />
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/extra_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingBottom="24dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:visibility="gone">
<include
layout="@layout/import_keys_list_item_extra"
app:entry="@{entry}" />
</LinearLayout>
</FrameLayout> </FrameLayout>

View File

@@ -10,78 +10,95 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:paddingLeft="8dp"
<LinearLayout android:paddingRight="8dp">
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_key_id_colon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText"
app:keyId="@{entry.keyIdHex}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_algorithm_colon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="@{entry.algorithm ?? @string/unknown}"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_creation_colon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText"
app:keyCreation="@{entry.date}" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="vertical" android:orientation="vertical"
app:keyUserIds="@{entry.sortedUserIds}" android:paddingBottom="16dp"
app:query="@{entry.query}" /> android:paddingLeft="8dp"
android:paddingRight="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_key_id_colon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText"
app:keyId="@{entry.keyIdHex}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_algorithm_colon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="@{entry.algorithm ?? @string/unknown}"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_creation_colon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorText"
app:keyCreation="@{entry.date}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="vertical"
app:keyUserIds="@{entry.sortedUserIds}"
app:query="@{entry.query}" />
</LinearLayout>
<Button
android:id="@+id/import_key"
style="@style/CardViewActionButton"
android:text="@string/btn_import" />
</LinearLayout> </LinearLayout>