afonsotrepa / PocketGopher

Gopher browser for android written in java
The Unlicense
47 stars 9 forks source link

TextView autosizing causing lockups and shrinking text #13

Open jnlon opened 5 years ago

jnlon commented 5 years ago

Hello!

I find PocketGopher has trouble handling large menus smoothly, for example this page with >1400 lines: gopher://sdf.org:70/1/aged-maps/

On my device (Nexus 6P, android 8.1.0) after the initial load there are intermittent freezes where I cannot scroll and menu text shrinks several times before finally settling (possibly the same issue as #4). This happens for about 30s before it feels stable.

After some experimenting I discovered the cause is related to TextView's autoresize feature. With the feature enabled TextView tries to grow/shrink itself so long lines fit without wrapping, for whatever reason it does not work well with many lines.

Disabling autosizing fixes both issues on my device with this change:

$ git diff app/src/main/res/layout/activity_menu.xml

--- a/app/src/main/res/layout/activity_menu.xml
+++ b/app/src/main/res/layout/activity_menu.xml
@@ -24,7 +24,7 @@
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 android:layout_margin="16dp"
-                android:autoSizeTextType="uniform"
+                android:autoSizeTextType="none"
                 android:textIsSelectable="true"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintLeft_toLeftOf="parent"

The downside is that menus are stuck with a fixed text size which may be suboptimal on some screens. Also some users may appreciate the ability to set their own text size preference.

In addition to disabling autosizing, maybe there can be a "Set font size" button via the drop-down menu which could display a NumberPicker in a dialog/popup to adjust text size. I would be willing to make a PR for this (or something like it).

Thanks for the great app btw!