Loading packages/SystemUI/res/drawable/bubble_stack_user_education_bg_rtl.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <!-- ~ 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> packages/SystemUI/res/layout/bubbles_manage_button_education.xml +2 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ android:layout_marginEnd="24dp" android:orientation="vertical" android:background="@drawable/bubble_stack_user_education_bg" android:alpha="0.9" > <TextView Loading Loading @@ -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 Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +7 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); } } } Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleManageEducationView.java +21 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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, Loading @@ -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); } /** Loading @@ -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); } } } packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +49 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -1107,6 +1107,7 @@ public class BubbleStackView extends FrameLayout title.setTextColor(textColor); description.setTextColor(textColor); updateUserEducationForLayoutDirection(); addView(mUserEducationView); } Loading @@ -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); } } Loading Loading @@ -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. */ Loading Loading @@ -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(); Loading Loading @@ -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(); Loading @@ -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. * Loading Loading
packages/SystemUI/res/drawable/bubble_stack_user_education_bg_rtl.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <!-- ~ 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>
packages/SystemUI/res/layout/bubbles_manage_button_education.xml +2 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ android:layout_marginEnd="24dp" android:orientation="vertical" android:background="@drawable/bubble_stack_user_education_bg" android:alpha="0.9" > <TextView Loading Loading @@ -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 Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +7 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); } } } Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleManageEducationView.java +21 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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, Loading @@ -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); } /** Loading @@ -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); } } }
packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +49 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -1107,6 +1107,7 @@ public class BubbleStackView extends FrameLayout title.setTextColor(textColor); description.setTextColor(textColor); updateUserEducationForLayoutDirection(); addView(mUserEducationView); } Loading @@ -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); } } Loading Loading @@ -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. */ Loading Loading @@ -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(); Loading Loading @@ -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(); Loading @@ -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. * Loading