From d22d50f9e28bc5c922c42d88dbefcf7bcdcf1d75 Mon Sep 17 00:00:00 2001 From: memms Date: Mon, 1 Apr 2024 12:40:43 -0400 Subject: [PATCH] style: Added relevant icons for preferences UI #4902 (#4992) #### Description Added appropriate icons (SVG) to the preferences fragment UI. SVGs (most) used (and edited) from svgrepo. Appropriate licensing was checked to allow change and use of the SVG. #### Related issues Fixes #4902 #### Screenshots ![p1](https://github.com/openfoodfacts/openfoodfacts-androidapp/assets/16926153/d9342ced-98d8-471c-8481-6a674318d79a) ![p2](https://github.com/openfoodfacts/openfoodfacts-androidapp/assets/16926153/aa070bf1-9faa-4c19-844f-728cbffb8bf0) ![p3](https://github.com/openfoodfacts/openfoodfacts-androidapp/assets/16926153/bc09992a-347c-45cf-9375-cc1e6f792287) ![p4](https://github.com/openfoodfacts/openfoodfacts-androidapp/assets/16926153/976e13b8-e553-4f56-a90b-702e3b29c8c1) #### Link to the automatically generated build APK --- .../preferences/PreferencesFragment.kt | 13 +++++- .../drawable/ic_preference_all_products.xml | 10 +++++ .../res/drawable/ic_preference_contact.xml | 21 +++++++++ .../res/drawable/ic_preference_country.xml | 10 +++++ .../drawable/ic_preference_crash_report.xml | 14 ++++++ .../main/res/drawable/ic_preference_crop.xml | 10 +++++ .../ic_preference_database_export.xml | 12 +++++ .../res/drawable/ic_preference_donate.xml | 10 +++++ .../main/res/drawable/ic_preference_drop.xml | 10 +++++ .../res/drawable/ic_preference_energy.xml | 10 +++++ .../main/res/drawable/ic_preference_faq.xml | 21 +++++++++ .../main/res/drawable/ic_preference_fast.xml | 21 +++++++++ .../res/drawable/ic_preference_image_res.xml | 10 +++++ .../res/drawable/ic_preference_language.xml | 10 +++++ .../drawable/ic_preference_mobile_data.xml | 19 ++++++++ .../res/drawable/ic_preference_no_image.xml | 10 +++++ .../res/drawable/ic_preference_power_mode.xml | 37 +++++++++++++++ .../res/drawable/ic_preference_scanner.xml | 45 +++++++++++++++++++ .../res/drawable/ic_preference_send_data.xml | 14 ++++++ .../main/res/drawable/ic_preference_share.xml | 15 +++++++ .../main/res/drawable/ic_preference_star.xml | 10 +++++ .../res/drawable/ic_preference_startup.xml | 40 +++++++++++++++++ .../main/res/drawable/ic_preference_terms.xml | 13 ++++++ .../main/res/drawable/ic_preference_theme.xml | 10 +++++ .../main/res/drawable/ic_preference_trash.xml | 42 +++++++++++++++++ .../main/res/drawable/ic_preference_vegan.xml | 10 +++++ .../res/drawable/ic_preference_vegetarian.xml | 15 +++++++ .../res/drawable/ic_preference_volume.xml | 14 ++++++ app/src/main/res/xml/preferences.xml | 27 ++++++++++- 29 files changed, 501 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/ic_preference_all_products.xml create mode 100644 app/src/main/res/drawable/ic_preference_contact.xml create mode 100644 app/src/main/res/drawable/ic_preference_country.xml create mode 100644 app/src/main/res/drawable/ic_preference_crash_report.xml create mode 100644 app/src/main/res/drawable/ic_preference_crop.xml create mode 100644 app/src/main/res/drawable/ic_preference_database_export.xml create mode 100644 app/src/main/res/drawable/ic_preference_donate.xml create mode 100644 app/src/main/res/drawable/ic_preference_drop.xml create mode 100644 app/src/main/res/drawable/ic_preference_energy.xml create mode 100644 app/src/main/res/drawable/ic_preference_faq.xml create mode 100644 app/src/main/res/drawable/ic_preference_fast.xml create mode 100644 app/src/main/res/drawable/ic_preference_image_res.xml create mode 100644 app/src/main/res/drawable/ic_preference_language.xml create mode 100644 app/src/main/res/drawable/ic_preference_mobile_data.xml create mode 100644 app/src/main/res/drawable/ic_preference_no_image.xml create mode 100644 app/src/main/res/drawable/ic_preference_power_mode.xml create mode 100644 app/src/main/res/drawable/ic_preference_scanner.xml create mode 100644 app/src/main/res/drawable/ic_preference_send_data.xml create mode 100644 app/src/main/res/drawable/ic_preference_share.xml create mode 100644 app/src/main/res/drawable/ic_preference_star.xml create mode 100644 app/src/main/res/drawable/ic_preference_startup.xml create mode 100644 app/src/main/res/drawable/ic_preference_terms.xml create mode 100644 app/src/main/res/drawable/ic_preference_theme.xml create mode 100644 app/src/main/res/drawable/ic_preference_trash.xml create mode 100644 app/src/main/res/drawable/ic_preference_vegan.xml create mode 100644 app/src/main/res/drawable/ic_preference_vegetarian.xml create mode 100644 app/src/main/res/drawable/ic_preference_volume.xml diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/features/preferences/PreferencesFragment.kt b/app/src/main/java/openfoodfacts/github/scrachx/openfood/features/preferences/PreferencesFragment.kt index 8ab7d95ab33c..c305c54de9ca 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/features/preferences/PreferencesFragment.kt +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/features/preferences/PreferencesFragment.kt @@ -28,6 +28,7 @@ import android.widget.Toast import androidx.annotation.StringRes import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate +import androidx.core.content.ContextCompat import androidx.core.content.edit import androidx.core.content.pm.PackageInfoCompat import androidx.core.net.toUri @@ -395,9 +396,11 @@ class PreferencesFragment : PreferenceFragmentCompat(), INavigationItem { pref.summary = null pref.widgetLayoutResource = R.layout.loading } + WorkInfo.State.SUCCEEDED -> { setupAnalysisTagConfigs() } + else -> Unit // Nothing } } @@ -416,7 +419,15 @@ class PreferencesFragment : PreferenceFragmentCompat(), INavigationItem { key = config.type title = getString(R.string.display_analysis_tag_status, config.typeName.lowercase(Locale.getDefault())) - + val drawable = when (config.typeName.lowercase(Locale.getDefault())) { + "palm oil" -> R.drawable.ic_preference_drop + "vegan" -> R.drawable.ic_preference_vegan + "vegetarian" -> R.drawable.ic_preference_vegetarian + else -> null + } + drawable?.let { + icon = ContextCompat.getDrawable(requireContext(), it) + } summary = null summaryOn = null summaryOff = null diff --git a/app/src/main/res/drawable/ic_preference_all_products.xml b/app/src/main/res/drawable/ic_preference_all_products.xml new file mode 100644 index 000000000000..2da33526a037 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_all_products.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_contact.xml b/app/src/main/res/drawable/ic_preference_contact.xml new file mode 100644 index 000000000000..06631914c343 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_contact.xml @@ -0,0 +1,21 @@ + + + + diff --git a/app/src/main/res/drawable/ic_preference_country.xml b/app/src/main/res/drawable/ic_preference_country.xml new file mode 100644 index 000000000000..dac28695ad45 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_country.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_crash_report.xml b/app/src/main/res/drawable/ic_preference_crash_report.xml new file mode 100644 index 000000000000..58721c21b15a --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_crash_report.xml @@ -0,0 +1,14 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_crop.xml b/app/src/main/res/drawable/ic_preference_crop.xml new file mode 100644 index 000000000000..9f6f282296dd --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_crop.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_database_export.xml b/app/src/main/res/drawable/ic_preference_database_export.xml new file mode 100644 index 000000000000..9448afb24c58 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_database_export.xml @@ -0,0 +1,12 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_donate.xml b/app/src/main/res/drawable/ic_preference_donate.xml new file mode 100644 index 000000000000..b5118de3d23e --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_donate.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_drop.xml b/app/src/main/res/drawable/ic_preference_drop.xml new file mode 100644 index 000000000000..8a1d5446d0e5 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_drop.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_energy.xml b/app/src/main/res/drawable/ic_preference_energy.xml new file mode 100644 index 000000000000..fc8734cf0da6 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_energy.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_faq.xml b/app/src/main/res/drawable/ic_preference_faq.xml new file mode 100644 index 000000000000..642ed169ea3c --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_faq.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_preference_fast.xml b/app/src/main/res/drawable/ic_preference_fast.xml new file mode 100644 index 000000000000..d7b3556446b7 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_fast.xml @@ -0,0 +1,21 @@ + + + + diff --git a/app/src/main/res/drawable/ic_preference_image_res.xml b/app/src/main/res/drawable/ic_preference_image_res.xml new file mode 100644 index 000000000000..ecb636cc411b --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_image_res.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_language.xml b/app/src/main/res/drawable/ic_preference_language.xml new file mode 100644 index 000000000000..bd28d6856472 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_language.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_mobile_data.xml b/app/src/main/res/drawable/ic_preference_mobile_data.xml new file mode 100644 index 000000000000..7992903db5bb --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_mobile_data.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_preference_no_image.xml b/app/src/main/res/drawable/ic_preference_no_image.xml new file mode 100644 index 000000000000..5b23fd2fd44c --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_no_image.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_power_mode.xml b/app/src/main/res/drawable/ic_preference_power_mode.xml new file mode 100644 index 000000000000..4d0b8571da14 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_power_mode.xml @@ -0,0 +1,37 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_preference_scanner.xml b/app/src/main/res/drawable/ic_preference_scanner.xml new file mode 100644 index 000000000000..1357cb2168e8 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_scanner.xml @@ -0,0 +1,45 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_preference_send_data.xml b/app/src/main/res/drawable/ic_preference_send_data.xml new file mode 100644 index 000000000000..ca7e9e63eeaf --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_send_data.xml @@ -0,0 +1,14 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_share.xml b/app/src/main/res/drawable/ic_preference_share.xml new file mode 100644 index 000000000000..f2bd3cc08b5f --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_share.xml @@ -0,0 +1,15 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_star.xml b/app/src/main/res/drawable/ic_preference_star.xml new file mode 100644 index 000000000000..d69796b1f4be --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_star.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_startup.xml b/app/src/main/res/drawable/ic_preference_startup.xml new file mode 100644 index 000000000000..feb48cab7c0b --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_startup.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_preference_terms.xml b/app/src/main/res/drawable/ic_preference_terms.xml new file mode 100644 index 000000000000..1d0df0a89bc2 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_terms.xml @@ -0,0 +1,13 @@ + + + + diff --git a/app/src/main/res/drawable/ic_preference_theme.xml b/app/src/main/res/drawable/ic_preference_theme.xml new file mode 100644 index 000000000000..659fca68ae1d --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_theme.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_trash.xml b/app/src/main/res/drawable/ic_preference_trash.xml new file mode 100644 index 000000000000..3e42f81469bf --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_trash.xml @@ -0,0 +1,42 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_preference_vegan.xml b/app/src/main/res/drawable/ic_preference_vegan.xml new file mode 100644 index 000000000000..e5c6d1d7de25 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_vegan.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_preference_vegetarian.xml b/app/src/main/res/drawable/ic_preference_vegetarian.xml new file mode 100644 index 000000000000..a0f64c32c683 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_vegetarian.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_preference_volume.xml b/app/src/main/res/drawable/ic_preference_volume.xml new file mode 100644 index 000000000000..73b801308a05 --- /dev/null +++ b/app/src/main/res/drawable/ic_preference_volume.xml @@ -0,0 +1,14 @@ + + + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index a5c48ff3ab3e..dffc9bedb8a3 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -18,6 +18,7 @@ android:defaultValue="@string/pref_app_theme_default" android:dialogTitle="@string/pref_app_theme_dialog_title" android:key="@string/pref_app_theme_key" + android:icon="@drawable/ic_preference_theme" android:title="@string/pref_app_theme_title" app:useSimpleSummaryProvider="true" /> @@ -25,6 +26,7 @@ android:defaultValue="@string/kcal" android:dialogTitle="@string/pref_energy_unit_title" android:key="@string/pref_energy_unit_key" + android:icon="@drawable/ic_preference_energy" android:title="@string/pref_energy_unit_title" app:useSimpleSummaryProvider="true" /> @@ -33,18 +35,21 @@ android:dialogTitle="@string/pref_volume_unit_title" android:key="@string/pref_volume_unit_key" android:title="@string/pref_volume_unit_title" + android:icon="@drawable/ic_preference_volume" app:useSimpleSummaryProvider="true" /> @@ -82,6 +91,7 @@ android:key="@string/pref_enable_mobile_data_key" android:summaryOff="@string/pref_enable_mobile_data_summary_off" android:summaryOn="@string/pref_enable_mobile_data_summary_on" + android:icon="@drawable/ic_preference_mobile_data" android:title="@string/pref_enable_mobile_data_title" /> android:summaryOff="@string/pref_low_battery_summary" /> @@ -113,7 +125,8 @@ + android:title="@string/Donate" + android:icon="@drawable/ic_preference_donate"> @@ -122,6 +135,7 @@ @@ -129,6 +143,7 @@ android:defaultValue="true" android:key="cropNewImage" android:summaryOn="@string/pref_crop_new_images_summary" + android:icon="@drawable/ic_preference_crop" android:title="@string/pref_crop_new_images_title" /> android:summaryOff="@string/pref_crop_new_images_summary" /> @@ -136,6 +151,7 @@ android:defaultValue="true" android:key="@string/pref_fast_addition_key" android:summaryOn="@string/pref_fast_addition_summary" + android:icon="@drawable/ic_preference_fast" android:title="@string/pref_fast_addition_title" /> android:summaryOff="@string/pref_fast_addition_summary" /> @@ -143,6 +159,7 @@ android:defaultValue="false" android:key="@string/pref_contribution_tab_key" android:summaryOn="@string/pref_contribution_tab_summary" + android:icon="@drawable/ic_preference_share" android:title="@string/pref_contribution_tab_title" /> android:summaryOff="@string/pref_contribution_tab_summary" /> @@ -150,6 +167,7 @@ android:defaultValue="false" android:key="@string/pref_show_product_photos_key" android:summaryOn="@string/pref_show_product_photos_summary" + android:icon="@drawable/ic_preference_all_products" android:title="@string/pref_show_product_photos_title" /> android:summaryOff="@string/pref_show_product_photos_summary" /> @@ -164,6 +182,7 @@ android:key="@string/pref_crash_reporting_key" android:summaryOff="@string/preference_crash_summary" android:summaryOn="@string/preference_crash_summary" + android:icon="@drawable/ic_preference_crash_report" android:title="@string/preference_crash_title" /> @@ -183,20 +203,25 @@ +