summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2019-04-05 13:52:35 -0700
committerTony Wickham <twickham@google.com>2019-04-09 10:53:24 -0700
commit9791bd1555b2143fcc39830cdc555aa51114f4b0 (patch)
tree4ccb461497a01766d21b339e0ecb72a9c7feff11 /src/com
parent2a059c7802c68ffbccbde00b6036b8cbd2b04a7d (diff)
downloadandroid_packages_apps_Trebuchet-9791bd1555b2143fcc39830cdc555aa51114f4b0.tar.gz
android_packages_apps_Trebuchet-9791bd1555b2143fcc39830cdc555aa51114f4b0.tar.bz2
android_packages_apps_Trebuchet-9791bd1555b2143fcc39830cdc555aa51114f4b0.zip
Swipe up on nav bar to go home from -1 and widgets
More specifically, any window (e.g. qsb search) or AbstractFloatingView. NavBarToHomeTouchController now implements TouchController directly instead of AbstractStateChangeTouchController, as it not only dealing with launcher states. This makes it easier to override intercept logic to handle cases like not having window focus, for example. AbstractFloatingViews can createHintCloseAnim() to play an animation hinting that it is about to be closed by swiping up. Widgets sheets use this to pull back similar to the all apps transition to home. Bug: 129976669 Change-Id: Ie157b978d9f1ee36d5fd32cea72ec02ce40878c0
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/AbstractFloatingView.java20
-rw-r--r--src/com/android/launcher3/folder/Folder.java7
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java7
-rw-r--r--src/com/android/launcher3/views/BottomUserEducationView.java10
-rw-r--r--src/com/android/launcher3/widget/BaseWidgetSheet.java7
-rw-r--r--src/com/android/launcher3/widget/WidgetsBottomSheet.java28
-rw-r--r--src/com/android/launcher3/widget/WidgetsFullSheet.java16
7 files changed, 84 insertions, 11 deletions
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 599a3533d..e7d7a69fd 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -19,9 +19,11 @@ package com.android.launcher3;
import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
+
import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
+import android.animation.Animator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
@@ -30,7 +32,11 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
+import androidx.annotation.IntDef;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;
@@ -38,8 +44,6 @@ import com.android.launcher3.views.BaseDragLayer;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import androidx.annotation.IntDef;
-
/**
* Base class for a View which shows a floating UI on top of the launcher UI.
*/
@@ -124,8 +128,20 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
protected abstract void handleClose(boolean animate);
+ /**
+ * Creates a user-controlled animation to hint that the view will be closed if completed.
+ * @param distanceToMove The max distance that elements should move from their starting point.
+ */
+ public @Nullable Animator createHintCloseAnim(float distanceToMove) {
+ return null;
+ }
+
public abstract void logActionCommand(int command);
+ public int getLogContainerType() {
+ return ContainerType.DEFAULT_CONTAINERTYPE;
+ }
+
public final boolean isOpen() {
return mIsOpen;
}
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index bcddd037e..2ce663433 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -1406,7 +1406,12 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
@Override
public void logActionCommand(int command) {
mLauncher.getUserEventDispatcher().logActionCommand(
- command, getFolderIcon(), ContainerType.FOLDER);
+ command, getFolderIcon(), getLogContainerType());
+ }
+
+ @Override
+ public int getLogContainerType() {
+ return ContainerType.FOLDER;
}
@Override
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 080a0cb69..593dbd46c 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -157,7 +157,12 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
@Override
public void logActionCommand(int command) {
mLauncher.getUserEventDispatcher().logActionCommand(
- command, mOriginalIcon, ContainerType.DEEPSHORTCUTS);
+ command, mOriginalIcon, getLogContainerType());
+ }
+
+ @Override
+ public int getLogContainerType() {
+ return ContainerType.DEEPSHORTCUTS;
}
public OnClickListener getItemClickListener() {
diff --git a/src/com/android/launcher3/views/BottomUserEducationView.java b/src/com/android/launcher3/views/BottomUserEducationView.java
index a291fc605..bdc69af69 100644
--- a/src/com/android/launcher3/views/BottomUserEducationView.java
+++ b/src/com/android/launcher3/views/BottomUserEducationView.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.views;
+import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
+
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
@@ -28,8 +30,7 @@ import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.anim.Interpolators;
-
-import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
public class BottomUserEducationView extends AbstractSlideInView implements Insettable {
@@ -71,6 +72,11 @@ public class BottomUserEducationView extends AbstractSlideInView implements Inse
}
@Override
+ public int getLogContainerType() {
+ return ContainerType.TIP;
+ }
+
+ @Override
protected boolean isOfType(int type) {
return (type & TYPE_ON_BOARD_POPUP) != 0;
}
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index df8266119..72cddc780 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -162,11 +162,16 @@ abstract class BaseWidgetSheet extends AbstractSlideInView
@Override
public final void logActionCommand(int command) {
- Target target = newContainerTarget(ContainerType.WIDGETS);
+ Target target = newContainerTarget(getLogContainerType());
target.cardinality = getElementsRowCount();
mLauncher.getUserEventDispatcher().logActionCommand(command, target);
}
+ @Override
+ public int getLogContainerType() {
+ return ContainerType.WIDGETS;
+ }
+
protected abstract int getElementsRowCount();
protected SystemUiController getSystemUiController() {
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index 05368faa6..3e2c0aef4 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -16,10 +16,13 @@
package com.android.launcher3.widget;
+import android.animation.Animator;
+import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
+import android.util.IntProperty;
import android.util.Pair;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -27,6 +30,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.Insettable;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
@@ -43,6 +48,20 @@ import java.util.List;
*/
public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
+ private static final IntProperty<View> PADDING_BOTTOM =
+ new IntProperty<View>("paddingBottom") {
+ @Override
+ public void setValue(View view, int paddingBottom) {
+ view.setPadding(view.getPaddingLeft(), view.getPaddingTop(),
+ view.getPaddingRight(), paddingBottom);
+ }
+
+ @Override
+ public Integer get(View view) {
+ return view.getPaddingBottom();
+ }
+ };
+
private static final int DEFAULT_CLOSE_DURATION = 200;
private ItemInfo mOriginalItemInfo;
private Rect mInsets;
@@ -158,8 +177,7 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
int rightInset = insets.right - mInsets.right;
int bottomInset = insets.bottom - mInsets.bottom;
mInsets.set(insets);
- setPadding(getPaddingLeft() + leftInset, getPaddingTop(),
- getPaddingRight() + rightInset, getPaddingBottom() + bottomInset);
+ setPadding(leftInset, getPaddingTop(), rightInset, bottomInset);
}
@Override
@@ -172,4 +190,10 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
return Pair.create(findViewById(R.id.title), getContext().getString(
mIsOpen ? R.string.widgets_list : R.string.widgets_list_closed));
}
+
+ @Nullable
+ @Override
+ public Animator createHintCloseAnim(float distanceToMove) {
+ return ObjectAnimator.ofInt(this, PADDING_BOTTOM, (int) (distanceToMove + mInsets.bottom));
+ }
}
diff --git a/src/com/android/launcher3/widget/WidgetsFullSheet.java b/src/com/android/launcher3/widget/WidgetsFullSheet.java
index ec06d1e6d..521f5117a 100644
--- a/src/com/android/launcher3/widget/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsFullSheet.java
@@ -17,6 +17,8 @@ package com.android.launcher3.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
@@ -27,6 +29,9 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AnimationUtils;
+import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
+
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
@@ -35,8 +40,6 @@ import com.android.launcher3.R;
import com.android.launcher3.views.RecyclerViewFastScroller;
import com.android.launcher3.views.TopRoundedCornerView;
-import androidx.annotation.VisibleForTesting;
-
/**
* Popup for showing the full list of available widgets
*/
@@ -235,4 +238,13 @@ public class WidgetsFullSheet extends BaseWidgetSheet
protected int getElementsRowCount() {
return mAdapter.getItemCount();
}
+
+ @Nullable
+ @Override
+ public Animator createHintCloseAnim(float distanceToMove) {
+ AnimatorSet anim = new AnimatorSet();
+ anim.play(ObjectAnimator.ofFloat(mRecyclerView, TRANSLATION_Y, -distanceToMove));
+ anim.play(ObjectAnimator.ofFloat(mRecyclerView, ALPHA, 0.5f));
+ return anim;
+ }
}