Snap for 8543047 from a5318619e6 to udc-release
Change-Id: I25ef77d2a6b34f2179303c69647b002697f25ce4
This commit is contained in:
commit
b6ec3dc96c
35 files changed
+480
-204
No files matched your search
@@ -55,13 +55,13 @@ import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.touch.ItemLongClickListener;
|
||||
import com.android.launcher3.uioverrides.PredictedAppIcon;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.OnboardingPrefs;
|
||||
import com.android.launcher3.views.Snackbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -480,8 +480,8 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
*
|
||||
* @param matcher filter matching items that have been removed
|
||||
*/
|
||||
public void onModelItemsRemoved(ItemInfoMatcher matcher) {
|
||||
if (mPredictedItems.removeIf(matcher::matchesInfo)) {
|
||||
public void onModelItemsRemoved(Predicate<ItemInfo> matcher) {
|
||||
if (mPredictedItems.removeIf(matcher)) {
|
||||
fillGapsWithPrediction(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ import com.android.systemui.shared.recents.model.Task;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Handles long click on Taskbar items to start a system drag and drop operation.
|
||||
@@ -439,12 +440,12 @@ public class TaskbarDragController extends DragController<BaseTaskbarContext> im
|
||||
target = taskbarViewController.getAllAppsButtonView();
|
||||
} else if (item.container >= 0) {
|
||||
// Since folders close when the drag starts, target the folder icon instead.
|
||||
ItemInfoMatcher matcher = ItemInfoMatcher.forFolderMatch(
|
||||
Predicate<ItemInfo> matcher = ItemInfoMatcher.forFolderMatch(
|
||||
ItemInfoMatcher.ofItemIds(IntSet.wrap(item.id)));
|
||||
target = taskbarViewController.getFirstIconMatch(matcher);
|
||||
} else if (item.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
// Find first icon with same package/user as the deep shortcut.
|
||||
ItemInfoMatcher packageUserMatcher = ItemInfoMatcher.ofPackages(
|
||||
Predicate<ItemInfo> packageUserMatcher = ItemInfoMatcher.ofPackages(
|
||||
Collections.singleton(item.getTargetPackage()), item.user);
|
||||
target = taskbarViewController.getFirstIconMatch(packageUserMatcher);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Launcher model Callbacks for rendering taskbar.
|
||||
@@ -137,16 +138,16 @@ public class TaskbarModelCallbacks implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher) {
|
||||
public void bindWorkspaceComponentsRemoved(Predicate<ItemInfo> matcher) {
|
||||
if (handleItemsRemoved(matcher)) {
|
||||
commitItemsToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleItemsRemoved(ItemInfoMatcher matcher) {
|
||||
private boolean handleItemsRemoved(Predicate<ItemInfo> matcher) {
|
||||
boolean modified = false;
|
||||
for (int i = mHotseatItems.size() - 1; i >= 0; i--) {
|
||||
if (matcher.matchesInfo(mHotseatItems.valueAt(i))) {
|
||||
if (matcher.test(mHotseatItems.valueAt(i))) {
|
||||
modified = true;
|
||||
mHotseatItems.removeAt(i);
|
||||
}
|
||||
|
||||
@@ -41,12 +41,13 @@ import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.uioverrides.ApiWrapper;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.LauncherBindableItemsContainer;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.AllAppsButton;
|
||||
import com.android.launcher3.views.DoubleShadowBubbleTextView;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Hosts the Taskbar content such as Hotseat and Recent Apps. Drawn on top of other apps.
|
||||
*/
|
||||
@@ -424,8 +425,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
* Finds the first icon to match one of the given matchers, from highest to lowest priority.
|
||||
* @return The first match, or All Apps button if no match was found.
|
||||
*/
|
||||
public View getFirstMatch(ItemInfoMatcher... matchers) {
|
||||
for (ItemInfoMatcher matcher : matchers) {
|
||||
public View getFirstMatch(Predicate<ItemInfo>... matchers) {
|
||||
for (Predicate<ItemInfo> matcher : matchers) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View item = getChildAt(i);
|
||||
if (!(item.getTag() instanceof ItemInfo)) {
|
||||
@@ -433,7 +434,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
continue;
|
||||
}
|
||||
ItemInfo info = (ItemInfo) item.getTag();
|
||||
if (matcher.matchesInfo(info)) {
|
||||
if (matcher.test(info)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Handles properties/data collection, then passes the results to TaskbarView to render.
|
||||
@@ -318,8 +319,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
* 2) FolderIcon of the Folder containing the given icon
|
||||
* 3) All Apps button
|
||||
*/
|
||||
public View getFirstIconMatch(ItemInfoMatcher matcher) {
|
||||
ItemInfoMatcher folderMatcher = ItemInfoMatcher.forFolderMatch(matcher);
|
||||
public View getFirstIconMatch(Predicate<ItemInfo> matcher) {
|
||||
Predicate<ItemInfo> folderMatcher = ItemInfoMatcher.forFolderMatch(matcher);
|
||||
return mTaskbarView.getFirstMatch(matcher, folderMatcher);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ import com.android.launcher3.uioverrides.touchcontrollers.TransposedQuickSwitchT
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.TwoButtonNavbarTouchController;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.PendingRequestArgs;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.launcher3.util.UiThreadHelper;
|
||||
@@ -86,6 +85,7 @@ import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
@@ -245,7 +245,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher) {
|
||||
public void bindWorkspaceComponentsRemoved(Predicate<ItemInfo> matcher) {
|
||||
super.bindWorkspaceComponentsRemoved(matcher);
|
||||
mHotseatPredictionController.onModelItemsRemoved(matcher);
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ public class AllAppsState extends LauncherState {
|
||||
|
||||
@Override
|
||||
public int getVisibleElements(Launcher launcher) {
|
||||
// Don't add HOTSEAT_ICONS for phones in ALL_APPS state.
|
||||
return launcher.getDeviceProfile().isPhone ? ALL_APPS_CONTENT
|
||||
: ALL_APPS_CONTENT | HOTSEAT_ICONS;
|
||||
// Don't add HOTSEAT_ICONS for non-tablets in ALL_APPS state.
|
||||
return launcher.getDeviceProfile().isTablet ? ALL_APPS_CONTENT | HOTSEAT_ICONS
|
||||
: ALL_APPS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,9 +66,9 @@ public class OverviewState extends LauncherState {
|
||||
@Override
|
||||
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
|
||||
RecentsView recentsView = launcher.getOverviewPanel();
|
||||
float workspacePageWidth = launcher.getDeviceProfile().getWorkspaceWidth();
|
||||
float workspacePageHeight = launcher.getDeviceProfile().getCellLayoutHeight();
|
||||
recentsView.getTaskSize(sTempRect);
|
||||
float scale = (float) sTempRect.width() / workspacePageWidth;
|
||||
float scale = (float) sTempRect.height() / workspacePageHeight;
|
||||
float parallaxFactor = 0.5f;
|
||||
return new ScaleAndTranslation(scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
|
||||
import static com.android.launcher3.BaseActivity.INVISIBLE_ALL;
|
||||
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS;
|
||||
import static com.android.launcher3.BaseActivity.PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION;
|
||||
@@ -37,6 +38,7 @@ import android.view.animation.Interpolator;
|
||||
import android.window.BackEvent;
|
||||
import android.window.IOnBackInvokedCallback;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.BaseQuickstepLauncher;
|
||||
import com.android.launcher3.QuickstepTransitionManager;
|
||||
import com.android.launcher3.R;
|
||||
@@ -274,6 +276,10 @@ public class LauncherBackAnimationController {
|
||||
mLauncher.getStateManager().moveToRestState();
|
||||
}
|
||||
|
||||
// Explicitly close opened floating views (which is typically called from
|
||||
// Launcher#onResumed, but in the predictive back flow launcher is not resumed until
|
||||
// the transition is fully finished.)
|
||||
AbstractFloatingView.closeAllOpenViewsExcept(mLauncher, false, TYPE_REBIND_SAFE);
|
||||
float cornerRadius = Utilities.mapRange(
|
||||
mBackProgress, mWindowScaleStartCornerRadius, mWindowScaleEndCornerRadius);
|
||||
Pair<RectFSpringAnim, AnimatorSet> pair =
|
||||
|
||||
@@ -104,8 +104,7 @@ public class RecentsAnimationCallbacks implements
|
||||
.map(RemoteAnimationTargetCompat::unwrap)
|
||||
.toArray(RemoteAnimationTarget[]::new);
|
||||
|
||||
RemoteAnimationTarget[] nonAppTargets =
|
||||
mSystemUiProxy.onGoingToRecentsLegacy(mCancelled, nonHomeApps);
|
||||
RemoteAnimationTarget[] nonAppTargets = mSystemUiProxy.onGoingToRecentsLegacy(nonHomeApps);
|
||||
|
||||
RecentsAnimationTargets targets = new RecentsAnimationTargets(appTargets,
|
||||
wallpaperTargets, RemoteAnimationTargetCompat.wrap(nonAppTargets),
|
||||
|
||||
@@ -680,14 +680,12 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
|
||||
* Call this when going to recents so that shell can set-up and provide appropriate leashes
|
||||
* for animation (eg. DividerBar).
|
||||
*
|
||||
* @param cancel true if recents starting is being cancelled.
|
||||
* @return RemoteAnimationTargets of windows that need to animate but only exist in shell.
|
||||
*/
|
||||
public RemoteAnimationTarget[] onGoingToRecentsLegacy(boolean cancel,
|
||||
RemoteAnimationTarget[] apps) {
|
||||
public RemoteAnimationTarget[] onGoingToRecentsLegacy(RemoteAnimationTarget[] apps) {
|
||||
if (mSplitScreen != null) {
|
||||
try {
|
||||
return mSplitScreen.onGoingToRecentsLegacy(cancel, apps);
|
||||
return mSplitScreen.onGoingToRecentsLegacy(apps);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed call onGoingToRecentsLegacy");
|
||||
}
|
||||
@@ -695,6 +693,17 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
|
||||
return null;
|
||||
}
|
||||
|
||||
public RemoteAnimationTarget[] onStartingSplitLegacy(RemoteAnimationTarget[] apps) {
|
||||
if (mSplitScreen != null) {
|
||||
try {
|
||||
return mSplitScreen.onStartingSplitLegacy(apps);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed call onStartingSplitLegacy");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// One handed
|
||||
//
|
||||
|
||||
@@ -177,8 +177,9 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
((RecentsActivity) activityInterface.getCreatedActivity()).startHome();
|
||||
return;
|
||||
}
|
||||
RemoteAnimationTarget[] nonAppTargets = SystemUiProxy.INSTANCE.get(mCtx)
|
||||
.onGoingToRecentsLegacy(false, nonHomeApps);
|
||||
|
||||
RemoteAnimationTarget[] nonAppTargets =
|
||||
SystemUiProxy.INSTANCE.getNoCreate().onStartingSplitLegacy(nonHomeApps);
|
||||
|
||||
if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode()
|
||||
&& activityInterface.getCreatedActivity() != null) {
|
||||
|
||||
@@ -2704,13 +2704,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
PendingAnimation anim) {
|
||||
// Use setFloat instead of setViewAlpha as we want to keep the view visible even when it's
|
||||
// alpha is set to 0 so that it can be recycled in the view pool properly
|
||||
if (ENABLE_QUICKSTEP_LIVE_TILE.get() && taskView.isRunningTask()) {
|
||||
runActionOnRemoteHandles(remoteTargetHandle -> {
|
||||
TransformParams params = remoteTargetHandle.getTransformParams();
|
||||
anim.setFloat(params, TransformParams.TARGET_ALPHA, 0,
|
||||
clampToProgress(FINAL_FRAME, 0, 0.5f));
|
||||
});
|
||||
}
|
||||
anim.setFloat(taskView, VIEW_ALPHA, 0,
|
||||
clampToProgress(isOnGridBottomRow(taskView) ? ACCEL : FINAL_FRAME, 0, 0.5f));
|
||||
FloatProperty<TaskView> secondaryViewTranslate =
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<string name="folder_name_format_exact" msgid="8626242716117004803">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> items"</string>
|
||||
<string name="folder_name_format_overflow" msgid="4270108890534995199">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> or more items"</string>
|
||||
<string name="wallpaper_button_text" msgid="8404103075899945851">"Wallpapers"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper & style"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper and style"</string>
|
||||
<string name="settings_button_text" msgid="8873672322605444408">"Home settings"</string>
|
||||
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Disabled by your admin"</string>
|
||||
<string name="allow_rotation_title" msgid="7222049633713050106">"Allow home screen rotation"</string>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<string name="folder_name_format_exact" msgid="8626242716117004803">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> items"</string>
|
||||
<string name="folder_name_format_overflow" msgid="4270108890534995199">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> or more items"</string>
|
||||
<string name="wallpaper_button_text" msgid="8404103075899945851">"Wallpapers"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper & style"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper and style"</string>
|
||||
<string name="settings_button_text" msgid="8873672322605444408">"Home settings"</string>
|
||||
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Disabled by your admin"</string>
|
||||
<string name="allow_rotation_title" msgid="7222049633713050106">"Allow home screen rotation"</string>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<string name="folder_name_format_exact" msgid="8626242716117004803">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> items"</string>
|
||||
<string name="folder_name_format_overflow" msgid="4270108890534995199">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> or more items"</string>
|
||||
<string name="wallpaper_button_text" msgid="8404103075899945851">"Wallpapers"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper & style"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper and style"</string>
|
||||
<string name="settings_button_text" msgid="8873672322605444408">"Home settings"</string>
|
||||
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Disabled by your admin"</string>
|
||||
<string name="allow_rotation_title" msgid="7222049633713050106">"Allow home screen rotation"</string>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<string name="folder_name_format_exact" msgid="8626242716117004803">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> items"</string>
|
||||
<string name="folder_name_format_overflow" msgid="4270108890534995199">"Folder: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> or more items"</string>
|
||||
<string name="wallpaper_button_text" msgid="8404103075899945851">"Wallpapers"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper & style"</string>
|
||||
<string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Wallpaper and style"</string>
|
||||
<string name="settings_button_text" msgid="8873672322605444408">"Home settings"</string>
|
||||
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Disabled by your admin"</string>
|
||||
<string name="allow_rotation_title" msgid="7222049633713050106">"Allow home screen rotation"</string>
|
||||
|
||||
@@ -78,11 +78,11 @@
|
||||
<string name="dismiss_prediction_label" msgid="3357562989568808658">"Թաքցնել առաջարկը"</string>
|
||||
<string name="pin_prediction" msgid="4196423321649756498">"Ամրացնել առաջարկվող հավելվածը"</string>
|
||||
<string name="permlab_install_shortcut" msgid="5632423390354674437">"Դյուրանցումների տեղադրում"</string>
|
||||
<string name="permdesc_install_shortcut" msgid="923466509822011139">"Ծրագրին թույլ է տալիս ավելացնել դյուրանցումներ՝ առանց օգտագործողի միջամտության:"</string>
|
||||
<string name="permdesc_install_shortcut" msgid="923466509822011139">"Հավելվածին թույլ է տալիս ավելացնել դյուրանցումներ՝ առանց օգտագործողի միջամտության:"</string>
|
||||
<string name="permlab_read_settings" msgid="5136500343007704955">"կարդալ հիմնական էկրանի կարգավորումներն ու դյուրանցումները"</string>
|
||||
<string name="permdesc_read_settings" msgid="4208061150510996676">"Ծրագրին թույլ է տալիս կարդալ հիմնական էկրանի կարգավորումներն ու դյուրանցումները։"</string>
|
||||
<string name="permdesc_read_settings" msgid="4208061150510996676">"Հավելվածին թույլ է տալիս կարդալ հիմնական էկրանի կարգավորումներն ու դյուրանցումները։"</string>
|
||||
<string name="permlab_write_settings" msgid="4820028712156303762">"փոփոխել հիմնական էկրանի կարգավորումներն ու դյուրանցումները"</string>
|
||||
<string name="permdesc_write_settings" msgid="726859348127868466">"Ծրագրին թույլ է տալիս փոփոխել հիմնական էկրանի կարգավորումներն ու դյուրանցումները։"</string>
|
||||
<string name="permdesc_write_settings" msgid="726859348127868466">"Հավելվածին թույլ է տալիս փոփոխել հիմնական էկրանի կարգավորումներն ու դյուրանցումները։"</string>
|
||||
<string name="msg_no_phone_permission" msgid="9208659281529857371">"<xliff:g id="APP_NAME">%1$s</xliff:g> հավելվածին չի թույլատրվում հեռախոսազանգեր կատարել"</string>
|
||||
<string name="gadget_error_text" msgid="740356548025791839">"Չհաջողվեց բեռնել վիջեթը"</string>
|
||||
<string name="gadget_setup_text" msgid="8348374825537681407">"Վիջեթի կարգավորումներ"</string>
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
<string name="action_dismiss_notification" msgid="5909461085055959187">"Zamknij"</string>
|
||||
<string name="accessibility_close" msgid="2277148124685870734">"Zamknij"</string>
|
||||
<string name="notification_dismissed" msgid="6002233469409822874">"Powiadomienie odrzucone"</string>
|
||||
<string name="all_apps_personal_tab" msgid="4190252696685155002">"Prywatne"</string>
|
||||
<string name="all_apps_personal_tab" msgid="4190252696685155002">"Osobiste"</string>
|
||||
<string name="all_apps_work_tab" msgid="4884822796154055118">"Służbowe"</string>
|
||||
<string name="work_profile_toggle_label" msgid="3081029915775481146">"Profil służbowy"</string>
|
||||
<string name="work_profile_edu_work_apps" msgid="7895468576497746520">"Aplikacje służbowe mają plakietki i są widoczne dla administratora IT"</string>
|
||||
|
||||
@@ -501,7 +501,7 @@ public class DeviceProfile {
|
||||
*/
|
||||
private int calculateQsbWidth() {
|
||||
if (isQsbInline) {
|
||||
int columns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
||||
int columns = getPanelCount() * inv.numColumns;
|
||||
return getIconToIconWidthForColumns(columns)
|
||||
- iconSizePx * numShownHotseatIcons
|
||||
- hotseatBorderSpace * numShownHotseatIcons;
|
||||
@@ -665,11 +665,10 @@ public class DeviceProfile {
|
||||
updateIconSize(1f, res);
|
||||
|
||||
updateWorkspacePadding();
|
||||
Point workspacePadding = getTotalWorkspacePadding();
|
||||
|
||||
// Check to see if the icons fit within the available height.
|
||||
float usedHeight = getCellLayoutHeightSpecification();
|
||||
final int maxHeight = getWorkspaceHeight(workspacePadding);
|
||||
final int maxHeight = getCellLayoutHeight();
|
||||
float extraHeight = Math.max(0, maxHeight - usedHeight);
|
||||
float scaleY = maxHeight / usedHeight;
|
||||
boolean shouldScale = scaleY < 1f;
|
||||
@@ -702,7 +701,7 @@ public class DeviceProfile {
|
||||
}
|
||||
|
||||
private int getCellLayoutWidthSpecification() {
|
||||
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
||||
int numColumns = getPanelCount() * inv.numColumns;
|
||||
return (cellWidthPx * numColumns) + (cellLayoutBorderSpacePx.x * (numColumns - 1))
|
||||
+ cellLayoutPaddingPx.left + cellLayoutPaddingPx.right;
|
||||
}
|
||||
@@ -902,18 +901,20 @@ public class DeviceProfile {
|
||||
result = new Point();
|
||||
}
|
||||
|
||||
// Since we are only concerned with the overall padding, layout direction does
|
||||
// not matter.
|
||||
Point padding = getTotalWorkspacePadding();
|
||||
|
||||
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
||||
int screenWidthPx = getWorkspaceWidth(padding);
|
||||
result.x = calculateCellWidth(screenWidthPx, cellLayoutBorderSpacePx.x, numColumns);
|
||||
int screenHeightPx = getWorkspaceHeight(padding);
|
||||
result.y = calculateCellHeight(screenHeightPx, cellLayoutBorderSpacePx.y, inv.numRows);
|
||||
result.x = calculateCellWidth(getShortcutAndWidgetContainerWidth(),
|
||||
cellLayoutBorderSpacePx.x, inv.numColumns);
|
||||
result.y = calculateCellHeight(getShortcutAndWidgetContainerHeight(),
|
||||
cellLayoutBorderSpacePx.y, inv.numRows);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of panels within the workspace.
|
||||
*/
|
||||
public int getPanelCount() {
|
||||
return isTwoPanels ? 2 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the space in px from the bottom of last item in the vertical-bar hotseat to the
|
||||
* bottom of the screen.
|
||||
@@ -932,7 +933,7 @@ public class DeviceProfile {
|
||||
/**
|
||||
* Gets the scaled top of the workspace in px for the spring-loaded edit state.
|
||||
*/
|
||||
public float getWorkspaceSpringLoadShrunkTop() {
|
||||
public float getCellLayoutSpringLoadShrunkTop() {
|
||||
workspaceSpringLoadShrunkTop = mInsets.top + dropTargetBarTopMarginPx + dropTargetBarSizePx
|
||||
+ dropTargetBarBottomMarginPx;
|
||||
return workspaceSpringLoadShrunkTop;
|
||||
@@ -941,7 +942,7 @@ public class DeviceProfile {
|
||||
/**
|
||||
* Gets the scaled bottom of the workspace in px for the spring-loaded edit state.
|
||||
*/
|
||||
private float getWorkspaceSpringLoadShrunkBottom() {
|
||||
private float getCellLayoutSpringLoadShrunkBottom() {
|
||||
int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx;
|
||||
workspaceSpringLoadShrunkBottom =
|
||||
heightPx - (isVerticalBarLayout() ? getVerticalHotseatLastItemBottomOffset()
|
||||
@@ -960,9 +961,8 @@ public class DeviceProfile {
|
||||
* Gets the scale of the workspace for the spring-loaded edit state.
|
||||
*/
|
||||
public float getWorkspaceSpringLoadScale() {
|
||||
float cellLayoutHeight = availableHeightPx - workspacePadding.top - workspacePadding.bottom;
|
||||
float scale = (getWorkspaceSpringLoadShrunkBottom() - getWorkspaceSpringLoadShrunkTop())
|
||||
/ cellLayoutHeight;
|
||||
float scale = (getCellLayoutSpringLoadShrunkBottom() - getCellLayoutSpringLoadShrunkTop())
|
||||
/ getCellLayoutHeight();
|
||||
scale = Math.min(scale, 1f);
|
||||
|
||||
// Reduce scale if next pages would not be visible after scaling the workspace
|
||||
@@ -976,19 +976,55 @@ public class DeviceProfile {
|
||||
return scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the width of the Workspace, aka a scrollable page of the homescreen.
|
||||
*/
|
||||
public int getWorkspaceWidth() {
|
||||
return getWorkspaceWidth(getTotalWorkspacePadding());
|
||||
return availableWidthPx;
|
||||
}
|
||||
|
||||
public int getWorkspaceWidth(Point workspacePadding) {
|
||||
int cellLayoutTotalPadding =
|
||||
(isTwoPanels ? 2 : 1) * (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right);
|
||||
return availableWidthPx - workspacePadding.x - cellLayoutTotalPadding;
|
||||
/**
|
||||
* Gets the height of the Workspace, aka a scrollable page of the homescreen.
|
||||
*/
|
||||
public int getWorkspaceHeight() {
|
||||
return availableHeightPx;
|
||||
}
|
||||
|
||||
private int getWorkspaceHeight(Point workspacePadding) {
|
||||
return availableHeightPx - workspacePadding.y - (cellLayoutPaddingPx.top
|
||||
+ cellLayoutPaddingPx.bottom);
|
||||
/**
|
||||
* Gets the width of a single Cell Layout, aka a single panel within a Workspace.
|
||||
*
|
||||
* <p>This is the width of a Workspace, less its horizontal padding. Note that two-panel
|
||||
* layouts have two Cell Layouts per workspace.
|
||||
*/
|
||||
public int getCellLayoutWidth() {
|
||||
return (getWorkspaceWidth() - getTotalWorkspacePadding().x) / getPanelCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the height of a single Cell Layout, aka a single panel within a Workspace.
|
||||
*
|
||||
* <p>This is the height of a Workspace, less its vertical padding.
|
||||
*/
|
||||
public int getCellLayoutHeight() {
|
||||
return getWorkspaceHeight() - getTotalWorkspacePadding().y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the width of the container holding the shortcuts and widgets.
|
||||
*
|
||||
* <p>This is the width of one Cell Layout less its horizontal padding.
|
||||
*/
|
||||
public int getShortcutAndWidgetContainerWidth() {
|
||||
return getCellLayoutWidth() - (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the height of the container holding the shortcuts and widgets.
|
||||
*
|
||||
* <p>This is the height of one Cell Layout less its vertical padding.
|
||||
*/
|
||||
public int getShortcutAndWidgetContainerHeight() {
|
||||
return getCellLayoutHeight() - (cellLayoutPaddingPx.top + cellLayoutPaddingPx.bottom);
|
||||
}
|
||||
|
||||
public Point getTotalWorkspacePadding() {
|
||||
|
||||
@@ -61,6 +61,8 @@ import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
@@ -628,8 +630,21 @@ public class InvariantDeviceProfile {
|
||||
|
||||
float screenWidth = config.screenWidthDp * res.getDisplayMetrics().density;
|
||||
float screenHeight = config.screenHeightDp * res.getDisplayMetrics().density;
|
||||
return getBestMatch(screenWidth, screenHeight,
|
||||
WindowManagerProxy.INSTANCE.get(context).getRotation(context));
|
||||
int rotation = WindowManagerProxy.INSTANCE.get(context).getRotation(context);
|
||||
|
||||
if (Utilities.IS_DEBUG_DEVICE) {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
DisplayController.INSTANCE.get(context).dump(printWriter);
|
||||
printWriter.flush();
|
||||
Log.d("b/231312158", "getDeviceProfile -"
|
||||
+ "\nconfig: " + config
|
||||
+ "\ndisplayMetrics: " + res.getDisplayMetrics()
|
||||
+ "\nrotation: " + rotation
|
||||
+ "\n" + stringWriter.toString(),
|
||||
new Exception());
|
||||
}
|
||||
return getBestMatch(screenWidth, screenHeight, rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -182,7 +182,6 @@ import com.android.launcher3.util.ActivityTracker;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.OnboardingPrefs;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
@@ -2739,9 +2738,9 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
*/
|
||||
public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user,
|
||||
boolean supportsAllAppsState) {
|
||||
final ItemInfoMatcher preferredItem = (info, cn) ->
|
||||
final Predicate<ItemInfo> preferredItem = info ->
|
||||
info != null && info.id == preferredItemId;
|
||||
final ItemInfoMatcher packageAndUserAndApp = (info, cn) ->
|
||||
final Predicate<ItemInfo> packageAndUserAndApp = info ->
|
||||
info != null
|
||||
&& info.itemType == ITEM_TYPE_APPLICATION
|
||||
&& info.user.equals(user)
|
||||
@@ -2770,8 +2769,8 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
* @param operators List of operators, in order starting from best matching operator.
|
||||
*/
|
||||
private static View getFirstMatch(Iterable<ViewGroup> containers,
|
||||
final ItemInfoMatcher... operators) {
|
||||
for (ItemInfoMatcher operator : operators) {
|
||||
final Predicate<ItemInfo>... operators) {
|
||||
for (Predicate<ItemInfo> operator : operators) {
|
||||
for (ViewGroup container : containers) {
|
||||
View match = mapOverViewGroup(container, operator);
|
||||
if (match != null) {
|
||||
@@ -2786,11 +2785,11 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
* Returns the first view matching the operator in the given ViewGroups, or null if none.
|
||||
* Forward iteration matters.
|
||||
*/
|
||||
private static View mapOverViewGroup(ViewGroup container, ItemInfoMatcher op) {
|
||||
private static View mapOverViewGroup(ViewGroup container, Predicate<ItemInfo> op) {
|
||||
final int itemCount = container.getChildCount();
|
||||
for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
|
||||
View item = container.getChildAt(itemIdx);
|
||||
if (op.matchesInfo((ItemInfo) item.getTag())) {
|
||||
if (op.test((ItemInfo) item.getTag())) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -2887,7 +2886,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
* package-removal should clear all items by package name.
|
||||
*/
|
||||
@Override
|
||||
public void bindWorkspaceComponentsRemoved(final ItemInfoMatcher matcher) {
|
||||
public void bindWorkspaceComponentsRemoved(Predicate<ItemInfo> matcher) {
|
||||
mWorkspace.removeItemsByMatcher(matcher);
|
||||
mDragController.onAppsRemoved(matcher);
|
||||
PopupContainerWithArrow.dismissInvalidPopup(this);
|
||||
|
||||
@@ -102,7 +102,6 @@ import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.IntSparseArrayMap;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.LauncherBindableItemsContainer;
|
||||
import com.android.launcher3.util.OverlayEdgeEffect;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
@@ -3235,7 +3234,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
* as a part of an update, this is called to ensure that other widgets and application
|
||||
* shortcuts are not removed.
|
||||
*/
|
||||
public void removeItemsByMatcher(final ItemInfoMatcher matcher) {
|
||||
public void removeItemsByMatcher(final Predicate<ItemInfo> matcher) {
|
||||
for (CellLayout layout : getWorkspaceAndHotseatCellLayouts()) {
|
||||
ShortcutAndWidgetContainer container = layout.getShortcutsAndWidgets();
|
||||
// Iterate in reverse order as we are removing items
|
||||
@@ -3243,7 +3242,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
View child = container.getChildAt(i);
|
||||
ItemInfo info = (ItemInfo) child.getTag();
|
||||
|
||||
if (matcher.matchesInfo(info)) {
|
||||
if (matcher.test(info)) {
|
||||
layout.removeViewInLayout(child);
|
||||
if (child instanceof DropTarget) {
|
||||
mDragController.removeDropTarget((DropTarget) child);
|
||||
@@ -3251,7 +3250,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
} else if (child instanceof FolderIcon) {
|
||||
FolderInfo folderInfo = (FolderInfo) info;
|
||||
List<WorkspaceItemInfo> matches = folderInfo.contents.stream()
|
||||
.filter(matcher::matchesInfo)
|
||||
.filter(matcher)
|
||||
.collect(Collectors.toList());
|
||||
if (!matches.isEmpty()) {
|
||||
folderInfo.removeAll(matches, false);
|
||||
@@ -3330,7 +3329,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
*
|
||||
* @param matcher the matcher generated by the caller.
|
||||
*/
|
||||
public void persistRemoveItemsByMatcher(ItemInfoMatcher matcher) {
|
||||
public void persistRemoveItemsByMatcher(Predicate<ItemInfo> matcher) {
|
||||
mLauncher.getModelWriter().deleteItemsFromDatabase(matcher);
|
||||
removeItemsByMatcher(matcher);
|
||||
}
|
||||
|
||||
@@ -21,17 +21,18 @@ import android.content.Context;
|
||||
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.LabelComparator;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* The alphabetically sorted list of applications.
|
||||
@@ -82,7 +83,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
||||
private AppInfoComparator mAppNameComparator;
|
||||
private final int mNumAppsPerRowAllApps;
|
||||
private int mNumAppRowsInAdapter;
|
||||
private ItemInfoMatcher mItemFilter;
|
||||
private Predicate<ItemInfo> mItemFilter;
|
||||
|
||||
public AlphabeticalAppsList(Context context, AllAppsStore appsStore,
|
||||
WorkAdapterProvider adapterProvider) {
|
||||
@@ -94,7 +95,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
||||
mAllAppsStore.addUpdateListener(this);
|
||||
}
|
||||
|
||||
public void updateItemFilter(ItemInfoMatcher itemFilter) {
|
||||
public void updateItemFilter(Predicate<ItemInfo> itemFilter) {
|
||||
this.mItemFilter = itemFilter;
|
||||
onAppsUpdated();
|
||||
}
|
||||
@@ -200,13 +201,11 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
||||
// Sort the list of apps
|
||||
mApps.clear();
|
||||
|
||||
for (AppInfo app : mAllAppsStore.getApps()) {
|
||||
if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
|
||||
mApps.add(app);
|
||||
}
|
||||
Stream<AppInfo> appSteam = Stream.of(mAllAppsStore.getApps());
|
||||
if (!hasFilter() && mItemFilter != null) {
|
||||
appSteam = appSteam.filter(mItemFilter);
|
||||
}
|
||||
|
||||
Collections.sort(mApps, mAppNameComparator);
|
||||
appSteam = appSteam.sorted(mAppNameComparator);
|
||||
|
||||
// As a special case for some languages (currently only Simplified Chinese), we may need to
|
||||
// coalesce sections
|
||||
@@ -215,27 +214,16 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
||||
if (localeRequiresSectionSorting) {
|
||||
// Compute the section headers. We use a TreeMap with the section name comparator to
|
||||
// ensure that the sections are ordered when we iterate over it later
|
||||
TreeMap<String, ArrayList<AppInfo>> sectionMap = new TreeMap<>(new LabelComparator());
|
||||
for (AppInfo info : mApps) {
|
||||
// Add the section to the cache
|
||||
String sectionName = info.sectionName;
|
||||
|
||||
// Add it to the mapping
|
||||
ArrayList<AppInfo> sectionApps = sectionMap.get(sectionName);
|
||||
if (sectionApps == null) {
|
||||
sectionApps = new ArrayList<>();
|
||||
sectionMap.put(sectionName, sectionApps);
|
||||
}
|
||||
sectionApps.add(info);
|
||||
}
|
||||
|
||||
// Add each of the section apps to the list in order
|
||||
mApps.clear();
|
||||
for (Map.Entry<String, ArrayList<AppInfo>> entry : sectionMap.entrySet()) {
|
||||
mApps.addAll(entry.getValue());
|
||||
}
|
||||
appSteam = appSteam.collect(Collectors.groupingBy(
|
||||
info -> info.sectionName,
|
||||
() -> new TreeMap<>(new LabelComparator()),
|
||||
Collectors.toCollection(ArrayList::new)))
|
||||
.values()
|
||||
.stream()
|
||||
.flatMap(ArrayList::stream);
|
||||
}
|
||||
|
||||
appSteam.forEachOrdered(mApps::add);
|
||||
// Recompose the set of adapter items from the current set of apps
|
||||
if (mSearchResults.isEmpty()) {
|
||||
updateAdapterItems();
|
||||
|
||||
@@ -58,7 +58,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
import com.android.launcher3.model.StringCache;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
@@ -69,6 +69,8 @@ import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.OnActivePag
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Base all apps view container.
|
||||
@@ -91,7 +93,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
/** Context of an activity or window that is inflating this container. */
|
||||
protected final T mActivityContext;
|
||||
protected final List<AdapterHolder> mAH;
|
||||
protected final ItemInfoMatcher mPersonalMatcher = ItemInfoMatcher.ofUser(
|
||||
protected final Predicate<ItemInfo> mPersonalMatcher = ItemInfoMatcher.ofUser(
|
||||
Process.myUserHandle());
|
||||
private final SearchAdapterProvider<?> mMainAdapterProvider;
|
||||
private final AllAppsStore mAllAppsStore = new AllAppsStore();
|
||||
@@ -229,17 +231,10 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
}
|
||||
|
||||
private void onAppsUpdated() {
|
||||
boolean hasWorkApps = false;
|
||||
for (AppInfo app : mAllAppsStore.getApps()) {
|
||||
if (mWorkManager.getMatcher().matches(app, null)) {
|
||||
hasWorkApps = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mHasWorkApps = hasWorkApps;
|
||||
mHasWorkApps = Stream.of(mAllAppsStore.getApps()).anyMatch(mWorkManager.getMatcher());
|
||||
if (!mAH.get(AdapterHolder.MAIN).mAppsList.hasFilter()) {
|
||||
rebindAdapters();
|
||||
if (hasWorkApps) {
|
||||
if (mHasWorkApps) {
|
||||
mWorkManager.reset();
|
||||
}
|
||||
}
|
||||
@@ -731,7 +726,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
mLayoutManager = adapter.getLayoutManager();
|
||||
}
|
||||
|
||||
void setup(@NonNull View rv, @Nullable ItemInfoMatcher matcher) {
|
||||
void setup(@NonNull View rv, @Nullable Predicate<ItemInfo> matcher) {
|
||||
mAppsList.updateItemFilter(matcher);
|
||||
mRecyclerView = (AllAppsRecyclerView) rv;
|
||||
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -35,11 +34,12 @@ import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Companion class for {@link BaseAllAppsContainerView} to manage work tab and personal tab
|
||||
@@ -70,7 +70,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
|
||||
|
||||
private final BaseAllAppsContainerView<?> mAllApps;
|
||||
private final WorkAdapterProvider mAdapterProvider;
|
||||
private final ItemInfoMatcher mMatcher;
|
||||
private final Predicate<ItemInfo> mMatcher;
|
||||
|
||||
private WorkModeSwitch mWorkModeSwitch;
|
||||
|
||||
@@ -176,7 +176,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
|
||||
return mAdapterProvider;
|
||||
}
|
||||
|
||||
public ItemInfoMatcher getMatcher() {
|
||||
public Predicate<ItemInfo> getMatcher() {
|
||||
return mMatcher;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.launcher3.dragndrop;
|
||||
|
||||
import static com.android.launcher3.Utilities.ATLEAST_Q;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -36,12 +35,12 @@ import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Class for initiating a drag within a view or across multiple views.
|
||||
@@ -275,15 +274,12 @@ public abstract class DragController<T extends ActivityContext>
|
||||
|
||||
protected abstract void exitDrag();
|
||||
|
||||
public void onAppsRemoved(ItemInfoMatcher matcher) {
|
||||
public void onAppsRemoved(Predicate<ItemInfo> matcher) {
|
||||
// Cancel the current drag if we are removing an app that we are dragging
|
||||
if (mDragObject != null) {
|
||||
ItemInfo dragInfo = mDragObject.dragInfo;
|
||||
if (dragInfo instanceof WorkspaceItemInfo) {
|
||||
ComponentName cn = dragInfo.getTargetComponent();
|
||||
if (cn != null && matcher.matches(dragInfo, cn)) {
|
||||
cancelDrag();
|
||||
}
|
||||
if (dragInfo instanceof WorkspaceItemInfo && matcher.test(dragInfo)) {
|
||||
cancelDrag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ import com.android.launcher3.compat.AlphabeticIndexCompat;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.FlagOp;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
|
||||
@@ -47,6 +47,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
/**
|
||||
@@ -257,11 +258,11 @@ public class AllAppsList {
|
||||
/**
|
||||
* Updates the disabled flags of apps matching {@param matcher} based on {@param op}.
|
||||
*/
|
||||
public void updateDisabledFlags(ItemInfoMatcher matcher, FlagOp op) {
|
||||
public void updateDisabledFlags(Predicate<ItemInfo> matcher, FlagOp op) {
|
||||
final List<AppInfo> data = this.data;
|
||||
for (int i = data.size() - 1; i >= 0; i--) {
|
||||
AppInfo info = data.get(i);
|
||||
if (matcher.matches(info, info.componentName)) {
|
||||
if (matcher.test(info)) {
|
||||
info.runtimeStatusFlags = op.apply(info.runtimeStatusFlags);
|
||||
mDataChanged = true;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,6 +34,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
|
||||
scheduleCallbackTask(c -> c.bindAllWidgets(widgets));
|
||||
}
|
||||
|
||||
public void deleteAndBindComponentsRemoved(final ItemInfoMatcher matcher) {
|
||||
public void deleteAndBindComponentsRemoved(final Predicate<ItemInfo> matcher) {
|
||||
getModelWriter().deleteItemsFromDatabase(matcher);
|
||||
|
||||
// Call the components-removed callback
|
||||
|
||||
@@ -50,7 +50,6 @@ import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.IntSparseArrayMap;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.RunnableList;
|
||||
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
|
||||
|
||||
@@ -66,6 +65,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -495,7 +495,7 @@ public class BgDataModel {
|
||||
default void bindWorkspaceItemsChanged(List<WorkspaceItemInfo> updated) { }
|
||||
default void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets) { }
|
||||
default void bindRestoreItemsChange(HashSet<ItemInfo> updates) { }
|
||||
default void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher) { }
|
||||
default void bindWorkspaceComponentsRemoved(Predicate<ItemInfo> matcher) { }
|
||||
default void bindAllWidgets(List<WidgetsListBaseEntry> widgets) { }
|
||||
|
||||
default void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks) {
|
||||
|
||||
@@ -53,6 +53,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
@@ -278,10 +279,9 @@ public class ModelWriter {
|
||||
/**
|
||||
* Removes all the items from the database matching {@param matcher}.
|
||||
*/
|
||||
public void deleteItemsFromDatabase(ItemInfoMatcher matcher) {
|
||||
public void deleteItemsFromDatabase(Predicate<ItemInfo> matcher) {
|
||||
deleteItemsFromDatabase(StreamSupport.stream(mBgDataModel.itemsIdMap.spliterator(), false)
|
||||
.filter(matcher::matchesInfo)
|
||||
.collect(Collectors.toList()));
|
||||
.filter(matcher).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,6 +57,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Handles updates due to changes in package manager (app installed/updated/removed)
|
||||
@@ -95,7 +96,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||
final int N = packages.length;
|
||||
final FlagOp flagOp;
|
||||
final HashSet<String> packageSet = new HashSet<>(Arrays.asList(packages));
|
||||
final ItemInfoMatcher matcher = mOp == OP_USER_AVAILABILITY_CHANGE
|
||||
final Predicate<ItemInfo> matcher = mOp == OP_USER_AVAILABILITY_CHANGE
|
||||
? ItemInfoMatcher.ofUser(mUser) // We want to update all packages for this user
|
||||
: ItemInfoMatcher.ofPackages(packageSet, mUser);
|
||||
final HashSet<ComponentName> removedComponents = new HashSet<>();
|
||||
@@ -206,7 +207,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||
}
|
||||
|
||||
ComponentName cn = si.getTargetComponent();
|
||||
if (cn != null && matcher.matches(si, cn)) {
|
||||
if (cn != null && matcher.test(si)) {
|
||||
String packageName = cn.getPackageName();
|
||||
|
||||
if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI)) {
|
||||
@@ -336,7 +337,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||
}
|
||||
|
||||
if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) {
|
||||
ItemInfoMatcher removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser)
|
||||
Predicate<ItemInfo> removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser)
|
||||
.or(ItemInfoMatcher.ofComponents(removedComponents, mUser))
|
||||
.and(ItemInfoMatcher.ofItemIds(forceKeepShortcuts).negate());
|
||||
deleteAndBindComponentsRemoved(removeMatch);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SpringLoadedState extends LauncherState {
|
||||
return super.getWorkspaceScaleAndTranslation(launcher);
|
||||
}
|
||||
|
||||
float shrunkTop = grid.getWorkspaceSpringLoadShrunkTop();
|
||||
float shrunkTop = grid.getCellLayoutSpringLoadShrunkTop();
|
||||
float scale = grid.getWorkspaceSpringLoadScale();
|
||||
|
||||
float halfHeight = ws.getHeight() / 2;
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.android.launcher3.util;
|
||||
import android.content.ComponentName;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
@@ -27,90 +29,64 @@ import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* A utility class to check for {@link ItemInfo}
|
||||
*/
|
||||
public interface ItemInfoMatcher {
|
||||
public abstract class ItemInfoMatcher {
|
||||
|
||||
/**
|
||||
* Empty component used for match testing
|
||||
*/
|
||||
ComponentName EMPTY_COMPONENT = new ComponentName("", "");
|
||||
private static final ComponentName EMPTY_COMPONENT = new ComponentName("", "");
|
||||
|
||||
boolean matches(ItemInfo info, ComponentName cn);
|
||||
|
||||
/**
|
||||
* Returns true if the itemInfo matches this check
|
||||
*/
|
||||
default boolean matchesInfo(ItemInfo info) {
|
||||
if (info != null) {
|
||||
ComponentName cn = info.getTargetComponent();
|
||||
return matches(info, cn != null ? cn : EMPTY_COMPONENT);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public static Predicate<ItemInfo> ofUser(UserHandle user) {
|
||||
return info -> info != null && info.user.equals(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new matcher with returns true if either this or {@param matcher} returns true.
|
||||
*/
|
||||
default ItemInfoMatcher or(ItemInfoMatcher matcher) {
|
||||
return (info, cn) -> matches(info, cn) || matcher.matches(info, cn);
|
||||
public static Predicate<ItemInfo> ofComponents(
|
||||
HashSet<ComponentName> components, UserHandle user) {
|
||||
return info -> info != null && info.user.equals(user)
|
||||
&& components.contains(getNonNullComponent(info));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new matcher with returns true if both this and {@param matcher} returns true.
|
||||
*/
|
||||
default ItemInfoMatcher and(ItemInfoMatcher matcher) {
|
||||
return (info, cn) -> matches(info, cn) && matcher.matches(info, cn);
|
||||
public static Predicate<ItemInfo> ofPackages(Set<String> packageNames, UserHandle user) {
|
||||
return info -> info != null && info.user.equals(user)
|
||||
&& packageNames.contains(getNonNullComponent(info).getPackageName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new matcher with returns the opposite value of this.
|
||||
*/
|
||||
default ItemInfoMatcher negate() {
|
||||
return (info, cn) -> !matches(info, cn);
|
||||
}
|
||||
|
||||
static ItemInfoMatcher ofUser(UserHandle user) {
|
||||
return (info, cn) -> info.user.equals(user);
|
||||
}
|
||||
|
||||
static ItemInfoMatcher ofComponents(HashSet<ComponentName> components, UserHandle user) {
|
||||
return (info, cn) -> components.contains(cn) && info.user.equals(user);
|
||||
}
|
||||
|
||||
static ItemInfoMatcher ofPackages(Set<String> packageNames, UserHandle user) {
|
||||
return (info, cn) -> packageNames.contains(cn.getPackageName()) && info.user.equals(user);
|
||||
}
|
||||
|
||||
static ItemInfoMatcher ofShortcutKeys(Set<ShortcutKey> keys) {
|
||||
return (info, cn) -> info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT
|
||||
public static Predicate<ItemInfo> ofShortcutKeys(Set<ShortcutKey> keys) {
|
||||
return info -> info != null && info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT
|
||||
&& keys.contains(ShortcutKey.fromItemInfo(info));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a matcher for items within folders.
|
||||
*/
|
||||
static ItemInfoMatcher forFolderMatch(ItemInfoMatcher childOperator) {
|
||||
return (info, cn) -> info instanceof FolderInfo && ((FolderInfo) info).contents.stream()
|
||||
.anyMatch(childOperator::matchesInfo);
|
||||
public static Predicate<ItemInfo> forFolderMatch(Predicate<ItemInfo> childOperator) {
|
||||
return info -> info instanceof FolderInfo && ((FolderInfo) info).contents.stream()
|
||||
.anyMatch(childOperator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a matcher for items with provided ids
|
||||
*/
|
||||
static ItemInfoMatcher ofItemIds(IntSet ids) {
|
||||
return (info, cn) -> ids.contains(info.id);
|
||||
public static Predicate<ItemInfo> ofItemIds(IntSet ids) {
|
||||
return info -> info != null && ids.contains(info.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a matcher for items with provided items
|
||||
*/
|
||||
static ItemInfoMatcher ofItems(Collection<? extends ItemInfo> items) {
|
||||
public static Predicate<ItemInfo> ofItems(Collection<? extends ItemInfo> items) {
|
||||
IntSet ids = new IntSet();
|
||||
items.forEach(item -> ids.add(item.id));
|
||||
return ofItemIds(ids);
|
||||
}
|
||||
|
||||
private static ComponentName getNonNullComponent(@NonNull ItemInfo info) {
|
||||
ComponentName cn = info.getTargetComponent();
|
||||
return cn != null ? cn : EMPTY_COMPONENT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3
|
||||
|
||||
import android.graphics.PointF
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.launcher3.util.WindowBounds
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mockito.`when` as whenever
|
||||
|
||||
/**
|
||||
* Test for [DeviceProfile] grid dimensions.
|
||||
*
|
||||
* This includes workspace, cell layout, shortcut and widget container, cell sizes, etc.
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() {
|
||||
|
||||
@Test
|
||||
fun getWorkspaceWidth_twoPanelLandscapeScalable4By4GridTablet_workspaceWidthIsFullPage() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
val expectedWorkspaceWidth = availableWidth
|
||||
assertThat(dp.workspaceWidth).isEqualTo(expectedWorkspaceWidth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getWorkspaceHeight_twoPanelLandscapeScalable4By4GridTablet_workspaceHeightIsFullPage() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
val expectedWorkspaceHeight = availableHeight
|
||||
assertThat(dp.workspaceHeight).isEqualTo(expectedWorkspaceHeight)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getCellLayoutWidth_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelWidth() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
val expectedWorkspaceWidth = availableWidth
|
||||
val expectedCellLayoutWidth =
|
||||
(expectedWorkspaceWidth - (dp.workspacePadding.right + dp.workspacePadding.left)) /
|
||||
dp.panelCount
|
||||
assertThat(dp.cellLayoutWidth).isEqualTo(expectedCellLayoutWidth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getCellLayoutHeight_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelHeight() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
val expectedWorkspaceHeight = availableHeight
|
||||
val expectedCellLayoutHeight =
|
||||
expectedWorkspaceHeight - (dp.workspacePadding.top + dp.workspacePadding.bottom)
|
||||
assertThat(dp.cellLayoutHeight).isEqualTo(expectedCellLayoutHeight)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getShortcutAndWidgetContainerWidth_twoPanelLandscapeScalable4By4GridTablet_equalsIconsPlusBorderSpacesWidth() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
val expectedWorkspaceWidth = availableWidth
|
||||
val expectedCellLayoutWidth =
|
||||
(expectedWorkspaceWidth - (dp.workspacePadding.right + dp.workspacePadding.left)) /
|
||||
dp.panelCount
|
||||
val expectedShortcutAndWidgetContainerWidth = expectedCellLayoutWidth -
|
||||
(dp.cellLayoutPaddingPx.left + dp.cellLayoutPaddingPx.right)
|
||||
assertThat(dp.shortcutAndWidgetContainerWidth).isEqualTo(expectedShortcutAndWidgetContainerWidth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getShortcutAndWidgetContainerHeight_twoPanelLandscapeScalable4By4GridTablet_equalsIconsPlusBorderSpacesHeight() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
val expectedWorkspaceHeight = availableHeight
|
||||
val expectedCellLayoutHeight =
|
||||
expectedWorkspaceHeight - (dp.workspacePadding.top + dp.workspacePadding.bottom)
|
||||
val expectedShortcutAndWidgetContainerHeight = expectedCellLayoutHeight -
|
||||
(dp.cellLayoutPaddingPx.top + dp.cellLayoutPaddingPx.bottom)
|
||||
assertThat(dp.shortcutAndWidgetContainerHeight).isEqualTo(
|
||||
expectedShortcutAndWidgetContainerHeight)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getCellSize_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelWidth() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
val expectedWorkspaceWidth = availableWidth
|
||||
val expectedCellLayoutWidth =
|
||||
(expectedWorkspaceWidth - (dp.workspacePadding.right + dp.workspacePadding.left)) /
|
||||
dp.panelCount
|
||||
val expectedShortcutAndWidgetContainerWidth =
|
||||
expectedCellLayoutWidth -
|
||||
(dp.cellLayoutPaddingPx.left + dp.cellLayoutPaddingPx.right)
|
||||
assertThat(dp.getCellSize().x).isEqualTo(
|
||||
(expectedShortcutAndWidgetContainerWidth -
|
||||
((inv!!.numColumns - 1) * dp.cellLayoutBorderSpacePx.x)) / inv!!.numColumns)
|
||||
val expectedWorkspaceHeight = availableHeight
|
||||
val expectedCellLayoutHeight =
|
||||
expectedWorkspaceHeight - (dp.workspacePadding.top + dp.workspacePadding.bottom)
|
||||
val expectedShortcutAndWidgetContainerHeight = expectedCellLayoutHeight -
|
||||
(dp.cellLayoutPaddingPx.top + dp.cellLayoutPaddingPx.bottom)
|
||||
assertThat(dp.getCellSize().y).isEqualTo(
|
||||
(expectedShortcutAndWidgetContainerHeight -
|
||||
((inv!!.numRows - 1) * dp.cellLayoutBorderSpacePx.y)) / inv!!.numRows)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getPanelCount_twoPanelLandscapeScalable4By4GridTablet_equalsTwoPanels() {
|
||||
val tabletWidth = 2560
|
||||
val tabletHeight = 1600
|
||||
val availableWidth = 2560
|
||||
val availableHeight = 1500
|
||||
windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0)
|
||||
useTwoPanels = true
|
||||
whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true)
|
||||
whenever(info.getDensityDpi()).thenReturn(320)
|
||||
inv = getScalable4By4InvariantDeviceProfile()
|
||||
|
||||
val dp = newDP()
|
||||
|
||||
assertThat(dp.panelCount).isEqualTo(2)
|
||||
}
|
||||
|
||||
fun getScalable4By4InvariantDeviceProfile(): InvariantDeviceProfile {
|
||||
return InvariantDeviceProfile().apply {
|
||||
isScalable = true
|
||||
numColumns = 4
|
||||
numRows = 4
|
||||
numShownHotseatIcons = 4
|
||||
numDatabaseHotseatIcons = 6
|
||||
numShrunkenHotseatIcons = 5
|
||||
horizontalMargin = FloatArray(4) { 22f }
|
||||
borderSpaces = listOf(
|
||||
PointF(16f, 16f),
|
||||
PointF(16f, 16f),
|
||||
PointF(16f, 16f),
|
||||
PointF(16f, 16f)
|
||||
).toTypedArray()
|
||||
allAppsBorderSpaces = listOf(
|
||||
PointF(16f, 16f),
|
||||
PointF(16f, 16f),
|
||||
PointF(16f, 16f),
|
||||
PointF(16f, 16f)
|
||||
).toTypedArray()
|
||||
hotseatBorderSpaces = FloatArray(4) { 16f }
|
||||
hotseatColumnSpan = IntArray(4) { 4 }
|
||||
iconSize = FloatArray(4) { 56f }
|
||||
allAppsIconSize = FloatArray(4) { 56f }
|
||||
iconTextSize = FloatArray(4) { 14f }
|
||||
allAppsIconTextSize = FloatArray(4) { 14f }
|
||||
minCellSize = listOf(
|
||||
PointF(64f, 83f),
|
||||
PointF(64f, 83f),
|
||||
PointF(64f, 83f),
|
||||
PointF(64f, 83f)
|
||||
).toTypedArray()
|
||||
allAppsCellSize = listOf(
|
||||
PointF(64f, 83f),
|
||||
PointF(64f, 83f),
|
||||
PointF(64f, 83f),
|
||||
PointF(64f, 83f)
|
||||
).toTypedArray()
|
||||
inlineQsb = booleanArrayOf(
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user