packages/apps/Eleven
Revision | fd343429a1377d0b5b95e3b9fc9f7c4f0d3a91b1 (tree) |
---|---|
Time | 2018-08-18 20:07:14 |
Author | Joey <joey@line...> |
Commiter | Joey Rizzoli |
Eleven: bump to api26
Change-Id: Ib2099cf0852ce2194fbd1058ab74c0710746c7d8
Signed-off-by: Joey <joey@lineageos.org>
@@ -21,7 +21,7 @@ | ||
21 | 21 | |
22 | 22 | <uses-sdk |
23 | 23 | android:minSdkVersion="24" |
24 | - android:targetSdkVersion="24" /> | |
24 | + android:targetSdkVersion="26" /> | |
25 | 25 | |
26 | 26 | <original-package android:name="com.cyanogenmod.eleven" /> |
27 | 27 |
@@ -207,4 +207,6 @@ | ||
207 | 207 | <string name="search_title_playlists">All \"%s\" playlists</string> |
208 | 208 | |
209 | 209 | <string name="duration_format"><xliff:g id="hours">%1$s</xliff:g> <xliff:g id="minutes">%2$s</xliff:g></string> |
210 | + | |
211 | + <string name="channel_music">Music playback</string> | |
210 | 212 | </resources> |
@@ -18,6 +18,7 @@ import android.annotation.NonNull; | ||
18 | 18 | import android.annotation.SuppressLint; |
19 | 19 | import android.app.AlarmManager; |
20 | 20 | import android.app.Notification; |
21 | +import android.app.NotificationChannel; | |
21 | 22 | import android.app.NotificationManager; |
22 | 23 | import android.app.PendingIntent; |
23 | 24 | import android.app.Service; |
@@ -56,6 +57,7 @@ import android.os.SystemClock; | ||
56 | 57 | import android.provider.MediaStore; |
57 | 58 | import android.provider.MediaStore.Audio.AlbumColumns; |
58 | 59 | import android.provider.MediaStore.Audio.AudioColumns; |
60 | +import android.support.v4.os.BuildCompat; | |
59 | 61 | import android.text.TextUtils; |
60 | 62 | import android.util.Log; |
61 | 63 | import android.util.LongSparseArray; |
@@ -337,6 +339,8 @@ public class MusicPlaybackService extends Service { | ||
337 | 339 | */ |
338 | 340 | public static final int MAX_HISTORY_SIZE = 1000; |
339 | 341 | |
342 | + private static final String CHANNEL_NAME = "eleven_playback"; | |
343 | + | |
340 | 344 | public interface TrackErrorExtra { |
341 | 345 | /** |
342 | 346 | * Name of the track that was unable to play |
@@ -1645,7 +1649,7 @@ public class MusicPlaybackService extends Service { | ||
1645 | 1649 | mNotificationPostTime = System.currentTimeMillis(); |
1646 | 1650 | } |
1647 | 1651 | |
1648 | - Notification.Builder builder = new Notification.Builder(this) | |
1652 | + Notification.Builder builder = new Notification.Builder(this, CHANNEL_NAME) | |
1649 | 1653 | .setSmallIcon(R.drawable.ic_notification) |
1650 | 1654 | .setLargeIcon(artwork.getBitmap()) |
1651 | 1655 | .setContentIntent(clickIntent) |
@@ -1666,6 +1670,24 @@ public class MusicPlaybackService extends Service { | ||
1666 | 1670 | |
1667 | 1671 | builder.setColor(artwork.getVibrantDarkColor()); |
1668 | 1672 | |
1673 | + if (BuildCompat.isAtLeastO()) { | |
1674 | + NotificationChannel channel = mNotificationManager | |
1675 | + .getNotificationChannel(CHANNEL_NAME); | |
1676 | + | |
1677 | + if (channel == null) { | |
1678 | + String name = getString(R.string.channel_music); | |
1679 | + | |
1680 | + channel = new NotificationChannel(CHANNEL_NAME, name, | |
1681 | + mNotificationManager.IMPORTANCE_DEFAULT); | |
1682 | + channel.setShowBadge(false); | |
1683 | + channel.enableVibration(false); | |
1684 | + channel.setSound(null, null); | |
1685 | + mNotificationManager.createNotificationChannel(channel); | |
1686 | + } | |
1687 | + | |
1688 | + builder.setChannelId(channel.getId()); | |
1689 | + } | |
1690 | + | |
1669 | 1691 | return builder.build(); |
1670 | 1692 | } |
1671 | 1693 |