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

Commit 0edd4dca authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Update AlertService.java

Port Etar commit 2848e9a0
parent b411339b
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.text.format.DateUtils;
import android.text.format.Time;
import android.util.Log;

import android.support.v4.app.NotificationCompat;
import com.android.calendar.GeneralPreferences;
import com.android.calendar.OtherPreferences;
import com.android.calendar.Utils;
@@ -64,6 +65,7 @@ import foundation.e.calendar.R;
 */
public class AlertService extends Service {

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

    // Hard limit to the number of notifications displayed.
@@ -172,7 +174,7 @@ public class AlertService extends Service {
        }


        if (!prefs.getBoolean(GeneralPreferences.KEY_ALERTS, true)) {
        if (!prefs.getBoolean(GeneralPreferences.KEY_ALERTS, true) && !Utils.isOreoOrLater()) {
            if (DEBUG) {
                Log.d(TAG, "alert preference is OFF");
            }
@@ -980,6 +982,16 @@ public class AlertService extends Service {
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (intent != null) {
            
            if (Utils.isOreoOrLater()) {
                Notification notification = new NotificationCompat.Builder(this, ALERT_CHANNEL_ID)
                        .setContentTitle("Event notifications")
                        .setSmallIcon(R.drawable.stat_notify_calendar)
                        .setShowWhen(false)
                        .build();
                startForeground(1337, notification);
            }
            
            Message msg = mServiceHandler.obtainMessage();
            msg.arg1 = startId;
            msg.obj = intent.getExtras();