diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-20 11:25:47 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-20 11:25:47 +0200 |
commit | cf9613512515956bfca699ee23529ec9e459551a (patch) | |
tree | 853a6511b93a2af44d8d69c4c10ebee305d05e77 /android | |
parent | 1ff97783ea237c3bd76d0ab2c5c612b98320dee8 (diff) |
android/Main: remove SDK_INT diversion
MPD has minSdkVersion=21 which is above all the checks here.
Diffstat (limited to 'android')
-rw-r--r-- | android/src/Main.java | 58 |
1 files changed, 6 insertions, 52 deletions
diff --git a/android/src/Main.java b/android/src/Main.java index 5a5d9d048..82eebe89c 100644 --- a/android/src/Main.java +++ b/android/src/Main.java @@ -156,38 +156,6 @@ public class Main extends Service implements Runnable { sendMessage(MSG_SEND_STATUS, mStatus, 0, mError); } - @TargetApi(Build.VERSION_CODES.GINGERBREAD) - private Notification buildNotificationGB(int title, int text, int icon, PendingIntent contentIntent) { - final Notification notification = new Notification(); - notification.icon = R.drawable.icon; - notification.contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_gb); - notification.contentView.setImageViewResource(R.id.image, icon); - notification.contentView.setTextViewText(R.id.title, getText(title)); - notification.contentView.setTextViewText(R.id.text, getText(text)); - notification.contentIntent = contentIntent; - return notification; - } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - private Notification buildNotificationHC(int title, int text, int icon, PendingIntent contentIntent) { - return new Notification.Builder(this) - .setContentTitle(getText(title)) - .setContentText(getText(text)) - .setSmallIcon(icon) - .setContentIntent(contentIntent) - .getNotification(); - } - - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) - private Notification buildNotificationJB(int title, int text, int icon, PendingIntent contentIntent) { - return new Notification.Builder(this) - .setContentTitle(getText(title)) - .setContentText(getText(text)) - .setSmallIcon(icon) - .setContentIntent(contentIntent) - .build(); - } - private void start() { if (mThread != null) return; @@ -200,26 +168,12 @@ public class Main extends Service implements Runnable { final PendingIntent contentIntent = PendingIntent.getActivity(this, 0, mainIntent, PendingIntent.FLAG_CANCEL_CURRENT); - Notification notification; - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) - notification = buildNotificationJB( - R.string.notification_title_mpd_running, - R.string.notification_text_mpd_running, - R.drawable.notification_icon, - contentIntent); - else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) - notification = buildNotificationHC( - R.string.notification_title_mpd_running, - R.string.notification_text_mpd_running, - R.drawable.notification_icon, - contentIntent); - else - notification = buildNotificationGB( - R.string.notification_title_mpd_running, - R.string.notification_text_mpd_running, - R.drawable.notification_icon, - contentIntent); + Notification notification = new Notification.Builder(this) + .setContentTitle(getText(R.string.notification_title_mpd_running)) + .setContentText(getText(R.string.notification_text_mpd_running)) + .setSmallIcon(R.drawable.notification_icon) + .setContentIntent(contentIntent) + .build(); startForeground(R.string.notification_title_mpd_running, notification); startService(new Intent(this, Main.class)); |