Loading src/main/java/org/torproject/android/service/OrbotService.java +14 −5 Original line number Diff line number Diff line Loading @@ -114,17 +114,21 @@ public class OrbotService extends VpnService { } private void showConnectedToTorNetworkNotification() { if (mNotifyBuilder != null) { mNotifyBuilder.setProgress(0, 0, false); } showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.drawable.ic_stat_tor); } private void clearNotifications() { if (mNotificationManager != null) mNotificationManager.cancelAll(); if (mNotificationManager != null) mNotificationManager.cancel(NOTIFY_ID); if (mOrbotRawEventListener != null) mOrbotRawEventListener.getNodes().clear(); } @SuppressLint({"NewApi", "RestrictedApi"}) protected void showToolbarNotification(String notifyMsg, int notifyType, int icon) { if (!Prefs.isNotificationEnabled()) return; var intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); var pendIntent = PendingIntent.getActivity(OrbotService.this, 0, intent, PendingIntent.FLAG_IMMUTABLE); Loading Loading @@ -382,7 +386,7 @@ public class OrbotService extends VpnService { mActionBroadcastReceiver = new ActionBroadcastReceiver(); ContextCompat.registerReceiver(this, mActionBroadcastReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Prefs.isNotificationEnabled()) Notifications.createNotificationChannel(this); var hasGeoip = new File(appBinHome, GEOIP_ASSET_KEY).exists(); Loading Loading @@ -562,7 +566,10 @@ public class OrbotService extends VpnService { showConnectedToTorNetworkNotification(); return; } if (mNotifyBuilder != null) { mNotifyBuilder.setProgress(100, 0, false); } showToolbarNotification("", NOTIFY_ID, R.drawable.ic_stat_tor); if (Prefs.getTorConnectionPathway().equals(Prefs.CONNECTION_PATHWAY_SMART)) Loading Loading @@ -822,7 +829,9 @@ public class OrbotService extends VpnService { percent = percent.substring(0, percent.indexOf('%')).trim(); localIntent.putExtra(LOCAL_EXTRA_BOOTSTRAP_PERCENT, percent); var prog = Integer.parseInt(percent); mNotifyBuilder.setProgress(100, prog, false); if (mNotifyBuilder != null) { mNotifyBuilder.setProgress(100, Integer.parseInt(percent), false); } notificationMessage = notificationMessage.substring(notificationMessage.indexOf(':') + 1).trim(); } } Loading src/main/java/org/torproject/android/service/util/Prefs.java +10 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,8 @@ public class Prefs { }); public static final String PREF_SECURE_WINDOW_FLAG = "pref_flag_secure"; private final static String PREF_ENABLE_NOTIFICATION = "pref_enable_notification"; private static SharedPreferences prefs; Loading Loading @@ -234,6 +236,14 @@ public class Prefs { putString(PREF_EXIT_NODES, country); } 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); return PreferenceManager.getDefaultSharedPreferences(context); Loading Loading
src/main/java/org/torproject/android/service/OrbotService.java +14 −5 Original line number Diff line number Diff line Loading @@ -114,17 +114,21 @@ public class OrbotService extends VpnService { } private void showConnectedToTorNetworkNotification() { if (mNotifyBuilder != null) { mNotifyBuilder.setProgress(0, 0, false); } showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.drawable.ic_stat_tor); } private void clearNotifications() { if (mNotificationManager != null) mNotificationManager.cancelAll(); if (mNotificationManager != null) mNotificationManager.cancel(NOTIFY_ID); if (mOrbotRawEventListener != null) mOrbotRawEventListener.getNodes().clear(); } @SuppressLint({"NewApi", "RestrictedApi"}) protected void showToolbarNotification(String notifyMsg, int notifyType, int icon) { if (!Prefs.isNotificationEnabled()) return; var intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); var pendIntent = PendingIntent.getActivity(OrbotService.this, 0, intent, PendingIntent.FLAG_IMMUTABLE); Loading Loading @@ -382,7 +386,7 @@ public class OrbotService extends VpnService { mActionBroadcastReceiver = new ActionBroadcastReceiver(); ContextCompat.registerReceiver(this, mActionBroadcastReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Prefs.isNotificationEnabled()) Notifications.createNotificationChannel(this); var hasGeoip = new File(appBinHome, GEOIP_ASSET_KEY).exists(); Loading Loading @@ -562,7 +566,10 @@ public class OrbotService extends VpnService { showConnectedToTorNetworkNotification(); return; } if (mNotifyBuilder != null) { mNotifyBuilder.setProgress(100, 0, false); } showToolbarNotification("", NOTIFY_ID, R.drawable.ic_stat_tor); if (Prefs.getTorConnectionPathway().equals(Prefs.CONNECTION_PATHWAY_SMART)) Loading Loading @@ -822,7 +829,9 @@ public class OrbotService extends VpnService { percent = percent.substring(0, percent.indexOf('%')).trim(); localIntent.putExtra(LOCAL_EXTRA_BOOTSTRAP_PERCENT, percent); var prog = Integer.parseInt(percent); mNotifyBuilder.setProgress(100, prog, false); if (mNotifyBuilder != null) { mNotifyBuilder.setProgress(100, Integer.parseInt(percent), false); } notificationMessage = notificationMessage.substring(notificationMessage.indexOf(':') + 1).trim(); } } Loading
src/main/java/org/torproject/android/service/util/Prefs.java +10 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,8 @@ public class Prefs { }); public static final String PREF_SECURE_WINDOW_FLAG = "pref_flag_secure"; private final static String PREF_ENABLE_NOTIFICATION = "pref_enable_notification"; private static SharedPreferences prefs; Loading Loading @@ -234,6 +236,14 @@ public class Prefs { putString(PREF_EXIT_NODES, country); } 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); return PreferenceManager.getDefaultSharedPreferences(context); Loading