From 6aa3808c4c269e5a2af5b5d66ca1961b3930f3a8 Mon Sep 17 00:00:00 2001 From: Guillaume HUSTA Date: Wed, 15 Feb 2023 11:27:41 +0100 Subject: [PATCH] Migrating to Material Components for Android Closes: #329 Closes: #315 --- .../android/dockersearch/MainActivity.java | 16 ++++---- app/src/main/res/layout/activity_taglist.xml | 4 ++ app/src/main/res/layout/dialog_about.xml | 11 ++--- .../layout/list_docker_image_child_item.xml | 20 ++++----- .../layout/list_docker_image_group_item.xml | 8 ++-- .../layout/list_docker_tag_detail_headers.xml | 4 +- .../layout/list_docker_tag_detail_item.xml | 4 +- .../main/res/layout/list_docker_tag_item.xml | 2 +- app/src/main/res/values-night/colors.xml | 20 ++++++--- app/src/main/res/values/colors.xml | 22 +++++++--- app/src/main/res/values/styles.xml | 41 +++++++++++++++++-- app/src/main/res/values/themes.xml | 5 ++- 12 files changed, 110 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/fr/husta/android/dockersearch/MainActivity.java b/app/src/main/java/fr/husta/android/dockersearch/MainActivity.java index 51fd7df..6c9b11b 100644 --- a/app/src/main/java/fr/husta/android/dockersearch/MainActivity.java +++ b/app/src/main/java/fr/husta/android/dockersearch/MainActivity.java @@ -24,6 +24,8 @@ import android.widget.TextView; import android.widget.Toast; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.ArrayList; import java.util.Collections; import java.util.Objects; @@ -411,16 +413,16 @@ public void clickAbout(MenuItem item) applicationVersion )); - AlertDialog.Builder builder = new AlertDialog.Builder(this); ApplicationInfo applicationInfo = getApplicationInfo(); PackageManager packageManager = getPackageManager(); Drawable icon = packageManager.getApplicationIcon(applicationInfo); - builder.setIcon(icon); - builder.setTitle(R.string.app_name); - builder.setView(messageView); - builder.setPositiveButton(android.R.string.ok, null); - builder.create(); - builder.show(); + new MaterialAlertDialogBuilder(this, R.style.Custom_ThemeOverlay_MaterialAlertDialog) + .setIcon(icon) + .setTitle(R.string.app_name) + .setView(messageView) + .setPositiveButton(android.R.string.ok, null) + .create() + .show(); } public void clickSubmitIssue(MenuItem item) diff --git a/app/src/main/res/layout/activity_taglist.xml b/app/src/main/res/layout/activity_taglist.xml index b00dfb9..de5c5fa 100644 --- a/app/src/main/res/layout/activity_taglist.xml +++ b/app/src/main/res/layout/activity_taglist.xml @@ -22,6 +22,9 @@ + diff --git a/app/src/main/res/layout/dialog_about.xml b/app/src/main/res/layout/dialog_about.xml index abedf9d..93536f0 100644 --- a/app/src/main/res/layout/dialog_about.xml +++ b/app/src/main/res/layout/dialog_about.xml @@ -19,8 +19,8 @@ android:autoLink="web" android:paddingTop="20dip" android:text="@string/msg_about_credits" - android:textColor="?android:attr/textColorPrimary" - android:textSize="16sp" /> + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" + android:textColor="?android:attr/textColorPrimary" /> + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" + android:textColor="?android:attr/textColorPrimary" /> + tools:ignore="HardcodedText" /> diff --git a/app/src/main/res/layout/list_docker_image_child_item.xml b/app/src/main/res/layout/list_docker_image_child_item.xml index 3cf4a96..ca353d9 100644 --- a/app/src/main/res/layout/list_docker_image_child_item.xml +++ b/app/src/main/res/layout/list_docker_image_child_item.xml @@ -8,37 +8,37 @@ android:gravity="center_vertical|center_horizontal" android:orientation="horizontal"> + + app:tint="?attr/colorOnPrimary" + tools:ignore="HardcodedText" /> + tools:ignore="HardcodedText" /> + tools:ignore="HardcodedText" /> \ No newline at end of file diff --git a/app/src/main/res/layout/list_docker_image_group_item.xml b/app/src/main/res/layout/list_docker_image_group_item.xml index f72afa3..929f48e 100644 --- a/app/src/main/res/layout/list_docker_image_group_item.xml +++ b/app/src/main/res/layout/list_docker_image_group_item.xml @@ -13,7 +13,7 @@ android:layout_marginEnd="2dp" android:ellipsize="end" android:maxLines="2" - android:textAppearance="@style/TextAppearance.AppCompat.Large" + android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6" android:textColor="@color/textColorPrimary" app:layout_constraintBottom_toTopOf="@+id/listitem_image_desc" app:layout_constraintEnd_toStartOf="@id/barrier_1" @@ -30,6 +30,8 @@ android:layout_marginBottom="2dp" android:ellipsize="end" android:maxLines="2" + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2" + android:textColor="@color/textColorSecondary" app:layout_constraintEnd_toStartOf="@id/barrier_1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/listitem_image_name" @@ -55,7 +57,7 @@ app:layout_constraintStart_toStartOf="@+id/listitem_image_stars" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/ic_star_24dp" - app:tint="@color/secondaryTextColor" + app:tint="@color/textColorSecondary" tools:ignore="ContentDescription" tools:layout_gravity="center" /> @@ -88,7 +90,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/listitem_image_stars" app:srcCompat="@drawable/ic_official_image" - app:tint="@color/secondaryTextColor" + app:tint="@color/textColorSecondary" tools:ignore="ContentDescription" tools:layout_gravity="center" /> diff --git a/app/src/main/res/layout/list_docker_tag_detail_headers.xml b/app/src/main/res/layout/list_docker_tag_detail_headers.xml index c379d51..ce92e1a 100644 --- a/app/src/main/res/layout/list_docker_tag_detail_headers.xml +++ b/app/src/main/res/layout/list_docker_tag_detail_headers.xml @@ -18,7 +18,7 @@ android:text="@string/lbl_header_digest" android:textAlignment="textStart" android:textAllCaps="true" - android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" android:textColor="@color/textColorPrimary" android:textStyle="bold" tools:text="Digest" /> @@ -30,7 +30,7 @@ android:text="@string/lbl_header_osarch" android:textAlignment="textStart" android:textAllCaps="true" - android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" android:textColor="@color/textColorPrimary" android:textStyle="bold" tools:text="OS/Arch" /> diff --git a/app/src/main/res/layout/list_docker_tag_detail_item.xml b/app/src/main/res/layout/list_docker_tag_detail_item.xml index 898d691..e3e8ea5 100644 --- a/app/src/main/res/layout/list_docker_tag_detail_item.xml +++ b/app/src/main/res/layout/list_docker_tag_detail_item.xml @@ -17,7 +17,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:textAlignment="textStart" - android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" android:textColor="@color/textColorPrimary" tools:text="sha256" /> @@ -27,7 +27,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:textAlignment="textStart" - android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" android:textColor="@color/textColorPrimary" tools:text="linux/amd64" /> diff --git a/app/src/main/res/layout/list_docker_tag_item.xml b/app/src/main/res/layout/list_docker_tag_item.xml index 1d7a5ef..d8f4ef0 100644 --- a/app/src/main/res/layout/list_docker_tag_item.xml +++ b/app/src/main/res/layout/list_docker_tag_item.xml @@ -16,7 +16,7 @@ android:layout_marginEnd="1dp" android:ellipsize="end" android:maxLines="2" - android:textAppearance="@style/TextAppearance.AppCompat.Large" + android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6" android:textColor="@color/textColorPrimary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/barrier_1" diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index d2b1362..a2a01a4 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -1,13 +1,21 @@ #2F3D46 - #191B1B + #FFFFFF + #191B1B - - #157CAD - #DFA031 + #1593cd - #FF1593CD + + #1593cd + #FFFFFF + + @color/colorPrimary + #FFFFFF - #66FFFFFF + @color/m3_sys_color_dark_inverse_surface + @color/m3_sys_color_dark_inverse_on_surface + + #FF1593CD + #66FFFFFF diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 912c2ca..23f41bb 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,14 +1,24 @@ #1593cd - #09658f + #FFFFFF + #09658f - - #138ac1 - #ffab00 + #1593cd + + + #1593cd + #FFFFFF + + #FFFFFF + #1593cd + + @color/m3_sys_color_light_inverse_surface + @color/m3_sys_color_light_inverse_on_surface - #FF1593CD + #66000000 - #4D000000 + + #DFA031 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 26d0bdd..7feea3b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,14 +1,49 @@ - + + + + + + + + + + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index d907dd5..6738ced 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -5,7 +5,8 @@ true -