Snap for 6191568 from 5a0ee40cf4 to rvc-release
Change-Id: I0a43b06bb17f1b332f5d645e6cab0c9d07d49906
This commit is contained in:
commit
cfc4832e42
169 files changed
+3982
-1345
No files matched your search
+3
-6
@@ -78,9 +78,8 @@ include $(CLEAR_VARS)
|
||||
LOCAL_USE_AAPT2 := true
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||
Launcher3CommonDepsLib \
|
||||
SecondaryDisplayLauncherLib
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3CommonDepsLib
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(call all-java-files-under, src) \
|
||||
$(call all-java-files-under, src_shortcuts_overrides) \
|
||||
@@ -154,9 +153,7 @@ else
|
||||
endif
|
||||
LOCAL_MODULE := Launcher3QuickStepLib
|
||||
LOCAL_PRIVILEGED_MODULE := true
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||
Launcher3CommonDepsLib \
|
||||
SecondaryDisplayLauncherLib
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3CommonDepsLib
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(call all-java-files-under, src) \
|
||||
|
||||
@@ -184,5 +184,20 @@
|
||||
android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:exported="true"
|
||||
android:enabled="false" />
|
||||
|
||||
<!--
|
||||
Launcher activity for secondary display
|
||||
-->
|
||||
<activity
|
||||
android:name="com.android.launcher3.secondarydisplay.SecondaryDisplayLauncher"
|
||||
android:theme="@style/AppTheme"
|
||||
android:launchMode="singleTop"
|
||||
android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.SECONDARY_HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -17,9 +17,13 @@ package com.android.launcher3.icons;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Picture;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
|
||||
/**
|
||||
* Interface representing a bitmap draw operation.
|
||||
@@ -29,6 +33,7 @@ public interface BitmapRenderer {
|
||||
boolean USE_HARDWARE_BITMAP = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;
|
||||
|
||||
static Bitmap createSoftwareBitmap(int width, int height, BitmapRenderer renderer) {
|
||||
GraphicsUtils.noteNewBitmapCreated();
|
||||
Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
renderer.draw(new Canvas(result));
|
||||
return result;
|
||||
@@ -40,11 +45,26 @@ public interface BitmapRenderer {
|
||||
return createSoftwareBitmap(width, height, renderer);
|
||||
}
|
||||
|
||||
GraphicsUtils.noteNewBitmapCreated();
|
||||
Picture picture = new Picture();
|
||||
renderer.draw(picture.beginRecording(width, height));
|
||||
picture.endRecording();
|
||||
return Bitmap.createBitmap(picture);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bitmap from subset of the source bitmap. The new bitmap may be the
|
||||
* same object as source, or a copy may have been made.
|
||||
*/
|
||||
static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height) {
|
||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.O && source.getConfig() == Config.HARDWARE) {
|
||||
return createHardwareBitmap(width, height, c -> c.drawBitmap(source,
|
||||
new Rect(x, y, x + width, y + height), new RectF(0, 0, width, height), null));
|
||||
} else {
|
||||
GraphicsUtils.noteNewBitmapCreated();
|
||||
return Bitmap.createBitmap(source, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void draw(Canvas out);
|
||||
}
|
||||
@@ -21,15 +21,17 @@ import android.graphics.Region;
|
||||
import android.graphics.RegionIterator;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
public class GraphicsUtils {
|
||||
|
||||
private static final String TAG = "GraphicsUtils";
|
||||
|
||||
public static Runnable sOnNewBitmapRunnable = () -> { };
|
||||
|
||||
/**
|
||||
* Set the alpha component of {@code color} to be {@code alpha}. Unlike the support lib version,
|
||||
* it bounds the alpha in valid range instead of throwing an exception to allow for safer
|
||||
@@ -73,4 +75,11 @@ public class GraphicsUtils {
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to track new bitmap creation
|
||||
*/
|
||||
public static void noteNewBitmapCreated() {
|
||||
sOnNewBitmapRunnable.run();
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ package com.android.launcher3.icons;
|
||||
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.BlurMaskFilter;
|
||||
import android.graphics.BlurMaskFilter.Blur;
|
||||
import android.graphics.Canvas;
|
||||
@@ -135,9 +134,7 @@ public class ShadowGenerator {
|
||||
bounds.offsetTo(center - width / 2f, center - height / 2f);
|
||||
|
||||
int size = center * 2;
|
||||
Bitmap result = Bitmap.createBitmap(size, size, Config.ARGB_8888);
|
||||
drawShadow(new Canvas(result));
|
||||
return result;
|
||||
return BitmapRenderer.createHardwareBitmap(size, size, this::drawShadow);
|
||||
}
|
||||
|
||||
public void drawShadow(Canvas c) {
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
-->
|
||||
<vector android:height="24dp" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/hotseat_edu_background" android:pathData="M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z"/>
|
||||
<path android:fillColor="@color/bottom_panel_background" android:pathData="M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z"/>
|
||||
</vector>
|
||||
@@ -24,21 +24,22 @@
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/hotseat_prediction_edu_top" />
|
||||
android:backgroundTint="@color/bottom_panel_background"
|
||||
android:background="@drawable/bottom_sheet_top_border" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/hotseat_edu_background"
|
||||
android:background="@color/bottom_panel_background"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/TextHeadline"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:fontFamily="google-sans"
|
||||
android:paddingLeft="@dimen/hotseat_edu_padding"
|
||||
android:paddingRight="@dimen/hotseat_edu_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_edu_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_edu_padding"
|
||||
android:text="@string/hotseat_migrate_title"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@android:color/white"
|
||||
@@ -50,8 +51,8 @@
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginBottom="18dp"
|
||||
android:fontFamily="roboto-medium"
|
||||
android:paddingLeft="@dimen/hotseat_edu_padding"
|
||||
android:paddingRight="@dimen/hotseat_edu_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_edu_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_edu_padding"
|
||||
android:text="@string/hotseat_migrate_message"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@android:color/white"
|
||||
@@ -72,9 +73,9 @@
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/hotseat_edu_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_edu_padding"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="@dimen/hotseat_edu_padding">
|
||||
android:paddingRight="@dimen/bottom_sheet_edu_padding">
|
||||
|
||||
<Button
|
||||
android:id="@+id/turn_predictions_on"
|
||||
|
||||
@@ -6,6 +6,4 @@
|
||||
<color name="all_apps_label_text_dark">#61FFFFFF</color>
|
||||
<color name="all_apps_prediction_row_separator">#3c000000</color>
|
||||
<color name="all_apps_prediction_row_separator_dark">#3cffffff</color>
|
||||
|
||||
<color name="hotseat_edu_background">#f01A73E8</color>
|
||||
</resources>
|
||||
@@ -29,7 +29,4 @@
|
||||
<dimen name="swipe_up_y_overshoot">10dp</dimen>
|
||||
<dimen name="swipe_up_max_workspace_trans_y">-60dp</dimen>
|
||||
|
||||
<!-- Hybrid hotseat related -->
|
||||
<dimen name="hotseat_edu_padding">24dp</dimen>
|
||||
|
||||
</resources>
|
||||
+3
-3
@@ -317,8 +317,8 @@ public class PredictionUiStateManager implements StateListener, ItemInfoUpdateRe
|
||||
&& itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)) {
|
||||
return;
|
||||
}
|
||||
if (itemInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
|
||||
HotseatPredictionController.fillInHybridHotseatRank(itemInfo, target);
|
||||
if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_PREDICTION) {
|
||||
HotseatPredictionController.encodeHotseatLayoutIntoPredictionRank(itemInfo, target);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ public class PredictionUiStateManager implements StateListener, ItemInfoUpdateRe
|
||||
IntStream.range(0, predictedApps.size())
|
||||
.filter((i) -> k.equals(predictedApps.get(i).getComponentKey()))
|
||||
.findFirst()
|
||||
.ifPresent((rank) -> target.predictedRank = rank);
|
||||
.ifPresent((rank) -> target.predictedRank = 0 - rank);
|
||||
}
|
||||
|
||||
public static class PredictionState {
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public class HotseatEduController {
|
||||
NOTIFICATION_CHANNEL_ID)
|
||||
.setContentTitle(name)
|
||||
.setOngoing(true)
|
||||
.setColor(mLauncher.getColor(R.color.hotseat_edu_background))
|
||||
.setColor(mLauncher.getColor(R.color.bottom_panel_background))
|
||||
.setContentIntent(PendingIntent.getActivity(mLauncher, 0, intent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT))
|
||||
.setSmallIcon(R.drawable.hotseat_edu_notification_icon)
|
||||
|
||||
+23
-7
@@ -39,6 +39,7 @@ import com.android.launcher3.AppInfo;
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.DragSource;
|
||||
import com.android.launcher3.DropTarget;
|
||||
import com.android.launcher3.FolderInfo;
|
||||
import com.android.launcher3.Hotseat;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.ItemInfo;
|
||||
@@ -68,6 +69,7 @@ import com.android.launcher3.util.ComponentKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
@@ -442,6 +444,20 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
mHotseat.invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpins pinned app when it's converted into a folder
|
||||
*/
|
||||
public void folderCreatedFromIcon(ItemInfo info, FolderInfo folderInfo) {
|
||||
AppTarget target = getAppTargetFromItemInfo(info);
|
||||
if (folderInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT && !isInHotseat(
|
||||
info)) {
|
||||
notifyItemAction(target, APP_LOCATION_HOTSEAT, APPTARGET_ACTION_UNPIN);
|
||||
} else if (folderInfo.container == LauncherSettings.Favorites.CONTAINER_DESKTOP
|
||||
&& folderInfo.screenId == Workspace.FIRST_SCREEN_ID && !isInFirstPage(info)) {
|
||||
notifyItemAction(target, APP_LOCATION_WORKSPACE, APPTARGET_ACTION_UNPIN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragEnd() {
|
||||
if (mDragObject == null) {
|
||||
@@ -548,12 +564,11 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
* Fill in predicted_rank field based on app prediction.
|
||||
* Only applicable when {@link ItemInfo#itemType} is PREDICTED_HOTSEAT
|
||||
*/
|
||||
public static void fillInHybridHotseatRank(
|
||||
public static void encodeHotseatLayoutIntoPredictionRank(
|
||||
@NonNull ItemInfo itemInfo, @NonNull LauncherLogProto.Target target) {
|
||||
QuickstepLauncher launcher = QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity();
|
||||
if (launcher == null || launcher.getHotseatPredictionController() == null
|
||||
|| itemInfo.getTargetComponent() == null
|
||||
|| itemInfo.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
|
||||
|| itemInfo.getTargetComponent() == null) {
|
||||
return;
|
||||
}
|
||||
HotseatPredictionController controller = launcher.getHotseatPredictionController();
|
||||
@@ -561,11 +576,12 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
final ComponentKey k = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
|
||||
|
||||
final List<ComponentKeyMapper> predictedApps = controller.mComponentKeyMappers;
|
||||
IntStream.range(0, predictedApps.size())
|
||||
OptionalInt rank = IntStream.range(0, predictedApps.size())
|
||||
.filter((i) -> k.equals(predictedApps.get(i).getComponentKey()))
|
||||
.findFirst()
|
||||
.ifPresent((rank) -> target.predictedRank =
|
||||
Integer.parseInt(controller.mPredictedSpotsCount + "0" + rank));
|
||||
.findFirst();
|
||||
|
||||
target.predictedRank = 10000 + (controller.mPredictedSpotsCount * 100)
|
||||
+ (rank.isPresent() ? rank.getAsInt() + 1 : 0);
|
||||
}
|
||||
|
||||
private static boolean isPredictedIcon(View view) {
|
||||
|
||||
+12
-1
@@ -47,6 +47,7 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView {
|
||||
|
||||
private static final float RING_EFFECT_RATIO = 0.11f;
|
||||
|
||||
boolean mIsDrawingDot = false;
|
||||
private final DeviceProfile mDeviceProfile;
|
||||
private final Paint mIconRingPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private boolean mIsPinned = false;
|
||||
@@ -80,6 +81,16 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView {
|
||||
canvas.restoreToCount(count);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawDotIfNecessary(Canvas canvas) {
|
||||
mIsDrawingDot = true;
|
||||
int count = canvas.save();
|
||||
canvas.translate(-getWidth() * RING_EFFECT_RATIO, -getHeight() * RING_EFFECT_RATIO);
|
||||
super.drawDotIfNecessary(canvas);
|
||||
canvas.restoreToCount(count);
|
||||
mIsDrawingDot = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFromWorkspaceItem(WorkspaceItemInfo info) {
|
||||
super.applyFromWorkspaceItem(info);
|
||||
@@ -112,7 +123,7 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView {
|
||||
@Override
|
||||
public void getIconBounds(Rect outBounds) {
|
||||
super.getIconBounds(outBounds);
|
||||
if (!mIsPinned) {
|
||||
if (!mIsPinned && !mIsDrawingDot) {
|
||||
int predictionInset = (int) (getIconSize() * RING_EFFECT_RATIO);
|
||||
outBounds.inset(predictionInset, predictionInset);
|
||||
}
|
||||
|
||||
+19
-1
@@ -26,17 +26,21 @@ import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
|
||||
import com.android.launcher3.BaseQuickstepLauncher;
|
||||
import com.android.launcher3.CellLayout;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.WorkspaceItemInfo;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.folder.FolderIcon;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.FlingAndHoldTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.NavBarToHomeTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.NoButtonNavbarToOverviewTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.NoButtonQuickSwitchTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.OverviewToAllAppsTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
|
||||
@@ -168,6 +172,16 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FolderIcon addFolder(CellLayout layout, WorkspaceItemInfo info, int container,
|
||||
int screenId, int cellX, int cellY) {
|
||||
FolderIcon fi = super.addFolder(layout, info, container, screenId, cellX, cellY);
|
||||
if (mHotseatPredictionController != null) {
|
||||
mHotseatPredictionController.folderCreatedFromIcon(info, fi.getFolder().getInfo());
|
||||
}
|
||||
return fi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
|
||||
if (mHotseatPredictionController != null) {
|
||||
@@ -225,7 +239,11 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
if (mode == NO_BUTTON) {
|
||||
list.add(new NoButtonQuickSwitchTouchController(this));
|
||||
list.add(new NavBarToHomeTouchController(this));
|
||||
list.add(new FlingAndHoldTouchController(this));
|
||||
if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
list.add(new NoButtonNavbarToOverviewTouchController(this));
|
||||
} else {
|
||||
list.add(new FlingAndHoldTouchController(this));
|
||||
}
|
||||
} else {
|
||||
if (getDeviceProfile().isVerticalBarLayout()) {
|
||||
list.add(new OverviewToAllAppsTouchController(this));
|
||||
|
||||
+1
-3
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.android.launcher3.uioverrides.states;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
@@ -39,7 +37,7 @@ public class BackgroundAppState extends OverviewState {
|
||||
}
|
||||
|
||||
protected BackgroundAppState(int id, int logContainer) {
|
||||
super(id, logContainer, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
|
||||
super(id, logContainer, STATE_FLAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+34
-13
@@ -17,7 +17,6 @@ package com.android.launcher3.uioverrides.states;
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
|
||||
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
|
||||
@@ -30,11 +29,14 @@ import static com.android.launcher3.anim.Interpolators.ACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
|
||||
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
|
||||
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS;
|
||||
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
|
||||
import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
@@ -44,7 +46,6 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.allapps.DiscoveryBounce;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
@@ -66,15 +67,22 @@ public class OverviewState extends LauncherState {
|
||||
| FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY;
|
||||
|
||||
public OverviewState(int id) {
|
||||
this(id, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
|
||||
this(id, STATE_FLAGS);
|
||||
}
|
||||
|
||||
protected OverviewState(int id, int transitionDuration, int stateFlags) {
|
||||
this(id, ContainerType.TASKSWITCHER, transitionDuration, stateFlags);
|
||||
protected OverviewState(int id, int stateFlags) {
|
||||
this(id, ContainerType.TASKSWITCHER, stateFlags);
|
||||
}
|
||||
|
||||
protected OverviewState(int id, int logContainer, int transitionDuration, int stateFlags) {
|
||||
super(id, logContainer, transitionDuration, stateFlags);
|
||||
protected OverviewState(int id, int logContainer, int stateFlags) {
|
||||
super(id, logContainer, stateFlags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransitionDuration(Launcher launcher) {
|
||||
// In no-button mode, overview comes in all the way from the left, so give it more time.
|
||||
boolean isNoButtonMode = SysUINavigationMode.INSTANCE.get(launcher).getMode() == NO_BUTTON;
|
||||
return isNoButtonMode && ENABLE_OVERVIEW_ACTIONS.get() ? 380 : 250;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,6 +123,15 @@ public class OverviewState extends LauncherState {
|
||||
return new ScaleAndTranslation(1f, 0f, 0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScaleAndTranslation getQsbScaleAndTranslation(Launcher launcher) {
|
||||
if (this == OVERVIEW && ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
// Treat the QSB as part of the hotseat so they move together.
|
||||
return getHotseatScaleAndTranslation(launcher);
|
||||
}
|
||||
return super.getQsbScaleAndTranslation(launcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateEnabled(Launcher launcher) {
|
||||
AbstractFloatingView.closeAllOpenViews(launcher);
|
||||
@@ -141,7 +158,7 @@ public class OverviewState extends LauncherState {
|
||||
if (launcher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
return VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON;
|
||||
} else {
|
||||
if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
if (ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
return VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON;
|
||||
}
|
||||
|
||||
@@ -195,9 +212,10 @@ public class OverviewState extends LauncherState {
|
||||
@Override
|
||||
public void prepareForAtomicAnimation(Launcher launcher, LauncherState fromState,
|
||||
AnimatorSetBuilder builder) {
|
||||
if (fromState == NORMAL && this == OVERVIEW) {
|
||||
if (SysUINavigationMode.getMode(launcher) == SysUINavigationMode.Mode.NO_BUTTON) {
|
||||
builder.setInterpolator(ANIM_WORKSPACE_SCALE, ACCEL);
|
||||
if ((fromState == NORMAL || fromState == HINT_STATE) && this == OVERVIEW) {
|
||||
if (SysUINavigationMode.getMode(launcher) == NO_BUTTON) {
|
||||
builder.setInterpolator(ANIM_WORKSPACE_SCALE,
|
||||
fromState == NORMAL ? ACCEL : OVERSHOOT_1_2);
|
||||
builder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL);
|
||||
} else {
|
||||
builder.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2);
|
||||
@@ -210,8 +228,11 @@ public class OverviewState extends LauncherState {
|
||||
}
|
||||
builder.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2);
|
||||
builder.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2);
|
||||
builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7);
|
||||
builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, OVERSHOOT_1_7);
|
||||
Interpolator translationInterpolator = ENABLE_OVERVIEW_ACTIONS.get()
|
||||
? OVERSHOOT_1_2
|
||||
: OVERSHOOT_1_7;
|
||||
builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, translationInterpolator);
|
||||
builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, translationInterpolator);
|
||||
builder.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
|
||||
}
|
||||
}
|
||||
|
||||
+65
-39
@@ -43,6 +43,7 @@ import android.view.ViewConfiguration;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppTransitionManagerImpl;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||
@@ -60,7 +61,7 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController {
|
||||
private static final long PEEK_OUT_ANIM_DURATION = 100;
|
||||
private static final float MAX_DISPLACEMENT_PERCENT = 0.75f;
|
||||
|
||||
private final MotionPauseDetector mMotionPauseDetector;
|
||||
protected final MotionPauseDetector mMotionPauseDetector;
|
||||
private final float mMotionPauseMinDisplacement;
|
||||
private final float mMotionPauseMaxDisplacement;
|
||||
|
||||
@@ -85,37 +86,43 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController {
|
||||
super.onDragStart(start);
|
||||
|
||||
if (handlingOverviewAnim()) {
|
||||
mMotionPauseDetector.setOnMotionPauseListener(isPaused -> {
|
||||
RecentsView recentsView = mLauncher.getOverviewPanel();
|
||||
recentsView.setOverviewStateEnabled(isPaused);
|
||||
if (mPeekAnim != null) {
|
||||
mPeekAnim.cancel();
|
||||
}
|
||||
LauncherState fromState = isPaused ? NORMAL : OVERVIEW_PEEK;
|
||||
LauncherState toState = isPaused ? OVERVIEW_PEEK : NORMAL;
|
||||
long peekDuration = isPaused ? PEEK_IN_ANIM_DURATION : PEEK_OUT_ANIM_DURATION;
|
||||
mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(fromState, toState,
|
||||
new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT, peekDuration);
|
||||
mPeekAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mPeekAnim = null;
|
||||
}
|
||||
});
|
||||
mPeekAnim.start();
|
||||
VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
|
||||
|
||||
mLauncher.getDragLayer().getScrim().animateToSysuiMultiplier(isPaused ? 0 : 1,
|
||||
peekDuration, 0);
|
||||
});
|
||||
mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseChanged);
|
||||
}
|
||||
|
||||
if (mAtomicAnim != null) {
|
||||
mAtomicAnim.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onMotionPauseChanged(boolean isPaused) {
|
||||
RecentsView recentsView = mLauncher.getOverviewPanel();
|
||||
recentsView.setOverviewStateEnabled(isPaused);
|
||||
if (mPeekAnim != null) {
|
||||
mPeekAnim.cancel();
|
||||
}
|
||||
LauncherState fromState = isPaused ? NORMAL : OVERVIEW_PEEK;
|
||||
LauncherState toState = isPaused ? OVERVIEW_PEEK : NORMAL;
|
||||
long peekDuration = isPaused ? PEEK_IN_ANIM_DURATION : PEEK_OUT_ANIM_DURATION;
|
||||
mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(fromState, toState,
|
||||
new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT, peekDuration);
|
||||
mPeekAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mPeekAnim = null;
|
||||
}
|
||||
});
|
||||
mPeekAnim.start();
|
||||
VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
|
||||
|
||||
mLauncher.getDragLayer().getScrim().animateToSysuiMultiplier(isPaused ? 0 : 1,
|
||||
peekDuration, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether we are handling the overview animation, rather than
|
||||
* having it as part of the existing animation to the target state.
|
||||
*/
|
||||
private boolean handlingOverviewAnim() {
|
||||
protected boolean handlingOverviewAnim() {
|
||||
int stateFlags = SystemUiProxy.INSTANCE.get(mLauncher).getLastSystemUiStateFlags();
|
||||
return mStartState == NORMAL && (stateFlags & SYSUI_STATE_OVERVIEW_DISABLED) == 0;
|
||||
}
|
||||
@@ -162,7 +169,8 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController {
|
||||
@Override
|
||||
public boolean onDrag(float displacement, MotionEvent event) {
|
||||
float upDisplacement = -displacement;
|
||||
mMotionPauseDetector.setDisallowPause(upDisplacement < mMotionPauseMinDisplacement
|
||||
mMotionPauseDetector.setDisallowPause(!handlingOverviewAnim()
|
||||
|| upDisplacement < mMotionPauseMinDisplacement
|
||||
|| upDisplacement > mMotionPauseMaxDisplacement);
|
||||
mMotionPauseDetector.addPosition(displacement, event.getEventTime());
|
||||
return super.onDrag(displacement, event);
|
||||
@@ -171,19 +179,7 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController {
|
||||
@Override
|
||||
public void onDragEnd(float velocity) {
|
||||
if (mMotionPauseDetector.isPaused() && handlingOverviewAnim()) {
|
||||
if (mPeekAnim != null) {
|
||||
mPeekAnim.cancel();
|
||||
}
|
||||
|
||||
Animator overviewAnim = mLauncher.getAppTransitionManager().createStateElementAnimation(
|
||||
INDEX_PAUSE_TO_OVERVIEW_ANIM);
|
||||
overviewAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE);
|
||||
}
|
||||
});
|
||||
overviewAnim.start();
|
||||
goToOverviewOnDragEnd(velocity);
|
||||
} else {
|
||||
super.onDragEnd(velocity);
|
||||
}
|
||||
@@ -195,6 +191,36 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController {
|
||||
mMotionPauseDetector.clear();
|
||||
}
|
||||
|
||||
protected void goToOverviewOnDragEnd(float velocity) {
|
||||
if (mPeekAnim != null) {
|
||||
mPeekAnim.cancel();
|
||||
}
|
||||
|
||||
Animator overviewAnim = mLauncher.getAppTransitionManager().createStateElementAnimation(
|
||||
INDEX_PAUSE_TO_OVERVIEW_ANIM);
|
||||
mAtomicAnim = new AnimatorSet();
|
||||
mAtomicAnim.addListener(new AnimationSuccessListener() {
|
||||
@Override
|
||||
public void onAnimationSuccess(Animator animator) {
|
||||
onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
if (mCancelled) {
|
||||
mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(mFromState,
|
||||
mToState, new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT,
|
||||
PEEK_OUT_ANIM_DURATION);
|
||||
mPeekAnim.start();
|
||||
}
|
||||
mAtomicAnim = null;
|
||||
}
|
||||
});
|
||||
mAtomicAnim.play(overviewAnim);
|
||||
mAtomicAnim.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void goToTargetState(LauncherState targetState, int logAction) {
|
||||
if (mPeekAnim != null && mPeekAnim.isStarted()) {
|
||||
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.uioverrides.touchcontrollers;
|
||||
|
||||
import static com.android.launcher3.LauncherState.HINT_STATE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_PEEK_COMPONENT;
|
||||
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
|
||||
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
|
||||
import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.PointF;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.LauncherStateManager;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||
import com.android.launcher3.util.VibratorWrapper;
|
||||
import com.android.quickstep.util.StaggeredWorkspaceAnim;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
/**
|
||||
* Touch controller which handles swipe and hold from the nav bar to go to Overview. Swiping above
|
||||
* the nav bar falls back to go to All Apps. Swiping from the nav bar without holding goes to the
|
||||
* first home screen instead of to Overview.
|
||||
*/
|
||||
public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchController {
|
||||
|
||||
|
||||
// How much of the movement to use for translating overview after swipe and hold.
|
||||
private static final float OVERVIEW_MOVEMENT_FACTOR = 0.25f;
|
||||
private static final long TRANSLATION_ANIM_MIN_DURATION_MS = 80;
|
||||
private static final float TRANSLATION_ANIM_VELOCITY_DP_PER_MS = 0.8f;
|
||||
|
||||
private final RecentsView mRecentsView;
|
||||
|
||||
private boolean mDidTouchStartInNavBar;
|
||||
private boolean mReachedOverview;
|
||||
// The last recorded displacement before we reached overview.
|
||||
private PointF mStartDisplacement = new PointF();
|
||||
|
||||
public NoButtonNavbarToOverviewTouchController(Launcher l) {
|
||||
super(l);
|
||||
mRecentsView = l.getOverviewPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canInterceptTouch(MotionEvent ev) {
|
||||
mDidTouchStartInNavBar = (ev.getEdgeFlags() & EDGE_NAV_BAR) != 0;
|
||||
return super.canInterceptTouch(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
|
||||
if (fromState == NORMAL && mDidTouchStartInNavBar) {
|
||||
return HINT_STATE;
|
||||
} else if (fromState == OVERVIEW && isDragTowardPositive) {
|
||||
// Don't allow swiping up to all apps.
|
||||
return OVERVIEW;
|
||||
}
|
||||
return super.getTargetState(fromState, isDragTowardPositive);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float initCurrentAnimation(int animComponents) {
|
||||
float progressMultiplier = super.initCurrentAnimation(animComponents);
|
||||
if (mToState == HINT_STATE) {
|
||||
// Track the drag across the entire height of the screen.
|
||||
progressMultiplier = -1 / getShiftRange();
|
||||
}
|
||||
return progressMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragStart(boolean start) {
|
||||
super.onDragStart(start);
|
||||
|
||||
mReachedOverview = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSwipeCompleteAnimation(ValueAnimator animator, long expectedDuration,
|
||||
LauncherState targetState, float velocity, boolean isFling) {
|
||||
super.updateSwipeCompleteAnimation(animator, expectedDuration, targetState, velocity,
|
||||
isFling);
|
||||
if (targetState == HINT_STATE) {
|
||||
// Normally we compute the duration based on the velocity and distance to the given
|
||||
// state, but since the hint state tracks the entire screen without a clear endpoint, we
|
||||
// need to manually set the duration to a reasonable value.
|
||||
animator.setDuration(HINT_STATE.getTransitionDuration(mLauncher));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMotionPauseChanged(boolean isPaused) {
|
||||
if (mCurrentAnimation == null) {
|
||||
return;
|
||||
}
|
||||
mCurrentAnimation.dispatchOnCancelWithoutCancelRunnable(() -> {
|
||||
mLauncher.getStateManager().goToState(OVERVIEW, true, () -> {
|
||||
mReachedOverview = true;
|
||||
maybeSwipeInteractionToOverviewComplete();
|
||||
});
|
||||
});
|
||||
VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
|
||||
}
|
||||
|
||||
private void maybeSwipeInteractionToOverviewComplete() {
|
||||
if (mReachedOverview && mDetector.isSettlingState()) {
|
||||
onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handlingOverviewAnim() {
|
||||
return mDidTouchStartInNavBar && super.handlingOverviewAnim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDrag(float yDisplacement, float xDisplacement, MotionEvent event) {
|
||||
if (mMotionPauseDetector.isPaused()) {
|
||||
if (!mReachedOverview) {
|
||||
mStartDisplacement.set(xDisplacement, yDisplacement);
|
||||
} else {
|
||||
mRecentsView.setTranslationX((xDisplacement - mStartDisplacement.x)
|
||||
* OVERVIEW_MOVEMENT_FACTOR);
|
||||
mRecentsView.setTranslationY((yDisplacement - mStartDisplacement.y)
|
||||
* OVERVIEW_MOVEMENT_FACTOR);
|
||||
}
|
||||
// Stay in Overview.
|
||||
return true;
|
||||
}
|
||||
return super.onDrag(yDisplacement, xDisplacement, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void goToOverviewOnDragEnd(float velocity) {
|
||||
float velocityDp = dpiFromPx(velocity);
|
||||
boolean isFling = Math.abs(velocityDp) > 1;
|
||||
LauncherStateManager stateManager = mLauncher.getStateManager();
|
||||
if (isFling) {
|
||||
// When flinging, go back to home instead of overview.
|
||||
if (velocity > 0) {
|
||||
stateManager.goToState(NORMAL, true,
|
||||
() -> onSwipeInteractionCompleted(NORMAL, Touch.FLING));
|
||||
} else {
|
||||
StaggeredWorkspaceAnim staggeredWorkspaceAnim = new StaggeredWorkspaceAnim(
|
||||
mLauncher, velocity, false /* animateOverviewScrim */);
|
||||
staggeredWorkspaceAnim.start();
|
||||
|
||||
// StaggeredWorkspaceAnim doesn't animate overview, so we handle it here.
|
||||
stateManager.cancelAnimation();
|
||||
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
||||
long duration = OVERVIEW.getTransitionDuration(mLauncher);
|
||||
AnimatorSet anim = stateManager.createAtomicAnimation(
|
||||
stateManager.getState(), NORMAL, builder,
|
||||
ATOMIC_OVERVIEW_PEEK_COMPONENT, duration);
|
||||
anim.addListener(new AnimationSuccessListener() {
|
||||
@Override
|
||||
public void onAnimationSuccess(Animator animator) {
|
||||
onSwipeInteractionCompleted(NORMAL, Touch.SWIPE);
|
||||
}
|
||||
});
|
||||
anim.start();
|
||||
}
|
||||
} else {
|
||||
if (mReachedOverview) {
|
||||
float distanceDp = dpiFromPx(Math.max(
|
||||
Math.abs(mRecentsView.getTranslationX()),
|
||||
Math.abs(mRecentsView.getTranslationY())));
|
||||
long duration = (long) Math.max(TRANSLATION_ANIM_MIN_DURATION_MS,
|
||||
distanceDp / TRANSLATION_ANIM_VELOCITY_DP_PER_MS);
|
||||
mRecentsView.animate()
|
||||
.translationX(0)
|
||||
.translationY(0)
|
||||
.setInterpolator(ACCEL_DEACCEL)
|
||||
.setDuration(duration)
|
||||
.withEndAction(this::maybeSwipeInteractionToOverviewComplete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float dpiFromPx(float pixels) {
|
||||
return Utilities.dpiFromPx(pixels, mLauncher.getResources().getDisplayMetrics());
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -62,6 +62,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.OverviewScrim;
|
||||
import com.android.launcher3.touch.BaseSwipeDetector;
|
||||
import com.android.launcher3.touch.BothAxesSwipeDetector;
|
||||
@@ -181,6 +182,12 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
|
||||
|
||||
@Override
|
||||
public void onMotionPauseChanged(boolean isPaused) {
|
||||
VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
|
||||
|
||||
if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ShelfAnimState shelfState = isPaused ? PEEK : HIDE;
|
||||
if (shelfState == PEEK) {
|
||||
// Some shelf elements (e.g. qsb) were hidden, but we need them visible when peeking.
|
||||
@@ -197,7 +204,6 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
|
||||
}
|
||||
mShelfPeekAnim.setShelfState(shelfState, ShelfPeekAnim.INTERPOLATOR,
|
||||
ShelfPeekAnim.DURATION);
|
||||
VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
|
||||
}
|
||||
|
||||
private void setupAnimators() {
|
||||
|
||||
@@ -21,7 +21,7 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
|
||||
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
|
||||
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
|
||||
import static com.android.launcher3.util.DefaultDisplay.getSingleFrameMs;
|
||||
import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
|
||||
import static com.android.quickstep.GestureState.GestureEndTarget.HOME;
|
||||
@@ -973,7 +973,7 @@ public class LauncherSwipeHandler<T extends BaseDraggingActivity>
|
||||
}
|
||||
mLauncherTransitionController.getAnimationPlayer().setDuration(Math.max(0, duration));
|
||||
|
||||
if (UNSTABLE_SPRINGS.get()) {
|
||||
if (QUICKSTEP_SPRINGS.get()) {
|
||||
mLauncherTransitionController.dispatchOnStartWithVelocity(end, velocityPxPerMs.y);
|
||||
}
|
||||
mLauncherTransitionController.getAnimationPlayer().start();
|
||||
|
||||
@@ -74,6 +74,10 @@ public class OverviewCommandHelper {
|
||||
|
||||
@BinderThread
|
||||
public void onOverviewShown(boolean triggeredFromAltTab) {
|
||||
if (triggeredFromAltTab) {
|
||||
ActivityManagerWrapper.getInstance()
|
||||
.closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
|
||||
}
|
||||
MAIN_EXECUTOR.execute(new ShowRecentsCommand(triggeredFromAltTab));
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -111,6 +111,11 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
|
||||
@Override
|
||||
protected boolean isLauncherInitialized() {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
|
||||
"isLauncherInitialized.TouchInteractionService.isInitialized=" +
|
||||
TouchInteractionService.isInitialized());
|
||||
}
|
||||
return super.isLauncherInitialized() && TouchInteractionService.isInitialized();
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.model.AppLaunchTracker;
|
||||
import com.android.launcher3.provider.RestoreDbTask;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.tracing.nano.LauncherTraceProto;
|
||||
import com.android.launcher3.tracing.nano.TouchInteractionServiceProto;
|
||||
@@ -141,12 +142,16 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
TouchInteractionService.this.initInputMonitor();
|
||||
preloadOverview(true /* fromInit */);
|
||||
});
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "TIS initialized");
|
||||
}
|
||||
sIsInitialized = true;
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void onOverviewToggle() {
|
||||
TestLogging.recordEvent("onOverviewToggle");
|
||||
mOverviewCommandHelper.onOverviewToggle();
|
||||
}
|
||||
|
||||
@@ -406,6 +411,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "TIS destroyed");
|
||||
}
|
||||
sIsInitialized = false;
|
||||
if (mDeviceState.isUserUnlocked()) {
|
||||
mInputConsumer.unregisterInputConsumer();
|
||||
|
||||
+2
@@ -2,6 +2,7 @@ package com.android.quickstep.inputconsumers;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.quickstep.InputConsumer;
|
||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
|
||||
@@ -34,6 +35,7 @@ public abstract class DelegateInputConsumer implements InputConsumer {
|
||||
|
||||
protected void setActive(MotionEvent ev) {
|
||||
mState = STATE_ACTIVE;
|
||||
TestLogging.recordEvent("pilferPointers");
|
||||
mInputMonitor.pilferPointers();
|
||||
|
||||
// Send cancel event
|
||||
|
||||
+2
@@ -37,6 +37,7 @@ import android.view.ViewConfiguration;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.quickstep.GestureState;
|
||||
import com.android.quickstep.InputConsumer;
|
||||
@@ -202,6 +203,7 @@ public class DeviceLockedInputConsumer implements InputConsumer,
|
||||
|
||||
private void startRecentsTransition() {
|
||||
mThresholdCrossed = true;
|
||||
TestLogging.recordEvent("pilferPointers");
|
||||
mInputMonitorCompat.pilferPointers();
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN)
|
||||
|
||||
+2
@@ -44,6 +44,7 @@ import android.view.ViewConfiguration;
|
||||
import androidx.annotation.UiThread;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.util.Preconditions;
|
||||
import com.android.launcher3.util.TraceHelper;
|
||||
import com.android.quickstep.BaseActivityInterface;
|
||||
@@ -302,6 +303,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
if (mInteractionHandler == null) {
|
||||
return;
|
||||
}
|
||||
TestLogging.recordEvent("pilferPointers");
|
||||
mInputMonitorCompat.pilferPointers();
|
||||
|
||||
mActivityInterface.closeOverlay();
|
||||
|
||||
+2
@@ -25,6 +25,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.BaseActivityInterface;
|
||||
import com.android.quickstep.GestureState;
|
||||
@@ -106,6 +107,7 @@ public class OverviewInputConsumer<T extends BaseDraggingActivity>
|
||||
ActiveGestureLog.INSTANCE.addLog("startQuickstep");
|
||||
}
|
||||
if (mInputMonitor != null) {
|
||||
TestLogging.recordEvent("pilferPointers");
|
||||
mInputMonitor.pilferPointers();
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -22,6 +22,7 @@ import android.view.MotionEvent;
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.logging.StatsLogUtils;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||
import com.android.quickstep.GestureState;
|
||||
@@ -63,6 +64,7 @@ public class OverviewWithoutFocusInputConsumer implements InputConsumer {
|
||||
|
||||
private void onInterceptTouch() {
|
||||
if (mInputMonitor != null) {
|
||||
TestLogging.recordEvent("pilferPointers");
|
||||
mInputMonitor.pilferPointers();
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -224,7 +224,6 @@ public class AppWindowAnimationHelper {
|
||||
surfaceParams[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop, layer,
|
||||
cornerRadius / scale);
|
||||
}
|
||||
applySurfaceParams(params.syncTransactionApplier, surfaceParams);
|
||||
return surfaceParams;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.animation.AnimatorListenerAdapter;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
|
||||
/**
|
||||
@@ -48,7 +49,7 @@ public class ShelfPeekAnim {
|
||||
* Animates to the given state, canceling the previous animation if it was still running.
|
||||
*/
|
||||
public void setShelfState(ShelfAnimState shelfState, Interpolator interpolator, long duration) {
|
||||
if (mShelfState == shelfState) {
|
||||
if (mShelfState == shelfState || FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
return;
|
||||
}
|
||||
mLauncher.getStateManager().cancelStateElementAnimation(INDEX_SHELF_ANIM);
|
||||
|
||||
@@ -1917,6 +1917,11 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||
|
||||
@Override
|
||||
public void addView(View child, int index) {
|
||||
// RecentsView is set to RTL in the constructor when system is using LTR. Here we set the
|
||||
// child direction back to match system settings.
|
||||
child.setLayoutDirection(
|
||||
Utilities.isRtl(getResources())
|
||||
? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
|
||||
super.addView(child, index);
|
||||
if (isExtraCardView(child, index)) {
|
||||
mTaskViewStartIndex++;
|
||||
|
||||
+69
-35
@@ -20,7 +20,6 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
@@ -38,11 +37,11 @@ import android.graphics.Shader;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Property;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||
@@ -102,7 +101,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
private float mSaturation = 1f;
|
||||
|
||||
private boolean mOverlayEnabled;
|
||||
private boolean mRotated;
|
||||
private boolean mIsOrientationChanged;
|
||||
private OverviewScreenshotActions mOverviewScreenshotActionsPlugin;
|
||||
|
||||
public TaskThumbnailView(Context context) {
|
||||
@@ -323,7 +322,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
|
||||
private void updateOverlay() {
|
||||
// The overlay doesn't really work when the screenshot is rotated, so don't add it.
|
||||
if (mOverlayEnabled && !mRotated && mBitmapShader != null && mThumbnailData != null) {
|
||||
if (mOverlayEnabled && !mIsOrientationChanged && mBitmapShader != null && mThumbnailData != null) {
|
||||
mOverlay.initOverlay(mTask, mThumbnailData, mMatrix);
|
||||
} else {
|
||||
mOverlay.reset();
|
||||
@@ -346,6 +345,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
|
||||
private void updateThumbnailMatrix() {
|
||||
boolean isRotated = false;
|
||||
boolean isOrientationDifferent = false;
|
||||
mClipBottom = -1;
|
||||
if (mBitmapShader != null && mThumbnailData != null) {
|
||||
float scale = mThumbnailData.scale;
|
||||
@@ -356,51 +356,40 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
(thumbnailInsets.top + thumbnailInsets.bottom) * scale;
|
||||
|
||||
final float thumbnailScale;
|
||||
final DeviceProfile profile = mActivity.getDeviceProfile();
|
||||
|
||||
int thumbnailRotation = mThumbnailData.rotation;
|
||||
int currentRotation = getDisplay() != null ? getDisplay().getRotation() : 0;
|
||||
int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
|
||||
// Landscape vs portrait change
|
||||
boolean windowingModeSupportsRotation = !mActivity.isInMultiWindowMode()
|
||||
&& mThumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN;
|
||||
isOrientationDifferent = isOrientationChange(deltaRotate)
|
||||
&& windowingModeSupportsRotation;
|
||||
if (getMeasuredWidth() == 0) {
|
||||
// If we haven't measured , skip the thumbnail drawing and only draw the background
|
||||
// color
|
||||
thumbnailScale = 0f;
|
||||
} else {
|
||||
final Configuration configuration =
|
||||
getContext().getResources().getConfiguration();
|
||||
// Rotate the screenshot if not in multi-window mode
|
||||
isRotated = configuration.orientation != mThumbnailData.orientation &&
|
||||
!mActivity.isInMultiWindowMode() &&
|
||||
mThumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN;
|
||||
isRotated = deltaRotate > 0 && windowingModeSupportsRotation;
|
||||
// Scale the screenshot to always fit the width of the card.
|
||||
thumbnailScale = isRotated
|
||||
|
||||
thumbnailScale = isOrientationDifferent
|
||||
? getMeasuredWidth() / thumbnailHeight
|
||||
: getMeasuredWidth() / thumbnailWidth;
|
||||
}
|
||||
|
||||
if (isRotated) {
|
||||
int rotationDir = profile.isVerticalBarLayout() && !profile.isSeascape() ? -1 : 1;
|
||||
mMatrix.setRotate(90 * rotationDir);
|
||||
int newLeftInset = rotationDir == 1 ? thumbnailInsets.bottom : thumbnailInsets.top;
|
||||
int newTopInset = rotationDir == 1 ? thumbnailInsets.left : thumbnailInsets.right;
|
||||
mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
|
||||
if (rotationDir == -1) {
|
||||
// Crop the right/bottom side of the screenshot rather than left/top
|
||||
float excessHeight = thumbnailWidth * thumbnailScale - getMeasuredHeight();
|
||||
mClippedInsets.offset(0, excessHeight);
|
||||
}
|
||||
mMatrix.postTranslate(-mClippedInsets.left, -mClippedInsets.top);
|
||||
// Move the screenshot to the thumbnail window (rotation moved it out).
|
||||
if (rotationDir == 1) {
|
||||
mMatrix.postTranslate(mThumbnailData.thumbnail.getHeight(), 0);
|
||||
} else {
|
||||
mMatrix.postTranslate(0, mThumbnailData.thumbnail.getWidth());
|
||||
}
|
||||
} else {
|
||||
mClippedInsets.offsetTo(thumbnailInsets.left * scale, thumbnailInsets.top * scale);
|
||||
if (!isRotated) {
|
||||
// No Rotation
|
||||
mClippedInsets.offsetTo(thumbnailInsets.left * scale,
|
||||
thumbnailInsets.top * scale);
|
||||
mMatrix.setTranslate(-mClippedInsets.left, -mClippedInsets.top);
|
||||
} else {
|
||||
setThumbnailRotation(deltaRotate, thumbnailInsets, scale);
|
||||
}
|
||||
|
||||
final float widthWithInsets;
|
||||
final float heightWithInsets;
|
||||
if (isRotated) {
|
||||
if (isOrientationDifferent) {
|
||||
widthWithInsets = mThumbnailData.thumbnail.getHeight() * thumbnailScale;
|
||||
heightWithInsets = mThumbnailData.thumbnail.getWidth() * thumbnailScale;
|
||||
} else {
|
||||
@@ -415,7 +404,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
mMatrix.postScale(thumbnailScale, thumbnailScale);
|
||||
mBitmapShader.setLocalMatrix(mMatrix);
|
||||
|
||||
float bitmapHeight = Math.max((isRotated ? thumbnailWidth : thumbnailHeight)
|
||||
float bitmapHeight = Math.max((isOrientationDifferent ? thumbnailWidth : thumbnailHeight)
|
||||
* thumbnailScale, 0);
|
||||
if (Math.round(bitmapHeight) < getMeasuredHeight()) {
|
||||
mClipBottom = bitmapHeight;
|
||||
@@ -423,7 +412,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
mPaint.setShader(mBitmapShader);
|
||||
}
|
||||
|
||||
mRotated = isRotated;
|
||||
mIsOrientationChanged = isOrientationDifferent;
|
||||
invalidate();
|
||||
|
||||
// Update can be called from {@link #onSizeChanged} during layout, post handling of overlay
|
||||
@@ -431,6 +420,51 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
post(this::updateOverlay);
|
||||
}
|
||||
|
||||
private int getRotationDelta(int oldRotation, int newRotation) {
|
||||
int delta = newRotation - oldRotation;
|
||||
if (delta < 0) delta += 4;
|
||||
return delta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param deltaRotation the number of 90 degree turns from the current orientation
|
||||
* @return {@code true} if the change in rotation results in a shift from landscape to portrait
|
||||
* or vice versa, {@code false} otherwise
|
||||
*/
|
||||
private boolean isOrientationChange(int deltaRotation) {
|
||||
return deltaRotation == Surface.ROTATION_90 || deltaRotation == Surface.ROTATION_270;
|
||||
}
|
||||
|
||||
private void setThumbnailRotation(int deltaRotate, Rect thumbnailInsets, float scale) {
|
||||
int newLeftInset = 0;
|
||||
int newTopInset = 0;
|
||||
int translateX = 0;
|
||||
int translateY = 0;
|
||||
|
||||
mMatrix.setRotate(90 * deltaRotate);
|
||||
switch (deltaRotate) { /* Counter-clockwise */
|
||||
case Surface.ROTATION_90:
|
||||
newLeftInset = thumbnailInsets.bottom;
|
||||
newTopInset = thumbnailInsets.left;
|
||||
translateX = mThumbnailData.thumbnail.getHeight();
|
||||
break;
|
||||
case Surface.ROTATION_270:
|
||||
newLeftInset = thumbnailInsets.top;
|
||||
newTopInset = thumbnailInsets.right;
|
||||
translateY = mThumbnailData.thumbnail.getWidth();
|
||||
break;
|
||||
case Surface.ROTATION_180:
|
||||
newLeftInset = -thumbnailInsets.top;
|
||||
newTopInset = -thumbnailInsets.left;
|
||||
translateX = mThumbnailData.thumbnail.getWidth();
|
||||
translateY = mThumbnailData.thumbnail.getHeight();
|
||||
break;
|
||||
}
|
||||
mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
|
||||
mMatrix.postTranslate(translateX - mClippedInsets.left,
|
||||
translateY - mClippedInsets.top);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||
@@ -242,6 +243,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
getResources().getDimensionPixelSize(R.dimen.overview_actions_height),
|
||||
Gravity.BOTTOM);
|
||||
addView(mActionsView, params);
|
||||
mActionsView.setAlpha(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,6 +333,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
Consumer<Boolean> resultCallback, Handler resultCallbackHandler) {
|
||||
if (mTask != null) {
|
||||
final ActivityOptions opts;
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
TestLogging.recordEvent("startActivityFromRecentsAsync:" + mTask);
|
||||
}
|
||||
if (animate) {
|
||||
opts = mActivity.getActivityLaunchOptions(this);
|
||||
if (freezeTaskList) {
|
||||
@@ -443,7 +448,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
mIconView.setScaleX(scale);
|
||||
mIconView.setScaleY(scale);
|
||||
|
||||
if (mActionsView != null) {
|
||||
|
||||
if (mActionsView != null && isRunningTask()) {
|
||||
mActionsView.setAlpha(scale);
|
||||
}
|
||||
|
||||
@@ -519,9 +525,11 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
public void onPageScroll(ScrollState scrollState) {
|
||||
float curveInterpolation =
|
||||
CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation);
|
||||
float curveScaleForCurveInterpolation = getCurveScaleForCurveInterpolation(
|
||||
curveInterpolation);
|
||||
|
||||
mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA);
|
||||
setCurveScale(getCurveScaleForCurveInterpolation(curveInterpolation));
|
||||
setCurveScale(curveScaleForCurveInterpolation);
|
||||
|
||||
mFooterAlpha = Utilities.boundToRange(1.0f - 2 * scrollState.linearInterpolation, 0f, 1f);
|
||||
for (FooterWrapper footer : mFooters) {
|
||||
@@ -535,6 +543,28 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
mMenuView.setScaleX(getScaleX());
|
||||
mMenuView.setScaleY(getScaleY());
|
||||
}
|
||||
|
||||
// This is not the proper implementation and will be replaced with a proper layout.
|
||||
if (mActionsView != null) {
|
||||
if (mFocusTransitionProgress == 1f) {
|
||||
mActionsView.setAlpha(1 - curveInterpolation / MAX_PAGE_SCRIM_ALPHA);
|
||||
}
|
||||
maintainActionViewPosition(curveScaleForCurveInterpolation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void maintainActionViewPosition(float curveScaleForCurveInterpolation) {
|
||||
float inverseCurveScaleFactor = curveScaleForCurveInterpolation == 0 ? 0 :
|
||||
(1f / curveScaleForCurveInterpolation);
|
||||
mActionsView.setScaleX(inverseCurveScaleFactor);
|
||||
mActionsView.setScaleY(inverseCurveScaleFactor);
|
||||
mActionsView.setTranslationX(inverseCurveScaleFactor * (-getX()
|
||||
+ getRecentsView().getScrollX() + getRecentsView().scrollOffsetLeft()));
|
||||
mActionsView.setTranslationY(
|
||||
(1f - curveScaleForCurveInterpolation) * (mSnapshotView.getHeight()
|
||||
+ mActionsView.getHeight()) / 2f
|
||||
+ inverseCurveScaleFactor * (-getTranslationY()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,10 @@ public abstract class LauncherAnimationRunner implements RemoteAnimationRunnerCo
|
||||
RemoteAnimationTargetCompat[] wallpaperTargets, Runnable runnable) {
|
||||
Runnable r = () -> {
|
||||
finishExistingAnimation();
|
||||
mAnimationResult = new AnimationResult(runnable);
|
||||
mAnimationResult = new AnimationResult(() -> {
|
||||
runnable.run();
|
||||
mAnimationResult = null;
|
||||
});
|
||||
onCreateAnimation(appTargets, wallpaperTargets, mAnimationResult);
|
||||
};
|
||||
if (mStartAtFrontOfQueue) {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.android.launcher3.uioverrides.states;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
@@ -40,7 +39,12 @@ public class AllAppsState extends LauncherState {
|
||||
};
|
||||
|
||||
public AllAppsState(int id) {
|
||||
super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, STATE_FLAGS);
|
||||
super(id, ContainerType.ALLAPPS, STATE_FLAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransitionDuration(Launcher launcher) {
|
||||
return 320;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRE
|
||||
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
|
||||
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
@@ -277,7 +277,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
|
||||
private void handleFirstSwipeToOverview(final ValueAnimator animator,
|
||||
final long expectedDuration, final LauncherState targetState, final float velocity,
|
||||
final boolean isFling) {
|
||||
if (UNSTABLE_SPRINGS.get() && mFromState == OVERVIEW && mToState == ALL_APPS
|
||||
if (QUICKSTEP_SPRINGS.get() && mFromState == OVERVIEW && mToState == ALL_APPS
|
||||
&& targetState == OVERVIEW) {
|
||||
mFinishFastOnSecondTouch = true;
|
||||
} else if (mFromState == NORMAL && mToState == OVERVIEW && targetState == OVERVIEW) {
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS;
|
||||
import static com.android.launcher3.config.FeatureFlags.FLAGS_PREF_NAME;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserManager;
|
||||
@@ -22,6 +27,7 @@ import android.util.Log;
|
||||
|
||||
import com.android.launcher3.BuildConfig;
|
||||
import com.android.launcher3.MainProcessInitializer;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.systemui.shared.system.ThreadedRendererCompat;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -50,5 +56,21 @@ public class QuickstepProcessInitializer extends MainProcessInitializer {
|
||||
|
||||
// Elevate GPU priority for Quickstep and Remote animations.
|
||||
ThreadedRendererCompat.setContextPriority(ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG);
|
||||
|
||||
// Force disable some feature flags based on the system ui navigation mode.
|
||||
SysUINavigationMode.Mode currMode = SysUINavigationMode.INSTANCE.get(context)
|
||||
.addModeChangeListener(mode -> disableFeatureFlagsForSysuiNavMode(context, mode));
|
||||
disableFeatureFlagsForSysuiNavMode(context, currMode);
|
||||
}
|
||||
|
||||
private void disableFeatureFlagsForSysuiNavMode(Context ctx, SysUINavigationMode.Mode mode) {
|
||||
if (mode == SysUINavigationMode.Mode.TWO_BUTTONS) {
|
||||
ctx.getSharedPreferences(FLAGS_PREF_NAME, MODE_PRIVATE)
|
||||
.edit()
|
||||
.putBoolean(ENABLE_OVERVIEW_ACTIONS.key, false)
|
||||
.apply();
|
||||
|
||||
FeatureFlags.initialize(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,12 +269,6 @@ public class SystemUiProxy implements ISystemUiProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleImageAsScreenshot(
|
||||
Bitmap screenImage, Rect locationInScreen, Insets visibleInsets, int taskId) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See SharedApiCompat#setShelfHeight()
|
||||
*/
|
||||
@@ -291,4 +285,15 @@ public class SystemUiProxy implements ISystemUiProxy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleImageAsScreenshot(Bitmap bitmap, Rect rect, Insets insets, int i) {
|
||||
if (mSystemUiProxy != null) {
|
||||
try {
|
||||
mSystemUiProxy.handleImageAsScreenshot(bitmap, rect, insets, i);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed call handleImageAsScreenshot", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
@@ -155,12 +157,18 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
|
||||
mRemainingScreenPathValid = false;
|
||||
mShiftRange = mLauncher.getAllAppsController().getShiftRange();
|
||||
|
||||
Context context = getContext();
|
||||
if ((OVERVIEW.getVisibleElements(mLauncher) & ALL_APPS_HEADER_EXTRA) == 0) {
|
||||
mMidProgress = 1;
|
||||
mDragHandleProgress = 1;
|
||||
mMidAlpha = 0;
|
||||
if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
// Fade in all apps background quickly to distinguish from swiping from nav bar.
|
||||
mMidAlpha = Themes.getAttrInteger(context, R.attr.allAppsInterimScrimAlpha);
|
||||
mMidProgress = OverviewState.getDefaultVerticalProgress(mLauncher);
|
||||
} else {
|
||||
mMidAlpha = 0;
|
||||
mMidProgress = 1;
|
||||
}
|
||||
} else {
|
||||
Context context = getContext();
|
||||
mMidAlpha = Themes.getAttrInteger(context, R.attr.allAppsInterimScrimAlpha);
|
||||
mMidProgress = OVERVIEW.getVerticalProgress(mLauncher);
|
||||
Rect hotseatPadding = dp.getHotseatLayoutPadding();
|
||||
|
||||
@@ -68,7 +68,7 @@ public class DigitalWellBeingToastTest extends AbstractQuickStepTest {
|
||||
|
||||
private DigitalWellBeingToast getToast() {
|
||||
executeOnLauncher(launcher -> launcher.getStateManager().goToState(OVERVIEW));
|
||||
waitForState("Launcher internal state didn't switch to Overview", OVERVIEW);
|
||||
waitForState("Launcher internal state didn't switch to Overview", () -> OVERVIEW);
|
||||
final TaskView task = getOnceNotNull("No latest task", launcher -> getLatestTask(launcher));
|
||||
|
||||
return getFromLauncher(launcher -> {
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.android.launcher3.tapl.OverviewTask;
|
||||
import com.android.launcher3.tapl.TestHelpers;
|
||||
import com.android.launcher3.testcomponent.TestCommandReceiver;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.launcher3.util.rule.FailureRewriterRule;
|
||||
import com.android.launcher3.util.rule.FailureWatcher;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -94,12 +95,15 @@ public class FallbackRecentsTest {
|
||||
mDevice = UiDevice.getInstance(instrumentation);
|
||||
mDevice.setOrientationNatural();
|
||||
mLauncher = new LauncherInstrumentation();
|
||||
mLauncher.enableCheckEventsForSuccessfulGestures();
|
||||
|
||||
if (TestHelpers.isInLauncherProcess()) {
|
||||
Utilities.enableRunningInTestHarnessForTests();
|
||||
}
|
||||
|
||||
mOrderSensitiveRules = RuleChain.outerRule(new NavigationModeSwitchRule(mLauncher))
|
||||
mOrderSensitiveRules = RuleChain
|
||||
.outerRule(new FailureRewriterRule())
|
||||
.around(new NavigationModeSwitchRule(mLauncher))
|
||||
.around(new FailureWatcher(mDevice));
|
||||
|
||||
mOtherLauncherActivity = context.getPackageManager().queryIntentActivities(
|
||||
@@ -143,7 +147,7 @@ public class FallbackRecentsTest {
|
||||
@Test
|
||||
@Ignore // b/143488140
|
||||
public void goToOverviewFromApp() {
|
||||
startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
|
||||
startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
|
||||
|
||||
mLauncher.getBackground().switchToOverview();
|
||||
}
|
||||
@@ -178,8 +182,8 @@ public class FallbackRecentsTest {
|
||||
@Test
|
||||
@Ignore // b/143488140
|
||||
public void testOverview() {
|
||||
startAppFastAndWaitForRecentTask(getAppPackageName());
|
||||
startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
|
||||
startAppFast(getAppPackageName());
|
||||
startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
|
||||
startTestActivity(2);
|
||||
Wait.atMost("Expected three apps in the task list",
|
||||
() -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
|
||||
@@ -232,25 +236,4 @@ public class FallbackRecentsTest {
|
||||
private int getTaskCount(RecentsActivity recents) {
|
||||
return recents.<RecentsView>getOverviewPanel().getTaskViewCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround for b/141580748, there was an issue where the recent task is only updated when the
|
||||
* activity starting the task is resumed. In this case, we should wait until the task is in
|
||||
* the recents task list before continuing.
|
||||
*/
|
||||
private void startAppFastAndWaitForRecentTask(String packageName) {
|
||||
startAppFast(packageName);
|
||||
Wait.atMost("Expected app in task list",
|
||||
() -> containsRecentTaskWithPackage(packageName), DEFAULT_ACTIVITY_TIMEOUT,
|
||||
mLauncher);
|
||||
}
|
||||
|
||||
private boolean containsRecentTaskWithPackage(String packageName) {
|
||||
for (ComponentName cn : mLauncher.getRecentTasks()) {
|
||||
if (cn.getPackageName().equals(packageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,9 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
|
||||
private final LauncherInstrumentation mLauncher;
|
||||
|
||||
static final SysUINavigationMode SYS_UI_NAVIGATION_MODE =
|
||||
SysUINavigationMode.INSTANCE.get(getInstrumentation().getTargetContext());
|
||||
|
||||
public NavigationModeSwitchRule(LauncherInstrumentation launcher) {
|
||||
mLauncher = launcher;
|
||||
}
|
||||
@@ -83,32 +86,13 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
description.getAnnotation(NavigationModeSwitch.class) != null) {
|
||||
Mode mode = description.getAnnotation(NavigationModeSwitch.class).mode();
|
||||
return new Statement() {
|
||||
private void assertTrue(String message, boolean condition) {
|
||||
if (mLauncher.getDevice().hasObject(By.textStartsWith(""))) {
|
||||
// The condition above is "screen is not empty". We are not treating
|
||||
// "Screen is empty" as an anomaly here. It's an acceptable state when
|
||||
// Launcher just starts under instrumentation.
|
||||
mLauncher.checkForAnomaly();
|
||||
}
|
||||
if (!condition) {
|
||||
final AssertionError assertionError = new AssertionError(message);
|
||||
FailureWatcher.onError(mLauncher.getDevice(), description, assertionError);
|
||||
throw assertionError;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
mLauncher.enableDebugTracing();
|
||||
final Context context = getInstrumentation().getContext();
|
||||
final int currentInteractionMode =
|
||||
LauncherInstrumentation.getCurrentInteractionMode(context);
|
||||
final String prevOverlayPkg =
|
||||
QuickStepContract.isGesturalMode(currentInteractionMode)
|
||||
? NAV_BAR_MODE_GESTURAL_OVERLAY
|
||||
: QuickStepContract.isSwipeUpMode(currentInteractionMode)
|
||||
? NAV_BAR_MODE_2BUTTON_OVERLAY
|
||||
: NAV_BAR_MODE_3BUTTON_OVERLAY;
|
||||
final String prevOverlayPkg = getCurrentOverlayPackage(currentInteractionMode);
|
||||
final LauncherInstrumentation.NavigationModel originalMode =
|
||||
mLauncher.getNavigationModel();
|
||||
try {
|
||||
@@ -125,104 +109,47 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
Log.e(TAG, "Error", e);
|
||||
throw e;
|
||||
} finally {
|
||||
assertTrue("Couldn't set overlay",
|
||||
setActiveOverlay(prevOverlayPkg, originalMode));
|
||||
Log.d(TAG, "In Finally block");
|
||||
assertTrue(mLauncher, "Couldn't set overlay",
|
||||
setActiveOverlay(mLauncher, prevOverlayPkg, originalMode,
|
||||
description), description);
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateWithThreeButtons() throws Throwable {
|
||||
if (setActiveOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY,
|
||||
LauncherInstrumentation.NavigationModel.THREE_BUTTON)) {
|
||||
if (setActiveOverlay(mLauncher, NAV_BAR_MODE_3BUTTON_OVERLAY,
|
||||
LauncherInstrumentation.NavigationModel.THREE_BUTTON, description)) {
|
||||
base.evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateWithTwoButtons() throws Throwable {
|
||||
if (setActiveOverlay(NAV_BAR_MODE_2BUTTON_OVERLAY,
|
||||
LauncherInstrumentation.NavigationModel.TWO_BUTTON)) {
|
||||
if (setActiveOverlay(mLauncher, NAV_BAR_MODE_2BUTTON_OVERLAY,
|
||||
LauncherInstrumentation.NavigationModel.TWO_BUTTON, description)) {
|
||||
base.evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateWithZeroButtons() throws Throwable {
|
||||
if (setActiveOverlay(NAV_BAR_MODE_GESTURAL_OVERLAY,
|
||||
LauncherInstrumentation.NavigationModel.ZERO_BUTTON)) {
|
||||
if (setActiveOverlay(mLauncher, NAV_BAR_MODE_GESTURAL_OVERLAY,
|
||||
LauncherInstrumentation.NavigationModel.ZERO_BUTTON, description)) {
|
||||
base.evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean packageExists(String packageName) {
|
||||
try {
|
||||
PackageManager pm = getInstrumentation().getContext().getPackageManager();
|
||||
if (pm.getApplicationInfo(packageName, 0 /* flags */) == null) {
|
||||
return false;
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean setActiveOverlay(String overlayPackage,
|
||||
LauncherInstrumentation.NavigationModel expectedMode) throws Exception {
|
||||
if (!packageExists(overlayPackage)) {
|
||||
Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
setOverlayPackageEnabled(NAV_BAR_MODE_3BUTTON_OVERLAY,
|
||||
overlayPackage == NAV_BAR_MODE_3BUTTON_OVERLAY);
|
||||
setOverlayPackageEnabled(NAV_BAR_MODE_2BUTTON_OVERLAY,
|
||||
overlayPackage == NAV_BAR_MODE_2BUTTON_OVERLAY);
|
||||
setOverlayPackageEnabled(NAV_BAR_MODE_GESTURAL_OVERLAY,
|
||||
overlayPackage == NAV_BAR_MODE_GESTURAL_OVERLAY);
|
||||
|
||||
if (currentSysUiNavigationMode() != expectedMode) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final Context targetContext = getInstrumentation().getTargetContext();
|
||||
final SysUINavigationMode.NavigationModeChangeListener listener =
|
||||
newMode -> {
|
||||
if (LauncherInstrumentation.getNavigationModel(newMode.resValue)
|
||||
== expectedMode) {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
final SysUINavigationMode sysUINavigationMode =
|
||||
SysUINavigationMode.INSTANCE.get(targetContext);
|
||||
targetContext.getMainExecutor().execute(() ->
|
||||
sysUINavigationMode.addModeChangeListener(listener));
|
||||
latch.await(60, TimeUnit.SECONDS);
|
||||
targetContext.getMainExecutor().execute(() ->
|
||||
sysUINavigationMode.removeModeChangeListener(listener));
|
||||
assertTrue("Navigation mode didn't change to " + expectedMode,
|
||||
currentSysUiNavigationMode() == expectedMode);
|
||||
}
|
||||
|
||||
Wait.atMost("Couldn't switch to " + overlayPackage,
|
||||
() -> mLauncher.getNavigationModel() == expectedMode, WAIT_TIME_MS,
|
||||
mLauncher);
|
||||
|
||||
Wait.atMost(() -> "Switching nav mode: "
|
||||
+ mLauncher.getNavigationModeMismatchError(),
|
||||
() -> mLauncher.getNavigationModeMismatchError() == null, WAIT_TIME_MS,
|
||||
mLauncher);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setOverlayPackageEnabled(String overlayPackage, boolean enable)
|
||||
throws Exception {
|
||||
Log.d(TAG, "setOverlayPackageEnabled: " + overlayPackage + " " + enable);
|
||||
final String action = enable ? "enable" : "disable";
|
||||
UiDevice.getInstance(getInstrumentation()).executeShellCommand(
|
||||
"cmd overlay " + action + " " + overlayPackage);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCurrentOverlayPackage(int currentInteractionMode) {
|
||||
return QuickStepContract.isGesturalMode(currentInteractionMode)
|
||||
? NAV_BAR_MODE_GESTURAL_OVERLAY
|
||||
: QuickStepContract.isSwipeUpMode(currentInteractionMode)
|
||||
? NAV_BAR_MODE_2BUTTON_OVERLAY
|
||||
: NAV_BAR_MODE_3BUTTON_OVERLAY;
|
||||
}
|
||||
|
||||
private static LauncherInstrumentation.NavigationModel currentSysUiNavigationMode() {
|
||||
return LauncherInstrumentation.getNavigationModel(
|
||||
SysUINavigationMode.getMode(
|
||||
@@ -230,4 +157,85 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
getTargetContext()).
|
||||
resValue);
|
||||
}
|
||||
|
||||
public static boolean setActiveOverlay(LauncherInstrumentation launcher, String overlayPackage,
|
||||
LauncherInstrumentation.NavigationModel expectedMode, Description description)
|
||||
throws Exception {
|
||||
if (!packageExists(overlayPackage)) {
|
||||
Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
setOverlayPackageEnabled(NAV_BAR_MODE_3BUTTON_OVERLAY,
|
||||
overlayPackage == NAV_BAR_MODE_3BUTTON_OVERLAY);
|
||||
setOverlayPackageEnabled(NAV_BAR_MODE_2BUTTON_OVERLAY,
|
||||
overlayPackage == NAV_BAR_MODE_2BUTTON_OVERLAY);
|
||||
setOverlayPackageEnabled(NAV_BAR_MODE_GESTURAL_OVERLAY,
|
||||
overlayPackage == NAV_BAR_MODE_GESTURAL_OVERLAY);
|
||||
|
||||
if (currentSysUiNavigationMode() != expectedMode) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final Context targetContext = getInstrumentation().getTargetContext();
|
||||
final SysUINavigationMode.NavigationModeChangeListener listener =
|
||||
newMode -> {
|
||||
if (LauncherInstrumentation.getNavigationModel(newMode.resValue)
|
||||
== expectedMode) {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
targetContext.getMainExecutor().execute(() ->
|
||||
SYS_UI_NAVIGATION_MODE.addModeChangeListener(listener));
|
||||
latch.await(60, TimeUnit.SECONDS);
|
||||
targetContext.getMainExecutor().execute(() ->
|
||||
SYS_UI_NAVIGATION_MODE.removeModeChangeListener(listener));
|
||||
assertTrue(launcher, "Navigation mode didn't change to " + expectedMode,
|
||||
currentSysUiNavigationMode() == expectedMode, description);
|
||||
}
|
||||
|
||||
Wait.atMost("Couldn't switch to " + overlayPackage,
|
||||
() -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
|
||||
|
||||
Wait.atMost(() -> "Switching nav mode: "
|
||||
+ launcher.getNavigationModeMismatchError(),
|
||||
() -> launcher.getNavigationModeMismatchError() == null, WAIT_TIME_MS, launcher);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void setOverlayPackageEnabled(String overlayPackage, boolean enable)
|
||||
throws Exception {
|
||||
Log.d(TAG, "setOverlayPackageEnabled: " + overlayPackage + " " + enable);
|
||||
final String action = enable ? "enable" : "disable";
|
||||
UiDevice.getInstance(getInstrumentation()).executeShellCommand(
|
||||
"cmd overlay " + action + " " + overlayPackage);
|
||||
}
|
||||
|
||||
private static boolean packageExists(String packageName) {
|
||||
try {
|
||||
PackageManager pm = getInstrumentation().getContext().getPackageManager();
|
||||
if (pm.getApplicationInfo(packageName, 0 /* flags */) == null) {
|
||||
return false;
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void assertTrue(LauncherInstrumentation launcher, String message,
|
||||
boolean condition, Description description) {
|
||||
if (launcher.getDevice().hasObject(By.textStartsWith(""))) {
|
||||
// The condition above is "screen is not empty". We are not treating
|
||||
// "Screen is empty" as an anomaly here. It's an acceptable state when
|
||||
// Launcher just starts under instrumentation.
|
||||
launcher.checkForAnomaly();
|
||||
}
|
||||
if (!condition) {
|
||||
final AssertionError assertionError = new AssertionError(message);
|
||||
if (description != null) {
|
||||
FailureWatcher.onError(launcher.getDevice(), description, assertionError);
|
||||
}
|
||||
throw assertionError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,6 @@ package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.util.RaceConditionReproducer.enterEvt;
|
||||
import static com.android.launcher3.util.RaceConditionReproducer.exitEvt;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_PRESUBMIT;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.RUN_FLAFOR;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.UNBUNDLED_PRESUBMIT;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.UNBUNDLED_POSTSUBMIT;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -40,6 +42,7 @@ import com.android.launcher3.tapl.Overview;
|
||||
import com.android.launcher3.tapl.OverviewTask;
|
||||
import com.android.launcher3.tapl.TestHelpers;
|
||||
import com.android.launcher3.ui.TaplTestsLauncher3;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
@@ -56,6 +59,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mLauncherPid = 0;
|
||||
super.setUp();
|
||||
TaplTestsLauncher3.initialize(this);
|
||||
mLauncherPid = mLauncher.getPid();
|
||||
@@ -63,7 +67,9 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
assertEquals("Launcher crashed, pid mismatch:", mLauncherPid, mLauncher.getPid());
|
||||
if (mLauncherPid != 0) {
|
||||
assertEquals("Launcher crashed, pid mismatch:", mLauncherPid, mLauncher.getPid());
|
||||
}
|
||||
}
|
||||
|
||||
private void startTestApps() throws Exception {
|
||||
@@ -82,7 +88,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
@Ignore // Enable after b/131115533
|
||||
public void testPressRecentAppsLauncherAndGetOverview() throws RemoteException {
|
||||
mDevice.pressRecentApps();
|
||||
waitForState("Launcher internal state didn't switch to Overview", LauncherState.OVERVIEW);
|
||||
waitForState("Launcher internal state didn't switch to Overview",
|
||||
() -> LauncherState.OVERVIEW);
|
||||
|
||||
assertNotNull("getOverview() returned null", mLauncher.getOverview());
|
||||
}
|
||||
@@ -93,7 +100,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
public void testWorkspaceSwitchToAllApps() {
|
||||
assertNotNull("switchToAllApps() returned null",
|
||||
mLauncher.getWorkspace().switchToAllApps());
|
||||
assertTrue("Launcher internal state is not All Apps", isInState(LauncherState.ALL_APPS));
|
||||
assertTrue("Launcher internal state is not All Apps",
|
||||
isInState(() -> LauncherState.ALL_APPS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,7 +120,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
// mLauncher.pressHome() also tests an important case of pressing home while in background.
|
||||
Overview overview = mLauncher.pressHome().switchToOverview();
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(LauncherState.OVERVIEW));
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(
|
||||
launcher -> assertTrue("Don't have at least 3 tasks", getTaskCount(launcher) >= 3));
|
||||
|
||||
@@ -121,14 +129,16 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
0, getCurrentOverviewPage(launcher)));
|
||||
|
||||
overview.flingForward();
|
||||
assertTrue("Launcher internal state is not Overview", isInState(LauncherState.OVERVIEW));
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
final Integer currentTaskAfterFlingForward = getFromLauncher(
|
||||
launcher -> getCurrentOverviewPage(launcher));
|
||||
executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0",
|
||||
currentTaskAfterFlingForward > 0));
|
||||
|
||||
overview.flingBackward();
|
||||
assertTrue("Launcher internal state is not Overview", isInState(LauncherState.OVERVIEW));
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(launcher -> assertTrue("Flinging back in Overview did nothing",
|
||||
getCurrentOverviewPage(launcher) < currentTaskAfterFlingForward));
|
||||
|
||||
@@ -147,7 +157,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
// Test dismissing a task.
|
||||
overview = mLauncher.pressHome().switchToOverview();
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(LauncherState.OVERVIEW));
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
final Integer numTasks = getFromLauncher(launcher -> getTaskCount(launcher));
|
||||
task = overview.getCurrentTask();
|
||||
assertNotNull("overview.getCurrentTask() returned null (2)", task);
|
||||
@@ -162,29 +172,29 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
final AllAppsFromOverview allApps = overview.switchToAllApps();
|
||||
assertNotNull("overview.switchToAllApps() returned null (1)", allApps);
|
||||
assertTrue("Launcher internal state is not All Apps (1)",
|
||||
isInState(LauncherState.ALL_APPS));
|
||||
isInState(() -> LauncherState.ALL_APPS));
|
||||
|
||||
overview = allApps.switchBackToOverview();
|
||||
assertNotNull("allApps.switchBackToOverview() returned null", overview);
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(LauncherState.OVERVIEW));
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
|
||||
// Test UIDevice.pressBack()
|
||||
overview.switchToAllApps();
|
||||
assertNotNull("overview.switchToAllApps() returned null (2)", allApps);
|
||||
assertTrue("Launcher internal state is not All Apps (2)",
|
||||
isInState(LauncherState.ALL_APPS));
|
||||
isInState(() -> LauncherState.ALL_APPS));
|
||||
mDevice.pressBack();
|
||||
mLauncher.getOverview();
|
||||
}
|
||||
|
||||
// Test UIDevice.pressHome, once we are in AllApps.
|
||||
mDevice.pressHome();
|
||||
waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
|
||||
waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
|
||||
|
||||
// Test dismissing all tasks.
|
||||
mLauncher.getWorkspace().switchToOverview().dismissAllTasks();
|
||||
waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
|
||||
waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
|
||||
executeOnLauncher(
|
||||
launcher -> assertEquals("Still have tasks after dismissing all",
|
||||
0, getTaskCount(launcher)));
|
||||
@@ -202,7 +212,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
public void testAppIconLaunchFromAllAppsFromOverview() throws Exception {
|
||||
final AllApps allApps =
|
||||
mLauncher.getWorkspace().switchToOverview().switchToAllApps();
|
||||
assertTrue("Launcher internal state is not All Apps", isInState(LauncherState.ALL_APPS));
|
||||
assertTrue("Launcher internal state is not All Apps",
|
||||
isInState(() -> LauncherState.ALL_APPS));
|
||||
|
||||
TaplTestsLauncher3.runIconLaunchFromAllAppsTest(this, allApps);
|
||||
}
|
||||
@@ -214,7 +225,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
assertNotNull("Workspace.switchToOverview() returned null",
|
||||
mLauncher.pressHome().switchToOverview());
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(LauncherState.OVERVIEW));
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -226,7 +237,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
assertNotNull("Background.switchToOverview() returned null", background.switchToOverview());
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(LauncherState.OVERVIEW));
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
}
|
||||
|
||||
private Background getAndAssertBackground() {
|
||||
@@ -249,16 +260,21 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
TaplTestsLauncher3.runAllAppsTest(this, mLauncher.getAllApps());
|
||||
|
||||
// Testing pressHome.
|
||||
assertTrue("Launcher internal state is not All Apps", isInState(LauncherState.ALL_APPS));
|
||||
assertTrue("Launcher internal state is not All Apps",
|
||||
isInState(() -> LauncherState.ALL_APPS));
|
||||
assertNotNull("pressHome returned null", mLauncher.pressHome());
|
||||
assertTrue("Launcher internal state is not Home", isInState(LauncherState.NORMAL));
|
||||
assertTrue("Launcher internal state is not Home",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
assertNotNull("getHome returned null", mLauncher.getWorkspace());
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch
|
||||
@PortraitLandscape
|
||||
@Ignore // b/143285809
|
||||
// b/143285809 Remove @Stability on 02/21/20 if the test doesn't flake.
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | UNBUNDLED_POSTSUBMIT)
|
||||
// b/143285809
|
||||
@Ignore
|
||||
public void testQuickSwitchFromApp() throws Exception {
|
||||
startTestActivity(2);
|
||||
startTestActivity(3);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 41 KiB |
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2020, 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.
|
||||
*/
|
||||
-->
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="oval" >
|
||||
<solid android:color="#ffffffff" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<shape android:shape="oval" >
|
||||
<solid android:color="?android:attr/colorAccent" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
+1
-1
@@ -15,5 +15,5 @@
|
||||
-->
|
||||
<vector android:height="15.53398dp" android:viewportHeight="32"
|
||||
android:viewportWidth="412" android:width="200dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/hotseat_edu_background" android:pathData="M412,32v-2.64C349.26,10.51 279.5,0 206,0S62.74,10.51 0,29.36V32H412z"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M412,32v-2.64C349.26,10.51 279.5,0 206,0S62.74,10.51 0,29.36V32H412z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2018 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M4,8h4L8,4L4,4v4zM10,20h4v-4h-4v4zM4,20h4v-4L4,16v4zM4,14h4v-4L4,10v4zM10,14h4v-4h-4v4zM16,4v4h4L20,4h-4zM10,8h4L14,4h-4v4zM16,14h4v-4h-4v4zM16,20h4v-4h-4v4z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0"
|
||||
android:tint="?android:attr/textColorPrimary">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,2C6.48,2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M4,12c0-4.42,3.58-8,8-8c1.85,0,3.55,0.63,4.9,1.69
|
||||
L5.69,16.9C4.63,15.55,4,13.85,4,12z M12,20c-1.85,0-3.55-0.63-4.9-1.69L18.31,7.1C19.37,8.45,20,10.15,20,12
|
||||
C20,16.42,16.42,20,12,20z" />
|
||||
</vector>
|
||||
@@ -19,9 +19,5 @@
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?android:attr/textColorHint" >
|
||||
<path
|
||||
android:pathData="M20 6h-4V4c0-1.11-0.89-2-2-2h-4c-1.11 0-2 0.89-2 2v2H4c-1.11 0-1.99 0.89 -1.99
|
||||
2L2 19c0 1.11 0.89 2 2 2h16c1.11 0 2-0.89 2-2V8c0-1.11-0.89-2-2-2zM10
|
||||
4h4v2h-4V4zm10 15H4V8h16v11z"
|
||||
android:fillColor="@android:color/white"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20 6h-4V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-8 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm2-9h-4V4h4v2z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?android:attr/textColorHint" >
|
||||
<path
|
||||
android:pathData="M22 7.95c.05-1.11-.84-2-1.95-1.95H16V3.95c0-1.11-.84-2-1.95-1.95h-4C8.94 1.95 8 2.84 8 3.95v.32l14 14V7.95zM14 6h-4V4h4v2zm7.54 14.28l-7.56-7.56v.01l-1.7-1.7h.01L7.21 5.95 3.25 1.99 1.99 3.27 4.69 6h-.64c-1.11 0-1.99.86-1.99 1.97l-.01 11.02c0 1.11.89 2.01 2 2.01h15.64l2.05 2.02L23 21.75l-1.46-1.47z"
|
||||
android:fillColor="@android:color/white"/>
|
||||
</vector>
|
||||
File renamed without changes.
@@ -16,7 +16,7 @@
|
||||
<!-- The top and bottom paddings are defined in this container, but since we want
|
||||
the list view to span the full width (for touch interception purposes), we
|
||||
will bake the left/right padding into that view's background itself. -->
|
||||
<com.android.launcher3.allapps.AllAppsContainerView
|
||||
<com.android.launcher3.allapps.LauncherAllAppsContainerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/apps_view"
|
||||
android:layout_width="match_parent"
|
||||
@@ -57,7 +57,6 @@
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="@string/all_apps_personal_tab"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/all_apps_tab_text"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -68,7 +67,6 @@
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="@string/all_apps_work_tab"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/all_apps_tab_text"
|
||||
android:textSize="14sp" />
|
||||
</com.android.launcher3.allapps.PersonalWorkSlidingTabStrip>
|
||||
@@ -79,4 +77,4 @@
|
||||
layout="@layout/search_container_all_apps"/>
|
||||
|
||||
<include layout="@layout/all_apps_fast_scroller" />
|
||||
</com.android.launcher3.allapps.AllAppsContainerView>
|
||||
</com.android.launcher3.allapps.LauncherAllAppsContainerView>
|
||||
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.android.launcher3.secondarydisplay.SecondaryDragLayer
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/drag_layer" >
|
||||
|
||||
<GridView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="100dp"
|
||||
android:theme="@style/HomeScreenElementTheme"
|
||||
android:layout_gravity="center_horizontal|top"
|
||||
android:layout_margin="@dimen/dynamic_grid_edge_margin"
|
||||
android:id="@+id/workspace_grid" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/all_apps_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="40dp"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_apps"
|
||||
android:background="@drawable/bg_all_apps_button"
|
||||
android:contentDescription="@string/all_apps_button_label"
|
||||
android:onClick="onAppsButtonClicked" />
|
||||
|
||||
<com.android.launcher3.allapps.AllAppsContainerView
|
||||
android:id="@+id/apps_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="true"
|
||||
android:clipToPadding="false"
|
||||
android:focusable="false"
|
||||
android:saveEnabled="false"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:background="@drawable/round_rect_primary"
|
||||
android:elevation="2dp"
|
||||
android:visibility="invisible" >
|
||||
|
||||
<include
|
||||
layout="@layout/all_apps_rv_layout"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.android.launcher3.allapps.FloatingHeaderView
|
||||
android:id="@+id/all_apps_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/search_container_all_apps"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="@dimen/all_apps_header_top_padding"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<com.android.launcher3.allapps.PersonalWorkSlidingTabStrip
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/all_apps_header_tab_height"
|
||||
android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
|
||||
android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
|
||||
android:orientation="horizontal"
|
||||
style="@style/TextHeadline">
|
||||
|
||||
<Button
|
||||
android:id="@+id/tab_personal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="@string/all_apps_personal_tab"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/all_apps_tab_text"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/tab_work"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="@string/all_apps_work_tab"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/all_apps_tab_text"
|
||||
android:textSize="14sp" />
|
||||
</com.android.launcher3.allapps.PersonalWorkSlidingTabStrip>
|
||||
</com.android.launcher3.allapps.FloatingHeaderView>
|
||||
|
||||
<com.android.launcher3.allapps.search.AppsSearchContainerLayout
|
||||
android:id="@id/search_container_all_apps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/all_apps_search_bar_field_height"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
android:background="@drawable/bg_all_apps_searchbox"
|
||||
android:elevation="1dp"
|
||||
android:focusableInTouchMode="true"
|
||||
android:gravity="center"
|
||||
android:hint="@string/all_apps_search_bar_hint"
|
||||
android:imeOptions="actionSearch|flagNoExtractUi"
|
||||
android:inputType="text|textNoSuggestions|textCapWords"
|
||||
android:maxLines="1"
|
||||
android:padding="8dp"
|
||||
android:saveEnabled="false"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textColorHint="@drawable/all_apps_search_hint"
|
||||
android:textSize="16sp"
|
||||
android:translationY="24dp" />
|
||||
|
||||
<include layout="@layout/all_apps_fast_scroller" />
|
||||
</com.android.launcher3.allapps.AllAppsContainerView>
|
||||
</com.android.launcher3.secondarydisplay.SecondaryDragLayer>
|
||||
@@ -41,7 +41,7 @@
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="12dp" >
|
||||
|
||||
<com.android.launcher3.ExtendedEditText
|
||||
<com.android.launcher3.folder.FolderNameEditText
|
||||
android:id="@+id/folder_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2020 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.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="8dp"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/allAppsScrimColor"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:contentDescription="@string/work_apps_paused_title"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:tint="?attr/folderTextColor"
|
||||
android:src="@drawable/ic_corp_off" />
|
||||
|
||||
<TextView
|
||||
style="@style/TextHeadline"
|
||||
android:textColor="?attr/folderTextColor"
|
||||
android:id="@+id/work_apps_paused_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/work_apps_paused_title"
|
||||
android:textAlignment="center"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/folderTextColor"
|
||||
android:text="@string/work_apps_paused_body"
|
||||
android:textAlignment="center"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.android.launcher3.views.WorkEduView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:backgroundTint="@color/bottom_panel_background"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/bottom_sheet_top_border" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/bottom_panel_background"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/bottom_sheet_edu_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_edu_padding">
|
||||
|
||||
<TextView
|
||||
style="@style/TextHeadline"
|
||||
android:id="@+id/content_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_marginBottom="48dp"
|
||||
android:text="@string/work_profile_edu_personal_apps"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/proceed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="end"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:text="@string/work_profile_edu_next"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@android:color/white" />
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.launcher3.views.WorkEduView>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.android.launcher3.views.BottomUserEducationView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?android:attr/colorAccent"
|
||||
android:elevation="2dp"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="134dp"
|
||||
android:layout_height="134dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:src="@drawable/work_tab_user_education"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_bottom_user_tip"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_gravity="right"
|
||||
android:contentDescription="@string/bottom_work_tab_user_education_close_button"
|
||||
android:src="@drawable/ic_remove_no_shadow"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:fontFamily="roboto-medium"
|
||||
android:text="@string/bottom_work_tab_user_education_title"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:text="@string/bottom_work_tab_user_education_body"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.launcher3.views.BottomUserEducationView>
|
||||
@@ -17,63 +17,31 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/work_toggle_container"
|
||||
android:focusable="true"
|
||||
android:paddingBottom="@dimen/all_apps_work_profile_tab_footer_bottom_padding"
|
||||
android:paddingLeft="@dimen/dynamic_grid_cell_padding_x"
|
||||
android:paddingRight="@dimen/dynamic_grid_cell_padding_x"
|
||||
android:paddingTop="@dimen/all_apps_work_profile_tab_footer_top_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/work_footer_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:importantForAccessibility="no"
|
||||
android:paddingBottom="@dimen/all_apps_divider_margin_vertical"
|
||||
android:paddingTop="@dimen/all_apps_divider_margin_vertical"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/all_apps_divider"/>
|
||||
|
||||
<com.android.launcher3.allapps.WorkModeSwitch
|
||||
android:id="@+id/work_mode_toggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@id/work_footer_divider"/>
|
||||
android:paddingBottom="@dimen/all_apps_work_profile_tab_footer_padding_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/all_apps_work_profile_tab_footer_padding_horizontal"
|
||||
android:background="?attr/allAppsScrimColor"
|
||||
android:paddingRight="@dimen/all_apps_work_profile_tab_footer_padding_horizontal"
|
||||
android:paddingTop="@dimen/all_apps_work_profile_tab_footer_padding_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/work_mode_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableStart="@drawable/ic_corp"
|
||||
android:drawablePadding="3dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/work_mode_toggle"
|
||||
android:layout_alignParentStart="true"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:text="@string/work_profile_toggle_label"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@drawable/ic_corp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/managed_by_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_toEndOf="@android:id/icon"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:minHeight="24dp"
|
||||
android:paddingStart="12dp"
|
||||
android:textColor="?android:attr/textColorHint"
|
||||
android:textSize="13sp"/>
|
||||
android:paddingEnd="12dp"
|
||||
android:textSize="16sp"/>
|
||||
<com.android.launcher3.allapps.WorkModeSwitch
|
||||
android:id="@+id/work_mode_toggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</com.android.launcher3.views.WorkFooterContainer>
|
||||
@@ -43,4 +43,7 @@
|
||||
<color name="back_gesture_tutorial_title_color">#FF000000</color>
|
||||
<color name="back_gesture_tutorial_action_button_label_color">#FFFFFFFF</color>
|
||||
<color name="back_gesture_tutorial_primary_color">#1A73E8</color> <!-- Blue -->
|
||||
|
||||
|
||||
<color name="bottom_panel_background">#f01A73E8</color>
|
||||
</resources>
|
||||
@@ -63,6 +63,7 @@
|
||||
<!-- Various classes overriden by projects/build flavors. -->
|
||||
<string name="app_filter_class" translatable="false"></string>
|
||||
<string name="user_event_dispatcher_class" translatable="false"></string>
|
||||
<string name="folder_name_provider_class" translatable="false"></string>
|
||||
<string name="stats_log_manager_class" translatable="false"></string>
|
||||
<string name="app_transition_manager_class" translatable="false"></string>
|
||||
<string name="instant_app_resolver_class" translatable="false"></string>
|
||||
@@ -107,6 +108,7 @@
|
||||
<item type="id" name="action_shortcuts_and_notifications"/>
|
||||
<item type="id" name="action_dismiss_notification" />
|
||||
<item type="id" name="action_remote_action_shortcut" />
|
||||
<item type="id" name="action_dismiss_prediction" />
|
||||
|
||||
<!-- QSB IDs. DO not change -->
|
||||
<item type="id" name="search_container_workspace" />
|
||||
|
||||
@@ -85,6 +85,9 @@
|
||||
<dimen name="all_apps_tabs_side_padding">12dp</dimen>
|
||||
<dimen name="all_apps_divider_height">1dp</dimen>
|
||||
|
||||
<dimen name="all_apps_work_profile_tab_footer_padding_vertical">20dp</dimen>
|
||||
<dimen name="all_apps_work_profile_tab_footer_padding_horizontal">24dp</dimen>
|
||||
|
||||
<!-- Search bar in All Apps -->
|
||||
<dimen name="all_apps_header_max_elevation">3dp</dimen>
|
||||
<dimen name="all_apps_header_scroll_to_elevation">16dp</dimen>
|
||||
@@ -235,4 +238,7 @@
|
||||
<!-- Theming related -->
|
||||
<dimen name="default_dialog_corner_radius">8dp</dimen>
|
||||
|
||||
<!-- Onboarding bottomsheet related -->
|
||||
<dimen name="bottom_sheet_edu_padding">24dp</dimen>
|
||||
|
||||
</resources>
|
||||
+14
-8
@@ -327,17 +327,23 @@
|
||||
|
||||
<!-- This string is in the work profile tab when a user has All Apps open on their phone. This is a label for a toggle to turn the work profile on and off. "Work profile" means a separate profile on a user's phone that's specifically for their work apps and managed by their company. "Work" is used as an adjective.-->
|
||||
<string name="work_profile_toggle_label">Work profile</string>
|
||||
<!-- Title of an overlay in All Apps. This overlay is letting a user know about their work profile, which is managed by their employer. "Work apps" are apps in a user's work profile.-->
|
||||
<string name="bottom_work_tab_user_education_title">Find work apps here</string>
|
||||
<!-- Text in an overlay in All Apps. This overlay is letting a user know about their work profile, which is managed by their employer.-->
|
||||
<string name="bottom_work_tab_user_education_body">Each work app has a badge and is kept secure by your organization. Move apps to your Home screen for easier access.</string>
|
||||
<!--- User onboarding title for personal apps -->
|
||||
<string name="work_profile_edu_personal_apps">Personal apps are private & can\'t be seen by IT</string>
|
||||
<!--- User onboarding title for work profile apps -->
|
||||
<string name="work_profile_edu_work_apps">Work apps are badged and monitored by IT</string>
|
||||
<!-- Action label to proceed to the next work profile edu section-->
|
||||
<string name="work_profile_edu_next">Next</string>
|
||||
<!-- Action label to finish work profile edu-->
|
||||
<string name="work_profile_edu_accept">Got it</string>
|
||||
|
||||
<!-- This string is in the work profile tab when a user has All Apps open on their phone. It describes the label of a toggle, "Work profile," as being managed by the user's employer.
|
||||
"Organization" is used to represent a variety of businesses, non-profits, and educational institutions).-->
|
||||
<string name="work_mode_on_label">Managed by your organization</string>
|
||||
<string name="work_mode_on_label">Work apps: On</string>
|
||||
<!-- This string appears under a the label of a toggle in the work profile tab on a user's phone. It describes the status of the toggle, "Work profile," when it's turned off. "Work profile" means a separate profile on a user's phone that's speficially for their work apps and is managed by their company.-->
|
||||
<string name="work_mode_off_label">Notifications and apps are off</string>
|
||||
<string name="bottom_work_tab_user_education_close_button">Close</string>
|
||||
<string name="bottom_work_tab_user_education_closed">Closed</string>
|
||||
<string name="work_mode_off_label">Work apps: Paused</string>
|
||||
|
||||
<string name="work_apps_paused_title">Work apps are paused</string>
|
||||
<string name="work_apps_paused_body">You won\'t get any work notifications, and your IT admin can\'t see your location</string>
|
||||
|
||||
<!-- Failed action error message: e.g. Failed: Pause -->
|
||||
<string name="remote_action_failed">Failed: <xliff:g id="what" example="Pause">%1$s</xliff:g></string>
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">#00000000</item>
|
||||
<item name="android:navigationBarColor">#00000000</item>
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<style name="LauncherTheme.DarkMainColor" parent="@style/LauncherTheme">
|
||||
|
||||
@@ -29,7 +29,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
mockito-robolectric-prebuilt \
|
||||
truth-prebuilt
|
||||
LOCAL_JAVA_LIBRARIES := \
|
||||
platform-robolectric-4.3-prebuilt
|
||||
platform-robolectric-4.3.1-prebuilt
|
||||
|
||||
LOCAL_JAVA_RESOURCE_DIRS := resources config
|
||||
|
||||
@@ -56,4 +56,4 @@ LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src
|
||||
|
||||
LOCAL_ROBOTEST_TIMEOUT := 36000
|
||||
|
||||
include prebuilts/misc/common/robolectric/4.3/run_robotests.mk
|
||||
include prebuilts/misc/common/robolectric/4.3.1/run_robotests.mk
|
||||
@@ -1 +1 @@
|
||||
sdk=28
|
||||
sdk=29
|
||||
@@ -16,14 +16,32 @@
|
||||
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_RESTORE;
|
||||
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.BACKUP_TABLE_NAME;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.addTableToDb;
|
||||
import static com.android.launcher3.provider.LauncherDbUtils.dropTable;
|
||||
import static com.android.launcher3.provider.LauncherDbUtils.tableExists;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.APP_ICON;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.NO__ICON;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.SHORTCUT;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.robolectric.util.ReflectionHelpers.setField;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.provider.RestoreDbTask;
|
||||
import com.android.launcher3.shadows.LShadowBackupManager;
|
||||
import com.android.launcher3.shadows.LShadowUserManager;
|
||||
import com.android.launcher3.util.LauncherModelHelper;
|
||||
import com.android.launcher3.util.LauncherRoboTestRunner;
|
||||
|
||||
@@ -32,6 +50,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.LooperMode;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
|
||||
/**
|
||||
* Tests to verify backup and restore flow.
|
||||
@@ -40,18 +59,123 @@ import org.robolectric.annotation.LooperMode;
|
||||
@LooperMode(LooperMode.Mode.PAUSED)
|
||||
public class BackupRestoreTest {
|
||||
|
||||
private static final long MY_OLD_PROFILE_ID = 1;
|
||||
private static final long MY_PROFILE_ID = 0;
|
||||
private static final long OLD_WORK_PROFILE_ID = 11;
|
||||
private static final int WORK_PROFILE_ID = 10;
|
||||
|
||||
private static final int SYSTEM_USER = 0;
|
||||
private static final int FLAG_SYSTEM = 0x00000800;
|
||||
private static final int FLAG_PROFILE = 0x00001000;
|
||||
|
||||
private LShadowUserManager mUserManager;
|
||||
private BackupManager mBackupManager;
|
||||
private LauncherModelHelper mModelHelper;
|
||||
private SQLiteDatabase mDb;
|
||||
private InvariantDeviceProfile mIdp;
|
||||
private UserHandle mMainProfileUser;
|
||||
private UserHandle mWorkProfileUser;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
setupUserManager();
|
||||
setupBackupManager();
|
||||
mModelHelper = new LauncherModelHelper();
|
||||
RestoreDbTask.setPending(RuntimeEnvironment.application, true);
|
||||
mDb = mModelHelper.provider.getDb();
|
||||
mIdp = InvariantDeviceProfile.INSTANCE.get(RuntimeEnvironment.application);
|
||||
}
|
||||
|
||||
private void setupUserManager() {
|
||||
final UserManager userManager = RuntimeEnvironment.application.getSystemService(
|
||||
UserManager.class);
|
||||
mUserManager = Shadow.extract(userManager);
|
||||
// sign in to primary user
|
||||
mMainProfileUser = mUserManager.addUser(SYSTEM_USER, "me", FLAG_SYSTEM);
|
||||
// sign in to work profile
|
||||
mWorkProfileUser = mUserManager.addUser(WORK_PROFILE_ID, "work", FLAG_PROFILE);
|
||||
}
|
||||
|
||||
private void setupBackupManager() {
|
||||
mBackupManager = new BackupManager(RuntimeEnvironment.application);
|
||||
final LShadowBackupManager bm = Shadow.extract(mBackupManager);
|
||||
bm.addProfile(MY_OLD_PROFILE_ID, mMainProfileUser);
|
||||
bm.addProfile(OLD_WORK_PROFILE_ID, mWorkProfileUser);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnCreateDbIfNotExists_CreatesBackup() {
|
||||
assertTrue(tableExists(mDb, BACKUP_TABLE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnRestoreSessionWithValidCondition_PerformsRestore() throws Exception {
|
||||
setupBackup();
|
||||
verifyTableIsFilled(BACKUP_TABLE_NAME, false);
|
||||
verifyTableIsEmpty(TABLE_NAME);
|
||||
createRestoreSession();
|
||||
verifyTableIsFilled(TABLE_NAME, true);
|
||||
}
|
||||
|
||||
private void setupBackup() {
|
||||
createTableUsingOldProfileId();
|
||||
// setup grid for main user on first screen
|
||||
mModelHelper.createGrid(new int[][][]{{
|
||||
{ APP_ICON, APP_ICON, SHORTCUT, SHORTCUT},
|
||||
{ SHORTCUT, SHORTCUT, NO__ICON, NO__ICON},
|
||||
{ NO__ICON, NO__ICON, SHORTCUT, SHORTCUT},
|
||||
{ APP_ICON, SHORTCUT, SHORTCUT, APP_ICON},
|
||||
}}, 1, MY_OLD_PROFILE_ID);
|
||||
// setup grid for work profile on second screen
|
||||
mModelHelper.createGrid(new int[][][]{{
|
||||
{ NO__ICON, APP_ICON, SHORTCUT, SHORTCUT},
|
||||
{ SHORTCUT, SHORTCUT, NO__ICON, NO__ICON},
|
||||
{ NO__ICON, NO__ICON, SHORTCUT, SHORTCUT},
|
||||
{ APP_ICON, SHORTCUT, SHORTCUT, NO__ICON},
|
||||
}}, 2, OLD_WORK_PROFILE_ID);
|
||||
// simulates the creation of backup upon restore
|
||||
new GridBackupTable(RuntimeEnvironment.application, mDb, mIdp.numHotseatIcons,
|
||||
mIdp.numColumns, mIdp.numRows).doBackup(
|
||||
MY_OLD_PROFILE_ID, GridBackupTable.OPTION_REQUIRES_SANITIZATION);
|
||||
// reset favorites table
|
||||
createTableUsingOldProfileId();
|
||||
}
|
||||
|
||||
private void verifyTableIsEmpty(String tableName) {
|
||||
assertEquals(0, getCount(mDb, "SELECT * FROM " + tableName));
|
||||
}
|
||||
|
||||
private void verifyTableIsFilled(String tableName, boolean sanitized) {
|
||||
assertEquals(sanitized ? 12 : 13, getCount(mDb,
|
||||
"SELECT * FROM " + tableName + " WHERE profileId = "
|
||||
+ (sanitized ? MY_PROFILE_ID : MY_OLD_PROFILE_ID)));
|
||||
assertEquals(10, getCount(mDb, "SELECT * FROM " + tableName + " WHERE profileId = "
|
||||
+ (sanitized ? WORK_PROFILE_ID : OLD_WORK_PROFILE_ID)));
|
||||
}
|
||||
|
||||
private void createTableUsingOldProfileId() {
|
||||
// simulates the creation of favorites table on old device
|
||||
dropTable(mDb, TABLE_NAME);
|
||||
addTableToDb(mDb, MY_OLD_PROFILE_ID, false);
|
||||
}
|
||||
|
||||
private void createRestoreSession() throws Exception {
|
||||
final PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(
|
||||
PackageInstaller.SessionParams.MODE_FULL_INSTALL);
|
||||
final PackageInstaller installer = RuntimeEnvironment.application.getPackageManager()
|
||||
.getPackageInstaller();
|
||||
final int sessionId = installer.createSession(params);
|
||||
final PackageInstaller.SessionInfo info = installer.getSessionInfo(sessionId);
|
||||
setField(info, "installReason", INSTALL_REASON_DEVICE_RESTORE);
|
||||
// TODO: (b/148410677) we should verify the following call instead
|
||||
// InstallSessionHelper.INSTANCE.get(getContext()).restoreDbIfApplicable(info);
|
||||
RestoreDbTask.restoreIfPossible(RuntimeEnvironment.application,
|
||||
mModelHelper.provider.getHelper(), mBackupManager);
|
||||
}
|
||||
|
||||
private static int getCount(SQLiteDatabase db, String sql) {
|
||||
try (Cursor c = db.rawQuery(sql, null)) {
|
||||
return c.getCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.shadows;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.os.UserHandle;
|
||||
import android.util.LongSparseArray;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.shadows.ShadowBackupManager;
|
||||
|
||||
/**
|
||||
* Extension of {@link ShadowBackupManager} with missing shadow methods
|
||||
*/
|
||||
@Implements(value = BackupManager.class)
|
||||
public class LShadowBackupManager extends ShadowBackupManager {
|
||||
|
||||
private LongSparseArray<UserHandle> mProfileMapping = new LongSparseArray<>();
|
||||
|
||||
public void addProfile(long userSerial, UserHandle userHandle) {
|
||||
mProfileMapping.put(userSerial, userHandle);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
@Nullable
|
||||
public UserHandle getUserForAncestralSerialNumber(long ancestralSerialNumber) {
|
||||
return mProfileMapping.get(ancestralSerialNumber);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
@@ -43,6 +44,7 @@ import org.robolectric.shadows.ShadowLauncherApps;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -111,6 +113,17 @@ public class LShadowLauncherApps extends ShadowLauncherApps {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public List<PackageInstaller.SessionInfo> getAllPackageInstallerSessions() {
|
||||
return RuntimeEnvironment.application.getPackageManager().getPackageInstaller()
|
||||
.getAllSessions();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void registerPackageInstallerSessionCallback(
|
||||
Executor executor, PackageInstaller.SessionCallback callback) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<LauncherActivityInfo> getShortcutConfigActivityList(String packageName,
|
||||
UserHandle user) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTENT_URI;
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
@@ -30,6 +31,7 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.net.Uri;
|
||||
import android.os.Process;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.launcher3.AppInfo;
|
||||
@@ -42,6 +44,7 @@ import com.android.launcher3.LauncherProvider;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.model.AllAppsList;
|
||||
import com.android.launcher3.model.BgDataModel;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.robolectric.Robolectric;
|
||||
@@ -80,15 +83,17 @@ public class LauncherModelHelper {
|
||||
private static final int DEFAULT_BITMAP_SIZE = 10;
|
||||
private static final int DEFAULT_GRID_SIZE = 4;
|
||||
|
||||
|
||||
private final HashMap<Class, HashMap<String, Field>> mFieldCache = new HashMap<>();
|
||||
public final TestLauncherProvider provider;
|
||||
private final long mDefaultProfileId;
|
||||
|
||||
private BgDataModel mDataModel;
|
||||
private AllAppsList mAllAppsList;
|
||||
|
||||
public LauncherModelHelper() {
|
||||
provider = Robolectric.setupContentProvider(TestLauncherProvider.class);
|
||||
mDefaultProfileId = UserCache.INSTANCE.get(RuntimeEnvironment.application)
|
||||
.getSerialNumberForUser(Process.myUserHandle());
|
||||
ShadowContentResolver.registerProviderInternal(LauncherProvider.AUTHORITY, provider);
|
||||
}
|
||||
|
||||
@@ -224,12 +229,16 @@ public class LauncherModelHelper {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int addItem(int type, int screen, int container, int x, int y) {
|
||||
return addItem(type, screen, container, x, y, mDefaultProfileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a dummy item in the DB.
|
||||
* @param type {@link #APP_ICON} or {@link #SHORTCUT} or >= 2 for
|
||||
* folder (where the type represents the number of items in the folder).
|
||||
*/
|
||||
public int addItem(int type, int screen, int container, int x, int y) {
|
||||
public int addItem(int type, int screen, int container, int x, int y, long profileId) {
|
||||
Context context = RuntimeEnvironment.application;
|
||||
int id = LauncherSettings.Settings.call(context.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_NEW_ITEM_ID)
|
||||
@@ -243,6 +252,7 @@ public class LauncherModelHelper {
|
||||
values.put(LauncherSettings.Favorites.CELLY, y);
|
||||
values.put(LauncherSettings.Favorites.SPANX, 1);
|
||||
values.put(LauncherSettings.Favorites.SPANY, 1);
|
||||
values.put(LauncherSettings.Favorites.PROFILE_ID, profileId);
|
||||
|
||||
if (type == APP_ICON || type == SHORTCUT) {
|
||||
values.put(LauncherSettings.Favorites.ITEM_TYPE, type);
|
||||
@@ -253,11 +263,11 @@ public class LauncherModelHelper {
|
||||
LauncherSettings.Favorites.ITEM_TYPE_FOLDER);
|
||||
// Add folder items.
|
||||
for (int i = 0; i < type; i++) {
|
||||
addItem(APP_ICON, 0, id, 0, 0);
|
||||
addItem(APP_ICON, 0, id, 0, 0, profileId);
|
||||
}
|
||||
}
|
||||
|
||||
context.getContentResolver().insert(LauncherSettings.Favorites.CONTENT_URI, values);
|
||||
context.getContentResolver().insert(CONTENT_URI, values);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -265,6 +275,15 @@ public class LauncherModelHelper {
|
||||
return createGrid(typeArray, 1);
|
||||
}
|
||||
|
||||
public int[][][] createGrid(int[][][] typeArray, int startScreen) {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
LauncherSettings.Settings.call(context.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
|
||||
LauncherSettings.Settings.call(context.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_CLEAR_EMPTY_DB_FLAG);
|
||||
return createGrid(typeArray, startScreen, mDefaultProfileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the DB with dummy elements to represent the provided grid structure.
|
||||
* @param typeArray A 3d array of item types. {@see #addItem(int, long, long, int, int)} for
|
||||
@@ -273,14 +292,9 @@ public class LauncherModelHelper {
|
||||
* @param startScreen First screen id from where the icons will be added.
|
||||
* @return the same grid representation where each entry is the corresponding item id.
|
||||
*/
|
||||
public int[][][] createGrid(int[][][] typeArray, int startScreen) {
|
||||
public int[][][] createGrid(int[][][] typeArray, int startScreen, long profileId) {
|
||||
Context context = RuntimeEnvironment.application;
|
||||
LauncherSettings.Settings.call(context.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
|
||||
LauncherSettings.Settings.call(context.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_CLEAR_EMPTY_DB_FLAG);
|
||||
int[][][] ids = new int[typeArray.length][][];
|
||||
|
||||
for (int i = 0; i < typeArray.length; i++) {
|
||||
// Add screen to DB
|
||||
int screenId = startScreen + i;
|
||||
@@ -297,7 +311,8 @@ public class LauncherModelHelper {
|
||||
// Empty cell
|
||||
ids[i][y][x] = -1;
|
||||
} else {
|
||||
ids[i][y][x] = addItem(typeArray[i][y][x], screenId, DESKTOP, x, y);
|
||||
ids[i][y][x] = addItem(
|
||||
typeArray[i][y][x], screenId, DESKTOP, x, y, profileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,5 +372,9 @@ public class LauncherModelHelper {
|
||||
createDbIfNotExists();
|
||||
return mOpenHelper.getWritableDatabase();
|
||||
}
|
||||
|
||||
public DatabaseHelper getHelper() {
|
||||
return mOpenHelper;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,13 @@ package com.android.launcher3.util;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import com.android.launcher3.shadows.LShadowAppWidgetManager;
|
||||
import com.android.launcher3.shadows.LShadowBackupManager;
|
||||
import com.android.launcher3.shadows.LShadowBitmap;
|
||||
import com.android.launcher3.shadows.LShadowLauncherApps;
|
||||
import com.android.launcher3.shadows.LShadowUserManager;
|
||||
import com.android.launcher3.shadows.ShadowDeviceFlag;
|
||||
import com.android.launcher3.shadows.ShadowLooperExecutor;
|
||||
import com.android.launcher3.shadows.ShadowMainThreadInitializedObject;
|
||||
import com.android.launcher3.shadows.ShadowDeviceFlag;
|
||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||
|
||||
import org.junit.runners.model.InitializationError;
|
||||
@@ -47,7 +48,7 @@ public class LauncherRoboTestRunner extends RobolectricTestRunner {
|
||||
LShadowUserManager.class,
|
||||
LShadowLauncherApps.class,
|
||||
LShadowBitmap.class,
|
||||
|
||||
LShadowBackupManager.class,
|
||||
ShadowLooperExecutor.class,
|
||||
ShadowMainThreadInitializedObject.class,
|
||||
ShadowDeviceFlag.class,
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.launcher3.logging.StatsLogUtils;
|
||||
import com.android.launcher3.logging.StatsLogUtils.LogStateProvider;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.launcher3.util.ViewCache;
|
||||
@@ -329,6 +330,9 @@ public abstract class BaseActivity extends Activity
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
TestLogging.recordEvent("start: shortcut: " + packageName);
|
||||
}
|
||||
getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds,
|
||||
startActivityOptions, user);
|
||||
} catch (SecurityException | IllegalStateException e) {
|
||||
|
||||
@@ -29,12 +29,15 @@ import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.view.ActionMode;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.model.AppLaunchTracker;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.launcher3.uioverrides.DisplayRotationListener;
|
||||
import com.android.launcher3.uioverrides.WallpaperColorInfo;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
@@ -164,6 +167,9 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
|
||||
} else if (user == null || user.equals(Process.myUserHandle())) {
|
||||
// Could be launching some bookkeeping activity
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
TestLogging.recordEvent("start: activity: " + intent);
|
||||
}
|
||||
startActivity(intent, optsBundle);
|
||||
AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(),
|
||||
Process.myUserHandle(), sourceContainer);
|
||||
@@ -258,5 +264,9 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
}
|
||||
}
|
||||
|
||||
public OnClickListener getItemOnClickListener() {
|
||||
return ItemClickHandler.INSTANCE;
|
||||
}
|
||||
|
||||
protected abstract void reapplyUi();
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class DeviceProfile {
|
||||
allAppsIconTextSizePx = originalProfile.iconTextSizePx;
|
||||
allAppsCellHeightPx = originalProfile.allAppsCellHeightPx;
|
||||
allAppsIconDrawablePaddingPx = originalProfile.iconDrawablePaddingOriginalPx;
|
||||
allAppsCellWidthPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx;
|
||||
allAppsCellWidthPx = allAppsIconSizePx + 2 * allAppsIconDrawablePaddingPx;
|
||||
}
|
||||
updateWorkspacePadding();
|
||||
|
||||
@@ -360,7 +360,7 @@ public class DeviceProfile {
|
||||
allAppsIconTextSizePx = iconTextSizePx;
|
||||
allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
|
||||
allAppsCellHeightPx = getCellSize().y;
|
||||
allAppsCellWidthPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx;
|
||||
allAppsCellWidthPx = allAppsIconSizePx + 2 * allAppsIconDrawablePaddingPx;
|
||||
|
||||
if (isVerticalBarLayout()) {
|
||||
// Always hide the Workspace text with vertical bar layout.
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.dragndrop.DragView;
|
||||
import com.android.launcher3.folder.FolderNameProvider;
|
||||
|
||||
/**
|
||||
* Interface defining an object that can receive a drag.
|
||||
@@ -67,7 +70,12 @@ public interface DropTarget {
|
||||
|
||||
public DragViewStateAnnouncer stateAnnouncer;
|
||||
|
||||
public DragObject() {
|
||||
public FolderNameProvider folderNameProvider;
|
||||
|
||||
public DragObject(Context context) {
|
||||
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||
folderNameProvider = FolderNameProvider.newInstance(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,15 +21,11 @@ import android.util.AttributeSet;
|
||||
import android.view.DragEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.CompletionInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.android.launcher3.folder.FolderNameProvider;
|
||||
import com.android.launcher3.util.UiThreadHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* The edit text that reports back when the back key has been pressed.
|
||||
@@ -105,25 +101,6 @@ public class ExtendedEditText extends EditText {
|
||||
UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommitCompletion(CompletionInfo text) {
|
||||
setText(text.getText());
|
||||
setSelection(text.getText().length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently only used for folder name suggestion.
|
||||
*/
|
||||
public void displayCompletions(List<String> suggestList) {
|
||||
int cnt = Math.min(suggestList.size(), FolderNameProvider.SUGGEST_MAX);
|
||||
CompletionInfo[] cInfo = new CompletionInfo[cnt];
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
cInfo[i] = new CompletionInfo(i, i, suggestList.get(i));
|
||||
}
|
||||
post(() -> getContext().getSystemService(InputMethodManager.class)
|
||||
.displayCompletions(this, cInfo));
|
||||
}
|
||||
|
||||
private boolean showSoftInput() {
|
||||
return requestFocus() &&
|
||||
getContext().getSystemService(InputMethodManager.class)
|
||||
|
||||
@@ -29,36 +29,25 @@ import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Property;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.launcher3.graphics.PlaceHolderIconDrawable;
|
||||
import com.android.launcher3.icons.BitmapInfo;
|
||||
|
||||
|
||||
public class FastBitmapDrawable extends Drawable {
|
||||
|
||||
private static final float PRESSED_SCALE = 1.1f;
|
||||
|
||||
private static final float DISABLED_DESATURATION = 1f;
|
||||
private static final float DISABLED_BRIGHTNESS = 0.5f;
|
||||
private static final float DISABLED_ALPHA = 0.54f;
|
||||
|
||||
public static final int CLICK_FEEDBACK_DURATION = 200;
|
||||
|
||||
// Since we don't need 256^2 values for combinations of both the brightness and saturation, we
|
||||
// reduce the value space to a smaller value V, which reduces the number of cached
|
||||
// ColorMatrixColorFilters that we need to keep to V^2
|
||||
private static final int REDUCED_FILTER_VALUE_SPACE = 48;
|
||||
|
||||
// A cache of ColorFilters for optimizing brightness and saturation animations
|
||||
private static final SparseArray<ColorFilter> sCachedFilter = new SparseArray<>();
|
||||
|
||||
// Temporary matrices used for calculation
|
||||
private static final ColorMatrix sTempBrightnessMatrix = new ColorMatrix();
|
||||
private static final ColorMatrix sTempFilterMatrix = new ColorMatrix();
|
||||
private static ColorFilter sDisabledFColorFilter;
|
||||
|
||||
protected final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
|
||||
protected Bitmap mBitmap;
|
||||
@@ -84,13 +73,7 @@ public class FastBitmapDrawable extends Drawable {
|
||||
private ObjectAnimator mScaleAnimation;
|
||||
private float mScale = 1;
|
||||
|
||||
|
||||
// The saturation and brightness are values that are mapped to REDUCED_FILTER_VALUE_SPACE and
|
||||
// as a result, can be used to compose the key for the cached ColorMatrixColorFilters
|
||||
private int mDesaturation = 0;
|
||||
private int mBrightness = 0;
|
||||
private int mAlpha = 255;
|
||||
private int mPrevUpdateKey = Integer.MAX_VALUE;
|
||||
|
||||
public FastBitmapDrawable(Bitmap b) {
|
||||
this(b, Color.TRANSPARENT);
|
||||
@@ -243,15 +226,10 @@ public class FastBitmapDrawable extends Drawable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void invalidateDesaturationAndBrightness() {
|
||||
setDesaturation(mIsDisabled ? DISABLED_DESATURATION : 0);
|
||||
setBrightness(mIsDisabled ? DISABLED_BRIGHTNESS : 0);
|
||||
}
|
||||
|
||||
public void setIsDisabled(boolean isDisabled) {
|
||||
if (mIsDisabled != isDisabled) {
|
||||
mIsDisabled = isDisabled;
|
||||
invalidateDesaturationAndBrightness();
|
||||
updateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,90 +237,33 @@ public class FastBitmapDrawable extends Drawable {
|
||||
return mIsDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the saturation of this icon, 0 [full color] -> 1 [desaturated]
|
||||
*/
|
||||
private void setDesaturation(float desaturation) {
|
||||
int newDesaturation = (int) Math.floor(desaturation * REDUCED_FILTER_VALUE_SPACE);
|
||||
if (mDesaturation != newDesaturation) {
|
||||
mDesaturation = newDesaturation;
|
||||
updateFilter();
|
||||
private ColorFilter getDisabledColorFilter() {
|
||||
if (sDisabledFColorFilter == null) {
|
||||
ColorMatrix tempBrightnessMatrix = new ColorMatrix();
|
||||
ColorMatrix tempFilterMatrix = new ColorMatrix();
|
||||
|
||||
tempFilterMatrix.setSaturation(1f - DISABLED_DESATURATION);
|
||||
float scale = 1 - DISABLED_BRIGHTNESS;
|
||||
int brightnessI = (int) (255 * DISABLED_BRIGHTNESS);
|
||||
float[] mat = tempBrightnessMatrix.getArray();
|
||||
mat[0] = scale;
|
||||
mat[6] = scale;
|
||||
mat[12] = scale;
|
||||
mat[4] = brightnessI;
|
||||
mat[9] = brightnessI;
|
||||
mat[14] = brightnessI;
|
||||
mat[18] = DISABLED_ALPHA;
|
||||
tempFilterMatrix.preConcat(tempBrightnessMatrix);
|
||||
sDisabledFColorFilter = new ColorMatrixColorFilter(tempFilterMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
public float getDesaturation() {
|
||||
return (float) mDesaturation / REDUCED_FILTER_VALUE_SPACE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the brightness of this icon, 0 [no add. brightness] -> 1 [2bright2furious]
|
||||
*/
|
||||
private void setBrightness(float brightness) {
|
||||
int newBrightness = (int) Math.floor(brightness * REDUCED_FILTER_VALUE_SPACE);
|
||||
if (mBrightness != newBrightness) {
|
||||
mBrightness = newBrightness;
|
||||
updateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
private float getBrightness() {
|
||||
return (float) mBrightness / REDUCED_FILTER_VALUE_SPACE;
|
||||
return sDisabledFColorFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the paint to reflect the current brightness and saturation.
|
||||
*/
|
||||
protected void updateFilter() {
|
||||
boolean usePorterDuffFilter = false;
|
||||
int key = -1;
|
||||
if (mDesaturation > 0) {
|
||||
key = (mDesaturation << 16) | mBrightness;
|
||||
} else if (mBrightness > 0) {
|
||||
// Compose a key with a fully saturated icon if we are just animating brightness
|
||||
key = (1 << 16) | mBrightness;
|
||||
|
||||
// We found that in L, ColorFilters cause drawing artifacts with shadows baked into
|
||||
// icons, so just use a PorterDuff filter when we aren't animating saturation
|
||||
usePorterDuffFilter = true;
|
||||
}
|
||||
|
||||
// Debounce multiple updates on the same frame
|
||||
if (key == mPrevUpdateKey) {
|
||||
return;
|
||||
}
|
||||
mPrevUpdateKey = key;
|
||||
|
||||
if (key != -1) {
|
||||
ColorFilter filter = sCachedFilter.get(key);
|
||||
if (filter == null) {
|
||||
float brightnessF = getBrightness();
|
||||
int brightnessI = (int) (255 * brightnessF);
|
||||
if (usePorterDuffFilter) {
|
||||
filter = new PorterDuffColorFilter(Color.argb(brightnessI, 255, 255, 255),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
} else {
|
||||
float saturationF = 1f - getDesaturation();
|
||||
sTempFilterMatrix.setSaturation(saturationF);
|
||||
if (mBrightness > 0) {
|
||||
// Brightness: C-new = C-old*(1-amount) + amount
|
||||
float scale = 1f - brightnessF;
|
||||
float[] mat = sTempBrightnessMatrix.getArray();
|
||||
mat[0] = scale;
|
||||
mat[6] = scale;
|
||||
mat[12] = scale;
|
||||
mat[4] = brightnessI;
|
||||
mat[9] = brightnessI;
|
||||
mat[14] = brightnessI;
|
||||
sTempFilterMatrix.preConcat(sTempBrightnessMatrix);
|
||||
}
|
||||
filter = new ColorMatrixColorFilter(sTempFilterMatrix);
|
||||
}
|
||||
sCachedFilter.append(key, filter);
|
||||
}
|
||||
mPaint.setColorFilter(filter);
|
||||
} else {
|
||||
mPaint.setColorFilter(null);
|
||||
}
|
||||
mPaint.setColorFilter(mIsDisabled ? getDisabledColorFilter() : null);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Process;
|
||||
|
||||
import com.android.launcher3.model.ModelWriter;
|
||||
@@ -45,8 +46,12 @@ public class FolderInfo extends ItemInfo {
|
||||
*/
|
||||
public static final int FLAG_MULTI_PAGE_ANIMATION = 0x00000004;
|
||||
|
||||
public static final int FLAG_MANUAL_FOLDER_NAME = 0x00000008;
|
||||
|
||||
public int options;
|
||||
|
||||
public Intent suggestedFolderNames;
|
||||
|
||||
/**
|
||||
* The apps and shortcuts
|
||||
*/
|
||||
@@ -140,4 +145,10 @@ public class FolderInfo extends ItemInfo {
|
||||
writer.updateItemInDatabase(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String dumpProperties() {
|
||||
return super.dumpProperties()
|
||||
+ " manuallyTypedTitle=" + hasOption(FLAG_MANUAL_FOLDER_NAME);
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@ package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.Utilities.getDevicePrefs;
|
||||
import static com.android.launcher3.config.FeatureFlags.APPLY_CONFIG_AT_RUNTIME;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.settings.SettingsActivity.GRID_OPTIONS_PREFERENCE_KEY;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
@@ -41,6 +41,7 @@ import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TypedValue;
|
||||
import android.util.Xml;
|
||||
import android.view.Display;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -48,6 +49,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.launcher3.graphics.IconShape;
|
||||
import com.android.launcher3.util.ConfigMonitor;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.launcher3.util.DefaultDisplay.Info;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.Themes;
|
||||
@@ -171,6 +173,13 @@ public class InvariantDeviceProfile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor should NOT have any monitors by design.
|
||||
*/
|
||||
public InvariantDeviceProfile(Context context, Display display) {
|
||||
initGrid(context, null, new Info(display));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve system defined or RRO overriden icon shape.
|
||||
*/
|
||||
@@ -183,8 +192,10 @@ public class InvariantDeviceProfile {
|
||||
}
|
||||
|
||||
private String initGrid(Context context, String gridName) {
|
||||
DefaultDisplay.Info displayInfo = DefaultDisplay.INSTANCE.get(context).getInfo();
|
||||
return initGrid(context, gridName, DefaultDisplay.INSTANCE.get(context).getInfo());
|
||||
}
|
||||
|
||||
private String initGrid(Context context, String gridName, DefaultDisplay.Info displayInfo) {
|
||||
Point smallestSize = new Point(displayInfo.smallestSize);
|
||||
Point largestSize = new Point(displayInfo.largestSize);
|
||||
|
||||
|
||||
@@ -214,4 +214,11 @@ public class ItemInfo {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if an Item is a predicted item
|
||||
*/
|
||||
public boolean isPredictedItem() {
|
||||
return container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION
|
||||
|| container == LauncherSettings.Favorites.CONTAINER_PREDICTION;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOA
|
||||
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
|
||||
import static com.android.launcher3.logging.LoggerUtils.newTarget;
|
||||
import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
|
||||
import static com.android.launcher3.popup.SystemShortcut.DISMISS_PREDICTION;
|
||||
import static com.android.launcher3.popup.SystemShortcut.INSTALL;
|
||||
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
|
||||
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
|
||||
@@ -103,7 +102,6 @@ import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.dragndrop.DragView;
|
||||
import com.android.launcher3.folder.FolderGridOrganizer;
|
||||
import com.android.launcher3.folder.FolderIcon;
|
||||
import com.android.launcher3.folder.FolderNameProvider;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.keyboard.CustomActionsPopup;
|
||||
@@ -372,7 +370,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
mLauncherView = LayoutInflater.from(this).inflate(R.layout.launcher, null);
|
||||
|
||||
setupViews();
|
||||
mPopupDataProvider = new PopupDataProvider(this);
|
||||
mPopupDataProvider = new PopupDataProvider(this::updateNotificationDots);
|
||||
|
||||
mAppTransitionManager = LauncherAppTransitionManager.newInstance(this);
|
||||
mAppTransitionManager.registerRemoteAnimations();
|
||||
@@ -616,10 +614,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
return mStateManager;
|
||||
}
|
||||
|
||||
public FolderNameProvider getFolderNameProvider() {
|
||||
return new FolderNameProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends View> T findViewById(int id) {
|
||||
return mLauncherView.findViewById(id);
|
||||
@@ -1197,6 +1191,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
mDropTargetBar.setup(mDragController);
|
||||
|
||||
mAllAppsController.setupViews(mAppsView);
|
||||
|
||||
if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
// Overview is above all other launcher elements, including qsb, so move it to the top.
|
||||
mOverviewPanel.bringToFront();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1271,13 +1270,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
cellXY[1] = cellY;
|
||||
foundCellSpan = true;
|
||||
|
||||
DragObject dragObject = new DragObject(getApplicationContext());
|
||||
dragObject.dragInfo = info;
|
||||
// If appropriate, either create a folder or add to an existing folder
|
||||
if (mWorkspace.createUserFolderIfNecessary(view, container, layout, cellXY, 0,
|
||||
true, null)) {
|
||||
true, dragObject)) {
|
||||
return;
|
||||
}
|
||||
DragObject dragObject = new DragObject();
|
||||
dragObject.dragInfo = info;
|
||||
if (mWorkspace.addToExistingFolderIfNecessary(view, layout, cellXY, 0, dragObject,
|
||||
true)) {
|
||||
return;
|
||||
@@ -1743,8 +1742,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
}
|
||||
|
||||
FolderIcon addFolder(CellLayout layout, int container, final int screenId, int cellX,
|
||||
int cellY) {
|
||||
/**
|
||||
* Creates and adds new folder to CellLayout
|
||||
*/
|
||||
public FolderIcon addFolder(CellLayout layout, WorkspaceItemInfo info, int container,
|
||||
final int screenId, int cellX, int cellY) {
|
||||
final FolderInfo folderInfo = new FolderInfo();
|
||||
folderInfo.title = "";
|
||||
|
||||
@@ -1752,7 +1754,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
getModelWriter().addItemToDatabase(folderInfo, container, screenId, cellX, cellY);
|
||||
|
||||
// Create the view
|
||||
FolderIcon newFolder = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, this, layout, folderInfo);
|
||||
FolderIcon newFolder = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, this, layout,
|
||||
folderInfo);
|
||||
mWorkspace.addInScreen(newFolder, folderInfo);
|
||||
// Force measure the new folder icon
|
||||
CellLayout parent = mWorkspace.getParentCellLayoutForView(newFolder);
|
||||
@@ -1829,7 +1832,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
// Note: There should be at most one log per method call. This is enforced implicitly
|
||||
// by using if-else statements.
|
||||
UserEventDispatcher ued = getUserEventDispatcher();
|
||||
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
|
||||
if (topView != null && topView.onBackPressed()) {
|
||||
// Handled by the floating view.
|
||||
@@ -1897,6 +1899,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startActivitySafely(View v, Intent intent, ItemInfo item,
|
||||
@Nullable String sourceContainer) {
|
||||
if (!hasBeenResumed()) {
|
||||
@@ -2713,7 +2716,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
|
||||
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
|
||||
return Stream.of(APP_INFO, WIDGETS, INSTALL, DISMISS_PREDICTION);
|
||||
return Stream.of(APP_INFO, WIDGETS, INSTALL);
|
||||
}
|
||||
|
||||
public static Launcher getLauncher(Context context) {
|
||||
|
||||
@@ -27,9 +27,6 @@ public class LauncherAnimUtils {
|
||||
* Durations for various state animations. These are not defined in resources to allow
|
||||
* easier access from static classes and enums
|
||||
*/
|
||||
public static final int ALL_APPS_TRANSITION_MS = 320;
|
||||
public static final int OVERVIEW_TRANSITION_MS = 250;
|
||||
public static final int SPRING_LOADED_TRANSITION_MS = 150;
|
||||
public static final int SPRING_LOADED_EXIT_DELAY = 500;
|
||||
|
||||
// The progress of an animation to all apps must be at least this far along to snap to all apps.
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.android.launcher3.pm.InstallSessionTracker;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.IntSparseArrayMap;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
@@ -96,6 +97,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
private boolean mModelLoaded;
|
||||
public boolean isModelLoaded() {
|
||||
synchronized (mLock) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
|
||||
"isModelLoaded: " + mModelLoaded + ", " + mLoaderTask);
|
||||
}
|
||||
return mModelLoaded && mLoaderTask == null;
|
||||
}
|
||||
}
|
||||
@@ -368,6 +373,9 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
public boolean stopLoader() {
|
||||
synchronized (mLock) {
|
||||
LoaderTask oldTask = mLoaderTask;
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "LauncherModel.stopLoader");
|
||||
}
|
||||
mLoaderTask = null;
|
||||
if (oldTask != null) {
|
||||
oldTask.stopLocked();
|
||||
@@ -381,6 +389,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
synchronized (mLock) {
|
||||
stopLoader();
|
||||
mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, mBgDataModel, results);
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
|
||||
"LauncherModel.startLoaderForResults " + mLoaderTask);
|
||||
}
|
||||
|
||||
// Always post the loader task, instead of running directly (even on same thread) so
|
||||
// that we exit any nested synchronized blocks
|
||||
@@ -482,6 +494,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
public void close() {
|
||||
synchronized (mLock) {
|
||||
// If we are still the last one to be scheduled, remove ourselves.
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
|
||||
"LauncherModel.close " + mLoaderTask + ", " + mTask);
|
||||
}
|
||||
if (mLoaderTask == mTask) {
|
||||
mLoaderTask = null;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
|
||||
@@ -30,9 +30,11 @@ import static com.android.launcher3.anim.Interpolators.ACCEL_2;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
|
||||
import static com.android.launcher3.anim.Interpolators.clampToProgress;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS;
|
||||
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
|
||||
import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.HINT_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.NORMAL_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
|
||||
@@ -42,6 +44,7 @@ import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORD
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.states.HintState;
|
||||
import com.android.launcher3.states.SpringLoadedState;
|
||||
import com.android.launcher3.uioverrides.states.AllAppsState;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
@@ -53,7 +56,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* Base state for various states used for the Launcher
|
||||
*/
|
||||
public class LauncherState {
|
||||
public abstract class LauncherState {
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,15 +91,21 @@ public class LauncherState {
|
||||
}
|
||||
};
|
||||
|
||||
private static final LauncherState[] sAllStates = new LauncherState[7];
|
||||
private static final LauncherState[] sAllStates = new LauncherState[8];
|
||||
|
||||
/**
|
||||
* TODO: Create a separate class for NORMAL state.
|
||||
*/
|
||||
public static final LauncherState NORMAL = new LauncherState(NORMAL_STATE_ORDINAL,
|
||||
ContainerType.WORKSPACE, 0,
|
||||
ContainerType.WORKSPACE,
|
||||
FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON |
|
||||
FLAG_HAS_SYS_UI_SCRIM);
|
||||
FLAG_HAS_SYS_UI_SCRIM) {
|
||||
@Override
|
||||
public int getTransitionDuration(Launcher launcher) {
|
||||
// Arbitrary duration, when going to NORMAL we use the state we're coming from instead.
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Various Launcher states arranged in the increasing order of UI layers
|
||||
@@ -104,6 +113,7 @@ public class LauncherState {
|
||||
public static final LauncherState SPRING_LOADED = new SpringLoadedState(
|
||||
SPRING_LOADED_STATE_ORDINAL);
|
||||
public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL);
|
||||
public static final LauncherState HINT_STATE = new HintState(HINT_STATE_ORDINAL);
|
||||
|
||||
public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL);
|
||||
public static final LauncherState OVERVIEW_PEEK =
|
||||
@@ -143,8 +153,6 @@ public class LauncherState {
|
||||
*/
|
||||
public final boolean hasWorkspacePageBackground;
|
||||
|
||||
public final int transitionDuration;
|
||||
|
||||
/**
|
||||
* True if the state allows workspace icons to be dragged.
|
||||
*/
|
||||
@@ -174,9 +182,8 @@ public class LauncherState {
|
||||
|
||||
public final boolean hasSysUiScrim;
|
||||
|
||||
public LauncherState(int id, int containerType, int transitionDuration, int flags) {
|
||||
public LauncherState(int id, int containerType, int flags) {
|
||||
this.containerType = containerType;
|
||||
this.transitionDuration = transitionDuration;
|
||||
|
||||
this.hasWorkspacePageBackground = (flags & FLAG_PAGE_BACKGROUNDS) != 0;
|
||||
this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0;
|
||||
@@ -199,6 +206,12 @@ public class LauncherState {
|
||||
return Arrays.copyOf(sAllStates, sAllStates.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return How long the animation to this state should take (or from this state to NORMAL).
|
||||
* @param launcher
|
||||
*/
|
||||
public abstract int getTransitionDuration(Launcher launcher);
|
||||
|
||||
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
|
||||
return new ScaleAndTranslation(1, 0, 0);
|
||||
}
|
||||
@@ -212,6 +225,10 @@ public class LauncherState {
|
||||
return launcher.getOverviewScaleAndTranslationForNormalState();
|
||||
}
|
||||
|
||||
public ScaleAndTranslation getQsbScaleAndTranslation(Launcher launcher) {
|
||||
return new ScaleAndTranslation(1, 0, 0);
|
||||
}
|
||||
|
||||
public float getOverviewFullscreenProgress() {
|
||||
return 0;
|
||||
}
|
||||
@@ -319,6 +336,10 @@ public class LauncherState {
|
||||
if (!isHotseatVisible) {
|
||||
hotseat.setScaleX(0.92f);
|
||||
hotseat.setScaleY(0.92f);
|
||||
if (ENABLE_OVERVIEW_ACTIONS.get()) {
|
||||
launcher.getAppsView().setScaleX(0.92f);
|
||||
launcher.getAppsView().setScaleY(0.92f);
|
||||
}
|
||||
}
|
||||
} else if (this == NORMAL && fromState == OVERVIEW_PEEK) {
|
||||
// Keep fully visible until the very end (when overview is offscreen) to make invisible.
|
||||
|
||||
@@ -293,7 +293,9 @@ public class LauncherStateManager {
|
||||
Runnable onCompleteRunnable) {
|
||||
// Since state NORMAL can be reached from multiple states, just assume that the
|
||||
// transition plays in reverse and use the same duration as previous state.
|
||||
mConfig.duration = state == NORMAL ? fromState.transitionDuration : state.transitionDuration;
|
||||
mConfig.duration = state == NORMAL
|
||||
? fromState.getTransitionDuration(mLauncher)
|
||||
: state.getTransitionDuration(mLauncher);
|
||||
|
||||
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
||||
prepareForAtomicAnimation(fromState, state, builder);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.launcher3;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.BitmapCreationCheck;
|
||||
import com.android.launcher3.graphics.IconShape;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
@@ -39,5 +40,9 @@ public class MainProcessInitializer implements ResourceBasedOverride {
|
||||
FeatureFlags.initialize(context);
|
||||
SessionCommitReceiver.applyDefaultUserPrefs(context);
|
||||
IconShape.init(context);
|
||||
|
||||
if (BitmapCreationCheck.ENABLED) {
|
||||
BitmapCreationCheck.startTracking(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,6 +245,13 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
forceFinishScroller(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns left offset of a page. This is the gap between pages and prevents overlap.
|
||||
*/
|
||||
public int scrollOffsetLeft() {
|
||||
return mInsets.left + getPaddingLeft();
|
||||
}
|
||||
|
||||
private void abortScrollerAnimation(boolean resetNextPage) {
|
||||
mScroller.abortAnimation();
|
||||
// We need to clean up the next page here to avoid computeScrollHelper from
|
||||
|
||||
@@ -6,6 +6,7 @@ import static android.appwidget.AppWidgetProviderInfo.WIDGET_FEATURE_RECONFIGURA
|
||||
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_MASK;
|
||||
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_NO;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DISMISS_PREDICTION;
|
||||
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE;
|
||||
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL;
|
||||
|
||||
@@ -29,9 +30,11 @@ import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.Launcher.OnResumeCallback;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.logging.LoggerUtils;
|
||||
import com.android.launcher3.model.AppLaunchTracker;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
@@ -43,6 +46,7 @@ import java.net.URISyntaxException;
|
||||
* Drop target which provides a secondary option for an item.
|
||||
* For app targets: shows as uninstall
|
||||
* For configurable widgets: shows as setup
|
||||
* For predicted app icons: don't suggest app
|
||||
*/
|
||||
public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmListener {
|
||||
|
||||
@@ -81,7 +85,11 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
mHoverColor = getResources().getColor(R.color.uninstall_target_hover_tint);
|
||||
setDrawable(R.drawable.ic_uninstall_shadow);
|
||||
updateText(R.string.uninstall_drop_target_label);
|
||||
} else {
|
||||
} else if (action == DISMISS_PREDICTION) {
|
||||
mHoverColor = Themes.getColorAccent(getContext());
|
||||
setDrawable(R.drawable.ic_block);
|
||||
updateText(R.string.dismiss_prediction_label);
|
||||
} else if (action == RECONFIGURE) {
|
||||
mHoverColor = Themes.getColorAccent(getContext());
|
||||
setDrawable(R.drawable.ic_setup_shadow);
|
||||
updateText(R.string.gadget_setup_text);
|
||||
@@ -101,8 +109,13 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
@Override
|
||||
public Target getDropTargetForLogging() {
|
||||
Target t = LoggerUtils.newTarget(Target.Type.CONTROL);
|
||||
t.controlType = mCurrentAccessibilityAction == UNINSTALL ? ControlType.UNINSTALL_TARGET
|
||||
: ControlType.SETTINGS_BUTTON;
|
||||
if (mCurrentAccessibilityAction == UNINSTALL) {
|
||||
t.controlType = ControlType.UNINSTALL_TARGET;
|
||||
} else if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
|
||||
t.controlType = ControlType.DISMISS_PREDICTION;
|
||||
} else {
|
||||
t.controlType = ControlType.SETTINGS_BUTTON;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -119,6 +132,9 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
|
||||
setupUi(DISMISS_PREDICTION);
|
||||
return true;
|
||||
}
|
||||
|
||||
setupUi(UNINSTALL);
|
||||
@@ -229,6 +245,11 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
|
||||
AppLaunchTracker.INSTANCE.get(getContext()).onDismissApp(info.getTargetComponent(),
|
||||
info.user, AppLaunchTracker.CONTAINER_PREDICTIONS);
|
||||
return null;
|
||||
}
|
||||
// else: mCurrentAccessibilityAction == UNINSTALL
|
||||
|
||||
ComponentName cn = getUninstallTarget(info);
|
||||
|
||||
@@ -75,7 +75,6 @@ import com.android.launcher3.views.Transposable;
|
||||
import com.android.launcher3.widget.PendingAddShortcutInfo;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -382,7 +381,7 @@ public final class Utilities {
|
||||
return res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||
}
|
||||
|
||||
public static float dpiFromPx(int size, DisplayMetrics metrics){
|
||||
public static float dpiFromPx(float size, DisplayMetrics metrics) {
|
||||
float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
|
||||
return (size / densityRatio);
|
||||
}
|
||||
@@ -465,12 +464,14 @@ public final class Utilities {
|
||||
}
|
||||
|
||||
public static SharedPreferences getPrefs(Context context) {
|
||||
return context.getSharedPreferences(
|
||||
// Use application context for shared preferences, so that we use a single cached instance
|
||||
return context.getApplicationContext().getSharedPreferences(
|
||||
LauncherFiles.SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static SharedPreferences getDevicePrefs(Context context) {
|
||||
return context.getSharedPreferences(
|
||||
// Use application context for shared preferences, so that we use a single cached instance
|
||||
return context.getApplicationContext().getSharedPreferences(
|
||||
LauncherFiles.DEVICE_PREFERENCES_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
|
||||
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY;
|
||||
@@ -39,7 +38,6 @@ import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -79,6 +77,7 @@ import com.android.launcher3.folder.PreviewBackground;
|
||||
import com.android.launcher3.graphics.DragPreviewProvider;
|
||||
import com.android.launcher3.graphics.PreloadIconDrawable;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.icons.BitmapRenderer;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
|
||||
import com.android.launcher3.popup.PopupContainerWithArrow;
|
||||
@@ -1350,7 +1349,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
}
|
||||
|
||||
public void snapToPageFromOverView(int whichPage) {
|
||||
snapToPage(whichPage, OVERVIEW_TRANSITION_MS, Interpolators.ZOOM_IN);
|
||||
snapToPage(whichPage, OVERVIEW.getTransitionDuration(mLauncher), Interpolators.ZOOM_IN);
|
||||
}
|
||||
|
||||
private void onStartStateTransition(LauncherState state) {
|
||||
@@ -1673,7 +1672,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
}
|
||||
|
||||
boolean createUserFolderIfNecessary(View newView, int container, CellLayout target,
|
||||
int[] targetCell, float distance, boolean external, DragView dragView) {
|
||||
int[] targetCell, float distance, boolean external, DragObject d) {
|
||||
if (distance > mMaxDistanceForFolderCreation) return false;
|
||||
View v = target.getChildAt(targetCell[0], targetCell[1]);
|
||||
|
||||
@@ -1703,22 +1702,21 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
float scale = mLauncher.getDragLayer().getDescendantRectRelativeToSelf(v, folderLocation);
|
||||
target.removeView(v);
|
||||
|
||||
FolderIcon fi =
|
||||
mLauncher.addFolder(target, container, screenId, targetCell[0], targetCell[1]);
|
||||
FolderIcon fi = mLauncher.addFolder(target, sourceInfo, container, screenId,
|
||||
targetCell[0], targetCell[1]);
|
||||
destInfo.cellX = -1;
|
||||
destInfo.cellY = -1;
|
||||
sourceInfo.cellX = -1;
|
||||
sourceInfo.cellY = -1;
|
||||
|
||||
// If the dragView is null, we can't animate
|
||||
boolean animate = dragView != null;
|
||||
boolean animate = d != null;
|
||||
if (animate) {
|
||||
// In order to keep everything continuous, we hand off the currently rendered
|
||||
// folder background to the newly created icon. This preserves animation state.
|
||||
fi.setFolderBackground(mFolderCreateBg);
|
||||
mFolderCreateBg = new PreviewBackground();
|
||||
fi.performCreateAnimation(destInfo, v, sourceInfo, dragView, folderLocation, scale
|
||||
);
|
||||
fi.performCreateAnimation(destInfo, v, sourceInfo, d, folderLocation, scale);
|
||||
} else {
|
||||
fi.prepareCreateAnimation(v);
|
||||
fi.addItem(destInfo);
|
||||
@@ -1799,8 +1797,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
// If the item being dropped is a shortcut and the nearest drop
|
||||
// cell also contains a shortcut, then create a folder with the two shortcuts.
|
||||
if (createUserFolderIfNecessary(cell, container,
|
||||
dropTargetLayout, mTargetCell, distance, false, d.dragView) ||
|
||||
addToExistingFolderIfNecessary(cell, dropTargetLayout, mTargetCell,
|
||||
dropTargetLayout, mTargetCell, distance, false, d)
|
||||
|| addToExistingFolderIfNecessary(cell, dropTargetLayout, mTargetCell,
|
||||
distance, d, false)) {
|
||||
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
return;
|
||||
@@ -1916,7 +1914,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
// Animate the item to its original position, while simultaneously exiting
|
||||
// spring-loaded mode so the page meets the icon where it was picked up.
|
||||
mLauncher.getDragController().animateDragViewToOriginalPosition(
|
||||
onCompleteRunnable, cell, SPRING_LOADED_TRANSITION_MS);
|
||||
onCompleteRunnable, cell,
|
||||
SPRING_LOADED.getTransitionDuration(mLauncher));
|
||||
mLauncher.getStateManager().goToState(NORMAL);
|
||||
mLauncher.getDropTargetBar().onDragEnd();
|
||||
parent.onDropChild(cell);
|
||||
@@ -2561,7 +2560,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
|
||||
mDragViewVisualCenter[1], mTargetCell);
|
||||
if (createUserFolderIfNecessary(view, container, cellLayout, mTargetCell, distance,
|
||||
true, d.dragView)) {
|
||||
true, d)) {
|
||||
return;
|
||||
}
|
||||
if (addToExistingFolderIfNecessary(view, cellLayout, mTargetCell, distance, d,
|
||||
@@ -2606,11 +2605,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
int width = MeasureSpec.makeMeasureSpec(unScaledSize[0], MeasureSpec.EXACTLY);
|
||||
int height = MeasureSpec.makeMeasureSpec(unScaledSize[1], MeasureSpec.EXACTLY);
|
||||
Bitmap b = Bitmap.createBitmap(unScaledSize[0], unScaledSize[1],
|
||||
Bitmap.Config.ARGB_8888);
|
||||
layout.measure(width, height);
|
||||
layout.layout(0, 0, unScaledSize[0], unScaledSize[1]);
|
||||
layout.draw(new Canvas(b));
|
||||
Bitmap b = BitmapRenderer.createHardwareBitmap(
|
||||
unScaledSize[0], unScaledSize[1], layout::draw);
|
||||
layout.setVisibility(visibility);
|
||||
return b;
|
||||
}
|
||||
@@ -3256,7 +3254,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
return mOverlayShown;
|
||||
}
|
||||
|
||||
void moveToDefaultScreen() {
|
||||
/** Calls {@link #snapToPage(int)} on the {@link #DEFAULT_PAGE}, then requests focus on it. */
|
||||
public void moveToDefaultScreen() {
|
||||
int page = DEFAULT_PAGE;
|
||||
if (!workspaceInModalState() && getNextPage() != page) {
|
||||
snapToPage(page);
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.view.animation.Interpolator;
|
||||
import com.android.launcher3.LauncherState.PageAlphaProvider;
|
||||
import com.android.launcher3.LauncherState.ScaleAndTranslation;
|
||||
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
||||
import com.android.launcher3.allapps.AllAppsContainerView;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.graphics.WorkspaceAndHotseatScrim;
|
||||
@@ -77,6 +78,7 @@ public class WorkspaceStateTransitionAnimation {
|
||||
ScaleAndTranslation scaleAndTranslation = state.getWorkspaceScaleAndTranslation(mLauncher);
|
||||
ScaleAndTranslation hotseatScaleAndTranslation = state.getHotseatScaleAndTranslation(
|
||||
mLauncher);
|
||||
ScaleAndTranslation qsbScaleAndTranslation = state.getQsbScaleAndTranslation(mLauncher);
|
||||
mNewScale = scaleAndTranslation.scale;
|
||||
PageAlphaProvider pageAlphaProvider = state.getWorkspacePageAlphaProvider(mLauncher);
|
||||
final int childCount = mWorkspace.getChildCount();
|
||||
@@ -90,24 +92,24 @@ public class WorkspaceStateTransitionAnimation {
|
||||
pageAlphaProvider.interpolator);
|
||||
boolean playAtomicComponent = config.playAtomicOverviewScaleComponent();
|
||||
Hotseat hotseat = mWorkspace.getHotseat();
|
||||
// Since we set the pivot relative to mWorkspace, we need to scale a sibling of Workspace.
|
||||
AllAppsContainerView qsbScaleView = mLauncher.getAppsView();
|
||||
View qsbView = qsbScaleView.getSearchView();
|
||||
if (playAtomicComponent) {
|
||||
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
|
||||
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
|
||||
|
||||
if (!hotseat.getRotationMode().isTransposed) {
|
||||
// Set the hotseat's pivot point to match the workspace's, so that it scales
|
||||
// together. Since both hotseat and workspace can move, transform the point
|
||||
// manually instead of using dragLayer.getDescendantCoordRelativeToSelf and
|
||||
// related methods.
|
||||
hotseat.setPivotY(mWorkspace.getPivotY() + mWorkspace.getTop() - hotseat.getTop());
|
||||
hotseat.setPivotX(mWorkspace.getPivotX()
|
||||
+ mWorkspace.getLeft() - hotseat.getLeft());
|
||||
setPivotToScaleWithWorkspace(hotseat);
|
||||
setPivotToScaleWithWorkspace(qsbScaleView);
|
||||
}
|
||||
float hotseatScale = hotseatScaleAndTranslation.scale;
|
||||
Interpolator hotseatScaleInterpolator = builder.getInterpolator(ANIM_HOTSEAT_SCALE,
|
||||
scaleInterpolator);
|
||||
propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale,
|
||||
hotseatScaleInterpolator);
|
||||
propertySetter.setFloat(qsbScaleView, SCALE_PROPERTY, qsbScaleAndTranslation.scale,
|
||||
hotseatScaleInterpolator);
|
||||
|
||||
float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
|
||||
propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
|
||||
@@ -134,10 +136,24 @@ public class WorkspaceStateTransitionAnimation {
|
||||
hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
|
||||
propertySetter.setFloat(mWorkspace.getPageIndicator(), View.TRANSLATION_Y,
|
||||
hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
|
||||
propertySetter.setFloat(qsbView, View.TRANSLATION_Y,
|
||||
qsbScaleAndTranslation.translationY, hotseatTranslationInterpolator);
|
||||
|
||||
setScrim(propertySetter, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given view's pivot point to match the workspace's, so that it scales together. Since
|
||||
* both this view and workspace can move, transform the point manually instead of using
|
||||
* dragLayer.getDescendantCoordRelativeToSelf and related methods.
|
||||
*/
|
||||
private void setPivotToScaleWithWorkspace(View sibling) {
|
||||
sibling.setPivotY(mWorkspace.getPivotY() + mWorkspace.getTop()
|
||||
- sibling.getTop() - sibling.getTranslationY());
|
||||
sibling.setPivotX(mWorkspace.getPivotX() + mWorkspace.getLeft()
|
||||
- sibling.getLeft() - sibling.getTranslationX());
|
||||
}
|
||||
|
||||
public void setScrim(PropertySetter propertySetter, LauncherState state) {
|
||||
WorkspaceAndHotseatScrim scrim = mLauncher.getDragLayer().getScrim();
|
||||
propertySetter.setFloat(scrim, SCRIM_PROGRESS, state.getWorkspaceScrimAlpha(mLauncher),
|
||||
|
||||
@@ -54,6 +54,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
|
||||
|
||||
public static final int REMOVE = R.id.action_remove;
|
||||
public static final int UNINSTALL = R.id.action_uninstall;
|
||||
public static final int DISMISS_PREDICTION = R.id.action_dismiss_prediction;
|
||||
public static final int RECONFIGURE = R.id.action_reconfigure;
|
||||
protected static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace;
|
||||
protected static final int MOVE = R.id.action_move;
|
||||
@@ -86,6 +87,8 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
|
||||
launcher.getText(R.string.remove_drop_target_label)));
|
||||
mActions.put(UNINSTALL, new AccessibilityAction(UNINSTALL,
|
||||
launcher.getText(R.string.uninstall_drop_target_label)));
|
||||
mActions.put(DISMISS_PREDICTION, new AccessibilityAction(DISMISS_PREDICTION,
|
||||
launcher.getText(R.string.dismiss_prediction_label)));
|
||||
mActions.put(RECONFIGURE, new AccessibilityAction(RECONFIGURE,
|
||||
launcher.getText(R.string.gadget_setup_text)));
|
||||
mActions.put(ADD_TO_WORKSPACE, new AccessibilityAction(ADD_TO_WORKSPACE,
|
||||
@@ -166,13 +169,22 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
|
||||
}
|
||||
|
||||
public boolean performAction(final View host, final ItemInfo item, int action) {
|
||||
if (action == ACTION_LONG_CLICK && ShortcutUtil.isDeepShortcut(item)) {
|
||||
CustomActionsPopup popup = new CustomActionsPopup(mLauncher, host);
|
||||
if (popup.canShow()) {
|
||||
popup.show();
|
||||
if (action == ACTION_LONG_CLICK) {
|
||||
if (ShortcutUtil.isDeepShortcut(item)) {
|
||||
CustomActionsPopup popup = new CustomActionsPopup(mLauncher, host);
|
||||
if (popup.canShow()) {
|
||||
popup.show();
|
||||
return true;
|
||||
}
|
||||
} else if (host instanceof BubbleTextView) {
|
||||
// Long press should be consumed for workspace items, and it should invoke the
|
||||
// Shortcuts / Notifications / Actions pop-up menu, and not start a drag as the
|
||||
// standard long press path does.
|
||||
PopupContainerWithArrow.showForIcon((BubbleTextView) host);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == MOVE) {
|
||||
beginAccessibleDrag(host, item);
|
||||
} else if (action == ADD_TO_WORKSPACE) {
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static android.view.View.MeasureSpec.EXACTLY;
|
||||
import static android.view.View.MeasureSpec.makeMeasureSpec;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
@@ -40,6 +43,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.AppInfo;
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
|
||||
import com.android.launcher3.DragSource;
|
||||
@@ -47,20 +51,19 @@ import com.android.launcher3.DropTarget.DragObject;
|
||||
import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.InsettableFrameLayout;
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.BottomUserEducationView;
|
||||
import com.android.launcher3.views.RecyclerViewFastScroller;
|
||||
import com.android.launcher3.views.SpringRelativeLayout;
|
||||
import com.android.launcher3.views.WorkFooterContainer;
|
||||
|
||||
/**
|
||||
* The all apps view container.
|
||||
@@ -73,8 +76,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
private static final float FLING_ANIMATION_THRESHOLD = 0.55f;
|
||||
private static final int ALPHA_CHANNEL_COUNT = 2;
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final AdapterHolder[] mAH;
|
||||
protected final BaseDraggingActivity mLauncher;
|
||||
protected final AdapterHolder[] mAH;
|
||||
private final ItemInfoMatcher mPersonalMatcher = ItemInfoMatcher.ofUser(Process.myUserHandle());
|
||||
private final ItemInfoMatcher mWorkMatcher = ItemInfoMatcher.not(mPersonalMatcher);
|
||||
private final AllAppsStore mAllAppsStore = new AllAppsStore();
|
||||
@@ -82,14 +85,17 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
private final Paint mNavBarScrimPaint;
|
||||
private int mNavBarScrimHeight = 0;
|
||||
|
||||
private SearchUiManager mSearchUiManager;
|
||||
protected SearchUiManager mSearchUiManager;
|
||||
private View mSearchContainer;
|
||||
private AllAppsPagedView mViewPager;
|
||||
|
||||
private FloatingHeaderView mHeader;
|
||||
private WorkFooterContainer mWorkFooterContainer;
|
||||
|
||||
|
||||
private SpannableStringBuilder mSearchQueryBuilder = null;
|
||||
|
||||
private boolean mUsingTabs;
|
||||
protected boolean mUsingTabs;
|
||||
private boolean mSearchModeWhileUsingTabs = false;
|
||||
|
||||
private RecyclerViewFastScroller mTouchHandler;
|
||||
@@ -108,7 +114,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
public AllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
mLauncher = Launcher.getLauncher(context);
|
||||
mLauncher = BaseDraggingActivity.fromContext(context);
|
||||
mLauncher.addOnDeviceProfileChangeListener(this);
|
||||
|
||||
mSearchQueryBuilder = new SpannableStringBuilder();
|
||||
@@ -130,6 +136,15 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mMultiValueAlpha = new MultiValueAlpha(this, ALPHA_CHANNEL_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the long click listener for icons
|
||||
*/
|
||||
public void setOnIconLongClickListener(OnLongClickListener listener) {
|
||||
for (AdapterHolder holder : mAH) {
|
||||
holder.adapter.setOnIconLongClickListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public AllAppsStore getAppsStore() {
|
||||
return mAllAppsStore;
|
||||
}
|
||||
@@ -166,6 +181,15 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
}
|
||||
}
|
||||
rebindAdapters(hasWorkApps);
|
||||
if (hasWorkApps) {
|
||||
resetWorkProfile();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetWorkProfile() {
|
||||
mWorkFooterContainer.refresh();
|
||||
mAH[AdapterHolder.WORK].setupOverlay();
|
||||
mAH[AdapterHolder.WORK].applyPadding();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,11 +214,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
|
||||
// The AllAppsContainerView houses the QSB and is hence visible from the Workspace
|
||||
// Overview states. We shouldn't intercept for the scrubber in these cases.
|
||||
if (!mLauncher.isInState(LauncherState.ALL_APPS)) return false;
|
||||
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
AllAppsRecyclerView rv = getActiveRecyclerView();
|
||||
if (rv != null &&
|
||||
@@ -287,7 +306,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDropCompleted(View target, DragObject d, boolean success) { }
|
||||
public void onDropCompleted(View target, DragObject d, boolean success) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
@@ -305,10 +325,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
+ grid.cellLayoutPaddingLeftRightPx;
|
||||
|
||||
for (int i = 0; i < mAH.length; i++) {
|
||||
mAH[i].adapter.setAppsPerRow(grid.inv.numAllAppsColumns);
|
||||
mAH[i].padding.bottom = insets.bottom;
|
||||
mAH[i].padding.left = mAH[i].padding.right = leftRightPadding;
|
||||
mAH[i].applyPadding();
|
||||
mAH[i].setupOverlay();
|
||||
}
|
||||
|
||||
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
|
||||
@@ -323,8 +343,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
setLayoutParams(mlp);
|
||||
|
||||
InsettableFrameLayout.dispatchInsets(this, insets);
|
||||
mLauncher.getAllAppsController()
|
||||
.setScrollRangeDelta(mSearchUiManager.getScrollRangeDelta(insets));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -368,12 +386,17 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mAllAppsStore.unregisterIconContainer(mAH[AdapterHolder.WORK].recyclerView);
|
||||
|
||||
if (mUsingTabs) {
|
||||
setupWorkToggle();
|
||||
mAH[AdapterHolder.MAIN].setup(mViewPager.getChildAt(0), mPersonalMatcher);
|
||||
mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher);
|
||||
onTabChanged(mViewPager.getNextPage());
|
||||
} else {
|
||||
mAH[AdapterHolder.MAIN].setup(findViewById(R.id.apps_list_view), null);
|
||||
mAH[AdapterHolder.WORK].recyclerView = null;
|
||||
if (mWorkFooterContainer != null) {
|
||||
((ViewGroup) mWorkFooterContainer.getParent()).removeView(mWorkFooterContainer);
|
||||
mWorkFooterContainer = null;
|
||||
}
|
||||
}
|
||||
setupHeader();
|
||||
|
||||
@@ -381,6 +404,16 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mAllAppsStore.registerIconContainer(mAH[AdapterHolder.WORK].recyclerView);
|
||||
}
|
||||
|
||||
private void setupWorkToggle() {
|
||||
mWorkFooterContainer = (WorkFooterContainer) mLauncher.getLayoutInflater().inflate(
|
||||
R.layout.work_tab_footer, findViewById(R.id.work_toggle_container));
|
||||
mWorkFooterContainer.setLayoutParams(
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
this.addView(mWorkFooterContainer);
|
||||
mWorkFooterContainer.post(() -> mAH[AdapterHolder.WORK].applyPadding());
|
||||
}
|
||||
|
||||
private void replaceRVContainer(boolean showTabs) {
|
||||
for (int i = 0; i < mAH.length; i++) {
|
||||
if (mAH[i].recyclerView != null) {
|
||||
@@ -416,10 +449,9 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
.setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.MAIN));
|
||||
findViewById(R.id.tab_work)
|
||||
.setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.WORK));
|
||||
|
||||
}
|
||||
if (pos == AdapterHolder.WORK) {
|
||||
BottomUserEducationView.showIfNeeded(mLauncher);
|
||||
if (mWorkFooterContainer != null) {
|
||||
mWorkFooterContainer.setWorkTabVisible(pos == AdapterHolder.WORK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,6 +598,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
public static final int MAIN = 0;
|
||||
public static final int WORK = 1;
|
||||
|
||||
private final boolean mIsWork;
|
||||
public final AllAppsGridAdapter adapter;
|
||||
final LinearLayoutManager layoutManager;
|
||||
final AlphabeticalAppsList appsList;
|
||||
@@ -573,7 +606,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
AllAppsRecyclerView recyclerView;
|
||||
boolean verticalFadingEdge;
|
||||
|
||||
boolean mWorkDisabled;
|
||||
|
||||
AdapterHolder(boolean isWork) {
|
||||
mIsWork = isWork;
|
||||
appsList = new AlphabeticalAppsList(mLauncher, mAllAppsStore, isWork);
|
||||
adapter = new AllAppsGridAdapter(mLauncher, appsList);
|
||||
appsList.setAdapter(adapter);
|
||||
@@ -584,7 +620,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
appsList.updateItemFilter(matcher);
|
||||
recyclerView = (AllAppsRecyclerView) rv;
|
||||
recyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
|
||||
recyclerView.setApps(appsList, mUsingTabs);
|
||||
recyclerView.setApps(appsList);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
@@ -595,11 +631,36 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
adapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
|
||||
applyVerticalFadingEdgeEnabled(verticalFadingEdge);
|
||||
applyPadding();
|
||||
setupOverlay();
|
||||
}
|
||||
|
||||
void setupOverlay() {
|
||||
if (!mIsWork || recyclerView == null) return;
|
||||
boolean workDisabled = UserCache.INSTANCE.get(mLauncher).isAnyProfileQuietModeEnabled();
|
||||
recyclerView.getOverlay().clear();
|
||||
if (workDisabled) {
|
||||
View pausedOverlay = mLauncher.getLayoutInflater().inflate(
|
||||
R.layout.work_apps_paused, null);
|
||||
recyclerView.post(() -> {
|
||||
int width = recyclerView.getWidth();
|
||||
int height = recyclerView.getHeight();
|
||||
pausedOverlay.measure(makeMeasureSpec(width, EXACTLY),
|
||||
makeMeasureSpec(height, EXACTLY));
|
||||
pausedOverlay.layout(0, 0, width, height);
|
||||
applyPadding();
|
||||
});
|
||||
recyclerView.getOverlay().add(pausedOverlay);
|
||||
}
|
||||
mWorkDisabled = workDisabled;
|
||||
}
|
||||
|
||||
void applyPadding() {
|
||||
if (recyclerView != null) {
|
||||
recyclerView.setPadding(padding.left, padding.top, padding.right, padding.bottom);
|
||||
int bottomOffset =
|
||||
mWorkFooterContainer != null && mIsWork ? mWorkFooterContainer.getHeight()
|
||||
: 0;
|
||||
recyclerView.setPadding(padding.left, padding.top, padding.right,
|
||||
padding.bottom + bottomOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,17 +15,22 @@
|
||||
*/
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.touch.ItemLongClickListener.INSTANCE_ALL_APPS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnFocusChangeListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.accessibility.AccessibilityEventCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityRecordCompat;
|
||||
@@ -33,14 +38,11 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.AppInfo;
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.allapps.AlphabeticalAppsList.AdapterItem;
|
||||
import com.android.launcher3.model.AppLaunchTracker;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.launcher3.touch.ItemLongClickListener;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
import java.util.List;
|
||||
@@ -64,7 +66,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
|
||||
// A divider that separates the apps list and the search market button
|
||||
public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 4;
|
||||
public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 5;
|
||||
|
||||
// Common view type masks
|
||||
public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER;
|
||||
@@ -174,23 +175,26 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
}
|
||||
}
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final BaseDraggingActivity mLauncher;
|
||||
private final LayoutInflater mLayoutInflater;
|
||||
private final AlphabeticalAppsList mApps;
|
||||
private final GridLayoutManager mGridLayoutMgr;
|
||||
private final GridSpanSizer mGridSizer;
|
||||
|
||||
private final OnClickListener mOnIconClickListener;
|
||||
private OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS;
|
||||
|
||||
private int mAppsPerRow;
|
||||
|
||||
private BindViewCallback mBindViewCallback;
|
||||
private OnFocusChangeListener mIconFocusListener;
|
||||
|
||||
// The text to show when there are no search results and no market search handler.
|
||||
private String mEmptySearchMessage;
|
||||
protected String mEmptySearchMessage;
|
||||
// The intent to send off to the market app, updated each time the search query changes.
|
||||
private Intent mMarketSearchIntent;
|
||||
|
||||
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps) {
|
||||
public AllAppsGridAdapter(BaseDraggingActivity launcher, AlphabeticalAppsList apps) {
|
||||
Resources res = launcher.getResources();
|
||||
mLauncher = launcher;
|
||||
mApps = apps;
|
||||
@@ -200,6 +204,8 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
|
||||
mLayoutInflater = LayoutInflater.from(launcher);
|
||||
|
||||
mOnIconClickListener = launcher.getItemOnClickListener();
|
||||
|
||||
setAppsPerRow(mLauncher.getDeviceProfile().inv.numAllAppsColumns);
|
||||
}
|
||||
|
||||
@@ -208,6 +214,13 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
mGridLayoutMgr.setSpanCount(mAppsPerRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the long click listener for icons
|
||||
*/
|
||||
public void setOnIconLongClickListener(@Nullable OnLongClickListener listener) {
|
||||
mOnIconLongClickListener = listener;
|
||||
}
|
||||
|
||||
public static boolean isDividerViewType(int viewType) {
|
||||
return isViewType(viewType, VIEW_TYPE_MASK_DIVIDER);
|
||||
}
|
||||
@@ -254,8 +267,8 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
case VIEW_TYPE_ICON:
|
||||
BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(
|
||||
R.layout.all_apps_icon, parent, false);
|
||||
icon.setOnClickListener(ItemClickHandler.INSTANCE);
|
||||
icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
|
||||
icon.setOnClickListener(mOnIconClickListener);
|
||||
icon.setOnLongClickListener(mOnIconLongClickListener);
|
||||
icon.setLongPressTimeoutFactor(1f);
|
||||
icon.setOnFocusChangeListener(mIconFocusListener);
|
||||
|
||||
@@ -274,9 +287,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
case VIEW_TYPE_ALL_APPS_DIVIDER:
|
||||
return new ViewHolder(mLayoutInflater.inflate(
|
||||
R.layout.all_apps_divider, parent, false));
|
||||
case VIEW_TYPE_WORK_TAB_FOOTER:
|
||||
View footer = mLayoutInflater.inflate(R.layout.work_tab_footer, parent, false);
|
||||
return new ViewHolder(footer);
|
||||
default:
|
||||
throw new RuntimeException("Unexpected view type");
|
||||
}
|
||||
@@ -308,15 +318,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
case VIEW_TYPE_ALL_APPS_DIVIDER:
|
||||
// nothing to do
|
||||
break;
|
||||
case VIEW_TYPE_WORK_TAB_FOOTER:
|
||||
WorkModeSwitch workModeToggle = holder.itemView.findViewById(R.id.work_mode_toggle);
|
||||
workModeToggle.refresh();
|
||||
TextView managedByLabel = holder.itemView.findViewById(R.id.managed_by_label);
|
||||
boolean anyProfileQuietModeEnabled = UserCache.INSTANCE.get(
|
||||
managedByLabel.getContext()).isAnyProfileQuietModeEnabled();
|
||||
managedByLabel.setText(anyProfileQuietModeEnabled
|
||||
? R.string.work_mode_off_label : R.string.work_mode_on_label);
|
||||
break;
|
||||
}
|
||||
if (mBindViewCallback != null) {
|
||||
mBindViewCallback.onBindView(holder);
|
||||
|
||||
@@ -28,14 +28,13 @@ import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.BaseRecyclerView;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter.AppsGridLayoutManager;
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
import com.android.launcher3.logging.StatsLogUtils.LogContainerProvider;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
@@ -84,7 +83,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine
|
||||
/**
|
||||
* Sets the list of apps in this view, used to determine the fastscroll position.
|
||||
*/
|
||||
public void setApps(AlphabeticalAppsList apps, boolean usingTabs) {
|
||||
public void setApps(AlphabeticalAppsList apps) {
|
||||
mApps = apps;
|
||||
mFastScrollHelper = new AllAppsFastScrollHelper(this, apps);
|
||||
}
|
||||
@@ -94,7 +93,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine
|
||||
}
|
||||
|
||||
private void updatePoolSize() {
|
||||
DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
|
||||
DeviceProfile grid = BaseDraggingActivity.fromContext(getContext()).getDeviceProfile();
|
||||
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
|
||||
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
|
||||
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
|
||||
|
||||
@@ -11,7 +11,7 @@ import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRE
|
||||
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
|
||||
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
|
||||
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
|
||||
import static com.android.launcher3.util.SystemUiController.UI_STATE_ALL_APPS;
|
||||
|
||||
import android.animation.Animator;
|
||||
@@ -46,7 +46,7 @@ import com.android.launcher3.views.ScrimView;
|
||||
*/
|
||||
public class AllAppsTransitionController implements StateHandler, OnDeviceProfileChangeListener {
|
||||
|
||||
private static final float SPRING_DAMPING_RATIO = 0.9f;
|
||||
private static final float SPRING_DAMPING_RATIO = 0.75f;
|
||||
private static final float SPRING_STIFFNESS = 600f;
|
||||
|
||||
public static final FloatProperty<AllAppsTransitionController> ALL_APPS_PROGRESS =
|
||||
@@ -185,7 +185,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
|
||||
}
|
||||
|
||||
public Animator createSpringAnimation(float... progressValues) {
|
||||
if (UNSTABLE_SPRINGS.get()) {
|
||||
if (QUICKSTEP_SPRINGS.get()) {
|
||||
return new SpringObjectAnimator<>(this, ALL_APPS_PROGRESS, 1f / mShiftRange,
|
||||
SPRING_DAMPING_RATIO, SPRING_STIFFNESS, progressValues);
|
||||
}
|
||||
|
||||
Loaded 100 of 169 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user