Search in sources :

Example 11 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsBottomSheet method onWidgetsBound.

@Override
public void onWidgetsBound() {
    List<WidgetItem> widgets = mActivityContext.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey(mOriginalItemInfo.getTargetComponent().getPackageName(), mOriginalItemInfo.user));
    TableLayout widgetsTable = findViewById(R.id.widgets_table);
    widgetsTable.removeAllViews();
    WidgetsTableUtils.groupWidgetItemsIntoTable(widgets, mMaxHorizontalSpan).forEach(row -> {
        TableRow tableRow = new TableRow(getContext());
        tableRow.setGravity(Gravity.TOP);
        row.forEach(widgetItem -> {
            WidgetCell widget = addItemCell(tableRow);
            widget.setPreviewSize(widgetItem);
            widget.applyFromCellItem(widgetItem, LauncherAppState.getInstance(mActivityContext).getWidgetCache());
            widget.ensurePreview();
            widget.setVisibility(View.VISIBLE);
        });
        widgetsTable.addView(tableRow);
    });
}
Also used : TableRow(android.widget.TableRow) WidgetItem(com.android.launcher3.model.WidgetItem) PackageUserKey(com.android.launcher3.util.PackageUserKey) TableLayout(android.widget.TableLayout)

Example 12 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupDataProvider method onNotificationPosted.

@Override
public void onNotificationPosted(PackageUserKey postedPackageUserKey, NotificationKeyData notificationKey) {
    DotInfo dotInfo = mPackageUserToDotInfos.get(postedPackageUserKey);
    if (dotInfo == null) {
        dotInfo = new DotInfo();
        mPackageUserToDotInfos.put(postedPackageUserKey, dotInfo);
    }
    if (dotInfo.addOrUpdateNotificationKey(notificationKey)) {
        updateNotificationDots(postedPackageUserKey::equals);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo)

Example 13 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class InstallSessionTracker method onFinished.

@Override
public void onFinished(int sessionId, boolean success) {
    // For a finished session, we can't get the session info. So use the
    // packageName from our local cache.
    SparseArray<PackageUserKey> activeSessions = getActiveSessionMap();
    PackageUserKey key = activeSessions.get(sessionId);
    activeSessions.remove(sessionId);
    if (key != null && key.mPackageName != null) {
        String packageName = key.mPackageName;
        PackageInstallInfo info = PackageInstallInfo.fromState(success ? STATUS_INSTALLED : STATUS_FAILED, packageName, key.mUser);
        mCallback.onPackageStateChanged(info);
        if (!success && mInstallerCompat.promiseIconAddedForId(sessionId)) {
            mCallback.onSessionFailure(packageName, key.mUser);
            // If it is successful, the id is removed in the the package added flow.
            mInstallerCompat.removePromiseIconId(sessionId);
        }
    }
}
Also used : PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 14 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class InstallSessionTracker method pushSessionDisplayToLauncher.

private SessionInfo pushSessionDisplayToLauncher(int sessionId) {
    SessionInfo session = mInstallerCompat.getVerifiedSessionInfo(sessionId);
    if (session != null && session.getAppPackageName() != null) {
        PackageUserKey key = new PackageUserKey(session.getAppPackageName(), getUserHandle(session));
        getActiveSessionMap().put(session.getSessionId(), key);
        mCallback.onUpdateSessionDisplay(key, session);
        return session;
    }
    return null;
}
Also used : SessionInfo(android.content.pm.PackageInstaller.SessionInfo) PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 15 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class SdCardAvailableReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    final LauncherApps launcherApps = context.getSystemService(LauncherApps.class);
    final PackageManagerHelper pmHelper = new PackageManagerHelper(context);
    for (PackageUserKey puk : mPackages) {
        UserHandle user = puk.mUser;
        final ArrayList<String> packagesRemoved = new ArrayList<>();
        final ArrayList<String> packagesUnavailable = new ArrayList<>();
        if (!launcherApps.isPackageEnabled(puk.mPackageName, user)) {
            if (pmHelper.isAppOnSdcard(puk.mPackageName, user)) {
                packagesUnavailable.add(puk.mPackageName);
            } else {
                packagesRemoved.add(puk.mPackageName);
            }
        }
        if (!packagesRemoved.isEmpty()) {
            mModel.onPackagesRemoved(user, packagesRemoved.toArray(new String[packagesRemoved.size()]));
        }
        if (!packagesUnavailable.isEmpty()) {
            mModel.onPackagesUnavailable(packagesUnavailable.toArray(new String[packagesUnavailable.size()]), user, false);
        }
    }
    // Unregister the broadcast receiver, just in case
    mContext.unregisterReceiver(this);
}
Also used : UserHandle(android.os.UserHandle) ArrayList(java.util.ArrayList) LauncherApps(android.content.pm.LauncherApps) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) PackageUserKey(com.android.launcher3.util.PackageUserKey)

Aggregations

PackageUserKey (com.android.launcher3.util.PackageUserKey)94 ArrayList (java.util.ArrayList)53 Context (android.content.Context)42 ComponentName (android.content.ComponentName)39 UserHandle (android.os.UserHandle)35 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)31 HashMap (java.util.HashMap)31 HashSet (java.util.HashSet)31 List (java.util.List)29 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)26 IconCache (com.android.launcher3.icons.IconCache)24 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)24 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)24 DotInfo (com.android.launcher3.dot.DotInfo)22 Log (android.util.Log)21 FeatureFlags (com.android.launcher3.config.FeatureFlags)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 IntSet (com.android.launcher3.util.IntSet)21 Predicate (java.util.function.Predicate)21 Test (org.junit.Test)21