From e85ac8ed33fd190c4a52e31d7b679d3c650d5e98 Mon Sep 17 00:00:00 2001 From: Thomas <tschneider.ac@gmail.com> Date: Mon, 24 Oct 2022 09:55:54 +0200 Subject: [PATCH] Settings for icon size --- .../android/ui/drawer/StatusAdapter.java | 27 ++++++++++--------- .../settings/FragmentInterfaceSettings.java | 11 ++++++++ app/src/main/res/values/strings.xml | 6 ++++- app/src/main/res/xml/pref_compose.xml | 3 +++ app/src/main/res/xml/pref_interface.xml | 14 ++++++++++ 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index e8f327e6..eba2cdf4 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -924,6 +924,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> } //final float scale = context.getResources().getDisplayMetrics().density; final float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f); + final float scaleIcon = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE_ICON), 1.1f); if (statusToDeal.account.locked) { Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_lock_24); assert img != null; @@ -934,22 +935,22 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> } //Button sizes depending of the defined scale float normalSize = Helper.convertDpToPixel(28, context); - holder.binding.actionButtonReply.getLayoutParams().width = (int) (normalSize * scale); - holder.binding.actionButtonReply.getLayoutParams().height = (int) (normalSize * scale); + holder.binding.actionButtonReply.getLayoutParams().width = (int) (normalSize * scaleIcon); + holder.binding.actionButtonReply.getLayoutParams().height = (int) (normalSize * scaleIcon); holder.binding.actionButtonReply.requestLayout(); - holder.binding.actionButtonBoost.setImageSize((int) (normalSize * scale)); - holder.binding.actionButtonFavorite.setImageSize((int) (normalSize * scale)); - holder.binding.actionButtonBookmark.setImageSize((int) (normalSize * scale)); - holder.binding.statusAddCustomEmoji.getLayoutParams().width = (int) (normalSize * scale); - holder.binding.statusAddCustomEmoji.getLayoutParams().height = (int) (normalSize * scale); + holder.binding.actionButtonBoost.setImageSize((int) (normalSize * scaleIcon)); + holder.binding.actionButtonFavorite.setImageSize((int) (normalSize * scaleIcon)); + holder.binding.actionButtonBookmark.setImageSize((int) (normalSize * scaleIcon)); + holder.binding.statusAddCustomEmoji.getLayoutParams().width = (int) (normalSize * scaleIcon); + holder.binding.statusAddCustomEmoji.getLayoutParams().height = (int) (normalSize * scaleIcon); holder.binding.statusAddCustomEmoji.requestLayout(); - holder.binding.statusEmoji.getLayoutParams().width = (int) (normalSize * scale); - holder.binding.statusEmoji.getLayoutParams().height = (int) (normalSize * scale); - holder.binding.actionButtonMore.getLayoutParams().width = (int) (normalSize * scale); - holder.binding.actionButtonMore.getLayoutParams().height = (int) (normalSize * scale); + holder.binding.statusEmoji.getLayoutParams().width = (int) (normalSize * scaleIcon); + holder.binding.statusEmoji.getLayoutParams().height = (int) (normalSize * scaleIcon); + holder.binding.actionButtonMore.getLayoutParams().width = (int) (normalSize * scaleIcon); + holder.binding.actionButtonMore.getLayoutParams().height = (int) (normalSize * scaleIcon); holder.binding.actionButtonMore.requestLayout(); - holder.binding.actionShare.getLayoutParams().width = (int) (normalSize * scale); - holder.binding.actionShare.getLayoutParams().height = (int) (normalSize * scale); + holder.binding.actionShare.getLayoutParams().width = (int) (normalSize * scaleIcon); + holder.binding.actionShare.getLayoutParams().height = (int) (normalSize * scaleIcon); holder.binding.actionShare.requestLayout(); if (statusToDeal.account.bot) { diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentInterfaceSettings.java b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentInterfaceSettings.java index 8eda3aa3..1fc5545f 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentInterfaceSettings.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentInterfaceSettings.java @@ -49,6 +49,11 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen SET_FONT_SCALE.setMax(180); SET_FONT_SCALE.setMin(80); } + SeekBarPreference SET_FONT_SCALE_ICON = findPreference(getString(R.string.SET_FONT_SCALE_ICON_INT)); + if (SET_FONT_SCALE_ICON != null) { + SET_FONT_SCALE_ICON.setMax(180); + SET_FONT_SCALE_ICON.setMin(80); + } recreate = false; } @@ -63,6 +68,12 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen editor.putFloat(getString(R.string.SET_FONT_SCALE), scale); recreate = true; } + if (key.compareToIgnoreCase(getString(R.string.SET_FONT_SCALE_ICON_INT)) == 0) { + int progress = sharedPreferences.getInt(getString(R.string.SET_FONT_SCALE_ICON_INT), 110); + float scale = (float) (progress) / 100.0f; + editor.putFloat(getString(R.string.SET_FONT_SCALE_ICON), scale); + recreate = true; + } if (key.compareToIgnoreCase(getString(R.string.SET_USE_SINGLE_TOPBAR)) == 0) { recreate = true; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b74c404e..9c872089 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,7 +31,8 @@ <string name="camera">Camera</string> <string name="delete_all">Delete all</string> <string name="schedule">Schedule</string> - <string name="text_size">Text and icon sizes</string> + <string name="text_size">Text sizes</string> + <string name="icon_size">Icon sizes</string> <string name="next">Next</string> <string name="previous">Previous</string> <string name="open_with">Open with</string> @@ -915,6 +916,9 @@ <string name="SET_NOTIF_STATUS" translatable="false">SET_NOTIF_STATUS</string> <string name="SET_FONT_SCALE" translatable="false">SET_FONT_SCALE</string> <string name="SET_FONT_SCALE_INT" translatable="false">SET_FONT_SCALE_INT</string> + <string name="SET_FONT_SCALE_ICON" translatable="false">SET_FONT_SCALE_ICON</string> + <string name="SET_FONT_SCALE_ICON_INT" translatable="false">SET_FONT_SCALE_ICON_INT</string> + <string name="SET_FILTER_REGEX_HOME" translatable="false">SET_FILTER_REGEX_HOME</string> <string name="SET_FILTER_REGEX_LOCAL" translatable="false">SET_FILTER_REGEX_LOCAL</string> <string name="SET_FILTER_REGEX_PUBLIC" translatable="false">SET_FILTER_REGEX_PUBLIC</string> diff --git a/app/src/main/res/xml/pref_compose.xml b/app/src/main/res/xml/pref_compose.xml index 19fcdf4d..f1bbccb7 100644 --- a/app/src/main/res/xml/pref_compose.xml +++ b/app/src/main/res/xml/pref_compose.xml @@ -61,6 +61,7 @@ <SwitchPreferenceCompat app:defaultValue="true" app:iconSpaceReserved="false" + app:singleLineTitle="false" app:key="@string/SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL" app:title="@string/set_retrieve_metadata_share_from_extras" /> @@ -68,6 +69,7 @@ <SwitchPreferenceCompat app:iconSpaceReserved="false" app:key="@string/SET_CUSTOM_SHARING" + app:singleLineTitle="false" app:summary="@string/settings_title_custom_sharing_indication" app:title="@string/settings_title_custom_sharing" /> @@ -79,6 +81,7 @@ app:useSimpleSummaryProvider="true" /> <SwitchPreferenceCompat + app:singleLineTitle="false" app:iconSpaceReserved="false" app:key="@string/SET_FORWARD_TAGS_IN_REPLY" app:title="@string/set_forward_tags" /> diff --git a/app/src/main/res/xml/pref_interface.xml b/app/src/main/res/xml/pref_interface.xml index 1691ff1d..3e988e11 100644 --- a/app/src/main/res/xml/pref_interface.xml +++ b/app/src/main/res/xml/pref_interface.xml @@ -70,14 +70,26 @@ <androidx.preference.SeekBarPreference android:defaultValue="110" android:max="180" + app:singleLineTitle="false" app:iconSpaceReserved="false" app:key="@string/SET_FONT_SCALE_INT" app:showSeekBarValue="true" app:title="@string/text_size" /> + + <androidx.preference.SeekBarPreference + android:defaultValue="110" + android:max="180" + app:iconSpaceReserved="false" + app:key="@string/SET_FONT_SCALE_ICON_INT" + app:showSeekBarValue="true" + app:singleLineTitle="false" + app:title="@string/icon_size" /> + <androidx.preference.SeekBarPreference android:defaultValue="100" android:max="1000" + app:singleLineTitle="false" app:iconSpaceReserved="false" app:key="@string/SET_VIDEO_CACHE" app:showSeekBarValue="true" @@ -86,6 +98,7 @@ <androidx.preference.SeekBarPreference android:defaultValue="5" android:max="30" + app:singleLineTitle="false" app:iconSpaceReserved="false" app:key="@string/SET_NSFW_TIMEOUT" app:showSeekBarValue="true" @@ -94,6 +107,7 @@ <androidx.preference.SeekBarPreference android:defaultValue="3" android:max="30" + app:singleLineTitle="false" app:iconSpaceReserved="false" app:key="@string/SET_MED_DESC_TIMEOUT" app:showSeekBarValue="true"