Search in sources :

Example 1 with DbHelper

use of com.saggitt.omega.util.DbHelper in project Neo-Launcher by NeoApplications.

the class AlphabeticalAppsList method sortApps.

private void sortApps(int sortType) {
    switch(sortType) {
        // SORT BY NAME AZ
        case SORT_AZ:
            Collections.sort(mApps, mAppNameComparator);
            break;
        // SORT BY NAME ZA
        case SORT_ZA:
            Collections.sort(mApps, (p2, p1) -> Collator.getInstance().compare(p1.title, p2.title));
            break;
        // SORT BY LAST INSTALLED
        case SORT_LAST_INSTALLED:
            PackageManager pm = mLauncher.getApplicationContext().getPackageManager();
            InstallTimeComparator installTimeComparator = new InstallTimeComparator(pm);
            Collections.sort(mApps, installTimeComparator);
            break;
        // SORT BY MOST USED DESC
        case SORT_MOST_USED:
            DbHelper db = new DbHelper(mLauncher.getApplicationContext());
            List<AppCountInfo> appsCounter = db.getAppsCount();
            db.close();
            MostUsedComparator mostUsedComparator = new MostUsedComparator(appsCounter);
            Collections.sort(mApps, mostUsedComparator);
            break;
        case SORT_BY_COLOR:
            Collections.sort(mApps, mAppColorComparator);
            break;
        default:
            Collections.sort(mApps, mAppNameComparator);
            break;
    }
}
Also used : InstallTimeComparator(com.saggitt.omega.allapps.InstallTimeComparator) PackageManager(android.content.pm.PackageManager) AppCountInfo(com.saggitt.omega.model.AppCountInfo) MostUsedComparator(com.saggitt.omega.allapps.MostUsedComparator) DbHelper(com.saggitt.omega.util.DbHelper)

Example 2 with DbHelper

use of com.saggitt.omega.util.DbHelper in project Neo-Launcher by NeoApplications.

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher, @Nullable String sourceContainer) {
    Intent intent;
    if (item instanceof PromiseAppInfo) {
        PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
        intent = promiseAppInfo.getMarketIntent(launcher);
    } 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.getAppTransitionManager().supportsAdaptiveIconAnimation()) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    if (item instanceof AppInfo) {
        Log.i(TAG, "Clicking App " + item.title);
        DbHelper db = new DbHelper(launcher.getApplicationContext());
        db.updateAppCount(((AppInfo) item).componentName.getPackageName());
        db.close();
    }
    launcher.startActivitySafely(v, intent, item, sourceContainer);
    launcher.getUserEventDispatcher().logAppLaunch(v, intent, item.user);
}
Also used : PromiseAppInfo(com.android.launcher3.PromiseAppInfo) Intent(android.content.Intent) DbHelper(com.saggitt.omega.util.DbHelper) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) AppInfo(com.android.launcher3.AppInfo) PromiseAppInfo(com.android.launcher3.PromiseAppInfo)

Aggregations

DbHelper (com.saggitt.omega.util.DbHelper)2 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 AppInfo (com.android.launcher3.AppInfo)1 PromiseAppInfo (com.android.launcher3.PromiseAppInfo)1 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)1 InstallTimeComparator (com.saggitt.omega.allapps.InstallTimeComparator)1 MostUsedComparator (com.saggitt.omega.allapps.MostUsedComparator)1 AppCountInfo (com.saggitt.omega.model.AppCountInfo)1