Removing horizontal bar from page indicator

> Removing the clickable bar from pageIndicator in portrait view
> Moving onClick logic to respective classes

Change-Id: I83a8df90d8c5442890bc09fdda17a82b9d134b8a
diff --git a/res/drawable/all_apps_handle_landscape.xml b/res/drawable/all_apps_handle_landscape.xml
index 23826ab..15518ff 100644
--- a/res/drawable/all_apps_handle_landscape.xml
+++ b/res/drawable/all_apps_handle_landscape.xml
@@ -15,23 +15,26 @@
 -->
 
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="13dp"
-    android:height="13dp"
-    android:viewportWidth="13.0"
-    android:viewportHeight="13.0" >
+    android:width="@dimen/dynamic_grid_min_page_indicator_size"
+    android:height="@dimen/dynamic_grid_min_page_indicator_size"
+    android:viewportWidth="48.0"
+    android:viewportHeight="48.0" >
 
-    <path
-        android:pathData="M2 8.5L6.5 4L11 8.5"
-        android:strokeColor="?attr/workspaceAmbientShadowColor"
-        android:strokeWidth="4"
-        android:strokeLineCap="round"
-        android:strokeLineJoin="round" />
+    <group
+        android:translateX="17.5"
+        android:translateY="17.5">
+        <path
+            android:pathData="M2 8.5L6.5 4L11 8.5"
+            android:strokeColor="?attr/workspaceAmbientShadowColor"
+            android:strokeWidth="4"
+            android:strokeLineCap="round"
+            android:strokeLineJoin="round" />
 
-    <path
-        android:pathData="M2 8.5L6.5 4L11 8.5"
-        android:strokeColor="?attr/workspaceTextColor"
-        android:strokeWidth="2"
-        android:strokeLineCap="round"
-        android:strokeLineJoin="round" />
-
+        <path
+            android:pathData="M2 8.5L6.5 4L11 8.5"
+            android:strokeColor="?attr/workspaceTextColor"
+            android:strokeWidth="2"
+            android:strokeLineCap="round"
+            android:strokeLineJoin="round" />
+        </group>
 </vector>
diff --git a/res/drawable/all_apps_handle_portrait.xml b/res/drawable/all_apps_handle_portrait.xml
deleted file mode 100644
index 75aa448..0000000
--- a/res/drawable/all_apps_handle_portrait.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.
--->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="16dp"
-    android:height="13dp"
-    android:viewportWidth="16.0"
-    android:viewportHeight="13.0" >
-
-    <path
-        android:pathData="M2 6h12"
-        android:strokeColor="?attr/workspaceAmbientShadowColor"
-        android:strokeWidth="4"
-        android:strokeLineCap="round" />
-
-    <path
-        android:pathData="M2 6h12"
-        android:strokeColor="?attr/workspaceTextColor"
-        android:strokeWidth="2"
-        android:strokeLineCap="round" />
-</vector>
\ No newline at end of file
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 4ea32b4..d21e45d 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -47,13 +47,8 @@
             android:theme="@style/HomeScreenElementTheme"
             android:layout_width="@dimen/dynamic_grid_min_page_indicator_size"
             android:layout_height="@dimen/dynamic_grid_min_page_indicator_size"
-            android:layout_gravity="bottom|left">
-            <ImageView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/all_apps_handle_landscape"
-                android:layout_gravity="center" />
-        </com.android.launcher3.pageindicators.PageIndicatorLandscape>
+            android:layout_gravity="bottom|left"
+            android:background="@drawable/all_apps_handle_landscape" />
 
         <include layout="@layout/gradient_bg" />
 
diff --git a/res/layout/page_indicator.xml b/res/layout/page_indicator.xml
index 2df511b..7de0cde 100644
--- a/res/layout/page_indicator.xml
+++ b/res/layout/page_indicator.xml
@@ -18,12 +18,4 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:theme="@style/HomeScreenElementTheme"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/dynamic_grid_min_page_indicator_size">
-        <ImageView
-            android:id="@+id/all_apps_handle"
-            android:layout_width="48dp"
-            android:layout_height="@dimen/dynamic_grid_min_page_indicator_size"
-            android:src="@drawable/all_apps_handle_portrait"
-            android:layout_gravity="top|center"
-            android:scaleType="centerInside"/>
-</com.android.launcher3.pageindicators.PageIndicatorLine>
+    android:layout_height="@dimen/dynamic_grid_min_page_indicator_size" />
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index b211207..1497b5a 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -15,6 +15,9 @@
 -->
 
 <resources>
+    <!-- Dynamic Grid -->
+    <dimen name="dynamic_grid_min_page_indicator_size">24dp</dimen>
+
     <!-- All Apps -->
     <dimen name="all_apps_button_scale_down">8dp</dimen>
     <dimen name="all_apps_empty_search_message_top_offset">64dp</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e7f45c2..60f249e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -20,7 +20,7 @@
 
     <!-- Dynamic Grid -->
     <dimen name="dynamic_grid_edge_margin">8dp</dimen>
-    <dimen name="dynamic_grid_min_page_indicator_size">32dp</dimen>
+    <dimen name="dynamic_grid_min_page_indicator_size">24dp</dimen>
     <dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
     <dimen name="dynamic_grid_page_indicator_land_left_nav_bar_gutter_width">0dp</dimen>
     <dimen name="dynamic_grid_page_indicator_land_right_nav_bar_gutter_width">0dp</dimen>
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 09f9e82..20a6be2 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -16,6 +16,9 @@
 
 package com.android.launcher3;
 
+import static com.android.launcher3.LauncherState.ALL_APPS;
+import static com.android.launcher3.LauncherState.NORMAL;
+
 import android.content.Context;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
@@ -29,7 +32,9 @@
 
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.logging.UserEventDispatcher;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
 
 public class Hotseat extends FrameLayout
@@ -127,8 +132,13 @@
             allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
             allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
             if (mLauncher != null) {
-                mLauncher.setAllAppsButton(allAppsButton);
-                allAppsButton.setOnClickListener(mLauncher);
+                allAppsButton.setOnClickListener((v) -> {
+                    if (!mLauncher.isInState(ALL_APPS)) {
+                        mLauncher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
+                                ControlType.ALL_APPS_BUTTON);
+                        mLauncher.getStateManager().goToState(ALL_APPS);
+                    }
+                });
                 allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
             }
 
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 44b64d9..9ee59cc 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -60,7 +60,6 @@
 import android.content.pm.PackageManager;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Point;
-import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.os.AsyncTask;
@@ -117,7 +116,6 @@
 import com.android.launcher3.logging.UserEventDispatcher;
 import com.android.launcher3.model.ModelWriter;
 import com.android.launcher3.notification.NotificationListener;
-import com.android.launcher3.pageindicators.PageIndicator;
 import com.android.launcher3.popup.PopupContainerWithArrow;
 import com.android.launcher3.popup.PopupDataProvider;
 import com.android.launcher3.shortcuts.DeepShortcutManager;
@@ -127,7 +125,6 @@
 import com.android.launcher3.userevent.nano.LauncherLogProto;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
-import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
 import com.android.launcher3.util.ActivityResultInfo;
 import com.android.launcher3.util.ComponentKey;
@@ -230,8 +227,6 @@
 
     @Thunk Hotseat mHotseat;
 
-    private View mAllAppsButton;
-
     private DropTargetBar mDropTargetBar;
 
     // Main container view for the all apps screen.
@@ -1072,14 +1067,6 @@
     }
 
     /**
-     * Sets the all apps button. This method is called from {@link Hotseat}.
-     * TODO: Get rid of this.
-     */
-    public void setAllAppsButton(View allAppsButton) {
-        mAllAppsButton = allAppsButton;
-    }
-
-    /**
      * Creates a view representing a shortcut.
      *
      * @param info The data structure describing the shortcut.
@@ -1852,9 +1839,6 @@
             if (v instanceof FolderIcon) {
                 onClickFolderIcon(v);
             }
-        } else if ((v instanceof PageIndicator) ||
-            (v == mAllAppsButton && mAllAppsButton != null)) {
-            onClickAllAppsButton(v);
         } else if (tag instanceof AppInfo) {
             startAppShortcutOrInfoActivity(v);
         } else if (tag instanceof LauncherAppWidgetInfo) {
@@ -1903,24 +1887,6 @@
         }
     }
 
-    /**
-     * Event handler for the "grid" button or "caret" that appears on the home screen, which
-     * enters all apps mode. In verticalBarLayout the caret can be seen when all apps is open, and
-     * so in that case reverses the action.
-     *
-     * @param v The view that was clicked.
-     */
-    protected void onClickAllAppsButton(View v) {
-        if (LOGD) Log.d(TAG, "onClickAllAppsButton");
-        if (!isInState(ALL_APPS)) {
-            getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
-                    ControlType.ALL_APPS_BUTTON);
-            mStateManager.goToState(ALL_APPS);
-        } else {
-            mStateManager.goToState(NORMAL);
-        }
-    }
-
     private void onClickPendingAppItem(final View v, final String packageName,
             boolean downloadStarted) {
         if (downloadStarted) {
diff --git a/src/com/android/launcher3/pageindicators/PageIndicator.java b/src/com/android/launcher3/pageindicators/PageIndicator.java
index be6bcc5..5e3d216 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicator.java
@@ -17,18 +17,17 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
-import android.widget.FrameLayout;
+import android.view.View;
 
 /**
  * Base class for a page indicator.
  */
-public abstract class PageIndicator extends FrameLayout {
+public abstract class PageIndicator extends View {
 
     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) {}
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java b/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java
index 7325235..2d5a4a9 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java
@@ -15,17 +15,23 @@
  */
 package com.android.launcher3.pageindicators;
 
+import static com.android.launcher3.LauncherState.ALL_APPS;
+
 import android.content.Context;
 import android.util.AttributeSet;
+import android.view.View;
+import android.view.View.OnClickListener;
 
 import com.android.launcher3.Launcher;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 
 /**
  * Simply draws the caret drawable bottom-right aligned in the view. This ensures that we can have
  * a view with as large an area as we want (for touching) while maintaining a caret of size
  * all_apps_caret_size.  Used only for the landscape layout.
  */
-public class PageIndicatorLandscape extends PageIndicator {
+public class PageIndicatorLandscape extends PageIndicator implements OnClickListener {
     // all apps pull up handle drawable.
 
     public PageIndicatorLandscape(Context context) {
@@ -38,8 +44,17 @@
 
     public PageIndicatorLandscape(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
-        Launcher l = Launcher.getLauncher(context);
-        setOnClickListener(l);
-        setOnFocusChangeListener(l.mFocusHandler);
+        setOnClickListener(this);
+        setOnFocusChangeListener(Launcher.getLauncher(context).mFocusHandler);
+    }
+
+    @Override
+    public void onClick(View view) {
+        Launcher l = Launcher.getLauncher(getContext());
+        if (!l.isInState(ALL_APPS)) {
+            l.getUserEventDispatcher().logActionOnControl(
+                    Action.Touch.TAP, ControlType.ALL_APPS_BUTTON);
+            l.getStateManager().goToState(ALL_APPS);
+        }
     }
 }
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLine.java b/src/com/android/launcher3/pageindicators/PageIndicatorLine.java
index 09a06b0..6c4b898 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLine.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLine.java
@@ -14,7 +14,6 @@
 import android.util.AttributeSet;
 import android.util.Property;
 import android.view.ViewConfiguration;
-import android.widget.ImageView;
 
 import com.android.launcher3.Launcher;
 import com.android.launcher3.R;
@@ -54,7 +53,6 @@
     private Paint mLinePaint;
     private Launcher mLauncher;
     private final int mLineHeight;
-    private ImageView mAllAppsHandle;
 
     private static final Property<PageIndicatorLine, Integer> PAINT_ALPHA
             = new Property<PageIndicatorLine, Integer>(Integer.class, "paint_alpha") {
@@ -98,12 +96,7 @@
         }
     };
 
-    private Runnable mHideLineRunnable = new Runnable() {
-        @Override
-        public void run() {
-            animateLineToAlpha(0);
-        }
-    };
+    private Runnable mHideLineRunnable = () -> animateLineToAlpha(0);
 
     public PageIndicatorLine(Context context) {
         this(context, null);
@@ -129,20 +122,6 @@
     }
 
     @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-        mAllAppsHandle = findViewById(R.id.all_apps_handle);
-        mAllAppsHandle.setOnClickListener(mLauncher);
-        mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
-        mLauncher.setAllAppsButton(mAllAppsHandle);
-    }
-
-    @Override
-    public void setAccessibilityDelegate(AccessibilityDelegate delegate) {
-        mAllAppsHandle.setAccessibilityDelegate(delegate);
-    }
-
-    @Override
     protected void onDraw(Canvas canvas) {
         if (mTotalScroll == 0 || mNumPagesFloat == 0) {
             return;
@@ -159,11 +138,6 @@
     }
 
     @Override
-    public void setContentDescription(CharSequence contentDescription) {
-        mAllAppsHandle.setContentDescription(contentDescription);
-    }
-
-    @Override
     public void setScroll(int currentScroll, int totalScroll) {
         if (getAlpha() == 0) {
             return;