mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Combine initNotificationChannel() and setUpUpdateNotificationChannel() into a single method.
This commit is contained in:
parent
c4084c4f97
commit
f55381d689
@ -1,6 +1,5 @@
|
|||||||
package org.schabi.newpipe;
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
@ -33,6 +32,7 @@ import org.schabi.newpipe.util.StateSaver;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class App extends Application {
|
|||||||
Localization.init(getApplicationContext());
|
Localization.init(getApplicationContext());
|
||||||
|
|
||||||
StateSaver.init(this);
|
StateSaver.init(this);
|
||||||
initNotificationChannel();
|
initNotificationChannels();
|
||||||
|
|
||||||
ServiceHelper.initServices(this);
|
ServiceHelper.initServices(this);
|
||||||
|
|
||||||
@ -219,48 +219,31 @@ public class App extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initNotificationChannel() {
|
private void initNotificationChannels() {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String id = getString(R.string.notification_channel_id);
|
String id = getString(R.string.notification_channel_id);
|
||||||
final CharSequence name = getString(R.string.notification_channel_name);
|
String name = getString(R.string.notification_channel_name);
|
||||||
final String description = getString(R.string.notification_channel_description);
|
String description = getString(R.string.notification_channel_description);
|
||||||
|
|
||||||
// Keep this below DEFAULT to avoid making noise on every notification update
|
// Keep this below DEFAULT to avoid making noise on every notification update
|
||||||
final int importance = NotificationManager.IMPORTANCE_LOW;
|
final int importance = NotificationManager.IMPORTANCE_LOW;
|
||||||
|
|
||||||
final NotificationChannel mChannel = new NotificationChannel(id, name, importance);
|
final NotificationChannel mainChannel = new NotificationChannel(id, name, importance);
|
||||||
mChannel.setDescription(description);
|
mainChannel.setDescription(description);
|
||||||
|
|
||||||
final NotificationManager mNotificationManager = getSystemService(NotificationManager.class);
|
id = getString(R.string.app_update_notification_channel_id);
|
||||||
mNotificationManager.createNotificationChannel(mChannel);
|
name = getString(R.string.app_update_notification_channel_name);
|
||||||
|
description = getString(R.string.app_update_notification_channel_description);
|
||||||
|
|
||||||
setUpUpdateNotificationChannel(importance);
|
final NotificationChannel appUpdateChannel = new NotificationChannel(id, name, importance);
|
||||||
}
|
appUpdateChannel.setDescription(description);
|
||||||
|
|
||||||
/**
|
final NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||||
* Set up notification channel for app update.
|
notificationManager.createNotificationChannels(Arrays.asList(mainChannel,
|
||||||
*
|
appUpdateChannel));
|
||||||
* @param importance
|
|
||||||
*/
|
|
||||||
@TargetApi(Build.VERSION_CODES.O)
|
|
||||||
private void setUpUpdateNotificationChannel(final int importance) {
|
|
||||||
final String appUpdateId
|
|
||||||
= getString(R.string.app_update_notification_channel_id);
|
|
||||||
final CharSequence appUpdateName
|
|
||||||
= getString(R.string.app_update_notification_channel_name);
|
|
||||||
final String appUpdateDescription
|
|
||||||
= getString(R.string.app_update_notification_channel_description);
|
|
||||||
|
|
||||||
final NotificationChannel appUpdateChannel
|
|
||||||
= new NotificationChannel(appUpdateId, appUpdateName, importance);
|
|
||||||
appUpdateChannel.setDescription(appUpdateDescription);
|
|
||||||
|
|
||||||
final NotificationManager appUpdateNotificationManager
|
|
||||||
= getSystemService(NotificationManager.class);
|
|
||||||
appUpdateNotificationManager.createNotificationChannel(appUpdateChannel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isDisposedRxExceptionsReported() {
|
protected boolean isDisposedRxExceptionsReported() {
|
||||||
|
@ -15,10 +15,6 @@
|
|||||||
files="ListHelper.java"
|
files="ListHelper.java"
|
||||||
lines="282,314"/>
|
lines="282,314"/>
|
||||||
|
|
||||||
<suppress checks="LineLength"
|
|
||||||
files="App.java"
|
|
||||||
lines="237"/>
|
|
||||||
|
|
||||||
<!-- org.schabi.newpipe.streams -->
|
<!-- org.schabi.newpipe.streams -->
|
||||||
<suppress checks="LineLength"
|
<suppress checks="LineLength"
|
||||||
files="WebMWriter.java"
|
files="WebMWriter.java"
|
||||||
|
Loading…
Reference in New Issue
Block a user