Skip to content

Commit

Permalink
Fix notification err channel
Browse files Browse the repository at this point in the history
Pull request 28a9015
  • Loading branch information
federicoiosue committed Jan 12, 2020
1 parent b8f18a4 commit 433f05a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ public interface Constants extends ConstantsBase {
String PACKAGE = "it.feio.android.omninotes.alpha";
String PREFS_NAME = PACKAGE + "_preferences";

String CHANNEL_BACKUPS_ID = PACKAGE + ".backups";
String CHANNEL_REMINDERS_ID = PACKAGE + ".reminders";

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ public interface Constants extends ConstantsBase {
String PACKAGE = "it.feio.android.omninotes";
String PREFS_NAME = PACKAGE + "_preferences";

String CHANNEL_BACKUPS_ID = PACKAGE + ".backups";
String CHANNEL_REMINDERS_ID = PACKAGE + ".reminders";

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public interface Constants extends ConstantsBase {
String EXTERNAL_STORAGE_FOLDER = "Omni Notes Foss";
String PACKAGE = "it.feio.android.omninotes.foss";
String PREFS_NAME = PACKAGE + "_preferences";

String CHANNEL_BACKUPS_ID = PACKAGE + ".backups";
String CHANNEL_REMINDERS_ID = PACKAGE + ".reminders";

}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ public interface ConstantsBase {
String PROPERTIES_PARAMS_SEPARATOR = ",";

String AUTO_BACKUP_DIR = "_autobackup";

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

public class NotificationChannel {

int importance;
String name;
String description;
int importance;
String name;
String description;
String id;

NotificationChannel (int importance, String name, String description) {
this.importance = importance;
this.name = name;
this.description = description;
}
NotificationChannel(int importance, String name, String description, String id) {
this.importance = importance;
this.name = name;
this.description = description;
this.id = id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package it.feio.android.omninotes.utils.notifications;

import static androidx.core.app.NotificationManagerCompat.IMPORTANCE_DEFAULT;
import static it.feio.android.omninotes.utils.ConstantsBase.CHANNEL_BACKUPS_ID;
import static it.feio.android.omninotes.utils.ConstantsBase.CHANNEL_REMINDERS_ID;

import android.annotation.TargetApi;
import android.app.NotificationManager;
import android.os.Build;
import it.feio.android.omninotes.OmniNotes;
import it.feio.android.omninotes.R;
Expand All @@ -30,12 +32,16 @@
public class NotificationChannels {

private static List<NotificationChannel> channels = new ArrayList<NotificationChannel>() {{
add(new NotificationChannel(IMPORTANCE_DEFAULT, OmniNotes.getAppContext().getString(R.string
.channel_backups_name), OmniNotes.getAppContext().getString(R.string
.channel_backups_description)));
add(new NotificationChannel(IMPORTANCE_DEFAULT, OmniNotes.getAppContext().getString(R.string
.channel_reminders_name), OmniNotes.getAppContext().getString(R.string
.channel_reminders_description)));
add(new NotificationChannel(
NotificationManager.IMPORTANCE_DEFAULT,
OmniNotes.getAppContext().getString(R.string.channel_backups_name),
OmniNotes.getAppContext().getString(R.string.channel_backups_description),
CHANNEL_BACKUPS_ID));
add(new NotificationChannel(
NotificationManager.IMPORTANCE_DEFAULT,
OmniNotes.getAppContext().getString(R.string.channel_reminders_name),
OmniNotes.getAppContext().getString(R.string.channel_reminders_description),
CHANNEL_REMINDERS_ID));
}};

public static List<NotificationChannel> getChannels () {
Expand All @@ -45,4 +51,5 @@ public static List<NotificationChannel> getChannels () {
public enum NotificationChannelNames {
Backups, Reminders
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public NotificationsHelper (Context mContext) {
*/
@TargetApi(Build.VERSION_CODES.O)
public void initNotificationChannels () {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
for (it.feio.android.omninotes.utils.notifications.NotificationChannel notificationChannel : NotificationChannels.getChannels()) {
NotificationChannel channel = new NotificationChannel(notificationChannel.name, notificationChannel
NotificationChannel channel = new NotificationChannel(notificationChannel.id, notificationChannel
.name, notificationChannel.importance);
channel.setDescription(notificationChannel.description);
mNotificationManager.createNotificationChannel(channel);
Expand Down Expand Up @@ -187,4 +187,5 @@ public void cancel () {
public void cancel (int id) {
mNotificationManager.cancel(id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public interface Constants extends ConstantsBase {
String EXTERNAL_STORAGE_FOLDER = "Omni Notes";
String PACKAGE = "it.feio.android.omninotes";
String PREFS_NAME = PACKAGE + "_preferences";

String CHANNEL_BACKUPS_ID = PACKAGE + ".backups";
String CHANNEL_REMINDERS_ID = PACKAGE + ".reminders";

}

0 comments on commit 433f05a

Please sign in to comment.