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

Commit d7e99ee8 authored by Romain Hunault's avatar Romain Hunault 🚴🏻
Browse files

Merge branch 'sprint-alexandria' into 'master'

[RELEASE] Sprint alexandria

See merge request e/apps/Calendar!12
parents 86990a82 ab2c02dc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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"
+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/>
+18 −2
Original line number Diff line number Diff line
@@ -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 {
@@ -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
+5 −1
Original line number Diff line number Diff line
@@ -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,
+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, 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();