diff options
| author | 2020-06-22 11:38:35 +0200 | |
|---|---|---|
| committer | 2020-06-23 14:31:02 +0200 | |
| commit | 8dfc49b6d48185b1a272f3f3a7cc35211342cb85 (patch) | |
| tree | 65f89bcafb529a647eb2d8feccc63f70ff9d914a | |
| parent | ae64ae50de3354474b9f296b54630925089effe9 (diff) | |
Fix mic diclosure in RTL
Fix AudioRecordingDisclosureBar's layout and animations in RTL mode.
Bug: 159145397
Test: manually on TV, with "Force RTL" enabled
Change-Id: I494381d6c25658fb95d6d69482661e76501f8500
| -rw-r--r-- | packages/SystemUI/res/layout/tv_audio_recording_indicator.xml | 4 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java | 35 |
2 files changed, 27 insertions, 12 deletions
diff --git a/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml b/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml index cd90efe9a215..1d2340dadb8a 100644 --- a/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml +++ b/packages/SystemUI/res/layout/tv_audio_recording_indicator.xml @@ -45,7 +45,7 @@ android:id="@+id/icon_mic" android:layout_width="35dp" android:layout_height="35dp" - android:layout_marginLeft="6dp" + android:layout_marginStart="6dp" android:layout_marginTop="6dp" android:layout_marginBottom="6dp"> @@ -112,7 +112,7 @@ </FrameLayout> <View - android:id="@+id/bg_right" + android:id="@+id/bg_end" android:layout_width="12dp" android:layout_height="47dp" android:background="@drawable/tv_rect_dark_right_rounded" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java index 8b85a0961463..36e360da857f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/micdisclosure/AudioRecordingDisclosureBar.java @@ -99,9 +99,10 @@ public class AudioRecordingDisclosureBar implements private View mIconTextsContainer; private View mIconContainerBg; private View mIcon; - private View mBgRight; + private View mBgEnd; private View mTextsContainers; private TextView mTextView; + private boolean mIsLtr; @State private int mState = STATE_NOT_SHOWN; @@ -232,6 +233,9 @@ public class AudioRecordingDisclosureBar implements Log.d(TAG, "Showing indicator for " + packageName + " (" + label + ")..."); } + mIsLtr = mContext.getResources().getConfiguration().getLayoutDirection() + == View.LAYOUT_DIRECTION_LTR; + // Inflate the indicator view mIndicatorView = LayoutInflater.from(mContext).inflate( R.layout.tv_audio_recording_indicator, @@ -241,7 +245,17 @@ public class AudioRecordingDisclosureBar implements mIcon = mIconTextsContainer.findViewById(R.id.icon_mic); mTextsContainers = mIconTextsContainer.findViewById(R.id.texts_container); mTextView = mTextsContainers.findViewById(R.id.text); - mBgRight = mIndicatorView.findViewById(R.id.bg_right); + mBgEnd = mIndicatorView.findViewById(R.id.bg_end); + + // Swap background drawables depending on layout directions (both drawables have rounded + // corners only on one side) + if (mIsLtr) { + mBgEnd.setBackgroundResource(R.drawable.tv_rect_dark_right_rounded); + mIconContainerBg.setBackgroundResource(R.drawable.tv_rect_dark_left_rounded); + } else { + mBgEnd.setBackgroundResource(R.drawable.tv_rect_dark_left_rounded); + mIconContainerBg.setBackgroundResource(R.drawable.tv_rect_dark_right_rounded); + } // Set up the notification text mTextView.setText(mContext.getString(R.string.app_accessed_mic, label)); @@ -261,7 +275,8 @@ public class AudioRecordingDisclosureBar implements // Now that the width of the indicator has been assigned, we can // move it in from off the screen. - final int initialOffset = mIndicatorView.getWidth(); + final int initialOffset = + (mIsLtr ? 1 : -1) * mIndicatorView.getWidth(); final AnimatorSet set = new AnimatorSet(); set.setDuration(ANIMATION_DURATION); set.playTogether( @@ -294,7 +309,7 @@ public class AudioRecordingDisclosureBar implements WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); - layoutParams.gravity = Gravity.TOP | Gravity.RIGHT; + layoutParams.gravity = Gravity.TOP | (mIsLtr ? Gravity.RIGHT : Gravity.LEFT); layoutParams.setTitle(LAYOUT_PARAMS_TITLE); layoutParams.packageName = mContext.getPackageName(); final WindowManager windowManager = (WindowManager) mContext.getSystemService( @@ -317,7 +332,7 @@ public class AudioRecordingDisclosureBar implements ObjectAnimator.ofFloat(mIconTextsContainer, View.TRANSLATION_X, 0), ObjectAnimator.ofFloat(mIconContainerBg, View.ALPHA, 1f), ObjectAnimator.ofFloat(mTextsContainers, View.ALPHA, 1f), - ObjectAnimator.ofFloat(mBgRight, View.ALPHA, 1f)); + ObjectAnimator.ofFloat(mBgEnd, View.ALPHA, 1f)); set.setDuration(ANIMATION_DURATION); set.addListener( new AnimatorListenerAdapter() { @@ -334,13 +349,13 @@ public class AudioRecordingDisclosureBar implements @UiThread private void minimize() { if (DEBUG) Log.d(TAG, "Minimizing..."); - final int targetOffset = mTextsContainers.getWidth(); + final int targetOffset = (mIsLtr ? 1 : -1) * mTextsContainers.getWidth(); final AnimatorSet set = new AnimatorSet(); set.playTogether( ObjectAnimator.ofFloat(mIconTextsContainer, View.TRANSLATION_X, targetOffset), ObjectAnimator.ofFloat(mIconContainerBg, View.ALPHA, 0f), ObjectAnimator.ofFloat(mTextsContainers, View.ALPHA, 0f), - ObjectAnimator.ofFloat(mBgRight, View.ALPHA, 0f)); + ObjectAnimator.ofFloat(mBgEnd, View.ALPHA, 0f)); set.setDuration(ANIMATION_DURATION); set.addListener( new AnimatorListenerAdapter() { @@ -357,8 +372,8 @@ public class AudioRecordingDisclosureBar implements @UiThread private void hide() { if (DEBUG) Log.d(TAG, "Hiding..."); - final int targetOffset = - mIndicatorView.getWidth() - (int) mIconTextsContainer.getTranslationX(); + final int targetOffset = (mIsLtr ? 1 : -1) * (mIndicatorView.getWidth() + - (int) mIconTextsContainer.getTranslationX()); final AnimatorSet set = new AnimatorSet(); set.playTogether( ObjectAnimator.ofFloat(mIndicatorView, View.TRANSLATION_X, targetOffset), @@ -411,7 +426,7 @@ public class AudioRecordingDisclosureBar implements mIcon = null; mTextsContainers = null; mTextView = null; - mBgRight = null; + mBgEnd = null; mState = STATE_NOT_SHOWN; |