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

Commit 01a4c461 authored by Michael Potter's avatar Michael Potter Committed by Jochen Sprickerhof
Browse files

move foreground notification to own channel (#559)

* move foreground notification to own channel
parent 39ed11e5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -248,6 +248,10 @@
    <string name="alert_title">Calendar notifications</string>
    <!-- Notification window messages: -->
    <skip/>
    <string name="foreground_notification_channel_name">Alert Sync</string>
    <string name="foreground_notification_channel_description">
        Foreground notification required for internal alert sync. Please mute
    </string>

    <!-- Event info/edit screen labels:-->
    <skip/>
+14 −2
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ import static android.provider.CalendarContract.EXTRA_EVENT_ALL_DAY;
import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import static com.android.calendar.alerts.AlertService.ALERT_CHANNEL_ID;
import static com.android.calendar.alerts.AlertService.FOREGROUND_CHANNEL_ID;

public class AllInOneActivity extends AbstractCalendarActivity implements EventHandler,
        OnSharedPreferenceChangeListener, SearchView.OnQueryTextListener, SearchView.OnSuggestionListener, NavigationView.OnNavigationItemSelectedListener {
@@ -265,9 +266,20 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
        NotificationMgr nm = new AlertService.NotificationMgrWrapper(
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE));
        if (Utils.isOreoOrLater()) {
            String appName = this.getString(R.string.standalone_app_label);
            NotificationChannel channel  = new NotificationChannel(ALERT_CHANNEL_ID, appName, NotificationManager.IMPORTANCE_HIGH);
            NotificationChannel channel  = new NotificationChannel(
                    ALERT_CHANNEL_ID,
                    this.getString(R.string.standalone_app_label),
                    NotificationManager.IMPORTANCE_HIGH);

            NotificationChannel foregroundChannel = new NotificationChannel(
                    FOREGROUND_CHANNEL_ID,
                    this.getString(R.string.foreground_notification_channel_name),
                    NotificationManager.IMPORTANCE_LOW);
            foregroundChannel.setDescription(
                    this.getString(R.string.foreground_notification_channel_description));

            nm.createNotificationChannel(channel);
            nm.createNotificationChannel(foregroundChannel);
        }

        // Check and ask for most needed permissions
+2 −1
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import ws.xsoh.etar.R;
public class AlertService extends Service {

    public static final String ALERT_CHANNEL_ID = "alert_channel_01";// The id of the channel.
    public static final String FOREGROUND_CHANNEL_ID = "foreground_channel_01";

    // Hard limit to the number of notifications displayed.
    public static final int MAX_NOTIFICATIONS = 20;
@@ -983,7 +984,7 @@ public class AlertService extends Service {
        if (intent != null) {

            if (Utils.isOreoOrLater()) {
                Notification notification = new NotificationCompat.Builder(this, ALERT_CHANNEL_ID)
                Notification notification = new NotificationCompat.Builder(this, FOREGROUND_CHANNEL_ID)
                        .setContentTitle("Event notifications")
                        .setSmallIcon(R.drawable.stat_notify_calendar)
                        .setShowWhen(false)