diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java
index ef39e77799..5876c6418f 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java
@@ -19,6 +19,9 @@ package eu.faircode.email;
Copyright 2018-2020 by Marcel Bokhorst (M66B)
*/
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
@@ -36,6 +39,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
+import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -51,7 +55,9 @@ import static android.app.Activity.RESULT_OK;
public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private Button btnManage;
private Button btnManageDefault;
+ private ImageView ivChannelDefault;
private Button btnManageService;
+ private ImageView ivChannelService;
private SwitchCompat swBackground;
private CheckBox cbNotifyActionTrash;
@@ -112,7 +118,9 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
btnManage = view.findViewById(R.id.btnManage);
btnManageDefault = view.findViewById(R.id.btnManageDefault);
+ ivChannelDefault = view.findViewById(R.id.ivChannelDefault);
btnManageService = view.findViewById(R.id.btnManageService);
+ ivChannelService = view.findViewById(R.id.ivChannelService);
swBackground = view.findViewById(R.id.swBackground);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
@@ -181,6 +189,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
+ ivChannelDefault.setVisibility(View.GONE);
+
final Intent channelService = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName())
.putExtra(Settings.EXTRA_CHANNEL_ID, "service");
@@ -193,6 +203,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
+ ivChannelService.setVisibility(View.GONE);
+
swBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -409,6 +421,27 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
return view;
}
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
+
+ NotificationChannel notification = nm.getNotificationChannel("notification");
+ if (notification != null) {
+ ivChannelDefault.setImageLevel(notification.getImportance() == NotificationManager.IMPORTANCE_NONE ? 0 : 1);
+ ivChannelDefault.setVisibility(View.VISIBLE);
+ }
+
+ NotificationChannel service = nm.getNotificationChannel("service");
+ if (service != null) {
+ ivChannelService.setImageLevel(service.getImportance() == NotificationManager.IMPORTANCE_NONE ? 0 : 1);
+ ivChannelService.setVisibility(View.VISIBLE);
+ }
+ }
+ }
+
@Override
public void onDestroyView() {
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
diff --git a/app/src/main/res/drawable/off_on.xml b/app/src/main/res/drawable/off_on.xml
new file mode 100644
index 0000000000..b7ad84178c
--- /dev/null
+++ b/app/src/main/res/drawable/off_on.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/twotone_toggle_off_24.xml b/app/src/main/res/drawable/twotone_toggle_off_24.xml
new file mode 100644
index 0000000000..11ff1ae763
--- /dev/null
+++ b/app/src/main/res/drawable/twotone_toggle_off_24.xml
@@ -0,0 +1,15 @@
+
+
+
+
diff --git a/app/src/main/res/drawable/twotone_toggle_on_24.xml b/app/src/main/res/drawable/twotone_toggle_on_24.xml
new file mode 100644
index 0000000000..7dff18ca03
--- /dev/null
+++ b/app/src/main/res/drawable/twotone_toggle_on_24.xml
@@ -0,0 +1,15 @@
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml
index 06861354cc..4407a5242f 100644
--- a/app/src/main/res/layout/fragment_options_notifications.xml
+++ b/app/src/main/res/layout/fragment_options_notifications.xml
@@ -61,6 +61,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvManageHint" />
+
+
+
+