Loading src/main/java/org/torproject/android/service/OrbotService.java +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb @RequiresApi(api = Build.VERSION_CODES.O) private void createNotificationChannel() { if (!Prefs.isNotificationEnabled()) return; NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); CharSequence name = getString(R.string.app_name); // The user-visible name of the channel. Loading @@ -199,6 +201,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb @SuppressLint({"NewApi", "RestrictedApi"}) protected void showToolbarNotification(String notifyMsg, int notifyType, int icon) { if (!Prefs.isNotificationEnabled()) return; PackageManager pm = getPackageManager(); Intent intent = pm.getLaunchIntentForPackage(getPackageName()); PendingIntent pendIntent = PendingIntent.getActivity(OrbotService.this, 0, intent, PendingIntent.FLAG_IMMUTABLE); Loading src/main/java/org/torproject/android/service/util/Prefs.java +9 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ public class Prefs { private final static String PREF_BE_A_SNOWFLAKE = "pref_be_a_snowflake"; private final static String PREF_SHOW_SNOWFLAKE_MSG = "pref_show_snowflake_proxy_msg"; private final static String PREF_BE_A_SNOWFLAKE_LIMIT = "pref_be_a_snowflake_limit"; private final static String PREF_ENABLE_NOTIFICATION = "pref_enable_notification"; private final static String PREF_HOST_ONION_SERVICES = "pref_host_onionservices"; Loading Loading @@ -140,6 +141,14 @@ public class Prefs { putString(PREF_EXIT_NODES, exits); } public static void enableNotification(boolean value) { putBoolean(PREF_ENABLE_NOTIFICATION, value); } public static boolean isNotificationEnabled() { return prefs.getBoolean(PREF_ENABLE_NOTIFICATION, true); } public static SharedPreferences getSharedPrefs(Context context) { return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS, Context.MODE_MULTI_PROCESS); } Loading Loading
src/main/java/org/torproject/android/service/OrbotService.java +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb @RequiresApi(api = Build.VERSION_CODES.O) private void createNotificationChannel() { if (!Prefs.isNotificationEnabled()) return; NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); CharSequence name = getString(R.string.app_name); // The user-visible name of the channel. Loading @@ -199,6 +201,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb @SuppressLint({"NewApi", "RestrictedApi"}) protected void showToolbarNotification(String notifyMsg, int notifyType, int icon) { if (!Prefs.isNotificationEnabled()) return; PackageManager pm = getPackageManager(); Intent intent = pm.getLaunchIntentForPackage(getPackageName()); PendingIntent pendIntent = PendingIntent.getActivity(OrbotService.this, 0, intent, PendingIntent.FLAG_IMMUTABLE); Loading
src/main/java/org/torproject/android/service/util/Prefs.java +9 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ public class Prefs { private final static String PREF_BE_A_SNOWFLAKE = "pref_be_a_snowflake"; private final static String PREF_SHOW_SNOWFLAKE_MSG = "pref_show_snowflake_proxy_msg"; private final static String PREF_BE_A_SNOWFLAKE_LIMIT = "pref_be_a_snowflake_limit"; private final static String PREF_ENABLE_NOTIFICATION = "pref_enable_notification"; private final static String PREF_HOST_ONION_SERVICES = "pref_host_onionservices"; Loading Loading @@ -140,6 +141,14 @@ public class Prefs { putString(PREF_EXIT_NODES, exits); } public static void enableNotification(boolean value) { putBoolean(PREF_ENABLE_NOTIFICATION, value); } public static boolean isNotificationEnabled() { return prefs.getBoolean(PREF_ENABLE_NOTIFICATION, true); } public static SharedPreferences getSharedPrefs(Context context) { return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS, Context.MODE_MULTI_PROCESS); } Loading