Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bfa8c82 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

/e/ add Pref to enable/disable service notification.

parent a6a16469
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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.
@@ -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);
+9 −0
Original line number Diff line number Diff line
@@ -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";

@@ -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);
    }