Merge "RTL UI for stack & manage menu user education" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9fba23f97f
@@ -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>
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@drawable/bubble_stack_user_education_bg"
|
android:background="@drawable/bubble_stack_user_education_bg"
|
||||||
android:alpha="0.9"
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -61,6 +60,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:id="@+id/button_layout"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<com.android.systemui.statusbar.AlphaOptimizedButton
|
<com.android.systemui.statusbar.AlphaOptimizedButton
|
||||||
@@ -73,7 +73,6 @@
|
|||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:text="@string/manage_bubbles_text"
|
android:text="@string/manage_bubbles_text"
|
||||||
android:textColor="?attr/wallpaperTextColor"
|
android:textColor="?attr/wallpaperTextColor"
|
||||||
android:alpha="0.89"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<com.android.systemui.statusbar.AlphaOptimizedButton
|
<com.android.systemui.statusbar.AlphaOptimizedButton
|
||||||
|
|||||||
@@ -207,6 +207,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
|
|||||||
*/
|
*/
|
||||||
private int mDensityDpi = Configuration.DENSITY_DPI_UNDEFINED;
|
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;
|
private boolean mInflateSynchronously;
|
||||||
|
|
||||||
// TODO (b/145659174): allow for multiple callbacks to support the "shadow" new notif pipeline
|
// 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);
|
mBubbleIconFactory = new BubbleIconFactory(mContext);
|
||||||
mStackView.onDisplaySizeChanged();
|
mStackView.onDisplaySizeChanged();
|
||||||
}
|
}
|
||||||
|
if (newConfig.getLayoutDirection() != mLayoutDirection) {
|
||||||
mStackView.onLayoutDirectionChanged();
|
mLayoutDirection = newConfig.getLayoutDirection();
|
||||||
|
mStackView.onLayoutDirectionChanged(mLayoutDirection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -34,6 +35,8 @@ import com.android.systemui.R;
|
|||||||
public class BubbleManageEducationView extends LinearLayout {
|
public class BubbleManageEducationView extends LinearLayout {
|
||||||
|
|
||||||
private View mManageView;
|
private View mManageView;
|
||||||
|
private TextView mTitleTextView;
|
||||||
|
private TextView mDescTextView;
|
||||||
|
|
||||||
public BubbleManageEducationView(Context context) {
|
public BubbleManageEducationView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -57,6 +60,8 @@ public class BubbleManageEducationView extends LinearLayout {
|
|||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
mManageView = findViewById(R.id.manage_education_view);
|
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(
|
final TypedArray ta = mContext.obtainStyledAttributes(
|
||||||
new int[] {android.R.attr.colorAccent,
|
new int[] {android.R.attr.colorAccent,
|
||||||
@@ -66,8 +71,8 @@ public class BubbleManageEducationView extends LinearLayout {
|
|||||||
ta.recycle();
|
ta.recycle();
|
||||||
|
|
||||||
textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, true);
|
textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, true);
|
||||||
((TextView) findViewById(R.id.user_education_title)).setTextColor(textColor);
|
mTitleTextView.setTextColor(textColor);
|
||||||
((TextView) findViewById(R.id.user_education_description)).setTextColor(textColor);
|
mDescTextView.setTextColor(textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,4 +89,18 @@ public class BubbleManageEducationView extends LinearLayout {
|
|||||||
public int getManageViewHeight() {
|
public int getManageViewHeight() {
|
||||||
return mManageView.getHeight();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ import android.graphics.drawable.TransitionDrawable;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.StatusBarNotification;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
import android.view.DisplayCutout;
|
import android.view.DisplayCutout;
|
||||||
@@ -71,6 +70,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
|||||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.MainThread;
|
import androidx.annotation.MainThread;
|
||||||
@@ -1107,6 +1107,7 @@ public class BubbleStackView extends FrameLayout
|
|||||||
title.setTextColor(textColor);
|
title.setTextColor(textColor);
|
||||||
description.setTextColor(textColor);
|
description.setTextColor(textColor);
|
||||||
|
|
||||||
|
updateUserEducationForLayoutDirection();
|
||||||
addView(mUserEducationView);
|
addView(mUserEducationView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1123,7 +1124,7 @@ public class BubbleStackView extends FrameLayout
|
|||||||
false /* attachToRoot */);
|
false /* attachToRoot */);
|
||||||
mManageEducationView.setVisibility(GONE);
|
mManageEducationView.setVisibility(GONE);
|
||||||
mManageEducationView.setElevation(mBubbleElevation);
|
mManageEducationView.setElevation(mBubbleElevation);
|
||||||
|
mManageEducationView.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
|
||||||
addView(mManageEducationView);
|
addView(mManageEducationView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1205,13 +1206,17 @@ public class BubbleStackView extends FrameLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Tells the views with locale-dependent layout direction to resolve the new direction. */
|
/** Tells the views with locale-dependent layout direction to resolve the new direction. */
|
||||||
public void onLayoutDirectionChanged() {
|
public void onLayoutDirectionChanged(int direction) {
|
||||||
mManageMenu.resolveLayoutDirection();
|
mManageMenu.setLayoutDirection(direction);
|
||||||
mFlyout.resolveLayoutDirection();
|
mFlyout.setLayoutDirection(direction);
|
||||||
|
if (mUserEducationView != null) {
|
||||||
if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) {
|
mUserEducationView.setLayoutDirection(direction);
|
||||||
mExpandedBubble.getExpandedView().resolveLayoutDirection();
|
updateUserEducationForLayoutDirection();
|
||||||
}
|
}
|
||||||
|
if (mManageEducationView != null) {
|
||||||
|
mManageEducationView.setLayoutDirection(direction);
|
||||||
|
}
|
||||||
|
updateExpandedViewDirection(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Respond to the display size change by recalculating view size and location. */
|
/** 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) {
|
void setupLocalMenu(AccessibilityNodeInfo info) {
|
||||||
Resources res = mContext.getResources();
|
Resources res = mContext.getResources();
|
||||||
|
|
||||||
@@ -1633,6 +1650,8 @@ public class BubbleStackView extends FrameLayout
|
|||||||
if (mShouldShowUserEducation && mUserEducationView.getVisibility() != VISIBLE) {
|
if (mShouldShowUserEducation && mUserEducationView.getVisibility() != VISIBLE) {
|
||||||
mUserEducationView.setAlpha(0);
|
mUserEducationView.setAlpha(0);
|
||||||
mUserEducationView.setVisibility(VISIBLE);
|
mUserEducationView.setVisibility(VISIBLE);
|
||||||
|
updateUserEducationForLayoutDirection();
|
||||||
|
|
||||||
// Post so we have height of mUserEducationView
|
// Post so we have height of mUserEducationView
|
||||||
mUserEducationView.post(() -> {
|
mUserEducationView.post(() -> {
|
||||||
final int viewHeight = mUserEducationView.getHeight();
|
final int viewHeight = mUserEducationView.getHeight();
|
||||||
@@ -1650,6 +1669,28 @@ public class BubbleStackView extends FrameLayout
|
|||||||
return false;
|
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.
|
* If necessary, hides the user education view for the bubble stack.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -940,8 +940,12 @@ public class StackAnimationController extends
|
|||||||
|
|
||||||
/** Returns the default stack position, which is on the top left. */
|
/** Returns the default stack position, which is on the top left. */
|
||||||
public PointF getDefaultStartPosition() {
|
public PointF getDefaultStartPosition() {
|
||||||
return new PointF(
|
boolean isRtl = mLayout != null
|
||||||
getAllowableStackPositionRegion().left,
|
&& mLayout.getResources().getConfiguration().getLayoutDirection()
|
||||||
|
== View.LAYOUT_DIRECTION_RTL;
|
||||||
|
return new PointF(isRtl
|
||||||
|
? getAllowableStackPositionRegion().right
|
||||||
|
: getAllowableStackPositionRegion().left,
|
||||||
getAllowableStackPositionRegion().top + mStackStartingVerticalOffset);
|
getAllowableStackPositionRegion().top + mStackStartingVerticalOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user