use of com.farmerbb.taskbar.util.Callbacks 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);
}
use of com.farmerbb.taskbar.util.Callbacks in project Taskbar by farmerbb.
the class DummyActivity method onResume.
@SuppressLint("RestrictedApi")
@TargetApi(Build.VERSION_CODES.N)
@Override
protected void onResume() {
super.onResume();
if (shouldFinish)
finish();
else {
shouldFinish = true;
if (getIntent().hasExtra("uninstall")) {
UserManager userManager = (UserManager) getSystemService(USER_SERVICE);
Intent intent = new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + getIntent().getStringExtra("uninstall")));
intent.putExtra(Intent.EXTRA_USER, userManager.getUserForSerialNumber(getIntent().getLongExtra("user_id", 0)));
try {
startActivity(intent);
} catch (ActivityNotFoundException ignored) {
}
} else if (getIntent().hasExtra("accessibility")) {
AlertDialog.Builder builder = new AlertDialog.Builder(U.wrapContext(this));
builder.setTitle(R.string.tb_permission_dialog_title).setMessage(R.string.tb_enable_accessibility).setNegativeButton(R.string.tb_action_cancel, (dialog, which) -> U.newHandler().post(this::finish)).setPositiveButton(R.string.tb_action_activate, (dialog, which) -> {
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
SharedPreferences pref = U.getSharedPreferences(this);
if (pref.getBoolean(PREF_DISABLE_ANIMATIONS, false))
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
U.launchApp(this, () -> {
try {
startActivity(intent, U.getActivityOptionsBundle(this, ApplicationType.APP_PORTRAIT, null));
U.showToast(this, getString(R.string.tb_usage_stats_message, U.getAppName(this)), Toast.LENGTH_LONG);
} catch (ActivityNotFoundException e) {
U.showToast(this, R.string.tb_lock_device_not_supported);
finish();
}
});
});
AlertDialog dialog = builder.create();
dialog.show();
dialog.setCancelable(false);
} else if (getIntent().hasExtra(EXTRA_START_FREEFORM_HACK)) {
if (U.hasFreeformSupport(this) && U.isFreeformModeEnabled(this) && !FreeformHackHelper.getInstance().isFreeformHackActive()) {
U.startFreeformHack(this, true);
}
finish();
} else if (getIntent().hasExtra(EXTRA_SHOW_PERMISSION_DIALOG))
U.showPermissionDialog(U.wrapContext(this), new Callbacks(null, this::finish));
else if (getIntent().hasExtra(EXTRA_SHOW_RECENT_APPS_DIALOG))
U.showRecentAppsDialog(U.wrapContext(this), new Callbacks(null, this::finish));
else if (!finishOnPause)
finish();
}
}
Aggregations