Fix 6486099: Fix clipping issues with MultiWaveView on phone/tablet

This fixes a problem where the bounds of the view weren't being
calculated properly when a separate outer radius was specified.

The code now takes the maximum of the ring drawable's width/height
and that specified in the resource files.

This gives it the best default look on all devices while still
allowing minor tweaks.

Change-Id: I5daa40ff4f14653c8cc89b39102816afb976e4f7
diff --git a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
index d6ffba2..60cd895 100644
--- a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
+++ b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
@@ -258,14 +258,14 @@
     protected int getSuggestedMinimumWidth() {
         // View should be large enough to contain the background + handle and
         // target drawable on either edge.
-        return mOuterRing.getWidth() + mMaxTargetWidth;
+        return (int) (Math.max(mOuterRing.getWidth(), 2 * mOuterRadius) + mMaxTargetWidth);
     }
 
     @Override
     protected int getSuggestedMinimumHeight() {
         // View should be large enough to contain the unlock ring + target and
         // target drawable on either edge
-        return mOuterRing.getHeight() + mMaxTargetHeight;
+        return (int) (Math.max(mOuterRing.getHeight(), 2 * mOuterRadius) + mMaxTargetHeight);
     }
 
     private int resolveMeasured(int measureSpec, int desired)
@@ -941,10 +941,14 @@
         super.onLayout(changed, left, top, right, bottom);
         final int width = right - left;
         final int height = bottom - top;
+        // Target placement width/height. This puts the targets on the greater of the ring
+        // width or the specified outer radius.
+        final float placementWidth = Math.max(mOuterRing.getWidth(), 2 * mOuterRadius);
+        final float placementHeight = Math.max(mOuterRing.getHeight(), 2 * mOuterRadius);
         float newWaveCenterX = mHorizontalOffset + mHorizontalInset
-                + Math.max(width, mMaxTargetWidth + mOuterRing.getWidth()) / 2;
+                + Math.max(width, mMaxTargetWidth + placementWidth) / 2;
         float newWaveCenterY = mVerticalOffset + mVerticalInset
-                + Math.max(height, + mMaxTargetHeight + mOuterRing.getHeight()) / 2;
+                + Math.max(height, + mMaxTargetHeight + placementHeight) / 2;
 
         assignDefaultsIfNeeded(newWaveCenterX, newWaveCenterY);
 
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
index 055955e..efd406d 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
@@ -31,7 +31,7 @@
     <!-- top: status -->
     <RelativeLayout
         android:layout_height="0dip"
-        android:layout_weight="1"
+        android:layout_weight="0.42"
         android:layout_width="match_parent"
         android:gravity="center">
 
@@ -69,8 +69,9 @@
     <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="0dip"
-            android:layout_weight="1"
-            android:orientation="vertical">
+            android:layout_weight="0.58"
+            android:orientation="vertical"
+            android:gravity="bottom">
 
         <TextView
             android:id="@+id/screenLocked"
@@ -87,7 +88,7 @@
             android:orientation="horizontal"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_gravity="center"
+            android:layout_gravity="center_horizontal"
             android:gravity="center"
 
             android:targetDrawables="@array/lockscreen_targets_with_camera"
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml
index e68a0c1..de64a51 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml
@@ -30,7 +30,7 @@
     <!-- left side: status and music -->
     <RelativeLayout
         android:layout_height="match_parent"
-        android:layout_weight="1"
+        android:layout_weight="0.42"
         android:layout_width="0dip"
         android:gravity="center">
 
@@ -67,7 +67,7 @@
     <!-- right side -->
     <RelativeLayout
         android:layout_height="match_parent"
-        android:layout_weight="1"
+        android:layout_weight="0.58"
         android:layout_width="0dip"
         android:gravity="center_horizontal|center_vertical">
 
@@ -87,7 +87,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_rowSpan="7"
-            android:layout_gravity="center_vertical|center_horizontal"
+            android:layout_gravity="center_vertical|right"
             android:gravity="center"
 
             android:targetDrawables="@array/lockscreen_targets_with_camera"
diff --git a/packages/SystemUI/res/layout-land/status_bar_search_panel.xml b/packages/SystemUI/res/layout-land/status_bar_search_panel.xml
index 5d4d989..392a8b5 100644
--- a/packages/SystemUI/res/layout-land/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_search_panel.xml
@@ -52,7 +52,6 @@
                 prvandroid:directionDescriptions="@array/navbar_search_direction_descriptions"
                 prvandroid:handleDrawable="@drawable/navbar_search_handle"
                 prvandroid:waveDrawable="@drawable/navbar_search_outerring"
-                prvandroid:outerRadius="@dimen/navbar_search_target_placement_radius"
                 prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
                 prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
                 prvandroid:feedbackCount="0"
diff --git a/packages/SystemUI/res/layout-port/status_bar_search_panel.xml b/packages/SystemUI/res/layout-port/status_bar_search_panel.xml
index 2486b75..371c575 100644
--- a/packages/SystemUI/res/layout-port/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-port/status_bar_search_panel.xml
@@ -52,7 +52,6 @@
                 prvandroid:directionDescriptions="@array/navbar_search_direction_descriptions"
                 prvandroid:handleDrawable="@drawable/navbar_search_handle"
                 prvandroid:waveDrawable="@drawable/navbar_search_outerring"
-                prvandroid:outerRadius="@dimen/navbar_search_target_placement_radius"
                 prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
                 prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
                 prvandroid:feedbackCount="0"
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml
index 4b2fbc7..0ccfe95 100644
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml
@@ -61,7 +61,6 @@
                 prvandroid:directionDescriptions="@array/navbar_search_direction_descriptions"
                 prvandroid:handleDrawable="@drawable/navbar_search_handle"
                 prvandroid:waveDrawable="@drawable/navbar_search_outerring"
-                prvandroid:outerRadius="@dimen/navbar_search_target_placement_radius"
                 prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
                 prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
                 prvandroid:feedbackCount="0"
diff --git a/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml b/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
index ac2472c..0a5390a 100644
--- a/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
@@ -61,7 +61,6 @@
                 prvandroid:directionDescriptions="@array/navbar_search_direction_descriptions"
                 prvandroid:handleDrawable="@drawable/navbar_search_handle"
                 prvandroid:waveDrawable="@drawable/navbar_search_outerring"
-                prvandroid:outerRadius="@dimen/navbar_search_target_placement_radius"
                 prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
                 prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
                 prvandroid:feedbackCount="0"
diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml
index 2cb99ff..07d55f1 100644
--- a/packages/SystemUI/res/values-sw600dp/dimens.xml
+++ b/packages/SystemUI/res/values-sw600dp/dimens.xml
@@ -27,9 +27,6 @@
     <!-- 0x33 = center_horizontal|top -->
     <integer name="notification_panel_layout_gravity">0x31</integer>
 
-    <!-- Default target placement radius for navigation bar search target -->
-    <dimen name="navbar_search_target_placement_radius">182dip</dimen>
-
     <!-- Diameter of outer shape drawable shown in navbar search-->
     <dimen name="navbar_search_outerring_diameter">364dp</dimen>
 
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 21e5fd7..f548166 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -105,9 +105,6 @@
     <!-- The width of the view containing the menu status bar icon -->
     <dimen name="navigation_menu_key_width">40dip</dimen>
 
-    <!-- Default target placement radius for navigation bar search target -->
-    <dimen name="navbar_search_target_placement_radius">150dip</dimen>
-
     <!-- Default distance beyond which snaps to the target radius -->
     <dimen name="navbar_search_snap_margin">20dip</dimen>