Merge "Fix mic diclosure in RTL" into rvc-dev am: a5ddbacefd
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11931516 Change-Id: If663a6df742d9be5b445139582db7f9a76986df0
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user