Add option to invert colours in notifications
This commit is contained in:
parent
91094a85ab
commit
e7ea4941ea
@ -112,6 +112,8 @@ THE SOFTWARE.
|
|||||||
<string name="notification_mode_summary">When to show the notification</string>
|
<string name="notification_mode_summary">When to show the notification</string>
|
||||||
<string name="notification_action_title">Notification Action</string>
|
<string name="notification_action_title">Notification Action</string>
|
||||||
<string name="notification_action_summary">What to do when the notification is pressed</string>
|
<string name="notification_action_summary">What to do when the notification is pressed</string>
|
||||||
|
<string name="notification_invert_colour_title">Invert notification colour</string>
|
||||||
|
<string name="notification_invert_colour_summary">Use inverted colour for notifications</string>
|
||||||
|
|
||||||
<string name="pref_playback_view">Playback View</string>
|
<string name="pref_playback_view">Playback View</string>
|
||||||
<string name="display_mode_title">Display Mode</string>
|
<string name="display_mode_title">Display Mode</string>
|
||||||
|
@ -54,6 +54,11 @@ THE SOFTWARE.
|
|||||||
android:entries="@array/notification_action_entries"
|
android:entries="@array/notification_action_entries"
|
||||||
android:entryValues="@array/entry_values"
|
android:entryValues="@array/entry_values"
|
||||||
android:defaultValue="0" />
|
android:defaultValue="0" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="notification_inverted_colour"
|
||||||
|
android:title="@string/notification_invert_colour_title"
|
||||||
|
android:summary="@string/notification_invert_colour_summary"
|
||||||
|
android:defaultValue="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/pref_playback_view">
|
<PreferenceCategory android:title="@string/pref_playback_view">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
@ -425,6 +425,8 @@ public final class PlaybackService extends Service implements Handler.Callback,
|
|||||||
if (activity instanceof FullPlaybackActivity)
|
if (activity instanceof FullPlaybackActivity)
|
||||||
activity.finish();
|
activity.finish();
|
||||||
}
|
}
|
||||||
|
} else if ("notification_inverted_colour".equals(key)) {
|
||||||
|
updateNotification();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
@ -73,6 +74,17 @@ public class SongNotification extends Notification {
|
|||||||
views.setTextViewText(R.id.title, song.title);
|
views.setTextViewText(R.id.title, song.title);
|
||||||
views.setTextViewText(R.id.artist, song.artist);
|
views.setTextViewText(R.id.artist, song.artist);
|
||||||
|
|
||||||
|
TypedArray array = ContextApplication.getContext().getTheme().obtainStyledAttributes(new int[] {
|
||||||
|
android.R.attr.textColorPrimary,
|
||||||
|
android.R.attr.textColorPrimaryInverse,
|
||||||
|
});
|
||||||
|
int color1 = array.getColor(0, 0xFF00FF);
|
||||||
|
int color2 = array.getColor(1, 0xFF00FF);
|
||||||
|
int color = prefs.getBoolean("notification_inverted_colour", true) ? color1: color2;
|
||||||
|
array.recycle();
|
||||||
|
views.setTextColor(R.id.title, color);
|
||||||
|
views.setTextColor(R.id.artist, color);
|
||||||
|
|
||||||
contentView = views;
|
contentView = views;
|
||||||
icon = statusIcon;
|
icon = statusIcon;
|
||||||
flags |= Notification.FLAG_ONGOING_EVENT;
|
flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user