use NotificationCompat to get rid of some version checks

This commit is contained in:
Unpublished
2019-02-22 17:04:53 +01:00
parent 0edc7a8629
commit 7f66558566
2 changed files with 29 additions and 59 deletions

View File

@@ -4,11 +4,11 @@ import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
public class ServiceExternal extends Service {
private final static String ACTION_ENABLE = "eu.faircode.email.ENABLE";
@@ -61,12 +61,8 @@ public class ServiceExternal extends Service {
return null;
}
private Notification.Builder getNotification() {
Notification.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
builder = new Notification.Builder(this, "service");
else
builder = new Notification.Builder(this);
private NotificationCompat.Builder getNotification() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "service");
builder
.setSmallIcon(R.drawable.baseline_compare_arrows_white_24)
@@ -75,7 +71,7 @@ public class ServiceExternal extends Service {
.setShowWhen(false)
.setPriority(Notification.PRIORITY_MIN)
.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_SECRET);
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
return builder;
}