OSDN Git Service

Merge "Updating the assets for the all-apps search background." into ub-launcher3...
authorSunny Goyal <sunnygoyal@google.com>
Thu, 8 Sep 2016 20:16:48 +0000 (20:16 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Thu, 8 Sep 2016 20:16:49 +0000 (20:16 +0000)
12 files changed:
res/drawable/bg_pill_focused.xml [new file with mode: 0644]
res/layout-port/launcher.xml
res/layout-sw720dp/launcher.xml
res/layout/deep_shortcut.xml
res/layout/page_indicator.xml [new file with mode: 0644]
res/values/dimens.xml
src/com/android/launcher3/DeviceProfile.java
src/com/android/launcher3/dragndrop/DragController.java
src/com/android/launcher3/dragndrop/DragLayer.java
src/com/android/launcher3/pageindicators/CaretDrawable.java
src/com/android/launcher3/pageindicators/PageIndicator.java
src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java

diff --git a/res/drawable/bg_pill_focused.xml b/res/drawable/bg_pill_focused.xml
new file mode 100644 (file)
index 0000000..37afad0
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_focused="true">
+        <shape xmlns:android="http://schemas.android.com/apk/res/android"
+               android:shape="rectangle">
+            <stroke android:color="#616161" android:width="2dp"/>
+            <corners android:radius="@dimen/bg_pill_radius" />
+        </shape>
+    </item>
+</selector>
\ No newline at end of file
index 49bac3b..a2e2f9b 100644 (file)
 
         <!-- Keep these behind the workspace so that they are not visible when
              we go into AllApps -->
-        <com.android.launcher3.pageindicators.PageIndicatorLineCaret
-            android:id="@+id/page_indicator"
-            android:layout_width="match_parent"
-            android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
+        <include layout="@layout/page_indicator"
+            android:id="@+id/page_indicator" />
 
         <include
             android:id="@+id/drop_target_bar"
index 81d2e1b..12c01b7 100644 (file)
 
         <!-- Keep these behind the workspace so that they are not visible when
              we go into AllApps -->
-        <com.android.launcher3.pageindicators.PageIndicatorLineCaret
-            android:id="@+id/page_indicator"
-            android:layout_width="match_parent"
-            android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
+        <include layout="@layout/page_indicator"
+                 android:id="@+id/page_indicator" />
 
         <include
             layout="@layout/qsb_container"
index 2d66d72..7b42ec7 100644 (file)
@@ -26,7 +26,8 @@
         style="@style/Icon.DeepShortcut"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:focusable="true" />
+        android:focusable="true"
+        android:background="@drawable/bg_pill_focused" />
 
     <View
         android:id="@+id/deep_shortcut_icon"
diff --git a/res/layout/page_indicator.xml b/res/layout/page_indicator.xml
new file mode 100644 (file)
index 0000000..2e1b57f
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<com.android.launcher3.pageindicators.PageIndicatorLineCaret
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="@dimen/dynamic_grid_page_indicator_height">
+        <ImageView
+            android:id="@+id/all_apps_handle"
+            android:layout_width="48dp"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:scaleType="centerInside"/>
+</com.android.launcher3.pageindicators.PageIndicatorLineCaret>
index 87ef78b..1ae4685 100644 (file)
@@ -4,9 +4,9 @@
      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.
@@ -19,7 +19,6 @@
     <dimen name="dynamic_grid_edge_margin">8dp</dimen>
     <dimen name="dynamic_grid_page_indicator_height">28dp</dimen>
     <dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
-    <dimen name="dynamic_grid_page_indicator_extra_touch_height">12dp</dimen>
     <dimen name="dynamic_grid_page_indicator_gutter_width_left_nav_bar">38dp</dimen>
     <dimen name="dynamic_grid_page_indicator_gutter_width_right_nav_bar">48dp</dimen>
     <dimen name="dynamic_grid_icon_drawable_padding">8dp</dimen>
index e6802bd..c9fd85a 100644 (file)
@@ -533,7 +533,6 @@ public class DeviceProfile {
             } else {
                 // Put the page indicators above the hotseat
                 lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
-                lp.width = LayoutParams.WRAP_CONTENT;
                 lp.height = pageIndicatorHeightPx;
                 lp.bottomMargin = hotseatBarHeightPx + mInsets.bottom;
             }
index b67d3b8..29e33e9 100644 (file)
@@ -260,7 +260,7 @@ public class DragController implements DragDriver.EventListener, TouchController
         dragView.show(mMotionDownX, mMotionDownY);
         mDistanceSinceScroll = 0;
 
-        for (DragListener listener : mListeners) {
+        for (DragListener listener : new ArrayList<>(mListeners)) {
             listener.onDragStart(mDragObject, mOptions);
         }
 
index e5ec6ba..5863828 100644 (file)
@@ -506,7 +506,9 @@ public class DragLayer extends InsettableFrameLayout {
 
     @Override
     public boolean dispatchUnhandledMove(View focused, int direction) {
-        return mDragController.dispatchUnhandledMove(focused, direction);
+        // Consume the unhandled move if a container is open, to avoid switching pages underneath.
+        boolean isContainerOpen = mLauncher.getTopFloatingView() != null;
+        return isContainerOpen || mDragController.dispatchUnhandledMove(focused, direction);
     }
 
     @Override
index 1451773..4789f69 100644 (file)
@@ -37,6 +37,7 @@ public class CaretDrawable extends Drawable {
     private Paint mShadowPaint = new Paint();
     private Paint mCaretPaint = new Paint();
     private Path mPath = new Path();
+    private final int mCaretSizePx;
 
     public CaretDrawable(Context context) {
         final Resources res = context.getResources();
@@ -57,6 +58,18 @@ public class CaretDrawable extends Drawable {
         mShadowPaint.setStyle(Paint.Style.STROKE);
         mShadowPaint.setStrokeCap(Paint.Cap.ROUND);
         mShadowPaint.setStrokeJoin(Paint.Join.ROUND);
+
+        mCaretSizePx = res.getDimensionPixelSize(R.dimen.all_apps_caret_size);
+    }
+
+    @Override
+    public int getIntrinsicHeight() {
+        return mCaretSizePx;
+    }
+
+    @Override
+    public int getIntrinsicWidth() {
+        return mCaretSizePx;
     }
 
     @Override
index b53715d..47c2ffb 100644 (file)
@@ -18,20 +18,21 @@ package com.android.launcher3.pageindicators;
 import android.content.Context;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
-import android.view.View;
+import android.widget.FrameLayout;
 
 import com.android.launcher3.dynamicui.ExtractedColors;
 
 /**
  * Base class for a page indicator.
  */
-public abstract class PageIndicator extends View {
+public abstract class PageIndicator extends FrameLayout {
     private CaretDrawable mCaretDrawable;
 
     protected int mNumPages = 1;
 
     public PageIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
+        setWillNotDraw(false);
     }
 
     public void setScroll(int currentScroll, int totalScroll) {}
index 0d771ad..ca3a2dd 100644 (file)
@@ -15,14 +15,13 @@ import android.support.v4.graphics.ColorUtils;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.util.Property;
-import android.view.View;
 import android.view.ViewConfiguration;
+import android.widget.ImageView;
 
 import com.android.launcher3.Launcher;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.dynamicui.ExtractedColors;
-import com.android.launcher3.util.TransformingTouchDelegate;
 
 /**
  * A PageIndicator that briefly shows a fraction of a line when moving between pages.
@@ -60,10 +59,7 @@ public class PageIndicatorLineCaret extends PageIndicator {
     private Paint mLinePaint;
     private Launcher mLauncher;
     private final int mLineHeight;
-    private final TransformingTouchDelegate mTouchDelegate;
-    private final int mTouchExtensionHeight;
-    private final int mCaretSizePx;
-    private final int mCaretWorkspaceOffsetPx;
+    private ImageView mAllAppsHandle;
 
     private static final Property<PageIndicatorLineCaret, Integer> PAINT_ALPHA
             = new Property<PageIndicatorLineCaret, Integer>(Integer.class, "paint_alpha") {
@@ -128,48 +124,26 @@ public class PageIndicatorLineCaret extends PageIndicator {
         Resources res = context.getResources();
         mLinePaint = new Paint();
         mLinePaint.setAlpha(0);
-        mCaretSizePx = res.getDimensionPixelSize(R.dimen.all_apps_caret_size);
-        mCaretWorkspaceOffsetPx = res.getDimensionPixelSize(
-                R.dimen.all_apps_caret_workspace_offset);
 
         mLauncher = (Launcher) context;
-        setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
-        setOnClickListener(mLauncher);
-        setOnLongClickListener(mLauncher);
-        setOnFocusChangeListener(mLauncher.mFocusHandler);
-        setCaretDrawable(new CaretDrawable(context));
         mLineHeight = res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_line_height);
-        mTouchExtensionHeight = res.getDimensionPixelSize(
-                R.dimen.dynamic_grid_page_indicator_extra_touch_height);
-        mTouchDelegate = new TransformingTouchDelegate(this);
-    }
-
-    @Override
-    protected void onAttachedToWindow() {
-        super.onAttachedToWindow();
-        mLauncher.getDragLayer().setTouchDelegate(mTouchDelegate);
+        setCaretDrawable(new CaretDrawable(context));
     }
 
     @Override
-    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
-        super.onLayout(changed, left, top, right, bottom);
-        // Top/center align the caret in the page indicator space
-        int l = (right - left) / 2 - mCaretSizePx / 2;
-        getCaretDrawable().setBounds(l, mCaretWorkspaceOffsetPx, l + mCaretSizePx,
-                mCaretWorkspaceOffsetPx + mCaretSizePx);
-
-        // The touch area is expanded below this view by #mTouchExtensionHeight
-        // which extends to the top of the hotseat.
-        View parent = mLauncher.getDragLayer();
-        sTempCoords[0] = sTempCoords[1] = 0;
-        Utilities.getDescendantCoordRelativeToAncestor(this, parent, sTempCoords, true);
-        mTouchDelegate.setBounds(sTempCoords[0], sTempCoords[1], sTempCoords[0] + this.getWidth(),
-                sTempCoords[1] + getHeight() + mTouchExtensionHeight);
+    protected void onFinishInflate() {
+        super.onFinishInflate();
+        mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
+        mAllAppsHandle.setImageDrawable(getCaretDrawable());
+        mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
+        mAllAppsHandle.setOnClickListener(mLauncher);
+        mAllAppsHandle.setOnLongClickListener(mLauncher);
+        mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
+        mLauncher.setAllAppsButton(mAllAppsHandle);
     }
 
     @Override
     protected void onDraw(Canvas canvas) {
-        getCaretDrawable().draw(canvas);
         if (mTotalScroll == 0 || mNumPagesFloat == 0) {
             return;
         }