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

Commit aac8f840 authored by Suhail Alkowaileet's avatar Suhail Alkowaileet Committed by Gitsaibot
Browse files

Fix 404 - move notification channel creation to AllInOneActivity. (#413)

Fix 404 - move notification channel creation to AllInOneActivity.
parent acb8d3fe
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -28,10 +28,13 @@ import android.animation.ObjectAnimator;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.AsyncQueryHandler;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
@@ -80,6 +83,8 @@ import com.android.calendar.CalendarController.EventInfo;
import com.android.calendar.CalendarController.EventType;
import com.android.calendar.CalendarController.ViewType;
import com.android.calendar.agenda.AgendaFragment;
import com.android.calendar.alerts.AlertService;
import com.android.calendar.alerts.NotificationMgr;
import com.android.calendar.month.MonthByWeekFragment;
import com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment;
import com.android.datetimepicker.date.DatePickerDialog;
@@ -96,6 +101,7 @@ import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS;
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;

public class AllInOneActivity extends AbstractCalendarActivity implements EventHandler,
        OnSharedPreferenceChangeListener, SearchView.OnQueryTextListener, SearchView.OnSuggestionListener, NavigationView.OnNavigationItemSelectedListener {
@@ -276,6 +282,15 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
        // This needs to be created before setContentView
        mController = CalendarController.getInstance(this);

        // Create notification channel
        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);
            nm.createNotificationChannel(channel);
        }

        // Check and ask for most needed permissions
        checkAppPermissions();

+0 −5
Original line number Diff line number Diff line
@@ -155,11 +155,6 @@ public class AlertService extends Service {
        NotificationMgr nm = new NotificationMgrWrapper(
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            String appName = context.getString(R.string.standalone_app_label);
            NotificationChannel channel  = new NotificationChannel(ALERT_CHANNEL_ID, appName, NotificationManager.IMPORTANCE_HIGH);
            nm.createNotificationChannel(channel);
        }

        final long currentTime = System.currentTimeMillis();
        SharedPreferences prefs = GeneralPreferences.getSharedPreferences(context);