diff options
author | 2021-11-01 20:53:51 +0000 | |
---|---|---|
committer | 2021-11-01 20:53:51 +0000 | |
commit | 62c0e2020e24dfc00603bcb9da4f0d2cfc0b9f74 (patch) | |
tree | 75aaafb516efe138282d329681c77b6312e2c00a | |
parent | 0a768311748f197f8ff5fe75be2f5f4b86864ac1 (diff) | |
parent | cd12f1b260a0504615317401c8c2516fd22e45fa (diff) |
Merge "Do not use shared lib resources" into sc-v2-dev am: cd12f1b260
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16163399
Change-Id: I5a5d210e9847908546c950305ab9115029576ba7
13 files changed, 59 insertions, 94 deletions
diff --git a/packages/SystemUI/shared/res/layout/rotate_suggestion.xml b/packages/SystemUI/res/layout/rotate_suggestion.xml index 2fb775cbc9be..2fb775cbc9be 100644 --- a/packages/SystemUI/shared/res/layout/rotate_suggestion.xml +++ b/packages/SystemUI/res/layout/rotate_suggestion.xml diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml index c1c15d12dee1..d17ec7379511 100644 --- a/packages/SystemUI/res/values-sw600dp/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp/dimens.xml @@ -82,6 +82,8 @@ <dimen name="navigation_key_width">128dp</dimen> + <dimen name="navigation_key_padding">25dp</dimen> + <!-- Keyboard shortcuts helper --> <dimen name="ksh_layout_width">488dp</dimen> diff --git a/packages/SystemUI/res/values-sw900dp/dimens.xml b/packages/SystemUI/res/values-sw900dp/dimens.xml index ebae8c4bfa4c..2758fb439edd 100644 --- a/packages/SystemUI/res/values-sw900dp/dimens.xml +++ b/packages/SystemUI/res/values-sw900dp/dimens.xml @@ -17,6 +17,12 @@ --> <resources> + <!-- The maximum width of the navigation bar ripples. --> + <dimen name="key_button_ripple_max_width">76dp</dimen> + + <!-- The padding around the navigation buttons --> + <dimen name="navigation_key_padding">0dp</dimen> + <dimen name="button_size">80dp</dimen> <dimen name="navigation_side_padding">@dimen/button_size</dimen> <dimen name="navigation_key_width">@dimen/button_size</dimen> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 46869a0087a4..e5ea3688ec0d 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -522,6 +522,19 @@ <!-- Size of the icon inside each item in the ringer selector drawer. --> <dimen name="volume_ringer_drawer_icon_size">24dp</dimen> + <!-- The maximum width of the navigation bar ripples. --> + <dimen name="key_button_ripple_max_width">95dp</dimen> + + <dimen name="rounded_corner_content_padding">0dp</dimen> + + <dimen name="navigation_key_padding">0dp</dimen> + + <!-- Floating rotation button --> + <dimen name="floating_rotation_button_diameter">40dp</dimen> + <dimen name="floating_rotation_button_min_margin">20dp</dimen> + <dimen name="floating_rotation_button_taskbar_left_margin">20dp</dimen> + <dimen name="floating_rotation_button_taskbar_bottom_margin">10dp</dimen> + <!-- Gravity for the notification panel --> <integer name="notification_panel_layout_gravity">0x31</integer><!-- center_horizontal|top --> diff --git a/packages/SystemUI/shared/Android.bp b/packages/SystemUI/shared/Android.bp index 62e9d8bb2395..23307de519c8 100644 --- a/packages/SystemUI/shared/Android.bp +++ b/packages/SystemUI/shared/Android.bp @@ -45,9 +45,6 @@ android_library { ":wm_shell-aidls", ":wm_shell_util-sources", ], - resource_dirs: [ - "res", - ], static_libs: [ "PluginCoreLib", "androidx.dynamicanimation_dynamicanimation", diff --git a/packages/SystemUI/shared/res/values-sw600dp/dimens.xml b/packages/SystemUI/shared/res/values-sw600dp/dimens.xml deleted file mode 100644 index 5d9e0596b5c1..000000000000 --- a/packages/SystemUI/shared/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?><!-- - * Copyright (c) 2021, 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. -*/ ---> -<resources> - <dimen name="navigation_key_padding">25dp</dimen> -</resources> diff --git a/packages/SystemUI/shared/res/values-sw900dp/dimens.xml b/packages/SystemUI/shared/res/values-sw900dp/dimens.xml deleted file mode 100644 index 3efa5e3ecf70..000000000000 --- a/packages/SystemUI/shared/res/values-sw900dp/dimens.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?><!-- - * Copyright (c) 2021, 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. -*/ ---> -<resources> - <!-- The maximum width of the navigation bar ripples. --> - <dimen name="key_button_ripple_max_width">76dp</dimen> - - <!-- The padding around the navigation buttons --> - <dimen name="navigation_key_padding">0dp</dimen> -</resources>
\ No newline at end of file diff --git a/packages/SystemUI/shared/res/values/dimens.xml b/packages/SystemUI/shared/res/values/dimens.xml deleted file mode 100644 index b7f332846858..000000000000 --- a/packages/SystemUI/shared/res/values/dimens.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?><!-- - * Copyright (c) 2021, 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. -*/ ---> -<resources> - <!-- The maximum width of the navigation bar ripples. --> - <dimen name="key_button_ripple_max_width">95dp</dimen> - - <dimen name="rounded_corner_content_padding">0dp</dimen> - - <dimen name="navigation_key_padding">0dp</dimen> - - <!-- Floating rotation button --> - <dimen name="floating_rotation_button_diameter">40dp</dimen> - <dimen name="floating_rotation_button_min_margin">20dp</dimen> - <dimen name="floating_rotation_button_taskbar_left_margin">20dp</dimen> - <dimen name="floating_rotation_button_taskbar_bottom_margin">10dp</dimen> -</resources> diff --git a/packages/SystemUI/shared/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java b/packages/SystemUI/shared/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java index 53df0f3ab533..07ad0c8a5120 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java +++ b/packages/SystemUI/shared/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java @@ -35,10 +35,9 @@ import android.view.ViewConfiguration; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; +import androidx.annotation.DimenRes; import androidx.annotation.Keep; -import com.android.systemui.shared.R; - import java.util.ArrayList; import java.util.HashSet; @@ -90,8 +89,8 @@ public class KeyButtonRipple extends Drawable { private Type mType = Type.ROUNDED_RECT; - public KeyButtonRipple(Context ctx, View targetView) { - mMaxWidth = ctx.getResources().getDimensionPixelSize(R.dimen.key_button_ripple_max_width); + public KeyButtonRipple(Context ctx, View targetView, @DimenRes int maxWidthResource) { + mMaxWidth = ctx.getResources().getDimensionPixelSize(maxWidthResource); mTargetView = targetView; } diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java index be3d7800bb74..cbf739732361 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java @@ -16,6 +16,9 @@ package com.android.systemui.shared.rotation; +import android.annotation.DimenRes; +import android.annotation.IdRes; +import android.annotation.LayoutRes; import android.annotation.StringRes; import android.content.Context; import android.content.res.Resources; @@ -61,29 +64,33 @@ public class FloatingRotationButton implements RotationButton { private RotationButtonUpdatesCallback mUpdatesCallback; private Position mPosition; - public FloatingRotationButton(Context context, @StringRes int contentDescription) { + public FloatingRotationButton(Context context, @StringRes int contentDescription, + @LayoutRes int layout, @IdRes int keyButtonId, @DimenRes int minMargin, + @DimenRes int roundedContentPadding, @DimenRes int taskbarLeftMargin, + @DimenRes int taskbarBottomMargin, @DimenRes int buttonDiameter, + @DimenRes int rippleMaxWidth) { mWindowManager = context.getSystemService(WindowManager.class); - mKeyButtonContainer = (ViewGroup) LayoutInflater.from(context).inflate( - R.layout.rotate_suggestion, null); - mKeyButtonView = mKeyButtonContainer.findViewById(R.id.rotate_suggestion); + mKeyButtonContainer = (ViewGroup) LayoutInflater.from(context).inflate(layout, null); + mKeyButtonView = mKeyButtonContainer.findViewById(keyButtonId); mKeyButtonView.setVisibility(View.VISIBLE); mKeyButtonView.setContentDescription(context.getString(contentDescription)); + mKeyButtonView.setRipple(rippleMaxWidth); Resources res = context.getResources(); int defaultMargin = Math.max( - res.getDimensionPixelSize(R.dimen.floating_rotation_button_min_margin), - res.getDimensionPixelSize(R.dimen.rounded_corner_content_padding)); + res.getDimensionPixelSize(minMargin), + res.getDimensionPixelSize(roundedContentPadding)); int taskbarMarginLeft = - res.getDimensionPixelSize(R.dimen.floating_rotation_button_taskbar_left_margin); + res.getDimensionPixelSize(taskbarLeftMargin); int taskbarMarginBottom = - res.getDimensionPixelSize(R.dimen.floating_rotation_button_taskbar_bottom_margin); + res.getDimensionPixelSize(taskbarBottomMargin); mPositionCalculator = new FloatingRotationButtonPositionCalculator(defaultMargin, taskbarMarginLeft, taskbarMarginBottom); - final int diameter = res.getDimensionPixelSize(R.dimen.floating_rotation_button_diameter); + final int diameter = res.getDimensionPixelSize(buttonDiameter); mContainerSize = diameter + Math.max(defaultMargin, Math.max(taskbarMarginLeft, taskbarMarginBottom)); } diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButtonView.java b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButtonView.java index e0187f41c68a..c5f8fc15b3b7 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButtonView.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButtonView.java @@ -26,13 +26,15 @@ import android.util.AttributeSet; import android.view.View; import android.widget.ImageView; +import androidx.annotation.DimenRes; + import com.android.systemui.navigationbar.buttons.KeyButtonRipple; public class FloatingRotationButtonView extends ImageView { private static final float BACKGROUND_ALPHA = 0.92f; - private final KeyButtonRipple mRipple; + private KeyButtonRipple mRipple; private final Paint mOvalBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); public FloatingRotationButtonView(Context context, AttributeSet attrs) { @@ -44,12 +46,15 @@ public class FloatingRotationButtonView extends ImageView { setClickable(true); - mRipple = new KeyButtonRipple(context, this); - setBackground(mRipple); setWillNotDraw(false); forceHasOverlappingRendering(false); } + public void setRipple(@DimenRes int rippleMaxWidthResource) { + mRipple = new KeyButtonRipple(getContext(), this, rippleMaxWidthResource); + setBackground(mRipple); + } + @Override protected void onWindowVisibilityChanged(int visibility) { super.onWindowVisibilityChanged(visibility); diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java index cba76e004558..680cc5cb5cba 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java @@ -323,8 +323,16 @@ public class NavigationBarView extends FrameLayout implements mContextualButtonGroup.addButton(accessibilityButton); mRotationContextButton = new RotationContextButton(R.id.rotate_suggestion, mLightContext, R.drawable.ic_sysbar_rotate_button_ccw_start_0); - mFloatingRotationButton = new FloatingRotationButton(context, - R.string.accessibility_rotate_button); + mFloatingRotationButton = new FloatingRotationButton(mContext, + R.string.accessibility_rotate_button, + R.layout.rotate_suggestion, + R.id.rotate_suggestion, + R.dimen.floating_rotation_button_min_margin, + R.dimen.rounded_corner_content_padding, + R.dimen.floating_rotation_button_taskbar_left_margin, + R.dimen.floating_rotation_button_taskbar_bottom_margin, + R.dimen.floating_rotation_button_diameter, + R.dimen.key_button_ripple_max_width); mRotationButtonController = new RotationButtonController(mLightContext, mLightIconColor, mDarkIconColor, R.drawable.ic_sysbar_rotate_button_ccw_start_0, R.drawable.ic_sysbar_rotate_button_ccw_start_90, diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java index 9ea938325659..debd2ebb51be 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java @@ -168,7 +168,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { setClickable(true); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); - mRipple = new KeyButtonRipple(context, this); + mRipple = new KeyButtonRipple(context, this, R.dimen.key_button_ripple_max_width); mOverviewProxyService = Dependency.get(OverviewProxyService.class); mInputManager = manager; setBackground(mRipple); |