Make isParasitic final (#2426)
This commit is contained in:
parent
18893cd6b9
commit
97f74d8b2e
|
|
@ -141,9 +141,7 @@ public class App extends Application {
|
||||||
return executorService;
|
return executorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isParasitic() {
|
public static final boolean isParasitic = !Process.isApplicationUid(Process.myUid());
|
||||||
return !Process.isApplicationUid(Process.myUid());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Handler getMainHandler() {
|
public static Handler getMainHandler() {
|
||||||
return MainHandler;
|
return MainHandler;
|
||||||
|
|
@ -154,7 +152,7 @@ public class App extends Application {
|
||||||
super.attachBaseContext(base);
|
super.attachBaseContext(base);
|
||||||
Telemetry.start(this);
|
Telemetry.start(this);
|
||||||
var map = new HashMap<String, String>(1);
|
var map = new HashMap<String, String>(1);
|
||||||
map.put("isParasitic", String.valueOf(isParasitic()));
|
map.put("isParasitic", String.valueOf(isParasitic));
|
||||||
Telemetry.trackEvent("App start", map);
|
Telemetry.trackEvent("App start", map);
|
||||||
var am = getSystemService(ActivityManager.class);
|
var am = getSystemService(ActivityManager.class);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
|
@ -200,7 +198,7 @@ public class App extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
if (!BuildConfig.DEBUG && !isParasitic()) {
|
if (!BuildConfig.DEBUG && !isParasitic) {
|
||||||
setCrashReport();
|
setCrashReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ public class MainActivity extends BaseActivity implements RepoLoader.RepoListene
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restart() {
|
public void restart() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S || App.isParasitic()) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S || App.isParasitic) {
|
||||||
recreate();
|
recreate();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
@ -263,7 +263,7 @@ public class MainActivity extends BaseActivity implements RepoLoader.RepoListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(App.isParasitic()){
|
if(App.isParasitic){
|
||||||
ShortcutUtil.updateShortcut();
|
ShortcutUtil.updateShortcut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class WelcomeDialog extends DialogFragment {
|
||||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||||
var builder = new BlurBehindDialogBuilder(requireContext(),
|
var builder = new BlurBehindDialogBuilder(requireContext(),
|
||||||
R.style.ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons);
|
R.style.ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons);
|
||||||
if (App.isParasitic()) {
|
if (App.isParasitic) {
|
||||||
return parasiticDialog(builder);
|
return parasiticDialog(builder);
|
||||||
} else {
|
} else {
|
||||||
return appDialog(builder);
|
return appDialog(builder);
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ public class SettingsFragment extends BaseFragment {
|
||||||
|
|
||||||
MaterialSwitchPreference notification = findPreference("enable_status_notification");
|
MaterialSwitchPreference notification = findPreference("enable_status_notification");
|
||||||
if (notification != null) {
|
if (notification != null) {
|
||||||
if (App.isParasitic() && !ShortcutUtil.isLaunchShortcutPinned()) {
|
if (App.isParasitic && !ShortcutUtil.isLaunchShortcutPinned()) {
|
||||||
var s = notification.getContext().getString(R.string.disable_status_notification_error);
|
var s = notification.getContext().getString(R.string.disable_status_notification_error);
|
||||||
notification.setSummaryOn(notification.getSummary() + "\n" + s);
|
notification.setSummaryOn(notification.getSummary() + "\n" + s);
|
||||||
if (ConfigManager.enableStatusNotification()) notification.setEnabled(false);
|
if (ConfigManager.enableStatusNotification()) notification.setEnabled(false);
|
||||||
|
|
@ -168,7 +168,7 @@ public class SettingsFragment extends BaseFragment {
|
||||||
notification.setVisible(installed);
|
notification.setVisible(installed);
|
||||||
notification.setChecked(installed && ConfigManager.enableStatusNotification());
|
notification.setChecked(installed && ConfigManager.enableStatusNotification());
|
||||||
notification.setOnPreferenceChangeListener((p, v) -> {
|
notification.setOnPreferenceChangeListener((p, v) -> {
|
||||||
if ((boolean) v && App.isParasitic() && !ShortcutUtil.isLaunchShortcutPinned()) {
|
if ((boolean) v && App.isParasitic && !ShortcutUtil.isLaunchShortcutPinned()) {
|
||||||
p.setEnabled(false);
|
p.setEnabled(false);
|
||||||
}
|
}
|
||||||
return ConfigManager.setEnableStatusNotification((boolean) v);
|
return ConfigManager.setEnableStatusNotification((boolean) v);
|
||||||
|
|
@ -177,7 +177,7 @@ public class SettingsFragment extends BaseFragment {
|
||||||
|
|
||||||
Preference shortcut = findPreference("add_shortcut");
|
Preference shortcut = findPreference("add_shortcut");
|
||||||
if (shortcut != null) {
|
if (shortcut != null) {
|
||||||
shortcut.setVisible(App.isParasitic());
|
shortcut.setVisible(App.isParasitic);
|
||||||
if (ShortcutUtil.isLaunchShortcutPinned()) {
|
if (ShortcutUtil.isLaunchShortcutPinned()) {
|
||||||
shortcut.setEnabled(false);
|
shortcut.setEnabled(false);
|
||||||
shortcut.setSummary(R.string.settings_created_shortcut_summary);
|
shortcut.setSummary(R.string.settings_created_shortcut_summary);
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ public class ShortcutUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean requestPinLaunchShortcut(Runnable afterPinned) {
|
public static boolean requestPinLaunchShortcut(Runnable afterPinned) {
|
||||||
if (!App.isParasitic()) throw new RuntimeException();
|
if (!App.isParasitic) throw new RuntimeException();
|
||||||
var context = App.getInstance();
|
var context = App.getInstance();
|
||||||
var sm = context.getSystemService(ShortcutManager.class);
|
var sm = context.getSystemService(ShortcutManager.class);
|
||||||
if (!sm.isRequestPinShortcutSupported()) return false;
|
if (!sm.isRequestPinShortcutSupported()) return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue