Skip to content

Commit

Permalink
[Feature] Add notification category and priority.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Aug 6, 2019
1 parent 7a854f5 commit 3a167fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import me.zhanghai.android.files.file.FormatUtils;
import me.zhanghai.android.files.filelist.FileItem;
import me.zhanghai.android.files.filelist.OpenFileAsDialogActivity;
import me.zhanghai.android.files.notification.Notifications;
import me.zhanghai.android.files.provider.archive.ArchiveFileSystemProvider;
import me.zhanghai.android.files.provider.archive.archiver.ArchiveWriter;
import me.zhanghai.android.files.provider.common.ByteString;
Expand Down Expand Up @@ -603,9 +604,11 @@ protected void postNotification(@NonNull CharSequence title, @Nullable CharSeque
.setSubText(subText)
.setContentInfo(info)
.setProgress(max, progress, indeterminate)
.setOngoing(true);
// TODO
//.setContentIntent();
.setOngoing(true)
.setCategory(Notifications.Channels.FILE_JOB.CATEGORY)
.setPriority(Notifications.Channels.FILE_JOB.PRIORITY);
if (showCancel) {
int id = getId();
Intent intent = new Intent(context, FileJobReceiver.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package me.zhanghai.android.files.notification;

import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import me.zhanghai.android.files.R;

Expand All @@ -17,13 +18,17 @@ interface BACKGROUND_ACTIVITY_START {
int NAME_RES = R.string.notification_channel_background_activity_start_name;
int DESCRIPTION_RES = R.string.notification_channel_background_activity_start_description;
int IMPORTANCE = NotificationManagerCompat.IMPORTANCE_HIGH;
String CATEGORY = NotificationCompat.CATEGORY_ERROR;
int PRIORITY = NotificationCompat.PRIORITY_HIGH;
}

interface FILE_JOB {
String ID = "file_job";
int NAME_RES = R.string.notification_channel_file_job_name;
int DESCRIPTION_RES = R.string.notification_channel_file_job_description;
int IMPORTANCE = NotificationManagerCompat.IMPORTANCE_LOW;
String CATEGORY = NotificationCompat.CATEGORY_PROGRESS;
int PRIORITY = NotificationCompat.PRIORITY_LOW;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ private static void notifyStartActivity(@NonNull Intent intent, @NonNull CharSeq
.setContentIntent(pendingIntent)
.setOngoing(true)
.setAutoCancel(true)
.setCategory(Notifications.Channels.BACKGROUND_ACTIVITY_START.CATEGORY)
.setPriority(Notifications.Channels.BACKGROUND_ACTIVITY_START.PRIORITY)
.build();
notificationManager.notify(intent.hashCode(), notification);
}
Expand Down

0 comments on commit 3a167fc

Please sign in to comment.