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

Commit 07bfdd5b authored by Chihhang Chuang's avatar Chihhang Chuang
Browse files

Fix theme picker breaking in RTL mode

- Fix the preview screen.
- Fix the theme option layout.

Screenshot:
LTR: https://screenshot.googleplex.com/BwN8J2VKKg5.png
RTL: https://screenshot.googleplex.com/Fm4WQKKrB8i.png

Test: Manually, see screenshot
Bug: 159093562
Change-Id: I03cd05d3f4c85472a2bdc70b621cb2ad1651404e
parent 49bcc271
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@
            android:layout_width="@dimen/theme_option_icon_sample_width"
            android:layout_height="@dimen/theme_option_icon_sample_height"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:tint="?android:colorForeground"/>
        <ImageView
            android:id="@+id/theme_option_shape"
@@ -54,7 +54,7 @@
            android:layout_height="@dimen/theme_option_shape_sample_height"
            android:layout_alignBottom="@+id/theme_option_icon"
            android:layout_toEndOf="@id/theme_option_icon"
            android:layout_marginLeft="@dimen/theme_option_sample_margin"/>
            android:layout_marginStart="@dimen/theme_option_sample_margin"/>
        <TextView
            android:id="@+id/theme_option_font"
            android:layout_width="@dimen/theme_option_font_sample_width"
+11 −15
Original line number Diff line number Diff line
@@ -129,18 +129,18 @@
        </LinearLayout>

        <!-- Icons of CheckBox/RadioButton/Switch. -->
        <LinearLayout
        <RelativeLayout
            android:id="@+id/button_icons"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@id/qs_icons"
            app:layout_constraintBottom_toBottomOf="parent">
            <FrameLayout
                android:layout_width="@dimen/preview_theme_icon_size"
                android:layout_height="@dimen/preview_theme_icon_size">
                android:layout_height="@dimen/preview_theme_icon_size"
                android:layout_alignParentStart="true">
                <CheckBox
                    android:id="@+id/preview_check_selected"
                    android:layout_width="wrap_content"
@@ -149,13 +149,11 @@
                    android:checked="true"
                    android:enabled="false"/>
            </FrameLayout>
            <Space
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <FrameLayout
                android:layout_width="@dimen/preview_theme_icon_size"
                android:layout_height="@dimen/preview_theme_icon_size">
                android:layout_height="@dimen/preview_theme_icon_size"
                android:layout_centerHorizontal="true">
                <RadioButton
                    android:id="@+id/preview_radio_selected"
                    android:layout_width="wrap_content"
@@ -164,13 +162,11 @@
                    android:checked="true"
                    android:enabled="false"/>
            </FrameLayout>
            <Space
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <FrameLayout
                android:layout_width="@dimen/preview_theme_icon_size"
                android:layout_height="@dimen/preview_theme_icon_size">
                android:layout_width="wrap_content"
                android:layout_height="@dimen/preview_theme_icon_size"
                android:layout_alignParentEnd="true">
                <Switch
                    android:id="@+id/preview_toggle_selected"
                    android:layout_width="wrap_content"
@@ -179,7 +175,7 @@
                    android:checked="true"
                    android:enabled="false"/>
            </FrameLayout>
        </LinearLayout>
        </RelativeLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
+4 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.View.MeasureSpec.makeMeasureSpec;
import android.app.WallpaperColors;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
@@ -120,6 +121,8 @@ class ThemeOptionPreviewer implements LifecycleObserver {
        updateTime();
        final float screenAspectRatio =
                ScreenSizeCalculator.getInstance().getScreenAspectRatio(mContext);
        Configuration config = mContext.getResources().getConfiguration();
        final boolean directionLTR = config.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
        previewContainer.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View view, int left, int top, int right, int bottom,
@@ -141,7 +144,7 @@ class ThemeOptionPreviewer implements LifecycleObserver {
                mContentView.setScaleX(scale);
                mContentView.setScaleY(scale);
                // The pivot point is centered by default, set to (0, 0).
                mContentView.setPivotX(0f);
                mContentView.setPivotX(directionLTR ? 0f : mContentView.getMeasuredWidth());
                mContentView.setPivotY(0f);

                // Ensure there will be only one content view in the container.