OSDN Git Service

Eleven: bump to api26
authorJoey <joey@lineageos.org>
Sun, 29 Jul 2018 13:32:11 +0000 (15:32 +0200)
committerMichael Bestas <mkbestas@lineageos.org>
Tue, 19 Mar 2019 20:55:11 +0000 (22:55 +0200)
Change-Id: Ib2099cf0852ce2194fbd1058ab74c0710746c7d8
Signed-off-by: Joey <joey@lineageos.org>
AndroidManifest.xml
res/values/strings.xml
src/org/lineageos/eleven/MusicPlaybackService.java

index 164b327..67bb8bc 100644 (file)
@@ -21,7 +21,7 @@
 
     <uses-sdk
         android:minSdkVersion="24"
-        android:targetSdkVersion="24" />
+        android:targetSdkVersion="26" />
 
     <original-package android:name="com.cyanogenmod.eleven" />
 
index 7e96954..605dd8e 100644 (file)
     <string name="search_title_playlists">All \"%s\" playlists</string>
 
     <string name="duration_format"><xliff:g id="hours">%1$s</xliff:g> <xliff:g id="minutes">%2$s</xliff:g></string>
+
+    <string name="channel_music">Music playback</string>
 </resources>
index 312b788..9b8d77a 100644 (file)
@@ -18,6 +18,7 @@ import android.annotation.NonNull;
 import android.annotation.SuppressLint;
 import android.app.AlarmManager;
 import android.app.Notification;
+import android.app.NotificationChannel;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.app.Service;
@@ -56,6 +57,7 @@ import android.os.SystemClock;
 import android.provider.MediaStore;
 import android.provider.MediaStore.Audio.AlbumColumns;
 import android.provider.MediaStore.Audio.AudioColumns;
+import android.support.v4.os.BuildCompat;
 import android.text.TextUtils;
 import android.util.Log;
 import android.util.LongSparseArray;
@@ -337,6 +339,8 @@ public class MusicPlaybackService extends Service {
      */
     public static final int MAX_HISTORY_SIZE = 1000;
 
+    private static final String CHANNEL_NAME = "eleven_playback";
+
     public interface TrackErrorExtra {
         /**
          * Name of the track that was unable to play
@@ -1645,7 +1649,7 @@ public class MusicPlaybackService extends Service {
             mNotificationPostTime = System.currentTimeMillis();
         }
 
-        Notification.Builder builder = new Notification.Builder(this)
+        Notification.Builder builder = new Notification.Builder(this, CHANNEL_NAME)
                 .setSmallIcon(R.drawable.ic_notification)
                 .setLargeIcon(artwork.getBitmap())
                 .setContentIntent(clickIntent)
@@ -1666,6 +1670,24 @@ public class MusicPlaybackService extends Service {
 
         builder.setColor(artwork.getVibrantDarkColor());
 
+        if (BuildCompat.isAtLeastO()) {
+            NotificationChannel channel = mNotificationManager
+                    .getNotificationChannel(CHANNEL_NAME);
+
+            if (channel == null) {
+                String name = getString(R.string.channel_music);
+
+                channel = new NotificationChannel(CHANNEL_NAME, name,
+                        mNotificationManager.IMPORTANCE_DEFAULT);
+                channel.setShowBadge(false);
+                channel.enableVibration(false);
+                channel.setSound(null, null);
+                mNotificationManager.createNotificationChannel(channel);
+            }
+
+            builder.setChannelId(channel.getId());
+        }
+
         return builder.build();
     }