Search in sources :

Example 46 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class WorkspaceRevealAnim method prepareToAnimate.

/**
 * Setup workspace with 0 duration.
 */
private void prepareToAnimate(Launcher launcher, boolean animateOverviewScrim) {
    StateAnimationConfig config = new StateAnimationConfig();
    config.animFlags = SKIP_OVERVIEW | SKIP_DEPTH_CONTROLLER | SKIP_SCRIM;
    config.duration = 0;
    // setRecentsAttachedToAppWindow() will animate recents out.
    launcher.getStateManager().createAtomicAnimation(BACKGROUND_APP, NORMAL, config).start();
    // Stop scrolling so that it doesn't interfere with the translation offscreen.
    launcher.<RecentsView>getOverviewPanel().getScroller().forceFinished(true);
    if (animateOverviewScrim) {
        launcher.getWorkspace().getStateTransitionAnimation().setScrim(NO_ANIM_PROPERTY_SETTER, BACKGROUND_APP, config);
    }
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) RecentsView(com.android.quickstep.views.RecentsView)

Example 47 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsOrientedState method getLauncherDeviceProfile.

/**
 * Returns the device profile based on expected launcher rotation
 */
public DeviceProfile getLauncherDeviceProfile() {
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext);
    Point currentSize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
    int width, height;
    if ((mRecentsActivityRotation == ROTATION_90 || mRecentsActivityRotation == ROTATION_270)) {
        width = Math.max(currentSize.x, currentSize.y);
        height = Math.min(currentSize.x, currentSize.y);
    } else {
        width = Math.min(currentSize.x, currentSize.y);
        height = Math.max(currentSize.x, currentSize.y);
    }
    DeviceProfile bestMatch = idp.supportedProfiles.get(0);
    float minDiff = Float.MAX_VALUE;
    for (DeviceProfile profile : idp.supportedProfiles) {
        float diff = Math.abs(profile.widthPx - width) + Math.abs(profile.heightPx - height);
        if (diff < minDiff) {
            minDiff = diff;
            bestMatch = profile;
        }
    }
    return bestMatch;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) Point(android.graphics.Point) Point(android.graphics.Point)

Example 48 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class OptionsPopupView method show.

public static OptionsPopupView show(Launcher launcher, RectF targetRect, List<OptionItem> items, boolean shouldAddArrow, int width) {
    OptionsPopupView popup = (OptionsPopupView) launcher.getLayoutInflater().inflate(R.layout.longpress_options_menu, launcher.getDragLayer(), false);
    popup.mTargetRect = targetRect;
    popup.setShouldAddArrow(shouldAddArrow);
    for (OptionItem item : items) {
        DeepShortcutView view = (DeepShortcutView) popup.inflateAndAdd(R.layout.system_shortcut, popup);
        if (width > 0) {
            view.getLayoutParams().width = width;
        }
        view.getIconView().setBackgroundDrawable(item.icon);
        view.getBubbleText().setText(item.label);
        view.setOnClickListener(popup);
        view.setOnLongClickListener(popup);
        popup.mItemMap.put(view, item);
    }
    popup.addPreDrawForColorExtraction(launcher);
    popup.show();
    return popup;
}
Also used : DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

Example 49 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class ItemClickHandler method startMarketIntentForPackage.

private static void startMarketIntentForPackage(View v, Launcher launcher, String packageName) {
    ItemInfo item = (ItemInfo) v.getTag();
    if (Utilities.ATLEAST_Q) {
        SessionInfo sessionInfo = InstallSessionHelper.INSTANCE.get(launcher).getActiveSessionInfo(item.user, packageName);
        if (sessionInfo != null) {
            LauncherApps launcherApps = launcher.getSystemService(LauncherApps.class);
            try {
                launcherApps.startPackageInstallerSessionDetailsActivity(sessionInfo, null, launcher.getActivityLaunchOptions(v, item).toBundle());
                return;
            } catch (Exception e) {
                Log.e(TAG, "Unable to launch market intent for package=" + packageName, e);
            }
        }
    }
    // Fallback to using custom market intent.
    Intent intent = new PackageManagerHelper(launcher).getMarketIntent(packageName);
    launcher.startActivitySafely(v, intent, item);
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper)

Example 50 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    TrustDatabaseHelper db = TrustDatabaseHelper.getInstance(launcher);
    ComponentName cn = item.getTargetComponent();
    boolean isProtected = cn != null && db.isPackageProtected(cn.getPackageName());
    if (isProtected) {
        launcher.startActivitySafelyAuth(v, intent, item);
    } else {
        launcher.startActivitySafely(v, intent, item);
    }
}
Also used : TrustDatabaseHelper(com.android.launcher3.lineage.trust.db.TrustDatabaseHelper) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ComponentName(android.content.ComponentName) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

Launcher (com.android.launcher3.Launcher)194 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)102 Test (org.junit.Test)102 View (android.view.View)87 LargeTest (androidx.test.filters.LargeTest)83 ItemInfo (com.android.launcher3.model.data.ItemInfo)83 Rect (android.graphics.Rect)80 Point (android.graphics.Point)77 Intent (android.content.Intent)71 ArrayList (java.util.ArrayList)69 DeviceProfile (com.android.launcher3.DeviceProfile)66 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)64 Context (android.content.Context)61 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)49 RecentsView (com.android.quickstep.views.RecentsView)46 DragLayer (com.android.launcher3.dragndrop.DragLayer)45 ComponentName (android.content.ComponentName)43 FolderInfo (com.android.launcher3.model.data.FolderInfo)42 ViewGroup (android.view.ViewGroup)41 AllApps (com.android.launcher3.tapl.AllApps)40