mirror of
https://github.com/gsantner/dandelion
synced 2025-09-10 18:59:42 +02:00
Various additions & improvements to opoc utils
This commit is contained in:
parent
f1464b5f8f
commit
97d9bf434e
6 changed files with 147 additions and 57 deletions
|
@ -13,7 +13,6 @@ package net.gsantner.opoc.util;
|
|||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -39,7 +38,7 @@ import android.webkit.WebView;
|
|||
import android.widget.ScrollView;
|
||||
|
||||
|
||||
@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection"})
|
||||
@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection", "rawtypes", "UnusedReturnValue"})
|
||||
public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils {
|
||||
//########################
|
||||
//## Members, Constructors
|
||||
|
@ -239,13 +238,22 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils {
|
|||
}
|
||||
|
||||
public ActivityUtils setLauncherActivityEnabled(Class activityClass, boolean enable) {
|
||||
Context context = _context.getApplicationContext();
|
||||
PackageManager pkg = context.getPackageManager();
|
||||
ComponentName component = new ComponentName(context, activityClass);
|
||||
pkg.setComponentEnabledSetting(component, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
try {
|
||||
ComponentName component = new ComponentName(_context, activityClass);
|
||||
_context.getPackageManager().setComponentEnabledSetting(component, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isLauncherEnabled(Class activityClass) {
|
||||
try {
|
||||
ComponentName component = new ComponentName(_context, activityClass);
|
||||
return _context.getPackageManager().getComponentEnabledSetting(component) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public Integer getCurrentPrimaryColor() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue