Search in sources :

Example 1 with TaskbarController

use of com.farmerbb.taskbar.ui.TaskbarController in project Taskbar by farmerbb.

the class HomeActivityDelegate method startTaskbar.

private void startTaskbar() {
    // Ensure that the freeform hack is started whenever Taskbar starts
    if (U.hasFreeformSupport(this) && U.isFreeformModeEnabled(this) && !FreeformHackHelper.getInstance().isFreeformHackActive()) {
        U.startFreeformHack(this, true);
    }
    SharedPreferences pref = U.getSharedPreferences(this);
    if (pref.getBoolean(PREF_FIRST_RUN, true)) {
        SharedPreferences.Editor editor = pref.edit();
        editor.putBoolean(PREF_FIRST_RUN, false);
        editor.putBoolean(PREF_COLLAPSED, true);
        editor.apply();
        dialog = U.showRecentAppsDialog(U.wrapContext(this), new Callbacks(() -> dialog = U.showErrorDialog(U.wrapContext(this), "GET_USAGE_STATS"), null));
    }
    if (isSecondaryHome) {
        // Stop any currently running services and switch to using HomeActivityDelegate as UI host
        stopService(new Intent(this, TaskbarService.class));
        stopService(new Intent(this, StartMenuService.class));
        stopService(new Intent(this, DashboardService.class));
        taskbarController = new TaskbarController(this);
        startMenuController = new StartMenuController(this);
        dashboardController = new DashboardController(this);
        taskbarController.onCreateHost(this);
        startMenuController.onCreateHost(this);
        dashboardController.onCreateHost(this);
    } else {
        // We always start the Taskbar and Start Menu services, even if the app isn't normally running
        try {
            startService(new Intent(this, TaskbarService.class));
            startService(new Intent(this, StartMenuService.class));
            startService(new Intent(this, DashboardService.class));
        } catch (IllegalStateException ignored) {
        }
    }
    if (pref.getBoolean(PREF_TASKBAR_ACTIVE, false) && !U.isServiceRunning(this, NotificationService.class))
        pref.edit().putBoolean(PREF_TASKBAR_ACTIVE, false).apply();
    // Show the Taskbar temporarily, as nothing else will be visible on screen
    U.newHandler().postDelayed(() -> U.sendBroadcast(this, ACTION_TEMP_SHOW_TASKBAR), 100);
}
Also used : Callbacks(com.farmerbb.taskbar.util.Callbacks) SharedPreferences(android.content.SharedPreferences) StartMenuController(com.farmerbb.taskbar.ui.StartMenuController) DashboardService(com.farmerbb.taskbar.service.DashboardService) DashboardController(com.farmerbb.taskbar.ui.DashboardController) Intent(android.content.Intent) TaskbarService(com.farmerbb.taskbar.service.TaskbarService) StartMenuService(com.farmerbb.taskbar.service.StartMenuService) TaskbarController(com.farmerbb.taskbar.ui.TaskbarController)

Aggregations

Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 DashboardService (com.farmerbb.taskbar.service.DashboardService)1 StartMenuService (com.farmerbb.taskbar.service.StartMenuService)1 TaskbarService (com.farmerbb.taskbar.service.TaskbarService)1 DashboardController (com.farmerbb.taskbar.ui.DashboardController)1 StartMenuController (com.farmerbb.taskbar.ui.StartMenuController)1 TaskbarController (com.farmerbb.taskbar.ui.TaskbarController)1 Callbacks (com.farmerbb.taskbar.util.Callbacks)1