Snap for 8970787 from b6d673ad40 to udc-release

Change-Id: Ia2eb62d4219b226db8b92a123ff9f8cafb46cdcb
This commit is contained in:
Android Build Coastguard Worker committed 2022-08-20 03:26:10 +00:00
commit 6c58febf25
15 files changed
+160 -182

No files matched your search

@@ -188,9 +188,6 @@ public class QuickstepAtomicAnimationFactory extends
AllAppsSwipeController.applyAllAppsToNormalConfig(mActivity, config);
} else if (fromState == NORMAL && toState == ALL_APPS) {
AllAppsSwipeController.applyNormalToAllAppsAnimConfig(mActivity, config);
} else if (fromState == OVERVIEW && toState == OVERVIEW_SPLIT_SELECT) {
config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE,
clampToProgress(LINEAR, 0, 0.167f));
}
}
}
@@ -16,8 +16,6 @@
package com.android.launcher3.uioverrides.states;
import android.content.Context;
import com.android.launcher3.Launcher;
import com.android.quickstep.views.RecentsView;
@@ -26,8 +24,6 @@ import com.android.quickstep.views.RecentsView;
* pinned and user is selecting the second one
*/
public class SplitScreenSelectState extends OverviewState {
private static final int OVERVIEW_SPLIT_SELECT_SLIDE_IN_DURATION = 500;
public SplitScreenSelectState(int id) {
super(id);
}
@@ -42,9 +38,4 @@ public class SplitScreenSelectState extends OverviewState {
RecentsView recentsView = launcher.getOverviewPanel();
return recentsView.getSplitSelectTranslation();
}
@Override
public int getTransitionDuration(Context context, boolean isToState) {
return OVERVIEW_SPLIT_SELECT_SLIDE_IN_DURATION;
}
}
@@ -2,9 +2,8 @@ package com.android.quickstep.views;
import static com.android.launcher3.AbstractFloatingView.TYPE_TASK_MENU;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.FASTER_OUT_SLOWER_IN;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.clampToProgress;
import android.animation.ValueAnimator;
import android.content.Context;
@@ -201,16 +200,10 @@ public class FloatingTaskView extends FrameLayout {
RectF floatingTaskViewBounds = new RectF();
if (fadeWithThumbnail) {
// FloatingTaskThumbnailView: thumbnail fades out to transparent
animation.addFloat(mThumbnailView, LauncherAnimUtils.VIEW_ALPHA,
1, 0, clampToProgress(LINEAR, 0, 0.267f));
// SplitPlaceholderView: gray background fades in at the same time, then new icon fades
// in
animation.addFloat(mSplitPlaceholderView, SplitPlaceholderView.ALPHA_FLOAT,
0, 1, clampToProgress(LINEAR, 0, 0.267f));
animation.addFloat(mSplitPlaceholderView, SplitPlaceholderView.ICON_ALPHA,
0, 1, clampToProgress(LINEAR, 0.333f, 0.5f));
0, 1, ACCEL);
animation.addFloat(mThumbnailView, LauncherAnimUtils.VIEW_ALPHA,
1, 0, DEACCEL_3);
} else if (isStagedTask) {
// Fade in the placeholder view when split is initiated from homescreen / all apps
// icons.
@@ -221,15 +214,12 @@ public class FloatingTaskView extends FrameLayout {
}
MultiValueUpdateListener listener = new MultiValueUpdateListener() {
// SplitPlaceholderView: rectangle translates and stretches to new position
final FloatProp mDx = new FloatProp(0, prop.dX, 0, animDuration,
clampToProgress(FASTER_OUT_SLOWER_IN, 0, 0.833f));
final FloatProp mDy = new FloatProp(0, prop.dY, 0, animDuration,
clampToProgress(FASTER_OUT_SLOWER_IN, 0, 0.833f));
final FloatProp mDx = new FloatProp(0, prop.dX, 0, animDuration, LINEAR);
final FloatProp mDy = new FloatProp(0, prop.dY, 0, animDuration, LINEAR);
final FloatProp mTaskViewScaleX = new FloatProp(1f, prop.finalTaskViewScaleX, 0,
animDuration, clampToProgress(FASTER_OUT_SLOWER_IN, 0, 0.833f));
animDuration, LINEAR);
final FloatProp mTaskViewScaleY = new FloatProp(1f, prop.finalTaskViewScaleY, 0,
animDuration, clampToProgress(FASTER_OUT_SLOWER_IN, 0, 0.833f));
animDuration, LINEAR);
@Override
public void onUpdate(float percent, boolean initOnly) {
// Calculate the icon position.
@@ -35,7 +35,6 @@ import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_0_75;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.anim.Interpolators.EMPHASIZED_DECELERATE;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -114,7 +113,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.core.graphics.ColorUtils;
import androidx.dynamicanimation.animation.SpringForce;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.BaseActivity.MultiWindowModeChangedListener;
@@ -127,7 +125,6 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.SpringAnimationBuilder;
import com.android.launcher3.anim.SpringProperty;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
@@ -445,9 +442,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
private static final float ANIMATION_DISMISS_PROGRESS_MIDPOINT = 0.5f;
private static final float END_DISMISS_TRANSLATION_INTERPOLATION_OFFSET = 0.75f;
private static final float INITIAL_SPRING_DISMISS_TRANSLATION_INTERPOLATION_OFFSET = 0.133f;
private static final float ADDITIONAL_SPRING_DISMISS_TRANSLATION_INTERPOLATION_OFFSET = 0.033f;
private static final float SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE = 0.15f;
protected final RecentsOrientedState mOrientationState;
@@ -2838,20 +2832,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
RectF startingTaskRect = new RectF();
if (mSplitHiddenTaskView != null) {
// Split staging is initiated, hide the original TaskView except for the icon (which
// needs to animate out over time)
// If needed, visibility should be toggled back on in resetFromSplitSelectionState().
for (int i = 0; i < mSplitHiddenTaskView.getChildCount(); i++) {
View child = mSplitHiddenTaskView.getChildAt(i);
if (child != mSplitHiddenTaskView.mIconView) {
child.setVisibility(INVISIBLE);
}
}
// Icon animates out over time
anim.addFloat(mSplitHiddenTaskView, TaskView.ICON_ALPHA, 1, 0,
clampToProgress(LINEAR, 0, 0.167f));
mSplitHiddenTaskView.setVisibility(INVISIBLE);
mFirstFloatingTaskView = FloatingTaskView.getFloatingTaskView(mActivity,
mSplitHiddenTaskView.getThumbnail(),
mSplitHiddenTaskView.getThumbnail().getThumbnail(),
@@ -2868,15 +2849,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
false /* fadeWithThumbnail */, true /* isStagedTask */);
}
// SplitInstructionsView: animate in
mSplitInstructionsView = SplitInstructionsView.getSplitInstructionsView(mActivity);
mSplitInstructionsView.setAlpha(0);
anim.addFloat(mSplitInstructionsView, SplitInstructionsView.CONTAINER_ALPHA, 0, 1,
clampToProgress(LINEAR, 0, 0.167f));
anim.addFloat(mSplitInstructionsView, SplitInstructionsView.TEXT_ALPHA, 0, 1,
clampToProgress(LINEAR, 0.1f, 0.267f));
anim.addFloat(mSplitInstructionsView, mSplitInstructionsView.UNFOLD, 0.1f, 1,
clampToProgress(EMPHASIZED_DECELERATE, 0, 0.667f));
anim.addFloat(mSplitInstructionsView, SplitInstructionsView.ALPHA_FLOAT, 0, 1, ACCEL);
InteractionJankMonitorWrapper.begin(this,
InteractionJankMonitorWrapper.CUJ_SPLIT_SCREEN_ENTER, "First tile selected");
@@ -3156,22 +3131,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// Animate task with index >= dismissed index and in the same row as the
// dismissed index or next focused index. Offset successive task dismissal
// durations for a staggered effect.
distanceFromDismissedTask++;
// If user is initiating splitscreen from the focused (large) task, we use a
// spring-based animation and timings. For other, smaller, repositions, we currently
// fall back on a less complicated linear animation and timings.
float animationStartProgress = isFocusedTaskDismissed && nextFocusedTaskView == null
? Utilities.boundToRange(
INITIAL_SPRING_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
+ ADDITIONAL_SPRING_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
* (int) Math.ceil(distanceFromDismissedTask / 2f), 0f,
dismissTranslationInterpolationEnd)
: Utilities.boundToRange(
INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
+ ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
* distanceFromDismissedTask, 0f,
dismissTranslationInterpolationEnd);
float animationStartProgress = Utilities.boundToRange(
INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
+ ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
* ++distanceFromDismissedTask, 0f,
dismissTranslationInterpolationEnd);
if (taskView == nextFocusedTaskView) {
// Enlarge the task to be focused next, and translate into focus position.
float scale = mTaskWidth / (float) mLastComputedGridTaskSize.width();
@@ -3206,36 +3170,12 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
primaryTranslation +=
mIsRtl ? -mSplitPlaceholderSize : mSplitPlaceholderSize;
}
// Transitioning to split select -- set up staggered spring animation for
// other TaskViews.
Animator taskSlideIn = new SpringAnimationBuilder(taskView.mActivity)
.setDampingRatio(0.85f)
.setStiffness(SpringForce.STIFFNESS_LOW)
.setEndValue(mIsRtl ? primaryTranslation : -primaryTranslation)
.setStartValue(
taskView.getPrimaryDismissTranslationProperty()
.get(taskView)
)
.build(taskView, taskView.getPrimaryDismissTranslationProperty());
long taskSlideInDuration = taskSlideIn.getDuration();
anim.add(taskSlideIn);
taskSlideIn
.setDuration(taskSlideInDuration)
.setStartDelay(
Math.round(animationStartProgress * anim.getDuration()));
} else {
// Task was dismissed individually -- translate other TaskViews to fill the
// vacant space.
// TODO (b/242075836): This dismiss animation uses a linear transition.
// When the above bug is fixed, it can use the same (nicer) spring
// transition as the focused task split case above.
anim.setFloat(taskView, taskView.getPrimaryDismissTranslationProperty(),
mIsRtl ? primaryTranslation : -primaryTranslation,
clampToProgress(LINEAR, animationStartProgress,
dismissTranslationInterpolationEnd));
}
anim.setFloat(taskView, taskView.getPrimaryDismissTranslationProperty(),
mIsRtl ? primaryTranslation : -primaryTranslation,
clampToProgress(LINEAR, animationStartProgress,
dismissTranslationInterpolationEnd));
}
}
}
@@ -3256,8 +3196,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
final boolean finalCloseGapBetweenClearAll = closeGapBetweenClearAll;
final boolean finalSnapToLastTask = snapToLastTask;
final boolean finalIsFocusedTaskDismissed = isFocusedTaskDismissed;
Consumer endConsumer = new Consumer<Boolean>() {
mPendingAnimation.addEndListener(new Consumer<Boolean>() {
@Override
public void accept(Boolean success) {
if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile
@@ -3467,9 +3406,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
onDismissAnimationEnds();
mPendingAnimation = null;
}
};
mPendingAnimation.addListener(AnimatorListeners.forEndCallback(endConsumer));
});
return anim;
}
@@ -4290,6 +4227,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
resetTaskVisuals();
mSplitHiddenTaskViewIndex = -1;
if (mSplitHiddenTaskView != null) {
mSplitHiddenTaskView.setVisibility(VISIBLE);
mSplitHiddenTaskView = null;
}
}
@@ -25,7 +25,6 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
@@ -41,10 +40,9 @@ import com.android.launcher3.util.DisplayController;
*/
public class SplitInstructionsView extends FrameLayout {
private final StatefulActivity mLauncher;
private AppCompatTextView mTextView;
public static final FloatProperty<SplitInstructionsView> CONTAINER_ALPHA =
new FloatProperty<SplitInstructionsView>("SplitInstructionsContainerAlpha") {
public static final FloatProperty<SplitInstructionsView> ALPHA_FLOAT =
new FloatProperty<SplitInstructionsView>("SplitInstructionsAlpha") {
@Override
public void setValue(SplitInstructionsView splitInstructionsView, float v) {
splitInstructionsView.setVisibility(v != 0 ? VISIBLE : GONE);
@@ -57,32 +55,6 @@ public class SplitInstructionsView extends FrameLayout {
}
};
public static final FloatProperty<SplitInstructionsView> UNFOLD =
new FloatProperty<SplitInstructionsView>("SplitInstructionsUnfold") {
@Override
public void setValue(SplitInstructionsView splitInstructionsView, float v) {
splitInstructionsView.setScaleY(v);
}
@Override
public Float get(SplitInstructionsView splitInstructionsView) {
return splitInstructionsView.getScaleY();
}
};
public static final FloatProperty<SplitInstructionsView> TEXT_ALPHA =
new FloatProperty<SplitInstructionsView>("SplitInstructionsTextAlpha") {
@Override
public void setValue(SplitInstructionsView splitInstructionsView, float v) {
splitInstructionsView.mTextView.setAlpha(v);
}
@Override
public Float get(SplitInstructionsView splitInstructionsView) {
return splitInstructionsView.mTextView.getAlpha();
}
};
public SplitInstructionsView(Context context) {
this(context, null);
}
@@ -105,9 +77,6 @@ public class SplitInstructionsView extends FrameLayout {
false
);
splitInstructionsView.mTextView = splitInstructionsView.findViewById(
R.id.split_instructions_text);
dragLayer.addView(splitInstructionsView);
return splitInstructionsView;
}
@@ -47,19 +47,6 @@ public class SplitPlaceholderView extends FrameLayout {
}
};
public static final FloatProperty<SplitPlaceholderView> ICON_ALPHA =
new FloatProperty<SplitPlaceholderView>("SplitViewIconAlpha") {
@Override
public void setValue(SplitPlaceholderView splitPlaceholderView, float v) {
splitPlaceholderView.mIconView.setAlpha(v);
}
@Override
public Float get(SplitPlaceholderView splitPlaceholderView) {
return splitPlaceholderView.mIconView.getAlpha();
}
};
@Nullable
private IconView mIconView;
@@ -323,19 +323,6 @@ public class TaskView extends FrameLayout implements Reusable {
}
};
public static final FloatProperty<TaskView> ICON_ALPHA =
new FloatProperty<TaskView>("iconAlpha") {
@Override
public void setValue(TaskView taskView, float v) {
taskView.mIconView.setAlpha(v);
}
@Override
public Float get(TaskView taskView) {
return taskView.mIconView.getAlpha();
}
};
@Nullable
protected Task mTask;
protected TaskThumbnailView mSnapshotView;
@@ -50,8 +50,6 @@ public class Interpolators {
public static final Interpolator ACCEL_DEACCEL = new AccelerateDecelerateInterpolator();
public static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
public static final Interpolator FASTER_OUT_SLOWER_IN =
new PathInterpolator(0.3f, 0f, 0.1f, 1f);
public static final Interpolator AGGRESSIVE_EASE = new PathInterpolator(0.2f, 0f, 0f, 1f);
public static final Interpolator AGGRESSIVE_EASE_IN_OUT = new PathInterpolator(0.6f,0, 0.4f, 1);
@@ -169,6 +169,13 @@ public final class FeatureFlags {
"ENABLE_SMARTSPACE_DISMISS", true,
"Adds a menu option to dismiss the current Enhanced Smartspace card.");
/**
* Enables region sampling for text color: Needs system health assessment before turning on
*/
public static final BooleanFlag ENABLE_REGION_SAMPLING = getDebugFlag(
"ENABLE_REGION_SAMPLING", false,
"Enable region sampling to determine color of text on screen.");
public static final BooleanFlag ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS =
getDebugFlag(
"ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS", false,
@@ -297,6 +304,11 @@ public final class FeatureFlags {
"SECONDARY_DRAG_N_DROP_TO_PIN", false,
"Enable dragging and dropping to pin apps within secondary display");
// TODO(b/241843710): Deep Shortcut Icons can be rendered, but do not persist.
public static final BooleanFlag ENABLE_SECONDARY_DEEP_SHORTCUTS = getDebugFlag(
"ENABLE_SECONDARY_DEEP_SHORTCUTS", false,
"Enable deep shortcut pinning within secondary display");
public static void initialize(Context context) {
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2022 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.
*/
package com.android.launcher3.secondarydisplay;
import android.content.Context;
import android.os.Process;
import android.os.UserHandle;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.util.LabelComparator;
import java.util.Comparator;
/**
* A comparator to arrange items based on user profiles.
*/
final class ItemInfoComparator implements Comparator<ItemInfo> {
private final UserCache mUserManager;
private final UserHandle mMyUser;
private final LabelComparator mLabelComparator;
ItemInfoComparator(Context context) {
mUserManager = UserCache.INSTANCE.get(context);
mMyUser = Process.myUserHandle();
mLabelComparator = new LabelComparator();
}
@Override
public int compare(ItemInfo a, ItemInfo b) {
// Order by the title in the current locale.
int result = mLabelComparator.compare(
a.title == null ? "" : a.title.toString(),
b.title == null ? "" : b.title.toString());
if (result != 0) {
return result;
}
// If labels are same, compare target components.
result = a.getTargetComponent().compareTo(b.getTargetComponent());
if (result != 0) {
return result;
}
// Otherwise, order by user.
if (mMyUser.equals(a.user)) {
return -1;
} else {
Long aUserSerial = mUserManager.getSerialNumberForUser(a.user);
Long bUserSerial = mUserManager.getSerialNumberForUser(b.user);
return aUserSerial.compareTo(bUserSerial);
}
}
}
@@ -33,9 +33,10 @@ import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.allapps.AppInfoComparator;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.util.ComponentKey;
@@ -61,10 +62,10 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference
private final OnLongClickListener mOnLongClickListener;
private final SharedPreferences mPrefs;
private final AllAppsStore mAllAppsList;
private final AppInfoComparator mAppNameComparator;
private final ItemInfoComparator mItemInfoComparator;
private final Set<ComponentKey> mPinnedApps = new HashSet<>();
private final ArrayList<AppInfo> mItems = new ArrayList<>();
private final ArrayList<ItemInfo> mItems = new ArrayList<>();
public PinnedAppsAdapter(SecondaryDisplayLauncher launcher, AllAppsStore allAppsStore,
OnLongClickListener onLongClickListener) {
@@ -73,7 +74,7 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference
mOnLongClickListener = onLongClickListener;
mAllAppsList = allAppsStore;
mPrefs = launcher.getSharedPreferences(PINNED_APPS_KEY, MODE_PRIVATE);
mAppNameComparator = new AppInfoComparator(launcher);
mItemInfoComparator = new ItemInfoComparator(launcher);
mAllAppsList.addUpdateListener(this::createFilteredAppsList);
}
@@ -111,7 +112,7 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference
* {@inheritDoc}
*/
@Override
public AppInfo getItem(int position) {
public ItemInfo getItem(int position) {
return mItems.get(position);
}
@@ -141,7 +142,15 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference
icon.setPadding(padding, padding, padding, padding);
}
icon.applyFromApplicationInfo(mItems.get(position));
ItemInfo itemInfo = mItems.get(position);
if (itemInfo instanceof AppInfo) {
icon.applyFromApplicationInfo((AppInfo) itemInfo);
} else if (itemInfo instanceof WorkspaceItemInfo) {
icon.applyFromWorkspaceItem((WorkspaceItemInfo) itemInfo);
} else if (itemInfo instanceof ItemInfoWithIcon) {
icon.applyFromItemInfoWithIcon((ItemInfoWithIcon) itemInfo);
}
return icon;
}
@@ -149,7 +158,7 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference
mItems.clear();
mPinnedApps.stream().map(mAllAppsList::getApp)
.filter(Objects::nonNull).forEach(mItems::add);
mItems.sort(mAppNameComparator);
mItems.sort(mItemInfoComparator);
notifyDataSetChanged();
}
@@ -220,6 +229,14 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference
update(info, mPinnedApps::add);
}
/**
* Pins app to home screen
*/
public void addItem(ItemInfo item) {
mItems.add(item);
notifyDataSetChanged();
}
private class PinUnPinShortcut extends SystemShortcut<SecondaryDisplayLauncher> {
private final boolean mIsPinned;
@@ -36,7 +36,9 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.popup.PopupContainerWithArrow.PopupItemDragHandler;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.util.ShortcutUtil;
@@ -208,6 +210,28 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
(PopupContainerWithArrow) mActivity.getLayoutInflater().inflate(
R.layout.popup_container, mActivity.getDragLayer(), false);
container.setPopupItemDragHandler(new PopupItemDragHandler() {
@Override
public boolean onLongClick(View v) {
if (!(v.getTag() instanceof ItemInfoWithIcon)) {
return false;
}
if (FeatureFlags.ENABLE_SECONDARY_DEEP_SHORTCUTS.get()) {
((SecondaryDragLayer) mActivity.getDragLayer()).getPinnedAppsAdapter()
.addItem((ItemInfoWithIcon) v.getTag());
return true;
}
return false;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
container.populateAndShow((BubbleTextView) v,
popupDataProvider.getShortcutCountForItem(item),
Collections.emptyList(), systemShortcuts);
@@ -440,7 +440,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
public void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
int splitInstructionsWidth, int threeButtonNavShift) {
out.setPivotX(0);
out.setPivotY(splitInstructionsHeight);
out.setPivotY(0);
out.setRotation(getDegreesRotated());
int distanceToEdge = out.getResources().getDimensionPixelSize(
R.dimen.split_instructions_bottom_margin_phone_landscape);
@@ -448,8 +448,8 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
int insetCorrectionX = dp.getInsets().left;
// Center the view in case of unbalanced insets on top or bottom of screen
int insetCorrectionY = (dp.getInsets().bottom - dp.getInsets().top) / 2;
out.setTranslationX(distanceToEdge - insetCorrectionX);
out.setTranslationY(((-splitInstructionsHeight - splitInstructionsWidth) / 2f)
out.setTranslationX(splitInstructionsHeight + distanceToEdge - insetCorrectionX);
out.setTranslationY(((splitInstructionsHeight - splitInstructionsWidth) / 2f)
+ insetCorrectionY);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) out.getLayoutParams();
// Setting gravity to LEFT instead of the lint-recommended START because we always want this
@@ -500,7 +500,7 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
public void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
int splitInstructionsWidth, int threeButtonNavShift) {
out.setPivotX(0);
out.setPivotY(splitInstructionsHeight);
out.setPivotY(0);
out.setRotation(getDegreesRotated());
int distanceToEdge;
if ((DisplayController.getNavigationMode(out.getContext()) == THREE_BUTTONS)
@@ -190,7 +190,7 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
public void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
int splitInstructionsWidth, int threeButtonNavShift) {
out.setPivotX(0);
out.setPivotY(splitInstructionsHeight);
out.setPivotY(0);
out.setRotation(getDegreesRotated());
int distanceToEdge = out.getResources().getDimensionPixelSize(
R.dimen.split_instructions_bottom_margin_phone_landscape);
@@ -198,8 +198,9 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
int insetCorrectionX = dp.getInsets().right;
// Center the view in case of unbalanced insets on top or bottom of screen
int insetCorrectionY = (dp.getInsets().bottom - dp.getInsets().top) / 2;
out.setTranslationX(splitInstructionsWidth - distanceToEdge + insetCorrectionX);
out.setTranslationY(((-splitInstructionsHeight + splitInstructionsWidth) / 2f)
out.setTranslationX(splitInstructionsWidth - splitInstructionsHeight - distanceToEdge
+ insetCorrectionX);
out.setTranslationY(((splitInstructionsHeight + splitInstructionsWidth) / 2f)
+ insetCorrectionY);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) out.getLayoutParams();
// Setting gravity to RIGHT instead of the lint-recommended END because we always want this