Do not use shared lib resources

Temporary removes usages of SysUI shared
resources as it leads to crashes in Launcher
tests.

Bug: 204727471
Test: install launcher, try autorotate suggestion
Change-Id: I82dae0b2f5a9d2cb83f8a60e3c08353dc1bb60b6
diff --git a/packages/SystemUI/shared/res/layout/rotate_suggestion.xml b/packages/SystemUI/res/layout/rotate_suggestion.xml
similarity index 100%
rename from packages/SystemUI/shared/res/layout/rotate_suggestion.xml
rename to 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 c1c15d1..d17ec73 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 ebae8c4b..2758fb4 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 46869a0..e5ea368 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 62e9d8b..23307de 100644
--- a/packages/SystemUI/shared/Android.bp
+++ b/packages/SystemUI/shared/Android.bp
@@ -45,9 +45,6 @@
         ":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 5d9e059..0000000
--- 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 3efa5e3..0000000
--- 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 b7f3328..0000000
--- 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 53df0f3..07ad0c8 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.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 @@
 
     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 be3d780..cbf7397 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 @@
     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 e0187f41..c5f8fc1 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.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 @@
 
         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 cba76e0..680cc5c 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 @@
         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 9ea9383..debd2eb 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 @@
         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);