Snap for 11386701 from d4b2c8a858 to 24Q2-release
Change-Id: I589f367aa4eb3eaf0cb7bf162268e4e4735fefc7
This commit is contained in:
commit
25704a9eae
32 files changed
+606
-73
No files matched your search
@@ -140,3 +140,10 @@ flag {
|
||||
description: "Tie unfold animation with state animation"
|
||||
bug: "297057373"
|
||||
}
|
||||
|
||||
flag {
|
||||
name: "enable_categorized_widget_suggestions"
|
||||
namespace: "launcher"
|
||||
description: "Enables widget suggestions in widget picker to be displayed in categories"
|
||||
bug: "318410881"
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BA
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME;
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH;
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS;
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_SPACE;
|
||||
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_KEYGUARD;
|
||||
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_SMALL_SCREEN;
|
||||
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
|
||||
@@ -79,6 +80,7 @@ import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Space;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -207,6 +209,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
this::onComputeInsetsForSeparateWindow;
|
||||
private final RecentsHitboxExtender mHitboxExtender = new RecentsHitboxExtender();
|
||||
private ImageView mRecentsButton;
|
||||
private Space mSpace;
|
||||
|
||||
public NavbarButtonsViewController(TaskbarActivityContext context,
|
||||
@Nullable Context navigationBarPanelContext, NearestTouchFrame navButtonsView) {
|
||||
@@ -432,6 +435,11 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
mPropertyHolders.add(new StatePropertyHolder(mA11yButton,
|
||||
flags -> (flags & FLAG_A11Y_VISIBLE) != 0
|
||||
&& (flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0));
|
||||
|
||||
mSpace = new Space(mNavButtonsView.getContext());
|
||||
mSpace.setOnClickListener(view -> navButtonController.onButtonClick(BUTTON_SPACE, view));
|
||||
mSpace.setOnLongClickListener(view ->
|
||||
navButtonController.onButtonLongClick(BUTTON_SPACE, view));
|
||||
}
|
||||
|
||||
private void parseSystemUiFlags(int sysUiStateFlags) {
|
||||
@@ -760,7 +768,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
NavButtonLayoutFactory.Companion.getUiLayoutter(
|
||||
dp, mNavButtonsView, mImeSwitcherButton,
|
||||
mControllers.rotationButtonController.getRotationButton(),
|
||||
mA11yButton, res, isInKidsMode, isInSetup, isThreeButtonNav,
|
||||
mA11yButton, mSpace, res, isInKidsMode, isInSetup, isThreeButtonNav,
|
||||
mContext.isPhoneMode(), mWindowManagerProxy.getRotation(mContext));
|
||||
navButtonLayoutter.layoutButtons(mContext, isA11yButtonPersistent());
|
||||
updateButtonsBackground();
|
||||
|
||||
@@ -102,6 +102,7 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
|
||||
static final int BUTTON_A11Y = BUTTON_IME_SWITCH << 1;
|
||||
static final int BUTTON_QUICK_SETTINGS = BUTTON_A11Y << 1;
|
||||
static final int BUTTON_NOTIFICATIONS = BUTTON_QUICK_SETTINGS << 1;
|
||||
static final int BUTTON_SPACE = BUTTON_NOTIFICATIONS << 1;
|
||||
|
||||
private static final int SCREEN_UNPIN_COMBO = BUTTON_BACK | BUTTON_RECENTS;
|
||||
private int mLongPressedButtons = 0;
|
||||
@@ -123,6 +124,9 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
|
||||
}
|
||||
|
||||
public void onButtonClick(@TaskbarButton int buttonType, View view) {
|
||||
if (buttonType == BUTTON_SPACE) {
|
||||
return;
|
||||
}
|
||||
// Provide the same haptic feedback that the system offers for virtual keys.
|
||||
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
switch (buttonType) {
|
||||
@@ -156,6 +160,9 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
|
||||
}
|
||||
|
||||
public boolean onButtonLongClick(@TaskbarButton int buttonType, View view) {
|
||||
if (buttonType == BUTTON_SPACE) {
|
||||
return false;
|
||||
}
|
||||
// Provide the same haptic feedback that the system offers for virtual keys.
|
||||
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
switch (buttonType) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
|
||||
@@ -46,7 +47,8 @@ abstract class AbstractNavButtonLayoutter(
|
||||
protected val startContextualContainer: ViewGroup,
|
||||
protected val imeSwitcher: ImageView?,
|
||||
protected val rotationButton: RotationButton?,
|
||||
protected val a11yButton: ImageView?
|
||||
protected val a11yButton: ImageView?,
|
||||
protected val space: Space
|
||||
) : NavButtonLayoutter {
|
||||
protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
|
||||
protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
|
||||
@@ -37,7 +38,8 @@ class KidsNavLayoutter(
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?
|
||||
a11yButton: ImageView?,
|
||||
space: Space,
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
@@ -46,7 +48,8 @@ class KidsNavLayoutter(
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
@@ -114,6 +117,7 @@ class KidsNavLayoutter(
|
||||
}
|
||||
if (a11yButton != null) {
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.DeviceProfile
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
|
||||
@@ -60,6 +61,7 @@ class NavButtonLayoutFactory {
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space,
|
||||
resources: Resources,
|
||||
isKidsMode: Boolean,
|
||||
isInSetup: Boolean,
|
||||
@@ -86,7 +88,8 @@ class NavButtonLayoutFactory {
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
} else if (surfaceRotation == ROTATION_90) {
|
||||
navButtonsView.setIsVertical(true)
|
||||
@@ -97,7 +100,8 @@ class NavButtonLayoutFactory {
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
} else {
|
||||
navButtonsView.setIsVertical(true)
|
||||
@@ -108,7 +112,8 @@ class NavButtonLayoutFactory {
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -120,7 +125,8 @@ class NavButtonLayoutFactory {
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
deviceProfile.isTaskbarPresent -> {
|
||||
@@ -133,7 +139,8 @@ class NavButtonLayoutFactory {
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
isKidsMode -> {
|
||||
@@ -144,7 +151,8 @@ class NavButtonLayoutFactory {
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
else ->
|
||||
@@ -155,7 +163,8 @@ class NavButtonLayoutFactory {
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.widget.FrameLayout;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -42,7 +43,10 @@ public class NearestTouchFrame extends FrameLayout {
|
||||
private final List<View> mClickableChildren = new ArrayList<>();
|
||||
private final List<View> mAttachedChildren = new ArrayList<>();
|
||||
private final boolean mIsActive;
|
||||
private final int[] mTmpInt = new int[2];
|
||||
|
||||
// Offset (as the base) to translate window cords to view cords.
|
||||
private final int[] mWindowOffset = new int[2];
|
||||
private boolean mIsVertical;
|
||||
private View mTouchingChild;
|
||||
private final Map<View, Rect> mTouchableRegions = new HashMap<>();
|
||||
@@ -52,8 +56,11 @@ public class NearestTouchFrame extends FrameLayout {
|
||||
*/
|
||||
private final Comparator<View> mChildRegionComparator =
|
||||
(view1, view2) -> {
|
||||
int startingCoordView1 = mIsVertical ? view1.getTop() : view1.getLeft();
|
||||
int startingCoordView2 = mIsVertical ? view2.getTop() : view2.getLeft();
|
||||
int leftTopIndex = mIsVertical ? 1 : 0;
|
||||
view1.getLocationInWindow(mTmpInt);
|
||||
int startingCoordView1 = mTmpInt[leftTopIndex] - mWindowOffset[leftTopIndex];
|
||||
view2.getLocationInWindow(mTmpInt);
|
||||
int startingCoordView2 = mTmpInt[leftTopIndex] - mWindowOffset[leftTopIndex];
|
||||
|
||||
return startingCoordView1 - startingCoordView2;
|
||||
};
|
||||
@@ -74,6 +81,7 @@ public class NearestTouchFrame extends FrameLayout {
|
||||
mAttachedChildren.clear();
|
||||
mTouchableRegions.clear();
|
||||
addClickableChildren(this);
|
||||
getLocationInWindow(mWindowOffset);
|
||||
cacheClosestChildLocations();
|
||||
}
|
||||
|
||||
@@ -147,8 +155,9 @@ public class NearestTouchFrame extends FrameLayout {
|
||||
}
|
||||
|
||||
private Rect getChildsBounds(View child) {
|
||||
int left = child.getLeft();
|
||||
int top = child.getTop();
|
||||
child.getLocationInWindow(mTmpInt);
|
||||
int left = mTmpInt[0] - mWindowOffset[0];
|
||||
int top = mTmpInt[1] - mWindowOffset[1];
|
||||
int right = left + child.getWidth();
|
||||
int bottom = top + child.getHeight();
|
||||
return new Rect(left, top, right, bottom);
|
||||
@@ -194,6 +203,7 @@ public class NearestTouchFrame extends FrameLayout {
|
||||
public void dumpLogs(String prefix, PrintWriter pw) {
|
||||
pw.println(prefix + "NearestTouchFrame:");
|
||||
|
||||
pw.println(String.format("%s\tmWindowOffset=%s", prefix, Arrays.toString(mWindowOffset)));
|
||||
pw.println(String.format("%s\tmIsVertical=%s", prefix, mIsVertical));
|
||||
pw.println(String.format("%s\tmTouchingChild=%s", prefix, mTouchingChild));
|
||||
pw.println(String.format("%s\tmTouchableRegions=%s", prefix,
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.res.Resources
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
@@ -31,7 +32,8 @@ class PhoneGestureLayoutter(
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?
|
||||
a11yButton: ImageView?,
|
||||
space: Space,
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
@@ -40,7 +42,8 @@ class PhoneGestureLayoutter(
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
|
||||
+11
-4
@@ -19,9 +19,11 @@ package com.android.launcher3.taskbar.navbutton
|
||||
import android.content.res.Resources
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
@@ -34,6 +36,7 @@ open class PhoneLandscapeNavLayoutter(
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space,
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
@@ -42,7 +45,8 @@ open class PhoneLandscapeNavLayoutter(
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
@@ -60,7 +64,7 @@ open class PhoneLandscapeNavLayoutter(
|
||||
val navButtonContainerHeight = contentWidth - contextualButtonHeight * 2
|
||||
|
||||
val navContainerParams = FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, navButtonContainerHeight.toInt())
|
||||
MATCH_PARENT, navButtonContainerHeight.toInt())
|
||||
navContainerParams.apply {
|
||||
topMargin =
|
||||
(contextualButtonHeight + contentPadding + roundedCornerContentMargin).toInt()
|
||||
@@ -125,6 +129,8 @@ open class PhoneLandscapeNavLayoutter(
|
||||
val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
|
||||
repositionContextualContainer(startContextualContainer, buttonSize,
|
||||
roundedCornerContentMargin + contentPadding, 0, Gravity.TOP)
|
||||
repositionContextualContainer(endContextualContainer, buttonSize,
|
||||
0, roundedCornerContentMargin + contentPadding, Gravity.BOTTOM)
|
||||
|
||||
if (imeSwitcher != null) {
|
||||
startContextualContainer.addView(imeSwitcher)
|
||||
@@ -132,18 +138,19 @@ open class PhoneLandscapeNavLayoutter(
|
||||
}
|
||||
if (a11yButton != null) {
|
||||
startContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
startContextualContainer.addView(rotationButton.currentView)
|
||||
rotationButton.currentView.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
endContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)
|
||||
}
|
||||
|
||||
override fun repositionContextualContainer(contextualContainer: ViewGroup, buttonSize: Int,
|
||||
barAxisMarginTop: Int, barAxisMarginBottom: Int,
|
||||
gravity: Int) {
|
||||
val contextualContainerParams = FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, buttonSize)
|
||||
val contextualContainerParams = FrameLayout.LayoutParams(MATCH_PARENT, buttonSize)
|
||||
contextualContainerParams.apply {
|
||||
marginStart = 0
|
||||
marginEnd = 0
|
||||
|
||||
@@ -19,9 +19,11 @@ package com.android.launcher3.taskbar.navbutton
|
||||
import android.content.res.Resources
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
@@ -34,6 +36,7 @@ class PhonePortraitNavLayoutter(
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?,
|
||||
space: Space
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
@@ -42,7 +45,8 @@ class PhonePortraitNavLayoutter(
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
@@ -110,15 +114,19 @@ class PhonePortraitNavLayoutter(
|
||||
endContextualContainer.removeAllViews()
|
||||
startContextualContainer.removeAllViews()
|
||||
|
||||
repositionContextualContainer(startContextualContainer, contextualButtonWidth.toInt(),
|
||||
roundedCornerContentMargin + contentPadding, 0, Gravity.START)
|
||||
repositionContextualContainer(endContextualContainer, contextualButtonWidth.toInt(), 0,
|
||||
roundedCornerContentMargin + contentPadding, Gravity.END)
|
||||
|
||||
startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)
|
||||
if (imeSwitcher != null) {
|
||||
endContextualContainer.addView(imeSwitcher)
|
||||
imeSwitcher.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (a11yButton != null) {
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
|
||||
@@ -19,8 +19,10 @@ package com.android.launcher3.taskbar.navbutton
|
||||
import android.content.res.Resources
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
|
||||
@@ -31,7 +33,8 @@ class PhoneSeascapeNavLayoutter(
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?
|
||||
a11yButton: ImageView?,
|
||||
space: Space,
|
||||
) :
|
||||
PhoneLandscapeNavLayoutter(
|
||||
resources,
|
||||
@@ -40,7 +43,8 @@ class PhoneSeascapeNavLayoutter(
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun addThreeButtons() {
|
||||
@@ -57,15 +61,19 @@ class PhoneSeascapeNavLayoutter(
|
||||
val roundedCornerContentMargin = resources.getDimensionPixelSize(
|
||||
R.dimen.taskbar_phone_rounded_corner_content_margin)
|
||||
val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
|
||||
repositionContextualContainer(startContextualContainer, buttonSize,
|
||||
roundedCornerContentMargin + contentPadding, 0, Gravity.TOP)
|
||||
repositionContextualContainer(endContextualContainer, buttonSize, 0,
|
||||
roundedCornerContentMargin + contentPadding, Gravity.BOTTOM)
|
||||
|
||||
startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)
|
||||
if (imeSwitcher != null) {
|
||||
endContextualContainer.addView(imeSwitcher)
|
||||
imeSwitcher.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (a11yButton != null) {
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
@@ -34,7 +35,8 @@ class SetupNavLayoutter(
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?
|
||||
a11yButton: ImageView?,
|
||||
space: Space,
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
@@ -43,7 +45,8 @@ class SetupNavLayoutter(
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
@@ -72,6 +75,7 @@ class SetupNavLayoutter(
|
||||
}
|
||||
if (a11yButton != null) {
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.systemui.shared.rotation.RotationButton
|
||||
@@ -37,7 +38,8 @@ class TaskbarNavLayoutter(
|
||||
startContextualContainer: ViewGroup,
|
||||
imeSwitcher: ImageView?,
|
||||
rotationButton: RotationButton?,
|
||||
a11yButton: ImageView?
|
||||
a11yButton: ImageView?,
|
||||
space: Space
|
||||
) :
|
||||
AbstractNavButtonLayoutter(
|
||||
resources,
|
||||
@@ -46,7 +48,8 @@ class TaskbarNavLayoutter(
|
||||
startContextualContainer,
|
||||
imeSwitcher,
|
||||
rotationButton,
|
||||
a11yButton
|
||||
a11yButton,
|
||||
space
|
||||
) {
|
||||
|
||||
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
|
||||
@@ -107,6 +110,7 @@ class TaskbarNavLayoutter(
|
||||
}
|
||||
if (a11yButton != null) {
|
||||
endContextualContainer.addView(a11yButton)
|
||||
a11yButton.layoutParams = getParamsToCenterView()
|
||||
}
|
||||
if (rotationButton != null) {
|
||||
endContextualContainer.addView(rotationButton.currentView)
|
||||
|
||||
@@ -43,6 +43,7 @@ import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
|
||||
import static com.android.launcher3.popup.SystemShortcut.DONT_SUGGEST_APP;
|
||||
import static com.android.launcher3.popup.SystemShortcut.INSTALL;
|
||||
import static com.android.launcher3.popup.SystemShortcut.PRIVATE_PROFILE_INSTALL;
|
||||
import static com.android.launcher3.popup.SystemShortcut.UNINSTALL_APP;
|
||||
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
|
||||
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.ALL_APPS_PAGE_PROGRESS_INDEX;
|
||||
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.MINUS_ONE_PAGE_PROGRESS_INDEX;
|
||||
@@ -437,6 +438,9 @@ public class QuickstepLauncher extends Launcher {
|
||||
if (Flags.enableShortcutDontSuggestApp()) {
|
||||
shortcuts.add(DONT_SUGGEST_APP);
|
||||
}
|
||||
if (Flags.enablePrivateSpace()) {
|
||||
shortcuts.add(UNINSTALL_APP);
|
||||
}
|
||||
return shortcuts.stream();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import android.window.IRemoteTransitionFinishedCallback
|
||||
import android.window.TransitionInfo
|
||||
import com.android.launcher3.anim.AnimatorListeners.forEndCallback
|
||||
import com.android.launcher3.util.Executors
|
||||
import com.android.wm.shell.util.TransitionUtil
|
||||
import com.android.wm.shell.shared.TransitionUtil
|
||||
|
||||
/** Remote animation which fades out the closing targets */
|
||||
class FadeOutRemoteTransition : IRemoteTransition.Stub() {
|
||||
@@ -84,6 +84,5 @@ class FadeOutRemoteTransition : IRemoteTransition.Stub() {
|
||||
Executors.MAIN_EXECUTOR.execute { anim.start() }
|
||||
}
|
||||
|
||||
override fun onTransitionConsumed(transition: IBinder?, aborted: Boolean) {
|
||||
}
|
||||
override fun onTransitionConsumed(transition: IBinder?, aborted: Boolean) {}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import android.window.IRemoteTransitionFinishedCallback
|
||||
import android.window.TransitionInfo
|
||||
import com.android.launcher3.anim.AnimatorListeners.forEndCallback
|
||||
import com.android.launcher3.util.Executors
|
||||
import com.android.wm.shell.util.TransitionUtil
|
||||
import com.android.wm.shell.shared.TransitionUtil
|
||||
|
||||
/** Remote animation which slides the opening targets in and the closing targets out */
|
||||
class SlideInRemoteTransition(
|
||||
|
||||
+4
-1
@@ -9,6 +9,7 @@ import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Space
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import com.android.launcher3.DeviceProfile
|
||||
import com.android.launcher3.R
|
||||
@@ -38,6 +39,7 @@ class NavButtonLayoutFactoryTest {
|
||||
private val mockImeSwitcher: ImageView = mock()
|
||||
private val mockRotationButton: RotationButton = mock()
|
||||
private val mockA11yButton: ImageView = mock()
|
||||
private val mockSpace: Space = mock()
|
||||
|
||||
private var surfaceRotation = Surface.ROTATION_0
|
||||
|
||||
@@ -201,7 +203,8 @@ class NavButtonLayoutFactoryTest {
|
||||
surfaceRotation = surfaceRotation,
|
||||
imeSwitcher = mockImeSwitcher,
|
||||
rotationButton = mockRotationButton,
|
||||
a11yButton = mockA11yButton
|
||||
a11yButton = mockA11yButton,
|
||||
space = mockSpace,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
android:height="48dp">
|
||||
<path
|
||||
android:pathData="M48 24A24 24 0 0 1 0 24A24 24 0 0 1 48 24Z"
|
||||
android:fillColor="?attr/materialColorSurfaceBright" />
|
||||
android:fillColor="?attr/materialColorOutlineVariant" />
|
||||
<path
|
||||
android:pathData="M24.0002 10.667L13.3335 14.667V22.787C13.3335 29.5203 17.8802 35.8003 24.0002 37.3337C30.1202 35.8003 34.6668 29.5203 34.6668 22.787V14.667L24.0002 10.667ZM32.0002 22.787C32.0002 28.1203 28.6002 33.0537 24.0002 34.5603C19.4002 33.0537 16.0002 28.1337 16.0002 22.787V16.5203L24.0002 13.5203L32.0002 16.5203V22.787ZM25.2402 23.6937L26.0002 28.0003H22.0002L22.7602 23.6937C21.9068 23.2537 21.3335 22.3603 21.3335 21.3337C21.3335 19.867 22.5335 18.667 24.0002 18.667C25.4668 18.667 26.6668 19.867 26.6668 21.3337C26.6668 22.3603 26.0935 23.2537 25.2402 23.6937Z"
|
||||
android:fillColor="?attr/materialColorOnSurface" />
|
||||
|
||||
@@ -194,6 +194,11 @@
|
||||
|
||||
<string-array name="filtered_components" ></string-array>
|
||||
|
||||
<!-- Widget component names to be included in weather category of widget suggestions. -->
|
||||
<string-array name="weather_recommendations"></string-array>
|
||||
<!-- Widget component names to be included in fitness category of widget suggestions. -->
|
||||
<string-array name="fitness_recommendations"></string-array>
|
||||
|
||||
<!-- Name of the class used to generate colors from the wallpaper colors. Must be implementing the LauncherAppWidgetHostView.ColorGenerator interface. -->
|
||||
<string name="color_generator_class" translatable="false"/>
|
||||
|
||||
@@ -252,6 +257,9 @@
|
||||
<!-- Used for custom widgets -->
|
||||
<array name="custom_widget_providers"/>
|
||||
|
||||
<!-- Used for determining category of a widget presented in widget recommendations. -->
|
||||
<string name="widget_recommendation_category_provider_class" translatable="false"></string>
|
||||
|
||||
<!-- Embed parameters -->
|
||||
<dimen name="activity_split_ratio" format="float">0.5</dimen>
|
||||
<integer name="min_width_split">720</integer>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<item type="id" name="ime_switcher" />
|
||||
<item type="id" name="accessibility_button" />
|
||||
<item type="id" name="rotate_suggestion" />
|
||||
<item type="id" name="space" />
|
||||
<!-- /Do not change, must be kept in sync with sysui navbar button IDs for tests! -->
|
||||
|
||||
<item type="id" name="quick_settings_button" />
|
||||
|
||||
@@ -71,6 +71,12 @@
|
||||
<!-- Widget suggestions header title in the full widgets picker for large screen devices
|
||||
in landscape mode. [CHAR_LIMIT=50] -->
|
||||
<string name="suggested_widgets_header_title">Suggestions</string>
|
||||
<string name="productivity_widget_recommendation_category_label">Boost your day</string>
|
||||
<string name="news_widget_recommendation_category_label">News For You</string>
|
||||
<string name="social_and_entertainment_widget_recommendation_category_label">Your Chill Zone</string>
|
||||
<string name="fitness_widget_recommendation_category_label">Reach Your Fitness Goals</string>
|
||||
<string name="weather_widget_recommendation_category_label">Stay Ahead of the Weather</string>
|
||||
<string name="others_widget_recommendation_category_label">You Might Also Like</string>
|
||||
<!-- Label for showing the number of widgets an app has in the full widgets picker.
|
||||
[CHAR_LIMIT=25][ICU SYNTAX] -->
|
||||
<string name="widgets_count">
|
||||
|
||||
@@ -89,6 +89,7 @@ public class LauncherAppState implements SafeCloseable {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
@SuppressWarnings("NewApi")
|
||||
public LauncherAppState(Context context) {
|
||||
this(context, LauncherFiles.APP_ICONS_DB);
|
||||
Log.v(Launcher.TAG, "LauncherAppState initiated");
|
||||
@@ -103,9 +104,14 @@ public class LauncherAppState implements SafeCloseable {
|
||||
});
|
||||
|
||||
ModelLauncherCallbacks callbacks = mModel.newModelCallbacks();
|
||||
mContext.getSystemService(LauncherApps.class).registerCallback(callbacks);
|
||||
LauncherApps launcherApps = mContext.getSystemService(LauncherApps.class);
|
||||
launcherApps.registerCallback(callbacks);
|
||||
mOnTerminateCallback.add(() ->
|
||||
mContext.getSystemService(LauncherApps.class).unregisterCallback(callbacks));
|
||||
if (Flags.enableSupportForArchiving()) {
|
||||
launcherApps.setArchiveCompatibilityOptions(/* enableIconOverlay= */ true,
|
||||
/* enableUnarchivalConfirmation= */ false);
|
||||
}
|
||||
|
||||
SimpleBroadcastReceiver modelChangeReceiver =
|
||||
new SimpleBroadcastReceiver(mModel::onBroadcastIntent);
|
||||
|
||||
@@ -34,6 +34,8 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
@@ -43,6 +45,7 @@ import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
|
||||
@@ -176,6 +179,10 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
if (uninstallDisabled) {
|
||||
return INVALID;
|
||||
}
|
||||
if (Flags.enablePrivateSpace() && UserCache.getInstance(getContext()).getUserInfo(
|
||||
info.user).isPrivate()) {
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
if (info instanceof ItemInfoWithIcon) {
|
||||
ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
|
||||
@@ -184,7 +191,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
return INVALID;
|
||||
}
|
||||
}
|
||||
if (getUninstallTarget(info) == null) {
|
||||
if (getUninstallTarget(getContext(), info) == null) {
|
||||
return INVALID;
|
||||
}
|
||||
return UNINSTALL;
|
||||
@@ -193,7 +200,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
/**
|
||||
* @return the component name that should be uninstalled or null.
|
||||
*/
|
||||
private ComponentName getUninstallTarget(ItemInfo item) {
|
||||
public static ComponentName getUninstallTarget(Context context, ItemInfo item) {
|
||||
Intent intent = null;
|
||||
UserHandle user = null;
|
||||
if (item != null &&
|
||||
@@ -202,7 +209,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
user = item.user;
|
||||
}
|
||||
if (intent != null) {
|
||||
LauncherActivityInfo info = getContext().getSystemService(LauncherApps.class)
|
||||
LauncherActivityInfo info = context.getSystemService(LauncherApps.class)
|
||||
.resolveActivity(intent, user);
|
||||
if (info != null
|
||||
&& (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
@@ -280,32 +287,41 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
if (FeatureFlags.ENABLE_DISMISS_PREDICTION_UNDO.get()) {
|
||||
CharSequence announcement = getContext().getString(R.string.item_removed);
|
||||
mDropTargetHandler
|
||||
.dismissPrediction(announcement, () -> {}, () -> {
|
||||
mStatsLogManager.logger()
|
||||
.withInstanceId(instanceId)
|
||||
.withItemInfo(info)
|
||||
.log(LAUNCHER_DISMISS_PREDICTION_UNDO);
|
||||
});
|
||||
.dismissPrediction(announcement, () -> {
|
||||
}, () -> {
|
||||
mStatsLogManager.logger()
|
||||
.withInstanceId(instanceId)
|
||||
.withItemInfo(info)
|
||||
.log(LAUNCHER_DISMISS_PREDICTION_UNDO);
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
ComponentName cn = getUninstallTarget(info);
|
||||
return performUninstall(getContext(), getUninstallTarget(getContext(), info), info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs uninstall and returns the target component for the {@link ItemInfo} or null if
|
||||
* the uninstall was not performed.
|
||||
*/
|
||||
public static ComponentName performUninstall(Context context, @Nullable ComponentName cn,
|
||||
ItemInfo info) {
|
||||
if (cn == null) {
|
||||
// System applications cannot be installed. For now, show a toast explaining that.
|
||||
// We may give them the option of disabling apps this way.
|
||||
Toast.makeText(
|
||||
getContext(),
|
||||
context,
|
||||
R.string.uninstall_system_app_text,
|
||||
Toast.LENGTH_SHORT
|
||||
).show();
|
||||
).show();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Intent i = Intent.parseUri(getContext().getString(R.string.delete_package_intent), 0)
|
||||
Intent i = Intent.parseUri(context.getString(R.string.delete_package_intent), 0)
|
||||
.setData(Uri.fromParts("package", cn.getPackageName(), cn.getClassName()))
|
||||
.putExtra(Intent.EXTRA_USER, info.user);
|
||||
getContext().startActivity(i);
|
||||
context.startActivity(i);
|
||||
FileLog.d(TAG, "start uninstall activity " + cn.getPackageName());
|
||||
return cn;
|
||||
} catch (URISyntaxException e) {
|
||||
|
||||
@@ -112,7 +112,6 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
appIcon2?.setBounds(0, 0, memberIconSize.toInt(), memberIconSize.toInt())
|
||||
}
|
||||
|
||||
|
||||
/** Gets this icon graphic's bounds, with respect to the parent icon's coordinate system. */
|
||||
fun getIconBounds(outBounds: Rect) {
|
||||
outBounds.set(0, 0, backgroundSize.toInt(), backgroundSize.toInt())
|
||||
@@ -138,15 +137,8 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
// Draw background
|
||||
appPairBackground.draw(canvas)
|
||||
|
||||
// Make sure icons are loaded
|
||||
if (
|
||||
appIcon1 == null ||
|
||||
appIcon2 == null ||
|
||||
appIcon1 is PlaceHolderIconDrawable ||
|
||||
appIcon2 is PlaceHolderIconDrawable
|
||||
) {
|
||||
applyIcons(parentIcon.info.contents)
|
||||
}
|
||||
// Make sure icons are loaded and fresh
|
||||
applyIcons(parentIcon.info.contents)
|
||||
|
||||
// Draw first icon
|
||||
canvas.save()
|
||||
|
||||
@@ -717,7 +717,10 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
LAUNCHER_PRIVATE_SPACE_INSTALL_APP_BUTTON_TAP(1605),
|
||||
|
||||
@UiEvent(doc = "User attempted to create split screen with a widget")
|
||||
LAUNCHER_SPLIT_WIDGET_ATTEMPT(1604)
|
||||
LAUNCHER_SPLIT_WIDGET_ATTEMPT(1604),
|
||||
|
||||
@UiEvent(doc = "User tapped on private space uninstall system shortcut.")
|
||||
LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP(1608),
|
||||
|
||||
// ADD MORE
|
||||
;
|
||||
|
||||
@@ -330,12 +330,15 @@ public class AllAppsList {
|
||||
PackageManagerHelper.getLoadingProgress(info),
|
||||
PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
|
||||
applicationInfo.intent = launchIntent;
|
||||
if (enableSupportForArchiving() && info.getActivityInfo().isArchived) {
|
||||
if (enableSupportForArchiving()) {
|
||||
// In case an app is archived, the respective item flag corresponding to
|
||||
// archiving should also be applied during package updates
|
||||
applicationInfo.runtimeStatusFlags |= FLAG_ARCHIVED;
|
||||
if (info.getActivityInfo().isArchived) {
|
||||
applicationInfo.runtimeStatusFlags |= FLAG_ARCHIVED;
|
||||
} else {
|
||||
applicationInfo.runtimeStatusFlags &= (~FLAG_ARCHIVED);
|
||||
}
|
||||
}
|
||||
|
||||
mDataChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,4 +371,13 @@ public class FolderInfo extends ItemInfo {
|
||||
}
|
||||
return LauncherAtom.ToState.TO_STATE_UNSPECIFIED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
if (itemType == LauncherSettings.Favorites.ITEM_TYPE_APP_PAIR) {
|
||||
return contents.stream().anyMatch((WorkspaceItemInfo::isDisabled));
|
||||
}
|
||||
|
||||
return super.isDisabled();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.android.launcher3.popup;
|
||||
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_INSTALL_SYSTEM_SHORTCUT_TAP;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_WIDGETS_TAP;
|
||||
@@ -17,17 +18,21 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.Flags;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.SecondaryDropTarget;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.PrivateProfileManager;
|
||||
import com.android.launcher3.model.WidgetItem;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.uioverrides.ApiWrapper;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.InstantAppResolver;
|
||||
@@ -301,16 +306,11 @@ public abstract class SystemShortcut<T extends Context & ActivityContext> extend
|
||||
}
|
||||
}
|
||||
|
||||
public static final Factory<Launcher> DONT_SUGGEST_APP = new Factory<Launcher>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public SystemShortcut<Launcher> getShortcut(Launcher activity, ItemInfo itemInfo,
|
||||
View originalView) {
|
||||
if (!itemInfo.isPredictedItem()) {
|
||||
return null;
|
||||
}
|
||||
return new DontSuggestApp(activity, itemInfo, originalView);
|
||||
public static final Factory<Launcher> DONT_SUGGEST_APP = (activity, itemInfo, originalView) -> {
|
||||
if (!itemInfo.isPredictedItem()) {
|
||||
return null;
|
||||
}
|
||||
return new DontSuggestApp(activity, itemInfo, originalView);
|
||||
};
|
||||
|
||||
private static class DontSuggestApp extends SystemShortcut<Launcher> {
|
||||
@@ -329,6 +329,51 @@ public abstract class SystemShortcut<T extends Context & ActivityContext> extend
|
||||
}
|
||||
}
|
||||
|
||||
public static final Factory<Launcher> UNINSTALL_APP = (activity, itemInfo, originalView) -> {
|
||||
if (!Flags.enablePrivateSpace()) {
|
||||
return null;
|
||||
}
|
||||
if (!UserCache.getInstance(activity.getApplicationContext()).getUserInfo(
|
||||
itemInfo.user).isPrivate()) {
|
||||
// If app is not Private Space app.
|
||||
return null;
|
||||
}
|
||||
ComponentName cn = SecondaryDropTarget.getUninstallTarget(activity.getApplicationContext(),
|
||||
itemInfo);
|
||||
if (cn == null) {
|
||||
// If component name is null, don't show uninstall shortcut.
|
||||
// System apps will have component name as null.
|
||||
return null;
|
||||
}
|
||||
return new UninstallApp(activity, itemInfo, originalView, cn);
|
||||
};
|
||||
|
||||
private static class UninstallApp extends SystemShortcut<Launcher> {
|
||||
private static final String TAG = "UninstallApp";
|
||||
Context mContext;
|
||||
@NonNull
|
||||
ComponentName mComponentName;
|
||||
|
||||
UninstallApp(Launcher target, ItemInfo itemInfo, View originalView,
|
||||
@NonNull ComponentName cn) {
|
||||
super(R.drawable.ic_uninstall_no_shadow, R.string.uninstall_drop_target_label, target,
|
||||
itemInfo, originalView);
|
||||
mContext = target.getApplicationContext();
|
||||
mComponentName = cn;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismissTaskMenuView(mTarget);
|
||||
SecondaryDropTarget.performUninstall(mContext, mComponentName, mItemInfo);
|
||||
mTarget.getStatsLogManager()
|
||||
.logger()
|
||||
.withItemInfo(mItemInfo)
|
||||
.log(LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends Context & ActivityContext> void dismissTaskMenuView(T activity) {
|
||||
AbstractFloatingView.closeOpenViews(activity, true,
|
||||
AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);
|
||||
|
||||
@@ -149,7 +149,20 @@ public class ItemClickHandler {
|
||||
private static void onClickAppPairIcon(View v) {
|
||||
Launcher launcher = Launcher.getLauncher(v.getContext());
|
||||
AppPairIcon appPairIcon = (AppPairIcon) v;
|
||||
launcher.launchAppPair(appPairIcon);
|
||||
if (appPairIcon.getInfo().isDisabled()) {
|
||||
WorkspaceItemInfo app1 = appPairIcon.getInfo().contents.get(0);
|
||||
WorkspaceItemInfo app2 = appPairIcon.getInfo().contents.get(1);
|
||||
// Show the user why the app pair is disabled.
|
||||
if (app1.isDisabled() && !handleDisabledItemClicked(app1, launcher)) {
|
||||
// If handleDisabledItemClicked() did not handle the error message, we initiate an
|
||||
// app launch so Framework can tell the user why the app is suspended.
|
||||
onClickAppShortcut(v, app1, launcher);
|
||||
} else if (app2.isDisabled() && !handleDisabledItemClicked(app2, launcher)) {
|
||||
onClickAppShortcut(v, app2, launcher);
|
||||
}
|
||||
} else {
|
||||
launcher.launchAppPair(appPairIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.widget.picker;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A category of widget recommendations displayed in the widget picker (launched from "Widgets"
|
||||
* option in the pop-up opened on long press of launcher workspace).
|
||||
*/
|
||||
public class WidgetRecommendationCategory implements Comparable<WidgetRecommendationCategory> {
|
||||
/** Resource id that holds the user friendly label for the category. */
|
||||
@StringRes
|
||||
public final int categoryTitleRes;
|
||||
/**
|
||||
* Relative order of this category with respect to other categories.
|
||||
*
|
||||
* <p>Category with lowest order is displayed first in the recommendations section.</p>
|
||||
*/
|
||||
public final int order;
|
||||
|
||||
public WidgetRecommendationCategory(@StringRes int categoryTitleRes, int order) {
|
||||
this.categoryTitleRes = categoryTitleRes;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(categoryTitleRes, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof WidgetRecommendationCategory category)) {
|
||||
return false;
|
||||
}
|
||||
return categoryTitleRes == category.categoryTitleRes
|
||||
&& order == category.order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(WidgetRecommendationCategory widgetRecommendationCategory) {
|
||||
return order - widgetRecommendationCategory.order;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.widget.picker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.model.WidgetItem;
|
||||
import com.android.launcher3.util.Preconditions;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
|
||||
/**
|
||||
* A {@link ResourceBasedOverride} that categorizes widget recommendations.
|
||||
*
|
||||
* <p>Override the {@code widget_recommendation_category_provider_class} resource to provide your
|
||||
* own implementation. Method {@code getWidgetRecommendationCategory} is called per widget to get
|
||||
* the category.</p>
|
||||
*/
|
||||
public class WidgetRecommendationCategoryProvider implements ResourceBasedOverride {
|
||||
private static final String TAG = "WidgetRecommendationCategoryProvider";
|
||||
|
||||
/**
|
||||
* Retrieve instance of this object that can be overridden in runtime based on the build
|
||||
* variant of the application.
|
||||
*/
|
||||
public static WidgetRecommendationCategoryProvider newInstance(Context context) {
|
||||
Preconditions.assertWorkerThread();
|
||||
return Overrides.getObject(
|
||||
WidgetRecommendationCategoryProvider.class, context.getApplicationContext(),
|
||||
R.string.widget_recommendation_category_provider_class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link WidgetRecommendationCategory} for the provided widget item that can be used
|
||||
* to display the recommendation grouped by categories.
|
||||
*/
|
||||
@WorkerThread
|
||||
public WidgetRecommendationCategory getWidgetRecommendationCategory(Context context,
|
||||
WidgetItem item) {
|
||||
// This is a default implementation that uses application category to derive the category to
|
||||
// be displayed. The implementation can be overridden in individual launcher customization
|
||||
// via the overridden WidgetRecommendationCategoryProvider resource.
|
||||
|
||||
Preconditions.assertWorkerThread();
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (item.widgetInfo != null && item.widgetInfo.getComponent() != null) {
|
||||
String widgetComponentName = item.widgetInfo.getComponent().getClassName();
|
||||
try {
|
||||
int predictionCategory = pm.getApplicationInfo(
|
||||
item.widgetInfo.getComponent().getPackageName(), 0 /* flags */).category;
|
||||
return getCategoryFromApplicationCategory(context, predictionCategory,
|
||||
widgetComponentName);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Failed to retrieve application category when determining the "
|
||||
+ "widget category for " + widgetComponentName, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Maps application category to an appropriate displayable category. */
|
||||
private static WidgetRecommendationCategory getCategoryFromApplicationCategory(
|
||||
Context context, int applicationCategory, String componentName) {
|
||||
if (applicationCategory == ApplicationInfo.CATEGORY_PRODUCTIVITY) {
|
||||
return new WidgetRecommendationCategory(
|
||||
R.string.productivity_widget_recommendation_category_label, /*order=*/0);
|
||||
}
|
||||
|
||||
if (applicationCategory == ApplicationInfo.CATEGORY_NEWS) {
|
||||
return new WidgetRecommendationCategory(
|
||||
R.string.news_widget_recommendation_category_label, /*order=*/1);
|
||||
}
|
||||
|
||||
if (applicationCategory == ApplicationInfo.CATEGORY_SOCIAL
|
||||
|| applicationCategory == ApplicationInfo.CATEGORY_AUDIO
|
||||
|| applicationCategory == ApplicationInfo.CATEGORY_VIDEO
|
||||
|| applicationCategory == ApplicationInfo.CATEGORY_IMAGE) {
|
||||
return new WidgetRecommendationCategory(
|
||||
R.string.social_and_entertainment_widget_recommendation_category_label,
|
||||
/*order=*/4);
|
||||
}
|
||||
|
||||
// Fitness & weather categories don't map to a specific application category, so, we
|
||||
// maintain an allowlist.
|
||||
String[] weatherRecommendationAllowlist =
|
||||
context.getResources().getStringArray(R.array.weather_recommendations);
|
||||
for (String allowedWeatherComponentName : weatherRecommendationAllowlist) {
|
||||
if (componentName.equalsIgnoreCase(allowedWeatherComponentName)) {
|
||||
return new WidgetRecommendationCategory(
|
||||
R.string.weather_widget_recommendation_category_label, /*order=*/2);
|
||||
}
|
||||
}
|
||||
|
||||
String[] fitnessRecommendationAllowlist =
|
||||
context.getResources().getStringArray(R.array.fitness_recommendations);
|
||||
for (String allowedFitnessComponentName : fitnessRecommendationAllowlist) {
|
||||
if (componentName.equalsIgnoreCase(allowedFitnessComponentName)) {
|
||||
return new WidgetRecommendationCategory(
|
||||
R.string.fitness_widget_recommendation_category_label, /*order=*/3);
|
||||
}
|
||||
}
|
||||
|
||||
return new WidgetRecommendationCategory(
|
||||
R.string.others_widget_recommendation_category_label, /*order=*/5);
|
||||
}
|
||||
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.widget.picker;
|
||||
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_AUDIO;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_IMAGE;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_NEWS;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_PRODUCTIVITY;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_SOCIAL;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_UNDEFINED;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_VIDEO;
|
||||
|
||||
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Process;
|
||||
|
||||
import androidx.test.core.content.pm.ApplicationInfoBuilder;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.model.WidgetItem;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class WidgetRecommendationCategoryProviderTest {
|
||||
private static final String TEST_PACKAGE = "com.foo.test";
|
||||
private static final String TEST_APP_NAME = "foo";
|
||||
public static final WidgetRecommendationCategory SOCIAL_AND_ENTERTAINMENT_CATEGORY =
|
||||
new WidgetRecommendationCategory(
|
||||
R.string.social_and_entertainment_widget_recommendation_category_label,
|
||||
/*order=*/4);
|
||||
private final ApplicationInfo mTestAppInfo = ApplicationInfoBuilder.newBuilder().setPackageName(
|
||||
TEST_PACKAGE).setName(TEST_APP_NAME).build();
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private IconCache mIconCache;
|
||||
|
||||
private WidgetItem mTestWidgetItem;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
private InvariantDeviceProfile mTestProfile;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = new ContextWrapper(getInstrumentation().getTargetContext()) {
|
||||
@Override
|
||||
public PackageManager getPackageManager() {
|
||||
return mPackageManager;
|
||||
}
|
||||
};
|
||||
mTestProfile = new InvariantDeviceProfile();
|
||||
mTestProfile.numRows = 5;
|
||||
mTestProfile.numColumns = 5;
|
||||
createTestWidgetItem();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWidgetRecommendationCategory_returnsMappedCategory() throws Exception {
|
||||
ImmutableMap<Integer, WidgetRecommendationCategory> testCategories = ImmutableMap.of(
|
||||
CATEGORY_PRODUCTIVITY, new WidgetRecommendationCategory(
|
||||
R.string.productivity_widget_recommendation_category_label,
|
||||
/*order=*/
|
||||
0),
|
||||
CATEGORY_NEWS, new WidgetRecommendationCategory(
|
||||
R.string.news_widget_recommendation_category_label, /*order=*/1),
|
||||
CATEGORY_SOCIAL, SOCIAL_AND_ENTERTAINMENT_CATEGORY,
|
||||
CATEGORY_AUDIO, SOCIAL_AND_ENTERTAINMENT_CATEGORY,
|
||||
CATEGORY_IMAGE, SOCIAL_AND_ENTERTAINMENT_CATEGORY,
|
||||
CATEGORY_VIDEO, SOCIAL_AND_ENTERTAINMENT_CATEGORY,
|
||||
CATEGORY_UNDEFINED, new WidgetRecommendationCategory(
|
||||
R.string.others_widget_recommendation_category_label, /*order=*/5));
|
||||
|
||||
for (Map.Entry<Integer, WidgetRecommendationCategory> testCategory :
|
||||
testCategories.entrySet()) {
|
||||
|
||||
mTestAppInfo.category = testCategory.getKey();
|
||||
when(mPackageManager.getApplicationInfo(anyString(), anyInt())).thenReturn(
|
||||
mTestAppInfo);
|
||||
|
||||
WidgetRecommendationCategory category = Executors.MODEL_EXECUTOR.submit(() ->
|
||||
new WidgetRecommendationCategoryProvider().getWidgetRecommendationCategory(
|
||||
mContext,
|
||||
mTestWidgetItem)).get();
|
||||
|
||||
assertThat(category).isEqualTo(testCategory.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void createTestWidgetItem() {
|
||||
String widgetLabel = "Foo Widget";
|
||||
String widgetClassName = ".mWidget";
|
||||
|
||||
doAnswer(invocation -> widgetLabel).when(mIconCache).getTitleNoCache(any());
|
||||
|
||||
AppWidgetProviderInfo providerInfo = AppWidgetManager.getInstance(getApplicationContext())
|
||||
.getInstalledProvidersForPackage(
|
||||
getInstrumentation().getContext().getPackageName(), Process.myUserHandle())
|
||||
.get(0);
|
||||
providerInfo.provider = ComponentName.createRelative(TEST_PACKAGE, widgetClassName);
|
||||
|
||||
LauncherAppWidgetProviderInfo launcherAppWidgetProviderInfo =
|
||||
LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, providerInfo);
|
||||
launcherAppWidgetProviderInfo.spanX = 2;
|
||||
launcherAppWidgetProviderInfo.spanY = 2;
|
||||
launcherAppWidgetProviderInfo.label = widgetLabel;
|
||||
mTestWidgetItem = new WidgetItem(launcherAppWidgetProviderInfo, mTestProfile, mIconCache,
|
||||
mContext
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user