Search in sources :

Example 1 with AppTargetCompat

use of com.saggitt.omega.predictions.AppTargetCompat in project Neo-Launcher by NeoApplications.

the class PredictionAppTracker method onStartApp.

@Override
@UiThread
public void onStartApp(ComponentName cn, UserHandle user, String container) {
    if (cn != null) {
        AppTargetCompat target = new AppTargetCompat.Builder(new AppTargetIdCompat("app:" + cn), cn.getPackageName(), user).setClassName(cn.getClassName()).build();
        sendLaunch(target, container);
        // Relay onStartApp to every connected plugin.
        mAppLaunchEventsPluginsList.forEach(plugin -> plugin.onStartApp(cn, user, container != null ? container : CONTAINER_DEFAULT));
    }
}
Also used : AppTargetCompat(com.saggitt.omega.predictions.AppTargetCompat) AppTargetIdCompat(com.saggitt.omega.predictions.AppTargetIdCompat) UiThread(androidx.annotation.UiThread)

Example 2 with AppTargetCompat

use of com.saggitt.omega.predictions.AppTargetCompat in project Neo-Launcher by NeoApplications.

the class PredictionUiStateManager method parseLastState.

private PredictionState parseLastState() {
    PredictionState state = new PredictionState();
    state.isEnabled = mGettingValidPredictionResults;
    if (!state.isEnabled) {
        state.apps = Collections.EMPTY_LIST;
        return state;
    }
    state.apps = new ArrayList<>();
    List<AppTargetCompat> appTargets = mPredictionServicePredictions[mActiveClient.ordinal()];
    if (!appTargets.isEmpty()) {
        for (AppTargetCompat appTarget : appTargets) {
            ComponentKey key;
            if (appTarget.getShortcutInfo() != null) {
                key = ShortcutKey.fromInfo(appTarget.getShortcutInfo());
            } else {
                key = new ComponentKey(new ComponentName(appTarget.getPackageName(), appTarget.getClassName()), appTarget.getUser());
            }
            state.apps.add(new ComponentKeyMapper(mContext, key, mDynamicItemCache));
        }
    }
    updateDependencies(state);
    return state;
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) AppTargetCompat(com.saggitt.omega.predictions.AppTargetCompat) ComponentName(android.content.ComponentName)

Example 3 with AppTargetCompat

use of com.saggitt.omega.predictions.AppTargetCompat in project Neo-Launcher by NeoApplications.

the class PredictionAppTracker method onDismissApp.

@Override
@UiThread
public void onDismissApp(ComponentName cn, UserHandle user, String container) {
    if (cn == null)
        return;
    AppTargetCompat target = new AppTargetCompat.Builder(new AppTargetIdCompat("app: " + cn), cn.getPackageName(), user).setClassName(cn.getClassName()).build();
    sendDismiss(target, container);
    // Relay onDismissApp to every connected plugin.
    mAppLaunchEventsPluginsList.forEach(plugin -> plugin.onDismissApp(cn, user, container != null ? container : CONTAINER_DEFAULT));
}
Also used : AppTargetCompat(com.saggitt.omega.predictions.AppTargetCompat) AppTargetIdCompat(com.saggitt.omega.predictions.AppTargetIdCompat) UiThread(androidx.annotation.UiThread)

Example 4 with AppTargetCompat

use of com.saggitt.omega.predictions.AppTargetCompat in project Neo-Launcher by NeoApplications.

the class PredictionAppTracker method onStartShortcut.

@Override
@UiThread
public void onStartShortcut(String packageName, String shortcutId, UserHandle user, String container) {
    // TODO: Use the full shortcut info
    AppTargetCompat target = new AppTargetCompat.Builder(new AppTargetIdCompat("shortcut:" + shortcutId), packageName, user).setClassName(shortcutId).build();
    sendLaunch(target, container);
    // Relay onStartShortcut info to every connected plugin.
    mAppLaunchEventsPluginsList.forEach(plugin -> plugin.onStartShortcut(packageName, shortcutId, user, container != null ? container : CONTAINER_DEFAULT));
}
Also used : AppTargetCompat(com.saggitt.omega.predictions.AppTargetCompat) AppTargetIdCompat(com.saggitt.omega.predictions.AppTargetIdCompat) UiThread(androidx.annotation.UiThread)

Aggregations

AppTargetCompat (com.saggitt.omega.predictions.AppTargetCompat)4 UiThread (androidx.annotation.UiThread)3 AppTargetIdCompat (com.saggitt.omega.predictions.AppTargetIdCompat)3 ComponentName (android.content.ComponentName)1 ComponentKey (com.android.launcher3.util.ComponentKey)1