diff options
author | Selim Cinek <cinek@google.com> | 2014-08-26 17:29:20 +0200 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2014-08-27 12:38:15 +0200 |
commit | 06d3bca095aecbb7542ebf4bdaa56b368261dd9d (patch) | |
tree | 87ed508699dcd30cd073eb4ad9df5a8de93db6e8 /packages | |
parent | 19c8c708f16546fc75ae12659aa190f5e3dfbb52 (diff) | |
download | frameworks_base-06d3bca095aecbb7542ebf4bdaa56b368261dd9d.zip frameworks_base-06d3bca095aecbb7542ebf4bdaa56b368261dd9d.tar.gz frameworks_base-06d3bca095aecbb7542ebf4bdaa56b368261dd9d.tar.bz2 |
Made quick settings RTL compatible.
The layout is now mirrored correctly and the icons as well.
Bug: 15284805
Change-Id: I3d6fadad0a987adb49f826d4189f9dd58e20d326
Diffstat (limited to 'packages')
7 files changed, 38 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index a2136d2..a3ffc4e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java index 876652c..2b071cc 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java @@ -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(']'); } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java index 20fd5a0..9321614 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java b/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java index 1df3d20..0ecdeaa 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java index 109237b..0b83878 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -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) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java index f503657..8304291 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java @@ -93,6 +93,7 @@ public class CastTile extends QSTile<QSTile.BooleanState> { state.visible = !(mKeyguard.isSecure() && mKeyguard.isShowing()); state.label = mContext.getString(R.string.quick_settings_cast_title); state.value = false; + state.autoMirrorDrawable = false; final Set<CastDevice> devices = mController.getCastDevices(); boolean connecting = false; for (CastDevice device : devices) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java index ce42d47..25bcfd2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java @@ -95,6 +95,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> { : !cb.enabled || cb.airplaneModeEnabled ? R.drawable.ic_qs_signal_disabled : cb.mobileSignalIconId > 0 ? cb.mobileSignalIconId : R.drawable.ic_qs_signal_no_signal; + state.autoMirrorDrawable = !cb.noSim; state.overlayIconId = cb.enabled && (cb.dataTypeIconId > 0) && !cb.wifiConnected ? cb.dataTypeIconId : 0; |