Loading AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.mail" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <application android:name="com.android.calendar.CalendarApplication" android:hardwareAccelerated="true" Loading res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -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/> Loading src/com/android/calendar/AllInOneActivity.java +18 −2 Original line number Diff line number Diff line Loading @@ -103,6 +103,9 @@ 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 { Loading Loading @@ -288,9 +291,22 @@ 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); //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 Loading src/com/android/calendar/alerts/AlertReceiver.java +5 −1 Original line number Diff line number Diff line Loading @@ -132,9 +132,13 @@ public class AlertReceiver extends BroadcastReceiver { mStartingService.setReferenceCounted(false); } mStartingService.acquire(); if (Utils.isOreoOrLater()) { context.startForegroundService(intent); } else { context.startService(intent); } } } /** * Called back by the service when it has finished processing notifications, Loading src/com/android/calendar/alerts/AlertService.java +13 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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. Loading Loading @@ -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"); } Loading Loading @@ -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, FOREGROUND_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(); Loading Loading
AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.mail" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <application android:name="com.android.calendar.CalendarApplication" android:hardwareAccelerated="true" Loading
res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -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/> Loading
src/com/android/calendar/AllInOneActivity.java +18 −2 Original line number Diff line number Diff line Loading @@ -103,6 +103,9 @@ 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 { Loading Loading @@ -288,9 +291,22 @@ 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); //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 Loading
src/com/android/calendar/alerts/AlertReceiver.java +5 −1 Original line number Diff line number Diff line Loading @@ -132,9 +132,13 @@ public class AlertReceiver extends BroadcastReceiver { mStartingService.setReferenceCounted(false); } mStartingService.acquire(); if (Utils.isOreoOrLater()) { context.startForegroundService(intent); } else { context.startService(intent); } } } /** * Called back by the service when it has finished processing notifications, Loading
src/com/android/calendar/alerts/AlertService.java +13 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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. Loading Loading @@ -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"); } Loading Loading @@ -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, FOREGROUND_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(); Loading