From cca4b70b901969abfda8a431606c162061de07b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Wed, 20 May 2020 10:42:38 +0200 Subject: [PATCH] Fix card dashboard styling. - Center card text and make it darker. - Make card ripple when clicked. --- .../minicards/CardPreviewArrayAdapter.java | 12 ++++++--- app/src/main/res/layout/card_preview.xml | 27 +++++++++++++------ app/src/main/res/values/strings.xml | 1 + 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/codigoparallevar/minicards/CardPreviewArrayAdapter.java b/app/src/main/java/com/codigoparallevar/minicards/CardPreviewArrayAdapter.java index e0b8f69..0042d42 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/CardPreviewArrayAdapter.java +++ b/app/src/main/java/com/codigoparallevar/minicards/CardPreviewArrayAdapter.java @@ -17,6 +17,8 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import com.google.android.material.floatingactionbutton.FloatingActionButton; + import java.io.IOException; class CardPreviewArrayAdapter extends ArrayAdapter { @@ -41,7 +43,11 @@ class CardPreviewArrayAdapter extends ArrayAdapter { final View row = inflater.inflate(R.layout.card_preview, parent, false); final PreviewCard card = this.cards[position]; - row.setOnClickListener(new View.OnClickListener() { + TextView nameView = row.findViewById(R.id.card_preview_name); + final CardView cardView = row.findViewById(R.id.card_preview_card); + final FloatingActionButton settingsButton = row.findViewById(R.id.card_preview_settings_button); + + cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(CardActivity.INTENT); @@ -50,7 +56,7 @@ class CardPreviewArrayAdapter extends ArrayAdapter { } }); - final ImageView settingsButton = row.findViewById(R.id.card_preview_settings_button); + settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -58,8 +64,6 @@ class CardPreviewArrayAdapter extends ArrayAdapter { } }); - CardView cardView = row.findViewById(R.id.card_preview_card); - TextView nameView = row.findViewById(R.id.card_preview_name); nameView.setText(card.getName()); return row; diff --git a/app/src/main/res/layout/card_preview.xml b/app/src/main/res/layout/card_preview.xml index d136b2c..5cca6e4 100644 --- a/app/src/main/res/layout/card_preview.xml +++ b/app/src/main/res/layout/card_preview.xml @@ -16,6 +16,9 @@ android:layout_marginEnd="4dp" android:layout_marginRight="4dp" android:layout_marginBottom="8dp" + android:clickable="true" + android:focusable="auto" + android:foreground="?android:attr/selectableItemBackground" android:paddingLeft="15dp" android:paddingTop="5dp" android:paddingRight="15dp" @@ -28,23 +31,31 @@ card_view:layout_constraintStart_toStartOf="parent" card_view:layout_constraintTop_toTopOf="parent"> - + android:layout_height="100dp" + android:height="100dp"> + android:layout_marginEnd="20dp" + android:layout_marginRight="20dp" + android:layout_marginBottom="30dp" + android:text="@string/placeholder_text" + android:textColor="?android:attr/colorForeground" + android:textSize="25sp" + card_view:layout_constraintBottom_toBottomOf="parent" + card_view:layout_constraintEnd_toEndOf="parent" + card_view:layout_constraintStart_toStartOf="parent" + card_view:layout_constraintTop_toTopOf="parent" /> - + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 07d416e..2b9b2f9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,4 +15,5 @@ Login Loading... Invalid username/password + Placeholder text