use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.
the class DatabaseWidgetPreviewLoader method removeObsoletePreviews.
/**
* Updates the persistent DB:
* 1. Any preview generated for an old package version is removed
* 2. Any preview for an absent package is removed
* This ensures that we remove entries for packages which changed while the launcher was dead.
*
* @param packageUser if provided, specifies that list only contains previews for the
* given package/user, otherwise the list contains all previews
*/
public void removeObsoletePreviews(ArrayList<? extends ComponentKey> list, @Nullable PackageUserKey packageUser) {
Preconditions.assertWorkerThread();
LongSparseArray<HashSet<String>> validPackages = new LongSparseArray<>();
for (ComponentKey key : list) {
final long userId = mUserCache.getSerialNumberForUser(key.user);
HashSet<String> packages = validPackages.get(userId);
if (packages == null) {
packages = new HashSet<>();
validPackages.put(userId, packages);
}
packages.add(key.componentName.getPackageName());
}
LongSparseArray<HashSet<String>> packagesToDelete = new LongSparseArray<>();
long passedUserId = packageUser == null ? 0 : mUserCache.getSerialNumberForUser(packageUser.mUser);
Cursor c = null;
try {
c = mDb.query(new String[] { CacheDb.COLUMN_USER, CacheDb.COLUMN_PACKAGE, CacheDb.COLUMN_LAST_UPDATED, CacheDb.COLUMN_VERSION }, null, null);
while (c.moveToNext()) {
long userId = c.getLong(0);
String pkg = c.getString(1);
long lastUpdated = c.getLong(2);
long version = c.getLong(3);
if (packageUser != null && (!pkg.equals(packageUser.mPackageName) || userId != passedUserId)) {
// This preview is associated with a different package/user, no need to remove.
continue;
}
HashSet<String> packages = validPackages.get(userId);
if (packages != null && packages.contains(pkg)) {
long[] versions = getPackageVersion(pkg);
if (versions[0] == version && versions[1] == lastUpdated) {
// Every thing checks out
continue;
}
}
// We need to delete this package.
packages = packagesToDelete.get(userId);
if (packages == null) {
packages = new HashSet<>();
packagesToDelete.put(userId, packages);
}
packages.add(pkg);
}
for (int i = 0; i < packagesToDelete.size(); i++) {
long userId = packagesToDelete.keyAt(i);
UserHandle user = mUserCache.getUserForSerialNumber(userId);
for (String pkg : packagesToDelete.valueAt(i)) {
removePackage(pkg, user, userId);
}
}
} catch (SQLException e) {
Log.e(TAG, "Error updating widget previews", e);
} finally {
if (c != null) {
c.close();
}
}
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.
the class AbsSwipeUpHandler method createWindowAnimationToPip.
private SwipePipToHomeAnimator createWindowAnimationToPip(HomeAnimationFactory homeAnimFactory, RemoteAnimationTargetCompat runningTaskTarget, float startProgress) {
// Directly animate the app to PiP (picture-in-picture) mode
final ActivityManager.RunningTaskInfo taskInfo = mGestureState.getRunningTask();
final RecentsOrientedState orientationState = mTaskViewSimulator.getOrientationState();
final int windowRotation = orientationState.getDisplayRotation();
final int homeRotation = orientationState.getRecentsActivityRotation();
final Matrix homeToWindowPositionMap = new Matrix();
final RectF startRect = updateProgressForStartRect(homeToWindowPositionMap, startProgress);
// Move the startRect to Launcher space as floatingIconView runs in Launcher
final Matrix windowToHomePositionMap = new Matrix();
homeToWindowPositionMap.invert(windowToHomePositionMap);
windowToHomePositionMap.mapRect(startRect);
final Rect destinationBounds = SystemUiProxy.INSTANCE.get(mContext).startSwipePipToHome(taskInfo.topActivity, taskInfo.topActivityInfo, runningTaskTarget.taskInfo.pictureInPictureParams, homeRotation, mDp.hotseatBarSizePx);
final SwipePipToHomeAnimator.Builder builder = new SwipePipToHomeAnimator.Builder().setContext(mContext).setTaskId(runningTaskTarget.taskId).setComponentName(taskInfo.topActivity).setLeash(runningTaskTarget.leash.getSurfaceControl()).setSourceRectHint(runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint()).setAppBounds(taskInfo.configuration.windowConfiguration.getBounds()).setHomeToWindowPositionMap(homeToWindowPositionMap).setStartBounds(startRect).setDestinationBounds(destinationBounds).setCornerRadius(mRecentsView.getPipCornerRadius()).setAttachedView(mRecentsView);
// is not ROTATION_0 (which implies the rotation is turned on in launcher settings).
if (homeRotation == ROTATION_0 && (windowRotation == ROTATION_90 || windowRotation == ROTATION_270)) {
builder.setFromRotation(mTaskViewSimulator, windowRotation, taskInfo.displayCutoutInsets);
}
final SwipePipToHomeAnimator swipePipToHomeAnimator = builder.build();
AnimatorPlaybackController activityAnimationToHome = homeAnimFactory.createActivityAnimationToHome();
swipePipToHomeAnimator.addAnimatorListener(new AnimatorListenerAdapter() {
private boolean mHasAnimationEnded;
@Override
public void onAnimationStart(Animator animation) {
if (mHasAnimationEnded)
return;
// Ensure Launcher ends in NORMAL state
activityAnimationToHome.dispatchOnStart();
}
@Override
public void onAnimationEnd(Animator animation) {
if (mHasAnimationEnded)
return;
mHasAnimationEnded = true;
activityAnimationToHome.getAnimationPlayer().end();
if (mRecentsAnimationController == null) {
// skip doing any future work here for the current gesture.
return;
}
// Finalize the state and notify of the change
mGestureState.setState(STATE_END_TARGET_ANIMATION_FINISHED);
}
});
setupWindowAnimation(swipePipToHomeAnimator);
return swipePipToHomeAnimator;
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.
the class AbsSwipeUpHandler method onActivityInit.
protected boolean onActivityInit(Boolean alreadyOnHome) {
if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
return false;
}
T createdActivity = mActivityInterface.getCreatedActivity();
if (createdActivity != null) {
initTransitionEndpoints(createdActivity.getDeviceProfile());
}
final T activity = mActivityInterface.getCreatedActivity();
if (mActivity == activity) {
return true;
}
if (mActivity != null) {
if (mStateCallback.hasStates(STATE_GESTURE_COMPLETED)) {
// If the activity has restarted between setting the page scroll settling callback
// and actually receiving the callback, just mark the gesture completed
mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
return true;
}
// The launcher may have been recreated as a result of device rotation.
int oldState = mStateCallback.getState() & ~LAUNCHER_UI_STATES;
initStateCallbacks();
mStateCallback.setState(oldState);
}
mWasLauncherAlreadyVisible = alreadyOnHome;
mActivity = activity;
// up, or until we transition home and the home animation is composed
if (alreadyOnHome) {
mActivity.clearForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
} else {
mActivity.addForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
}
mRecentsView = activity.getOverviewPanel();
mRecentsView.setOnPageTransitionEndCallback(null);
mStateCallback.setState(STATE_LAUNCHER_PRESENT);
if (alreadyOnHome) {
onLauncherStart();
} else {
activity.runOnceOnStart(this::onLauncherStart);
}
// Set up a entire animation lifecycle callback to notify the current recents view when
// the animation is canceled
mGestureState.runOnceAtState(STATE_RECENTS_ANIMATION_CANCELED, () -> {
ThumbnailData snapshot = mGestureState.consumeRecentsAnimationCanceledSnapshot();
if (snapshot != null) {
mRecentsView.switchToScreenshot(snapshot, () -> {
if (mRecentsAnimationController != null) {
mRecentsAnimationController.cleanupScreenshot();
}
});
mRecentsView.onRecentsAnimationComplete();
}
});
setupRecentsViewUi();
linkRecentsViewScroll();
return true;
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherTaskbarUIController method createAnimToLauncher.
/**
* Create Taskbar animation when going from an app to Launcher.
* @param toState If known, the state we will end up in when reaching Launcher.
*/
public Animator createAnimToLauncher(@Nullable LauncherState toState, long duration) {
PendingAnimation anim = new PendingAnimation(duration);
anim.add(mTaskbarAnimationController.createAnimToBackgroundAlpha(0, duration));
if (toState != null) {
mTaskbarStateHandler.setStateWithAnimation(toState, new StateAnimationConfig(), anim);
}
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mIsAnimatingToLauncher = true;
mTaskbarView.setHolesAllowedInLayout(true);
mTaskbarView.updateHotseatItemsVisibility();
}
@Override
public void onAnimationEnd(Animator animation) {
mIsAnimatingToLauncher = false;
setTaskbarViewVisible(false);
}
});
return anim.buildAnim();
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherActivityInterface method onOneHandedModeStateChanged.
@Override
public void onOneHandedModeStateChanged(boolean activated) {
Launcher launcher = getCreatedActivity();
if (launcher == null) {
return;
}
launcher.onOneHandedStateChanged(activated);
}
Aggregations