Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e669056 authored by Sihua Ma's avatar Sihua Ma Committed by Android (Google) Code Review
Browse files

Merge "Showing Toast message when the target package is null for the disabled...

Merge "Showing Toast message when the target package is null for the disabled shortcut" into tm-qpr-dev
parents 59caeb94 1d8b7cba
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.launcher3.model.data;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

@@ -220,10 +219,10 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
    /** Creates an intent to that launches the app store at this app's page. */
    @Nullable
    public Intent getMarketIntent(Context context) {
        ComponentName componentName = getTargetComponent();
        String targetPackage = getTargetPackage();

        return componentName != null
                ? new PackageManagerHelper(context).getMarketIntent(componentName.getPackageName())
        return targetPackage != null
                ? new PackageManagerHelper(context).getMarketIntent(targetPackage)
                : null;
    }

+7 −1
Original line number Diff line number Diff line
@@ -248,13 +248,19 @@ public class ItemClickHandler {
            final Launcher launcher = Launcher.getLauncher(context);
            if (shortcut.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
                    && shortcut.isDisabledVersionLower()) {
                final Intent marketIntent = shortcut.getMarketIntent(context);
                // No market intent means no target package for the shortcut, which should be an
                // issue. Falling back to showing toast messages.
                if (marketIntent == null) {
                    return false;
                }

                new AlertDialog.Builder(context)
                        .setTitle(R.string.dialog_update_title)
                        .setMessage(R.string.dialog_update_message)
                        .setPositiveButton(R.string.dialog_update, (d, i) -> {
                            // Direct the user to the play store to update the app
                            context.startActivity(shortcut.getMarketIntent(context));
                            context.startActivity(marketIntent);
                        })
                        .setNeutralButton(R.string.dialog_remove, (d, i) -> {
                            // Remove the icon if launcher is successfully initialized