Make collapsing toolbar load font synchronously

Since collapsing toolbar might load the font asynchronously, it caused
that some settings pages are seeing a flicker on its title. This change
is using TextAppearanceConfig.setShouldLoadFontSynchronously(true)
method to have title font load synchronously, which would remove the
flicker problem.

Fixes: 182232144
Test: visual verified
1) Enable developer options
2) Settings > System > Developer options
3) See if there's a flicker on title

Change-Id: I4e1db1a0fae9f69c7ff5baca7ada49c08f1bcbea
This commit is contained in:
Mill Chen
2021-04-28 11:20:32 +08:00
parent dd9c9a8c17
commit 4d6bbc8af9

View File

@@ -47,6 +47,7 @@ import com.android.settings.dashboard.CategoryManager;
import com.android.settingslib.drawer.Tile; import com.android.settingslib.drawer.Tile;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.resources.TextAppearanceConfig;
import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper; import com.google.android.setupdesign.util.ThemeHelper;
@@ -80,6 +81,7 @@ public class SettingsBaseActivity extends FragmentActivity {
} }
final long startTime = System.currentTimeMillis(); final long startTime = System.currentTimeMillis();
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this)); getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
TextAppearanceConfig.setShouldLoadFontSynchronously(true);
final TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme); final TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) { if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {