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

Commit 06d3bca0 authored by Selim Cinek's avatar Selim Cinek
Browse files

Made quick settings RTL compatible.

The layout is now mirrored correctly and the icons as well.

Bug: 15284805
Change-Id: I3d6fadad0a987adb49f826d4189f9dd58e20d326
parent 19c8c708
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -401,16 +401,23 @@ public class QSPanel extends ViewGroup {
        mBrightnessView.layout(0, mBrightnessPaddingTop,
                mBrightnessView.getMeasuredWidth(),
                mBrightnessPaddingTop + mBrightnessView.getMeasuredHeight());
        boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
        for (TileRecord record : mRecords) {
            if (record.tileView.getVisibility() == GONE) continue;
            final int cols = getColumnCount(record.row);
            final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth;
            final int extra = (w - cw * cols) / (cols + 1);
            final int left = record.col * cw + (record.col + 1) * extra;
            int left = record.col * cw + (record.col + 1) * extra;
            final int top = getRowTop(record.row);
            record.tileView.layout(left, top,
                    left + record.tileView.getMeasuredWidth(),
                    top + record.tileView.getMeasuredHeight());
            int right;
            int tileWith = record.tileView.getMeasuredWidth();
            if (isRtl) {
                right = w - left;
                left = right - tileWith;
            } else {
                right = left + tileWith;
            }
            record.tileView.layout(left, top, right, top + record.tileView.getMeasuredHeight());
        }
        final int dh = Math.max(mDetail.getMeasuredHeight(), getMeasuredHeight());
        mDetail.layout(0, 0, mDetail.getMeasuredWidth(), dh);
+4 −0
Original line number Diff line number Diff line
@@ -306,6 +306,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
        public String label;
        public String contentDescription;
        public String dualLabelContentDescription;
        public boolean autoMirrorDrawable = true;

        public boolean copyTo(State other) {
            if (other == null) throw new IllegalArgumentException();
@@ -315,6 +316,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
                    || !Objects.equals(other.icon, icon)
                    || !Objects.equals(other.label, label)
                    || !Objects.equals(other.contentDescription, contentDescription)
                    || !Objects.equals(other.autoMirrorDrawable, autoMirrorDrawable)
                    || !Objects.equals(other.dualLabelContentDescription,
                    dualLabelContentDescription);
            other.visible = visible;
@@ -323,6 +325,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
            other.label = label;
            other.contentDescription = contentDescription;
            other.dualLabelContentDescription = dualLabelContentDescription;
            other.autoMirrorDrawable = autoMirrorDrawable;
            return changed;
        }

@@ -339,6 +342,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
            sb.append(",label=").append(label);
            sb.append(",contentDescription=").append(contentDescription);
            sb.append(",dualLabelContentDescription=").append(dualLabelContentDescription);
            sb.append(",autoMirrorDrawable=").append(autoMirrorDrawable);
            return sb.append(']');
        }
    }
+4 −0
Original line number Diff line number Diff line
@@ -265,6 +265,10 @@ public class QSTileView extends ViewGroup {
            } else if (state.iconId > 0) {
                iv.setImageResource(state.iconId);
            }
            Drawable drawable = iv.getDrawable();
            if (state.autoMirrorDrawable && drawable != null) {
                drawable.setAutoMirrored(true);
            }
        }
        if (mDual) {
            mDualLabel.setText(state.label);
+16 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.qs;

import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -78,10 +79,19 @@ public final class SignalTileView extends QSTileView {
    }

    private void layoutIndicator(View indicator) {
        boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
        int left, right;
        if (isRtl) {
            right = mIconFrame.getLeft();
            left = right - indicator.getMeasuredWidth();
        } else {
            left = mIconFrame.getRight();
            right = left + indicator.getMeasuredWidth();
        }
        indicator.layout(
                mIconFrame.getRight(),
                left,
                mIconFrame.getBottom() - indicator.getMeasuredHeight(),
                mIconFrame.getRight() + indicator.getMeasuredWidth(),
                right,
                mIconFrame.getBottom());
    }

@@ -96,6 +106,10 @@ public final class SignalTileView extends QSTileView {
        } else {
            mOverlay.setVisibility(GONE);
        }
        Drawable drawable = mSignal.getDrawable();
        if (state.autoMirrorDrawable && drawable != null) {
            drawable.setAutoMirrored(true);
        }
        final boolean shown = isShown();
        setVisibility(mIn, shown, s.activityIn);
        setVisibility(mOut, shown, s.activityOut);
+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
        final boolean connecting = mController.isBluetoothConnecting();
        state.visible = supported;
        state.value = enabled;
        state.autoMirrorDrawable = false;
        if (enabled) {
            state.label = null;
            if (connected) {
Loading