summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-06-19 05:15:44 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-06-19 05:15:44 +0000
commit9fba23f97f0831befd87f4c08bda1b3922519f04 (patch)
tree7d1fabc8a52b9069d0b51437ad44a1bfb926e780
parent1471727cdb141e2a96b305d4bc9cfec50f6021d7 (diff)
parent72f6dbdf3dc626c4a15e386587b81d7aaa506efb (diff)
Merge "RTL UI for stack & manage menu user education" into rvc-dev
-rw-r--r--packages/SystemUI/res/drawable/bubble_stack_user_education_bg_rtl.xml22
-rw-r--r--packages/SystemUI/res/layout/bubbles_manage_button_education.xml5
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleManageEducationView.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java57
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java8
6 files changed, 107 insertions, 17 deletions
diff --git a/packages/SystemUI/res/drawable/bubble_stack_user_education_bg_rtl.xml b/packages/SystemUI/res/drawable/bubble_stack_user_education_bg_rtl.xml
new file mode 100644
index 000000000000..c7baba14b5e5
--- /dev/null
+++ b/packages/SystemUI/res/drawable/bubble_stack_user_education_bg_rtl.xml
@@ -0,0 +1,22 @@
+<!--
+ ~ Copyright (C) 2020 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="?android:attr/colorAccent"/>
+ <corners
+ android:bottomLeftRadius="360dp"
+ android:topLeftRadius="360dp" />
+</shape>
diff --git a/packages/SystemUI/res/layout/bubbles_manage_button_education.xml b/packages/SystemUI/res/layout/bubbles_manage_button_education.xml
index 0f561cb933e6..87dd58e4f0ed 100644
--- a/packages/SystemUI/res/layout/bubbles_manage_button_education.xml
+++ b/packages/SystemUI/res/layout/bubbles_manage_button_education.xml
@@ -31,7 +31,6 @@
android:layout_marginEnd="24dp"
android:orientation="vertical"
android:background="@drawable/bubble_stack_user_education_bg"
- android:alpha="0.9"
>
<TextView
@@ -61,6 +60,7 @@
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
+ android:id="@+id/button_layout"
android:orientation="horizontal" >
<com.android.systemui.statusbar.AlphaOptimizedButton
@@ -73,7 +73,6 @@
android:clickable="false"
android:text="@string/manage_bubbles_text"
android:textColor="?attr/wallpaperTextColor"
- android:alpha="0.89"
/>
<com.android.systemui.statusbar.AlphaOptimizedButton
@@ -88,4 +87,4 @@
/>
</LinearLayout>
</LinearLayout>
-</com.android.systemui.bubbles.BubbleManageEducationView> \ No newline at end of file
+</com.android.systemui.bubbles.BubbleManageEducationView>
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index c42920965ed3..8f2c2c834384 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -207,6 +207,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
*/
private int mDensityDpi = Configuration.DENSITY_DPI_UNDEFINED;
+ /** Last known direction, used to detect layout direction changes @link #onConfigChanged}. */
+ private int mLayoutDirection = View.LAYOUT_DIRECTION_UNDEFINED;
+
private boolean mInflateSynchronously;
// TODO (b/145659174): allow for multiple callbacks to support the "shadow" new notif pipeline
@@ -832,8 +835,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
mBubbleIconFactory = new BubbleIconFactory(mContext);
mStackView.onDisplaySizeChanged();
}
-
- mStackView.onLayoutDirectionChanged();
+ if (newConfig.getLayoutDirection() != mLayoutDirection) {
+ mLayoutDirection = newConfig.getLayoutDirection();
+ mStackView.onLayoutDirectionChanged(mLayoutDirection);
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleManageEducationView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleManageEducationView.java
index 47120124a55f..86244ba5248a 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleManageEducationView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleManageEducationView.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
+import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -34,6 +35,8 @@ import com.android.systemui.R;
public class BubbleManageEducationView extends LinearLayout {
private View mManageView;
+ private TextView mTitleTextView;
+ private TextView mDescTextView;
public BubbleManageEducationView(Context context) {
this(context, null);
@@ -57,6 +60,8 @@ public class BubbleManageEducationView extends LinearLayout {
super.onFinishInflate();
mManageView = findViewById(R.id.manage_education_view);
+ mTitleTextView = findViewById(R.id.user_education_title);
+ mDescTextView = findViewById(R.id.user_education_description);
final TypedArray ta = mContext.obtainStyledAttributes(
new int[] {android.R.attr.colorAccent,
@@ -66,8 +71,8 @@ public class BubbleManageEducationView extends LinearLayout {
ta.recycle();
textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, true);
- ((TextView) findViewById(R.id.user_education_title)).setTextColor(textColor);
- ((TextView) findViewById(R.id.user_education_description)).setTextColor(textColor);
+ mTitleTextView.setTextColor(textColor);
+ mDescTextView.setTextColor(textColor);
}
/**
@@ -84,4 +89,18 @@ public class BubbleManageEducationView extends LinearLayout {
public int getManageViewHeight() {
return mManageView.getHeight();
}
+
+ @Override
+ public void setLayoutDirection(int direction) {
+ super.setLayoutDirection(direction);
+ if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
+ mManageView.setBackgroundResource(R.drawable.bubble_stack_user_education_bg_rtl);
+ mTitleTextView.setGravity(Gravity.RIGHT);
+ mDescTextView.setGravity(Gravity.RIGHT);
+ } else {
+ mManageView.setBackgroundResource(R.drawable.bubble_stack_user_education_bg);
+ mTitleTextView.setGravity(Gravity.LEFT);
+ mDescTextView.setGravity(Gravity.LEFT);
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 640475eb1be4..10bfcda90edb 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -51,7 +51,6 @@ import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
-import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.view.Choreographer;
import android.view.DisplayCutout;
@@ -71,6 +70,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.MainThread;
@@ -1107,6 +1107,7 @@ public class BubbleStackView extends FrameLayout
title.setTextColor(textColor);
description.setTextColor(textColor);
+ updateUserEducationForLayoutDirection();
addView(mUserEducationView);
}
@@ -1123,7 +1124,7 @@ public class BubbleStackView extends FrameLayout
false /* attachToRoot */);
mManageEducationView.setVisibility(GONE);
mManageEducationView.setElevation(mBubbleElevation);
-
+ mManageEducationView.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
addView(mManageEducationView);
}
}
@@ -1205,13 +1206,17 @@ public class BubbleStackView extends FrameLayout
}
/** Tells the views with locale-dependent layout direction to resolve the new direction. */
- public void onLayoutDirectionChanged() {
- mManageMenu.resolveLayoutDirection();
- mFlyout.resolveLayoutDirection();
-
- if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) {
- mExpandedBubble.getExpandedView().resolveLayoutDirection();
+ public void onLayoutDirectionChanged(int direction) {
+ mManageMenu.setLayoutDirection(direction);
+ mFlyout.setLayoutDirection(direction);
+ if (mUserEducationView != null) {
+ mUserEducationView.setLayoutDirection(direction);
+ updateUserEducationForLayoutDirection();
+ }
+ if (mManageEducationView != null) {
+ mManageEducationView.setLayoutDirection(direction);
}
+ updateExpandedViewDirection(direction);
}
/** Respond to the display size change by recalculating view size and location. */
@@ -1286,6 +1291,18 @@ public class BubbleStackView extends FrameLayout
});
}
+ void updateExpandedViewDirection(int direction) {
+ final List<Bubble> bubbles = mBubbleData.getBubbles();
+ if (bubbles.isEmpty()) {
+ return;
+ }
+ bubbles.forEach(bubble -> {
+ if (bubble.getExpandedView() != null) {
+ bubble.getExpandedView().setLayoutDirection(direction);
+ }
+ });
+ }
+
void setupLocalMenu(AccessibilityNodeInfo info) {
Resources res = mContext.getResources();
@@ -1633,6 +1650,8 @@ public class BubbleStackView extends FrameLayout
if (mShouldShowUserEducation && mUserEducationView.getVisibility() != VISIBLE) {
mUserEducationView.setAlpha(0);
mUserEducationView.setVisibility(VISIBLE);
+ updateUserEducationForLayoutDirection();
+
// Post so we have height of mUserEducationView
mUserEducationView.post(() -> {
final int viewHeight = mUserEducationView.getHeight();
@@ -1650,6 +1669,28 @@ public class BubbleStackView extends FrameLayout
return false;
}
+ private void updateUserEducationForLayoutDirection() {
+ if (mUserEducationView == null) {
+ return;
+ }
+ LinearLayout textLayout = mUserEducationView.findViewById(R.id.user_education_view);
+ TextView title = mUserEducationView.findViewById(R.id.user_education_title);
+ TextView description = mUserEducationView.findViewById(R.id.user_education_description);
+ boolean isLtr =
+ getResources().getConfiguration().getLayoutDirection() == LAYOUT_DIRECTION_LTR;
+ if (isLtr) {
+ mUserEducationView.setLayoutDirection(LAYOUT_DIRECTION_LTR);
+ textLayout.setBackgroundResource(R.drawable.bubble_stack_user_education_bg);
+ title.setGravity(Gravity.LEFT);
+ description.setGravity(Gravity.LEFT);
+ } else {
+ mUserEducationView.setLayoutDirection(LAYOUT_DIRECTION_RTL);
+ textLayout.setBackgroundResource(R.drawable.bubble_stack_user_education_bg_rtl);
+ title.setGravity(Gravity.RIGHT);
+ description.setGravity(Gravity.RIGHT);
+ }
+ }
+
/**
* If necessary, hides the user education view for the bubble stack.
*
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
index 3ef20444cb52..b378469c4c98 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
@@ -940,8 +940,12 @@ public class StackAnimationController extends
/** Returns the default stack position, which is on the top left. */
public PointF getDefaultStartPosition() {
- return new PointF(
- getAllowableStackPositionRegion().left,
+ boolean isRtl = mLayout != null
+ && mLayout.getResources().getConfiguration().getLayoutDirection()
+ == View.LAYOUT_DIRECTION_RTL;
+ return new PointF(isRtl
+ ? getAllowableStackPositionRegion().right
+ : getAllowableStackPositionRegion().left,
getAllowableStackPositionRegion().top + mStackStartingVerticalOffset);
}