Skip to content

Commit

Permalink
fwb: Add music note for now playing ticker
Browse files Browse the repository at this point in the history
Signed-off-by: Jayant-Deshmukh <[email protected]>
  • Loading branch information
Jayant-Deshmukh committed Jan 10, 2025
1 parent 5f9e6d2 commit d50d5f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
26 changes: 3 additions & 23 deletions packages/SystemUI/res/drawable/ic_music_note.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M12,3v10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4V7h4V3h-6z"/>
<?xml version='1.0' encoding='UTF-8'?>
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24.0dip" android:viewportHeight="24.0" android:viewportWidth="24.0" android:width="24.0dip">
<path android:fillColor="#ffffffff" android:pathData="M12,3l0.01,10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55C7.79,13 6,14.79 6,17c0,2.21 1.79,4 4.01,4S14,19.21 14,17V7h4V3H12zM10.01,19c-1.1,0 -2,-0.9 -2,-2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2C12.01,18.1 11.11,19 10.01,19z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public class KeyguardSliceProvider extends SliceProvider implements

private static final String TAG = "KgdSliceProvider";

private static final String NOW_PLAYING = "Now Playing";

private static final StyleSpan BOLD_STYLE = new StyleSpan(Typeface.BOLD);
public static final String KEYGUARD_SLICE_URI = "content://com.android.systemui.keyguard/main";
private static final String KEYGUARD_HEADER_URI =
Expand Down Expand Up @@ -256,6 +258,20 @@ protected void addMediaLocked(ListBuilder listBuilder) {
}
listBuilder.setHeader(new ListBuilder.HeaderBuilder(mHeaderUri).setTitle(mMediaTitle));

if (NOW_PLAYING.contentEquals(mMediaArtist)) {
RowBuilder albumBuilder = new RowBuilder(mMediaUri);
albumBuilder.setTitle(mMediaArtist);

// Use an icon from resources
IconCompat mediaIconCompat = IconCompat.createWithResource(getContext(), R.drawable.ic_music_note);
if (mediaIconCompat != null) {
albumBuilder.addEndItem(mediaIconCompat, ListBuilder.ICON_IMAGE);
}

listBuilder.addRow(albumBuilder);
return;
}

if (!TextUtils.isEmpty(mMediaArtist)) {
RowBuilder albumBuilder = new RowBuilder(mMediaUri);
albumBuilder.setTitle(mMediaArtist);
Expand Down Expand Up @@ -525,7 +541,7 @@ private void updateMediaStateLocked(MediaMetadata metadata, @PlaybackState.State

// Set new track info from playing media notification
mMediaTitle = title;
mMediaArtist = nowPlayingAvailable ? null : artist;
mMediaArtist = nowPlayingAvailable ? NOW_PLAYING : artist;
mMediaIsVisible = nextVisible || nowPlayingAvailable;

notifyChange();
Expand Down

0 comments on commit d50d5f1

Please sign in to comment.