Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 917ab11e authored by menghanli's avatar menghanli
Browse files

Fix Caption preview SubtitleView textSize cannot update correctly

Root caue: When received #OnLayoutChangeListener callback, the mPainText size keeps "zero" after called setTextSize() because the requestLayout() does not trigger the whole view re-measure & re-layout in not ui thread.
Solution: Post #refreshPreviewText to ui thread to get correct bounds to
measure & layout.

Bug: 223696269
Bug: 211178478
Test: Manually test
Change-Id: Idcbeba52876171e5f3641eafc77d203764c78788
parent 03ecb4f4
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.view.View;
import android.view.accessibility.CaptioningManager;
@@ -92,6 +94,7 @@ public class CaptionAppearanceFragment extends DashboardFragment

    private final List<Preference> mPreferenceList = new ArrayList<>();

    private final Handler mHandler = new Handler(Looper.getMainLooper());
    private final View.OnLayoutChangeListener mLayoutChangeListener =
            new View.OnLayoutChangeListener() {
                @Override
@@ -99,7 +102,7 @@ public class CaptionAppearanceFragment extends DashboardFragment
                        int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    // Remove the listener once the callback is triggered.
                    mPreviewViewport.removeOnLayoutChangeListener(this);
                    refreshPreviewText();
                    mHandler.post(() ->refreshPreviewText());
                }
            };