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:id="@+id/icon_mic"
|
||||||
android:layout_width="35dp"
|
android:layout_width="35dp"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
android:layout_marginLeft="6dp"
|
android:layout_marginStart="6dp"
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="6dp"
|
||||||
android:layout_marginBottom="6dp">
|
android:layout_marginBottom="6dp">
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/bg_right"
|
android:id="@+id/bg_end"
|
||||||
android:layout_width="12dp"
|
android:layout_width="12dp"
|
||||||
android:layout_height="47dp"
|
android:layout_height="47dp"
|
||||||
android:background="@drawable/tv_rect_dark_right_rounded"
|
android:background="@drawable/tv_rect_dark_right_rounded"
|
||||||
|
|||||||
@@ -99,9 +99,10 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
private View mIconTextsContainer;
|
private View mIconTextsContainer;
|
||||||
private View mIconContainerBg;
|
private View mIconContainerBg;
|
||||||
private View mIcon;
|
private View mIcon;
|
||||||
private View mBgRight;
|
private View mBgEnd;
|
||||||
private View mTextsContainers;
|
private View mTextsContainers;
|
||||||
private TextView mTextView;
|
private TextView mTextView;
|
||||||
|
private boolean mIsLtr;
|
||||||
|
|
||||||
@State private int mState = STATE_NOT_SHOWN;
|
@State private int mState = STATE_NOT_SHOWN;
|
||||||
|
|
||||||
@@ -232,6 +233,9 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
Log.d(TAG, "Showing indicator for " + packageName + " (" + label + ")...");
|
Log.d(TAG, "Showing indicator for " + packageName + " (" + label + ")...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mIsLtr = mContext.getResources().getConfiguration().getLayoutDirection()
|
||||||
|
== View.LAYOUT_DIRECTION_LTR;
|
||||||
|
|
||||||
// Inflate the indicator view
|
// Inflate the indicator view
|
||||||
mIndicatorView = LayoutInflater.from(mContext).inflate(
|
mIndicatorView = LayoutInflater.from(mContext).inflate(
|
||||||
R.layout.tv_audio_recording_indicator,
|
R.layout.tv_audio_recording_indicator,
|
||||||
@@ -241,7 +245,17 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
mIcon = mIconTextsContainer.findViewById(R.id.icon_mic);
|
mIcon = mIconTextsContainer.findViewById(R.id.icon_mic);
|
||||||
mTextsContainers = mIconTextsContainer.findViewById(R.id.texts_container);
|
mTextsContainers = mIconTextsContainer.findViewById(R.id.texts_container);
|
||||||
mTextView = mTextsContainers.findViewById(R.id.text);
|
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
|
// Set up the notification text
|
||||||
mTextView.setText(mContext.getString(R.string.app_accessed_mic, label));
|
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
|
// Now that the width of the indicator has been assigned, we can
|
||||||
// move it in from off the screen.
|
// 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();
|
final AnimatorSet set = new AnimatorSet();
|
||||||
set.setDuration(ANIMATION_DURATION);
|
set.setDuration(ANIMATION_DURATION);
|
||||||
set.playTogether(
|
set.playTogether(
|
||||||
@@ -294,7 +309,7 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
|
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
|
||||||
PixelFormat.TRANSLUCENT);
|
PixelFormat.TRANSLUCENT);
|
||||||
layoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
|
layoutParams.gravity = Gravity.TOP | (mIsLtr ? Gravity.RIGHT : Gravity.LEFT);
|
||||||
layoutParams.setTitle(LAYOUT_PARAMS_TITLE);
|
layoutParams.setTitle(LAYOUT_PARAMS_TITLE);
|
||||||
layoutParams.packageName = mContext.getPackageName();
|
layoutParams.packageName = mContext.getPackageName();
|
||||||
final WindowManager windowManager = (WindowManager) mContext.getSystemService(
|
final WindowManager windowManager = (WindowManager) mContext.getSystemService(
|
||||||
@@ -317,7 +332,7 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
ObjectAnimator.ofFloat(mIconTextsContainer, View.TRANSLATION_X, 0),
|
ObjectAnimator.ofFloat(mIconTextsContainer, View.TRANSLATION_X, 0),
|
||||||
ObjectAnimator.ofFloat(mIconContainerBg, View.ALPHA, 1f),
|
ObjectAnimator.ofFloat(mIconContainerBg, View.ALPHA, 1f),
|
||||||
ObjectAnimator.ofFloat(mTextsContainers, 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.setDuration(ANIMATION_DURATION);
|
||||||
set.addListener(
|
set.addListener(
|
||||||
new AnimatorListenerAdapter() {
|
new AnimatorListenerAdapter() {
|
||||||
@@ -334,13 +349,13 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
@UiThread
|
@UiThread
|
||||||
private void minimize() {
|
private void minimize() {
|
||||||
if (DEBUG) Log.d(TAG, "Minimizing...");
|
if (DEBUG) Log.d(TAG, "Minimizing...");
|
||||||
final int targetOffset = mTextsContainers.getWidth();
|
final int targetOffset = (mIsLtr ? 1 : -1) * mTextsContainers.getWidth();
|
||||||
final AnimatorSet set = new AnimatorSet();
|
final AnimatorSet set = new AnimatorSet();
|
||||||
set.playTogether(
|
set.playTogether(
|
||||||
ObjectAnimator.ofFloat(mIconTextsContainer, View.TRANSLATION_X, targetOffset),
|
ObjectAnimator.ofFloat(mIconTextsContainer, View.TRANSLATION_X, targetOffset),
|
||||||
ObjectAnimator.ofFloat(mIconContainerBg, View.ALPHA, 0f),
|
ObjectAnimator.ofFloat(mIconContainerBg, View.ALPHA, 0f),
|
||||||
ObjectAnimator.ofFloat(mTextsContainers, 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.setDuration(ANIMATION_DURATION);
|
||||||
set.addListener(
|
set.addListener(
|
||||||
new AnimatorListenerAdapter() {
|
new AnimatorListenerAdapter() {
|
||||||
@@ -357,8 +372,8 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
@UiThread
|
@UiThread
|
||||||
private void hide() {
|
private void hide() {
|
||||||
if (DEBUG) Log.d(TAG, "Hiding...");
|
if (DEBUG) Log.d(TAG, "Hiding...");
|
||||||
final int targetOffset =
|
final int targetOffset = (mIsLtr ? 1 : -1) * (mIndicatorView.getWidth()
|
||||||
mIndicatorView.getWidth() - (int) mIconTextsContainer.getTranslationX();
|
- (int) mIconTextsContainer.getTranslationX());
|
||||||
final AnimatorSet set = new AnimatorSet();
|
final AnimatorSet set = new AnimatorSet();
|
||||||
set.playTogether(
|
set.playTogether(
|
||||||
ObjectAnimator.ofFloat(mIndicatorView, View.TRANSLATION_X, targetOffset),
|
ObjectAnimator.ofFloat(mIndicatorView, View.TRANSLATION_X, targetOffset),
|
||||||
@@ -411,7 +426,7 @@ public class AudioRecordingDisclosureBar implements
|
|||||||
mIcon = null;
|
mIcon = null;
|
||||||
mTextsContainers = null;
|
mTextsContainers = null;
|
||||||
mTextView = null;
|
mTextView = null;
|
||||||
mBgRight = null;
|
mBgEnd = null;
|
||||||
|
|
||||||
mState = STATE_NOT_SHOWN;
|
mState = STATE_NOT_SHOWN;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user