Skip to content

Commit

Permalink
auto-resize search suggestion text to avoid horizontal cuts on device…
Browse files Browse the repository at this point in the history
…s with bigger text sizes
  • Loading branch information
CampelloManuel committed Apr 28, 2024
1 parent 5b58949 commit e4620a4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/src/main/res/values-v26/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- When users increase the text size in the accessibility settings, the search suggestions
popup cuts the text (it only shows the top half of the letters), because the height of the
"dropdown menu list item" is fixed somewhere. We solve the bug with this override of the style
used by "dropdown list items" such as the search suggestions -->
<style name="ReadableSearchSuggestionListItem" parent="android:Widget.Material.DropDownItem">
<!-- we force the text to resize in order to fit the fixed height of the list item -->
<item name="android:autoSizeTextType">uniform</item>
<item name="android:autoSizeMinTextSize">1sp</item>
<item name="android:autoSizeStepGranularity">0.1sp</item>
<item name="android:autoSizeMaxTextSize">50sp</item>
</style>
</resources>
9 changes: 9 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,13 @@
<item name="android:padding">0dp</item>
</style>

<!-- When users increase the text size in the accessibility settings, the search suggestions
popup cuts the text (it only shows the top half of the letters), because the height of the
"dropdown menu list item" is fixed somewhere. We solve the bug with this override of the style
used by "dropdown list items" such as the search suggestions -->
<style name="ReadableSearchSuggestionListItem" parent="android:Widget.Material.DropDownItem">
<!-- on API versions < 26 the bug is not present
and we don't have the API to fix it, anyway -->
</style>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<item name="ListDividerStyle">@style/ListSpaceDividerStyle</item>
<item name="ListMarginStyle">@style/ListMarginStyleClassic</item>
<item name="LeftDrawerStyle">@style/LeftDrawerStyleDark</item>
<item name="android:dropDownItemStyle">@style/ReadableSearchSuggestionListItem</item>
<!-- make all dialogs in the app use this dialog theme.
I chose a dark theme consistent with the device's OS design. -->
<item name="alertDialogTheme">@style/ThemeNnnDialogDark</item>
Expand Down Expand Up @@ -103,6 +104,7 @@
<item name="ListMarginStyle">@style/ListMarginStyleCard</item>
<item name="LeftDrawerStyle">@style/LeftDrawerStyleLight</item>
<item name="colorAccent">@color/accent</item>
<item name="android:dropDownItemStyle">@style/ReadableSearchSuggestionListItem</item>
<!-- make all dialogs in the app use this dialog theme.
I chose a LIGHT theme consistent with the device's OS design. -->
<item name="alertDialogTheme">@style/ThemeNnnDialogLight</item>
Expand Down

0 comments on commit e4620a4

Please sign in to comment.