* Add Settings → Display → UI text size sliders for chrome fonts. Each unique chrome size (7–40) gets a seek bar that remaps TextView setTextSize call sites through UiTextSize, separate from webpage Text size. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix UI text sizes resetting when leaving the slider screen. UiTextSize.load used if-nez so a valid PrefWeb always reset to defaults; flip to if-eqz, persist on slider change, recreate settings chrome, and route mlkit TextView sizing through UiTextSize. Co-authored-by: Cursor <cursoragent@cursor.com> * Remap idle address-bar URL text through the 16dp UI size slider. The focused editor already used UiTextSize; idle URL was Paint-drawn at MainApp.E1 (16dp px) and ignored prefs — resolvePx + MyIconView refresh. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
125 lines
4.6 KiB
Java
125 lines
4.6 KiB
Java
package com.mycompany.app.setting;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import com.mycompany.app.main.MainApp;
|
|
import com.mycompany.app.pref.PrefCore;
|
|
import com.mycompany.app.pref.PrefWeb;
|
|
import com.mycompany.app.pref.UiTextSize;
|
|
import com.mycompany.app.setting.SettingListAdapter;
|
|
import com.mycompany.app.soulbrowser.R;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Settings → Display → UI text size.
|
|
* One seek bar per unique chrome sp size used across the app.
|
|
*/
|
|
public class SettingUiText extends SettingActivity {
|
|
public static final /* synthetic */ int Y1 = 0;
|
|
|
|
/** Seek max progress; displayed size is progress + 1 (1sp..48sp). */
|
|
public static final int SEEK_MAX = 47;
|
|
|
|
private static final int[] TITLE_RES = {
|
|
R.string.ui_text_size_7,
|
|
R.string.ui_text_size_8,
|
|
R.string.ui_text_size_12,
|
|
R.string.ui_text_size_13,
|
|
R.string.ui_text_size_14,
|
|
R.string.ui_text_size_16,
|
|
R.string.ui_text_size_18,
|
|
R.string.ui_text_size_20,
|
|
R.string.ui_text_size_24,
|
|
R.string.ui_text_size_36,
|
|
R.string.ui_text_size_40
|
|
};
|
|
|
|
@Override
|
|
public final List D0() {
|
|
ArrayList arrayList = new ArrayList();
|
|
arrayList.add(new SettingListAdapter.SettingItem(0, true));
|
|
int n = UiTextSize.count();
|
|
for (int i = 0; i < n; i++) {
|
|
int progress = Math.round(UiTextSize.getValue(i)) - 1;
|
|
if (progress < 0) {
|
|
progress = 0;
|
|
} else if (progress > SEEK_MAX) {
|
|
progress = SEEK_MAX;
|
|
}
|
|
int corner;
|
|
if (n == 1) {
|
|
corner = 3;
|
|
} else if (i == 0) {
|
|
corner = 1;
|
|
} else if (i == n - 1) {
|
|
corner = 2;
|
|
} else {
|
|
corner = 0;
|
|
}
|
|
SettingListAdapter.SettingItem item =
|
|
new SettingListAdapter.SettingItem(i + 1, TITLE_RES[i], SEEK_MAX, progress, (Object) null);
|
|
item.r = "dp";
|
|
item.u = corner;
|
|
arrayList.add(item);
|
|
}
|
|
arrayList.add(new SettingListAdapter.SettingItem(n + 1, false));
|
|
return arrayList;
|
|
}
|
|
|
|
@Override
|
|
public final void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
// Ensure chrome size prefs are applied before building seek bars (PrefWeb.s
|
|
// can run before the JSON store is ready on some cold starts).
|
|
PrefWeb pref = PrefWeb.r(this, true);
|
|
UiTextSize.load(pref);
|
|
this.X1 = UiTextSize.generation;
|
|
F0(R.string.ui_text_size, false, false);
|
|
this.O1 = MainApp.F1;
|
|
Handler handler = this.O0;
|
|
if (handler == null) {
|
|
return;
|
|
}
|
|
handler.post(new Runnable() {
|
|
@Override
|
|
public final void run() {
|
|
final SettingUiText activity = SettingUiText.this;
|
|
if (activity.O0 == null) {
|
|
return;
|
|
}
|
|
SettingListAdapter adapter = new SettingListAdapter(
|
|
(ArrayList) activity.D0(),
|
|
false,
|
|
activity.M1,
|
|
new SettingListAdapter.SettingListener() {
|
|
@Override
|
|
public final void a(
|
|
SettingListAdapter.ViewHolder viewHolder,
|
|
int itemId,
|
|
boolean unused,
|
|
int progress) {
|
|
int index = itemId - 1;
|
|
if (index < 0 || index >= UiTextSize.count()) {
|
|
return;
|
|
}
|
|
float sp = progress + 1;
|
|
UiTextSize.setValue(index, sp);
|
|
// Use the activity (not only f1) so MainApp.p resolves; sync-write
|
|
// so values survive leaving the page before the async flush runs.
|
|
PrefWeb pref = PrefWeb.r(activity, false);
|
|
if (pref != null) {
|
|
pref.m(UiTextSize.prefKey(index), UiTextSize.getValue(index));
|
|
pref.c();
|
|
pref.a();
|
|
}
|
|
}
|
|
});
|
|
activity.N1 = adapter;
|
|
activity.L1.setAdapter(adapter);
|
|
activity.M0();
|
|
}
|
|
});
|
|
}
|
|
}
|