Fixed the notification coloring. Automatically refreshs notification when the color setting is changed. Colored notification for all Android versions now

This commit is contained in:
Karim Abou Zeid 2015-06-17 11:12:46 +02:00
commit d2fda4a839
33 changed files with 391 additions and 33 deletions

View file

@ -8,9 +8,11 @@ import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.TaskStackBuilder; import android.app.TaskStackBuilder;
import android.content.BroadcastReceiver;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v7.graphics.Palette; import android.support.v7.graphics.Palette;
@ -34,6 +36,8 @@ public class PlayingNotificationHelper {
public static final String TAG = PlayingNotificationHelper.class.getSimpleName(); public static final String TAG = PlayingNotificationHelper.class.getSimpleName();
public static final int NOTIFICATION_ID = 1337; public static final int NOTIFICATION_ID = 1337;
public static final String ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED = "com.kabouzeid.gramophone.NOTIFICATION_COLOR_PREFERENCE_CHANGED";
public static final String EXTRA_NOTIFICATION_COLORED = "com.kabouzeid.gramophone.EXTRA_NOTIFICATION_COLORED";
private final MusicService service; private final MusicService service;
@ -44,20 +48,53 @@ public class PlayingNotificationHelper {
private RemoteViews notificationLayoutExpanded; private RemoteViews notificationLayoutExpanded;
private Song currentSong; private Song currentSong;
private boolean isPlaying;
private String currentAlbumArtUri; private String currentAlbumArtUri;
private boolean isColored;
private boolean isReceiverRegistered;
private boolean isNotificationShown;
final IntentFilter intentFilter;
public PlayingNotificationHelper(final MusicService service) { public PlayingNotificationHelper(final MusicService service) {
this.service = service; this.service = service;
notificationManager = (NotificationManager) service notificationManager = (NotificationManager) service
.getSystemService(Context.NOTIFICATION_SERVICE); .getSystemService(Context.NOTIFICATION_SERVICE);
intentFilter = new IntentFilter();
intentFilter.addAction(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED);
} }
private BroadcastReceiver notificationColorPreferenceChangedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED)) {
boolean isColored = intent.getBooleanExtra(EXTRA_NOTIFICATION_COLORED, false);
if (isNotificationShown && PlayingNotificationHelper.this.isColored != isColored) {
buildNotification(currentSong, isPlaying, isColored);
}
}
}
};
public void buildNotification(final Song song, final boolean isPlaying) { public void buildNotification(final Song song, final boolean isPlaying) {
buildNotification(song, isPlaying, PreferenceUtils.getInstance(service).coloredNotification());
}
private void buildNotification(final Song song, final boolean isPlaying, final boolean isColored) {
this.isColored = isColored;
currentSong = song; currentSong = song;
this.isPlaying = isPlaying;
if (!isReceiverRegistered)
service.registerReceiver(notificationColorPreferenceChangedReceiver, intentFilter);
isReceiverRegistered = true;
isNotificationShown = true;
notificationLayout = new RemoteViews(service.getPackageName(), notificationLayout = new RemoteViews(service.getPackageName(),
R.layout.notification_controller); isColored ? R.layout.notification_controller_colored : R.layout.notification_controller);
notificationLayoutExpanded = new RemoteViews(service.getPackageName(), notificationLayoutExpanded = new RemoteViews(service.getPackageName(),
R.layout.notification_controller_big); isColored ? R.layout.notification_controller_big_colored : R.layout.notification_controller_big);
notification = new NotificationCompat.Builder(service) notification = new NotificationCompat.Builder(service)
.setSmallIcon(R.drawable.ic_notification) .setSmallIcon(R.drawable.ic_notification)
@ -73,8 +110,8 @@ public class PlayingNotificationHelper {
setUpCollapsedLayout(); setUpCollapsedLayout();
setUpExpandedLayout(); setUpExpandedLayout();
loadAlbumArt(); loadAlbumArt();
setUpPlaybackActions(isPlaying); setUpPlaybackActions();
setUpExpandedPlaybackActions(isPlaying); setUpExpandedPlaybackActions();
service.startForeground(NOTIFICATION_ID, notification); service.startForeground(NOTIFICATION_ID, notification);
} }
@ -87,7 +124,7 @@ public class PlayingNotificationHelper {
return taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); return taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
} }
private void setUpExpandedPlaybackActions(boolean isPlaying) { private void setUpExpandedPlaybackActions() {
notificationLayoutExpanded.setOnClickPendingIntent(R.id.action_play_pause, notificationLayoutExpanded.setOnClickPendingIntent(R.id.action_play_pause,
retrievePlaybackActions(1)); retrievePlaybackActions(1));
@ -104,7 +141,7 @@ public class PlayingNotificationHelper {
isPlaying ? R.drawable.ic_pause_white_36dp : R.drawable.ic_play_arrow_white_36dp); isPlaying ? R.drawable.ic_pause_white_36dp : R.drawable.ic_play_arrow_white_36dp);
} }
private void setUpPlaybackActions(boolean isPlaying) { private void setUpPlaybackActions() {
notificationLayout.setOnClickPendingIntent(R.id.action_play_pause, notificationLayout.setOnClickPendingIntent(R.id.action_play_pause,
retrievePlaybackActions(1)); retrievePlaybackActions(1));
@ -183,12 +220,14 @@ public class PlayingNotificationHelper {
} }
private void setAlbumArt(Bitmap albumArt) { private void setAlbumArt(Bitmap albumArt) {
int defaultColor = service.getResources().getColor(R.color.default_notification_color); int defaultColor = isColored ?
service.getResources().getColor(R.color.default_colored_notification_color) :
service.getResources().getColor(R.color.default_notification_color);
int newColor = defaultColor; int newColor = defaultColor;
if (albumArt != null) { if (albumArt != null) {
notificationLayout.setImageViewBitmap(R.id.icon, albumArt); notificationLayout.setImageViewBitmap(R.id.icon, albumArt);
notificationLayoutExpanded.setImageViewBitmap(R.id.icon, albumArt); notificationLayoutExpanded.setImageViewBitmap(R.id.icon, albumArt);
if (PreferenceUtils.getInstance(service).coloredNotification()) if (isColored)
newColor = Palette.from(albumArt).generate().getVibrantColor(defaultColor); newColor = Palette.from(albumArt).generate().getVibrantColor(defaultColor);
} else { } else {
notificationLayout.setImageViewResource(R.id.icon, R.drawable.default_album_art); notificationLayout.setImageViewResource(R.id.icon, R.drawable.default_album_art);
@ -201,11 +240,17 @@ public class PlayingNotificationHelper {
} }
public void killNotification() { public void killNotification() {
if (isReceiverRegistered)
service.unregisterReceiver(notificationColorPreferenceChangedReceiver);
isReceiverRegistered = false;
service.stopForeground(true); service.stopForeground(true);
notification = null; notification = null;
isNotificationShown = false;
} }
public void updatePlayState(final boolean isPlaying) { public void updatePlayState(final boolean isPlaying) {
this.isPlaying = isPlaying;
if (notification == null || notificationManager == null) { if (notification == null || notificationManager == null) {
return; return;
} }

View file

@ -13,6 +13,7 @@ public class UIPreferenceChangedEvent {
public static final int COLORED_NAVIGATION_BAR_CURRENT_PLAYING_CHANGED = 6; public static final int COLORED_NAVIGATION_BAR_CURRENT_PLAYING_CHANGED = 6;
public static final int COLORED_NAVIGATION_BAR_CHANGED = 10; public static final int COLORED_NAVIGATION_BAR_CHANGED = 10;
public static final int COLORED_NAVIGATION_BAR_OTHER_SCREENS_CHANGED = 7; public static final int COLORED_NAVIGATION_BAR_OTHER_SCREENS_CHANGED = 7;
public static final int COLORED_NOTIFICATION_CHANGED = 11;
private final int action; private final int action;
private final Object value; private final Object value;

View file

@ -17,6 +17,7 @@ import com.afollestad.materialdialogs.util.DialogUtils;
import com.kabouzeid.gramophone.App; import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R; import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog; import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
import com.kabouzeid.gramophone.helper.PlayingNotificationHelper;
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent; import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
import com.kabouzeid.gramophone.prefs.ColorChooserPreference; import com.kabouzeid.gramophone.prefs.ColorChooserPreference;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity; import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
@ -137,11 +138,13 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
} }
Preference coloredNotification = findPreference("colored_notification"); Preference coloredNotification = findPreference("colored_notification");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { coloredNotification.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
coloredNotification.setEnabled(false); @Override
coloredNotification.setWidgetLayoutResource(0); public boolean onPreferenceChange(Preference preference, Object newValue) {
coloredNotification.setSummary(R.string.pref_only_lollipop); getActivity().sendBroadcast(new Intent(PlayingNotificationHelper.ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED).putExtra(PlayingNotificationHelper.EXTRA_NOTIFICATION_COLORED, (boolean) newValue));
return true;
} }
});
equalizer = findPreference("equalizer"); equalizer = findPreference("equalizer");
resolveEqualizer(); resolveEqualizer();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 144 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 276 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 287 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 320 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 117 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 220 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

After

Width:  |  Height:  |  Size: 204 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 222 B

Before After
Before After

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/ripple_material_dark">
<item android:id="@android:id/mask">
<color android:color="@color/white" />
</item>
</ripple>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/grey_500"> android:color="@color/ripple_material_light">
<item android:id="@android:id/mask"> <item android:id="@android:id/mask">
<color android:color="@color/white" /> <color android:color="@color/white" />
</item> </item>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

After

Width:  |  Height:  |  Size: 156 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 B

After

Width:  |  Height:  |  Size: 336 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

After

Width:  |  Height:  |  Size: 334 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 343 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 249 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 425 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 495 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 B

After

Width:  |  Height:  |  Size: 518 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 364 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 519 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

After

Width:  |  Height:  |  Size: 669 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

After

Width:  |  Height:  |  Size: 677 B

Before After
Before After

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:state_pressed="true" android:drawable="@color/activated_selected_dark" />
<item android:state_activated="true" android:drawable="@color/ripple_material_dark" />
<item android:state_pressed="true" android:drawable="@color/ripple_material_dark" />
<item android:drawable="@android:color/transparent" />
</selector>

View file

@ -63,7 +63,7 @@
android:gravity="bottom" android:gravity="bottom"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification.Title" android:textAppearance="@style/Theme.MaterialMusic.Notification.Title"
android:textColor="@color/notification_default_content_color" android:textColor="@color/default_notification_content_color"
tools:ignore="NestedWeights" /> tools:ignore="NestedWeights" />
<TextView <TextView
@ -76,7 +76,7 @@
android:fadingEdge="horizontal" android:fadingEdge="horizontal"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification" android:textAppearance="@style/Theme.MaterialMusic.Notification"
android:textColor="@color/notification_default_secondary_content_color" /> android:textColor="@color/default_notification_secondary_content_color" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -101,7 +101,7 @@
android:background="@drawable/notification_selector" android:background="@drawable/notification_selector"
android:gravity="center" android:gravity="center"
android:src="@drawable/ic_skip_previous_white_36dp" android:src="@drawable/ic_skip_previous_white_36dp"
android:tint="@color/notification_default_content_color" android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android" <ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
@ -115,7 +115,7 @@
android:background="@drawable/notification_selector" android:background="@drawable/notification_selector"
android:gravity="center" android:gravity="center"
android:src="@drawable/ic_play_arrow_white_36dp" android:src="@drawable/ic_play_arrow_white_36dp"
android:tint="@color/notification_default_content_color" android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android" <ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
@ -129,7 +129,7 @@
android:background="@drawable/notification_selector" android:background="@drawable/notification_selector"
android:gravity="center" android:gravity="center"
android:src="@drawable/ic_skip_next_white_36dp" android:src="@drawable/ic_skip_next_white_36dp"
android:tint="@color/notification_default_content_color" android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -41,7 +41,7 @@
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:background="@drawable/notification_selector" android:background="@drawable/notification_selector"
android:src="@drawable/ic_close_white_24dp" android:src="@drawable/ic_close_white_24dp"
android:tint="@color/notification_default_content_color" android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<LinearLayout <LinearLayout
@ -66,7 +66,7 @@
android:fadingEdge="horizontal" android:fadingEdge="horizontal"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification.Title" android:textAppearance="@style/Theme.MaterialMusic.Notification.Title"
android:textColor="@color/notification_default_content_color" /> android:textColor="@color/default_notification_content_color" />
<TextView <TextView
android:id="@+id/text" android:id="@+id/text"
@ -79,7 +79,7 @@
android:fadingEdge="horizontal" android:fadingEdge="horizontal"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification" android:textAppearance="@style/Theme.MaterialMusic.Notification"
android:textColor="@color/notification_default_secondary_content_color" /> android:textColor="@color/default_notification_secondary_content_color" />
<TextView <TextView
android:id="@+id/text2" android:id="@+id/text2"
@ -91,7 +91,7 @@
android:fadingEdge="horizontal" android:fadingEdge="horizontal"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification" android:textAppearance="@style/Theme.MaterialMusic.Notification"
android:textColor="@color/notification_default_secondary_content_color" /> android:textColor="@color/default_notification_secondary_content_color" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -118,7 +118,7 @@
android:background="@drawable/notification_selector" android:background="@drawable/notification_selector"
android:gravity="center" android:gravity="center"
android:src="@drawable/ic_skip_previous_white_36dp" android:src="@drawable/ic_skip_previous_white_36dp"
android:tint="@color/notification_default_content_color" android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android" <ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
@ -132,7 +132,7 @@
android:background="@drawable/notification_selector" android:background="@drawable/notification_selector"
android:gravity="center" android:gravity="center"
android:src="@drawable/ic_play_arrow_white_36dp" android:src="@drawable/ic_play_arrow_white_36dp"
android:tint="@color/notification_default_content_color" android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android" <ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
@ -146,7 +146,7 @@
android:background="@drawable/notification_selector" android:background="@drawable/notification_selector"
android:gravity="center" android:gravity="center"
android:src="@drawable/ic_skip_next_white_36dp" android:src="@drawable/ic_skip_next_white_36dp"
android:tint="@color/notification_default_content_color" android:tint="@color/default_notification_content_color"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2014 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
-->
<!-- Layout to be used with only max 3 actions. It has a much larger picture at the left side-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="128dp"
android:background="@color/default_notification_color">
<ImageView
android:id="@+id/icon"
android:layout_width="128dp"
android:layout_height="128dp"
android:scaleType="centerCrop"
tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_quit"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:background="@drawable/colored_notification_selector"
android:src="@drawable/ic_close_white_24dp"
android:tint="@color/default_colored_notification_content_color"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="8dp"
android:layout_toEndOf="@id/icon"
android:layout_toLeftOf="@id/action_quit"
android:layout_toRightOf="@id/icon"
android:layout_toStartOf="@id/action_quit"
android:minHeight="@dimen/notification_large_icon_height"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification.Title"
android:textColor="@color/default_colored_notification_content_color" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-1dp"
android:layout_marginTop="-1dp"
android:layout_weight="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification"
android:textColor="@color/default_colored_notification_secondary_content_color" />
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification"
android:textColor="@color/default_colored_notification_secondary_content_color" />
</LinearLayout>
<LinearLayout
android:id="@+id/media_actions"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon"
android:layoutDirection="ltr"
android:orientation="horizontal"
tools:ignore="UnusedAttribute">
<!-- media buttons will be added here -->
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_prev"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="@drawable/colored_notification_selector"
android:gravity="center"
android:src="@drawable/ic_skip_previous_white_36dp"
android:tint="@color/default_colored_notification_content_color"
tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_play_pause"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="@drawable/colored_notification_selector"
android:gravity="center"
android:src="@drawable/ic_play_arrow_white_36dp"
android:tint="@color/default_colored_notification_content_color"
tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_next"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="@drawable/colored_notification_selector"
android:gravity="center"
android:src="@drawable/ic_skip_next_white_36dp"
android:tint="@color/default_colored_notification_content_color"
tools:ignore="ContentDescription" />
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2014 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
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@color/default_notification_color"
android:orientation="horizontal"
internal:layout_maxHeight="64dp"
internal:layout_minHeight="64dp"
tools:ignore="DisableBaselineAlignment">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:id="@+id/icon_group"
android:layout_width="@dimen/notification_large_icon_width"
android:layout_height="@dimen/notification_large_icon_height"
android:layout_weight="0">
<ImageView
android:id="@+id/icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="12dp"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:scaleType="centerInside"
tools:ignore="ContentDescription" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_weight="1"
android:minHeight="@dimen/notification_large_icon_height"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:gravity="bottom"
android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification.Title"
android:textColor="@color/default_colored_notification_content_color"
tools:ignore="NestedWeights" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="@style/Theme.MaterialMusic.Notification"
android:textColor="@color/default_colored_notification_secondary_content_color" />
</LinearLayout>
<LinearLayout
android:id="@+id/media_actions"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="6dp"
android:layout_marginRight="6dp"
android:layoutDirection="ltr"
android:orientation="horizontal"
tools:ignore="UnusedAttribute">
<!-- media buttons will be added here -->
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_prev"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="@drawable/colored_notification_selector"
android:gravity="center"
android:src="@drawable/ic_skip_previous_white_36dp"
android:tint="@color/default_colored_notification_content_color"
tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_play_pause"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="@drawable/colored_notification_selector"
android:gravity="center"
android:src="@drawable/ic_play_arrow_white_36dp"
android:tint="@color/default_colored_notification_content_color"
tools:ignore="ContentDescription" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_next"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="@drawable/colored_notification_selector"
android:gravity="center"
android:src="@drawable/ic_skip_next_white_36dp"
android:tint="@color/default_colored_notification_content_color"
tools:ignore="ContentDescription" />
</LinearLayout>
</LinearLayout>

View file

@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="notification_default_content_color">#de000000</color> <color name="default_notification_content_color">#de000000</color>
<color name="notification_default_secondary_content_color">#aa000000</color> <color name="default_notification_secondary_content_color">#aa000000</color>
<color name="default_colored_notification_color">@color/grey_800</color>
<color name="default_colored_notification_content_color">#deFFFFFF</color>
<color name="default_colored_notification_secondary_content_color">#aaFFFFFF</color>
<!--must be solid colors so the ripple will not be semi transparent. Note: the color have no effect on the ripple--> <!--must be solid colors so the ripple will not be semi transparent. Note: the color have no effect on the ripple-->
<!--<color name="button_selected">#FFFFFFFF</color>--> <!--<color name="button_selected">#FFFFFFFF</color>-->

View file

@ -24,7 +24,7 @@
<style name="NotificationButton" parent="NotificationButtonParent"> <style name="NotificationButton" parent="NotificationButtonParent">
<item name="android:background">@drawable/notification_selector</item> <item name="android:background">@drawable/notification_selector</item>
<item name="android:tint">@color/notification_default_content_color</item> <item name="android:tint">@color/default_notification_content_color</item>
</style> </style>
<style name="MusicProgressSlider" parent="MusicProgressSliderParent"> <style name="MusicProgressSlider" parent="MusicProgressSliderParent">

View file

@ -24,11 +24,13 @@
<color name="sliding_tabs_activated">#FFFFFF</color> <color name="sliding_tabs_activated">#FFFFFF</color>
<color name="sliding_tabs_deactivated">#99FFFFFF</color> <color name="sliding_tabs_deactivated">#99FFFFFF</color>
<color name="default_notification_color">@android:color/transparent</color>
<color name="notification_default_content_color">#deFFFFFF</color>
<color name="notification_default_secondary_content_color">#aaFFFFFF</color>
<!--notification--> <!--notification-->
<drawable name="notification_template_divider_media">#29ffffff</drawable> <color name="default_notification_color">@android:color/transparent</color>
<color name="default_notification_content_color">#deFFFFFF</color>
<color name="default_notification_secondary_content_color">#aaFFFFFF</color>
<color name="default_colored_notification_color">@android:color/transparent</color>
<color name="default_colored_notification_content_color">#deFFFFFF</color>
<color name="default_colored_notification_secondary_content_color">#aaFFFFFF</color>
</resources> </resources>