create notification channel for export service
This commit is contained in:
parent
c141f16065
commit
3624d11824
|
@ -6,6 +6,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
@ -56,7 +57,7 @@ public class ExportLogsService extends Service {
|
||||||
List<Conversation> conversations = mDatabaseBackend.getConversations(Conversation.STATUS_AVAILABLE);
|
List<Conversation> conversations = mDatabaseBackend.getConversations(Conversation.STATUS_AVAILABLE);
|
||||||
conversations.addAll(mDatabaseBackend.getConversations(Conversation.STATUS_ARCHIVED));
|
conversations.addAll(mDatabaseBackend.getConversations(Conversation.STATUS_ARCHIVED));
|
||||||
NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext());
|
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext(), "export");
|
||||||
mBuilder.setContentTitle(getString(R.string.notification_export_logs_title))
|
mBuilder.setContentTitle(getString(R.string.notification_export_logs_title))
|
||||||
.setSmallIcon(R.drawable.ic_import_export_white_24dp)
|
.setSmallIcon(R.drawable.ic_import_export_white_24dp)
|
||||||
.setProgress(conversations.size(), 0, false);
|
.setProgress(conversations.size(), 0, false);
|
||||||
|
@ -67,9 +68,11 @@ public class ExportLogsService extends Service {
|
||||||
writeToFile(conversation);
|
writeToFile(conversation);
|
||||||
progress++;
|
progress++;
|
||||||
mBuilder.setProgress(conversations.size(), progress, false);
|
mBuilder.setProgress(conversations.size(), progress, false);
|
||||||
|
if (mNotifyManager != null) {
|
||||||
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
|
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void writeToFile(Conversation conversation) {
|
private void writeToFile(Conversation conversation) {
|
||||||
Jid accountJid = resolveAccountUuid(conversation.getAccountUuid());
|
Jid accountJid = resolveAccountUuid(conversation.getAccountUuid());
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class NotificationService {
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
public void initializeChannels() {
|
public void initializeChannels() {
|
||||||
final Context c = mXmppConnectionService;
|
final Context c = mXmppConnectionService;
|
||||||
NotificationManager notificationManager = c.getSystemService(NotificationManager.class);
|
final NotificationManager notificationManager = c.getSystemService(NotificationManager.class);
|
||||||
if (notificationManager == null) {
|
if (notificationManager == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,13 @@ public class NotificationService {
|
||||||
videoCompressionChannel.setGroup("status");
|
videoCompressionChannel.setGroup("status");
|
||||||
notificationManager.createNotificationChannel(videoCompressionChannel);
|
notificationManager.createNotificationChannel(videoCompressionChannel);
|
||||||
|
|
||||||
|
final NotificationChannel exportChannel = new NotificationChannel("export",
|
||||||
|
c.getString(R.string.export_channel_name),
|
||||||
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
|
exportChannel.setShowBadge(false);
|
||||||
|
exportChannel.setGroup("status");
|
||||||
|
notificationManager.createNotificationChannel(exportChannel);
|
||||||
|
|
||||||
final NotificationChannel messagesChannel = new NotificationChannel("messages",
|
final NotificationChannel messagesChannel = new NotificationChannel("messages",
|
||||||
c.getString(R.string.messages_channel_name),
|
c.getString(R.string.messages_channel_name),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
|
|
@ -736,4 +736,5 @@
|
||||||
<string name="video_compression_channel_name">Video compression</string>
|
<string name="video_compression_channel_name">Video compression</string>
|
||||||
<string name="view_media">View media</string>
|
<string name="view_media">View media</string>
|
||||||
<string name="media_browser">Media browser</string>
|
<string name="media_browser">Media browser</string>
|
||||||
|
<string name="export_channel_name">History export</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue