Merge pull request #199 from arkon/notif-color

Default classic notification background to white
This commit is contained in:
Eugene Cheung 2017-08-31 18:52:45 -04:00 committed by GitHub
commit 4181d3d5c1
3 changed files with 229 additions and 233 deletions

View file

@ -102,7 +102,7 @@ public class PlayingNotificationImpl extends PlayingNotification {
@Override @Override
public void onLoadFailed(Exception e, Drawable errorDrawable) { public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable); super.onLoadFailed(e, errorDrawable);
update(null, Color.TRANSPARENT); update(null, Color.WHITE);
} }
private void update(@Nullable Bitmap bitmap, int bgColor) { private void update(@Nullable Bitmap bitmap, int bgColor) {
@ -115,10 +115,10 @@ public class PlayingNotificationImpl extends PlayingNotification {
} }
if (!PreferenceUtil.getInstance(service).coloredNotification()) { if (!PreferenceUtil.getInstance(service).coloredNotification()) {
bgColor = Color.TRANSPARENT; bgColor = Color.WHITE;
} }
setBackgroundColor(bgColor); setBackgroundColor(bgColor);
setNotificationContent(bgColor == Color.TRANSPARENT ? Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP : ColorUtil.isColorLight(bgColor)); setNotificationContent(ColorUtil.isColorLight(bgColor));
if (stopped) if (stopped)
return; // notification has been stopped before loading was finished return; // notification has been stopped before loading was finished

View file

@ -14,130 +14,121 @@
~ limitations under the License ~ limitations under the License
--> -->
<!--This FrameLayout IS necessary in order tp prevent fucking TouchWiz to interpret the "background="#00000000" as making the whole notification transparent--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="64dp"> android:layout_height="64dp"
android:baselineAligned="false"
android:orientation="horizontal">
<FrameLayout
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/image"
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 <LinearLayout
android:id="@+id/root" android:id="@+id/media_titles"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="#00000000" android:layout_gravity="fill_vertical"
android:baselineAligned="false" android:layout_weight="1"
android:orientation="horizontal" android:minHeight="@dimen/notification_large_icon_height"
tools:ignore="UselessParent"> android:orientation="vertical">
<FrameLayout <TextView
android:id="@+id/icon_group" android:id="@+id/title"
android:layout_width="@dimen/notification_large_icon_width"
android:layout_height="@dimen/notification_large_icon_height"
android:layout_weight="0">
<ImageView
android:id="@+id/image"
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:id="@+id/media_titles"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_weight="1" android:layout_weight="1"
android:minHeight="@dimen/notification_large_icon_height" android:ellipsize="marquee"
android:orientation="vertical"> android:fadingEdge="horizontal"
android:gravity="bottom"
android:singleLine="true"
android:textAppearance="@style/Theme.Phonograph.Notification.Title"
tools:ignore="NestedWeights" />
<TextView <TextView
android:id="@+id/title" android:id="@+id/text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_gravity="center"
android:ellipsize="marquee" android:layout_weight="1"
android:fadingEdge="horizontal" android:ellipsize="marquee"
android:gravity="bottom" android:fadingEdge="horizontal"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/Theme.Phonograph.Notification.Title" android:textAppearance="@style/Theme.Phonograph.Notification" />
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.Phonograph.Notification" />
</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
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> <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
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
</LinearLayout>
</LinearLayout>

View file

@ -16,132 +16,137 @@
<!-- Layout to be used with only max 3 actions. It has a much larger picture at the left side--> <!-- Layout to be used with only max 3 actions. It has a much larger picture at the left side-->
<!--This FrameLayout IS necessary in order tp prevent fucking TouchWiz to interpret the "background="#00000000" as making the whole notification transparent--> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="128dp"> android:layout_height="128dp">
<RelativeLayout <ImageView
android:id="@+id/root" android:id="@+id/image"
android:layout_width="match_parent" android:layout_width="@dimen/notification_big_image_size"
android:layout_height="match_parent" android:layout_height="@dimen/notification_big_image_size"
android:background="#00000000" android:scaleType="centerCrop"
tools:ignore="UselessParent"> tools:ignore="ContentDescription" />
<ImageView <ImageButton
android:id="@+id/image" android:id="@+id/action_quit"
android:layout_width="@dimen/notification_big_image_size" android:layout_width="36dp"
android:layout_height="@dimen/notification_big_image_size" android:layout_height="36dp"
android:scaleType="centerCrop" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="2dp"
android:background="@drawable/notification_selector"
android:padding="6dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<LinearLayout
android:id="@+id/media_titles"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="8dp"
android:layout_toEndOf="@id/image"
android:layout_toLeftOf="@id/action_quit"
android:layout_toRightOf="@id/image"
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.Phonograph.Notification.Title" />
<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.Phonograph.Notification" />
<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.Phonograph.Notification" />
</LinearLayout>
<LinearLayout
android:id="@+id/media_actions"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@+id/media_titles"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_toEndOf="@id/image"
android:layout_toRightOf="@id/image"
android:layoutDirection="ltr"
android:orientation="horizontal"
tools:ignore="UnusedAttribute">
<!-- media buttons will be added here -->
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<LinearLayout <ImageButton
android:id="@+id/media_titles" android:id="@+id/action_play_pause"
android:layout_width="match_parent" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_height="64dp" android:layout_width="48dp"
android:layout_marginBottom="8dp" android:layout_height="match_parent"
android:layout_marginLeft="12dp" android:layout_marginLeft="2dp"
android:layout_marginStart="12dp" android:layout_marginRight="2dp"
android:layout_marginTop="8dp" android:layout_weight="1"
android:layout_toEndOf="@id/image" android:background="@drawable/notification_selector"
android:layout_toRightOf="@id/image" android:gravity="center"
android:minHeight="@dimen/notification_large_icon_height" android:padding="8dp"
android:orientation="vertical"> android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<TextView <ImageButton
android:id="@+id/title" android:id="@+id/action_next"
android:layout_width="match_parent" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_height="wrap_content" android:layout_width="48dp"
android:layout_weight="1" android:layout_height="match_parent"
android:ellipsize="marquee" android:layout_marginLeft="2dp"
android:fadingEdge="horizontal" android:layout_marginRight="2dp"
android:singleLine="true" android:layout_weight="1"
android:textAppearance="@style/Theme.Phonograph.Notification.Title" /> android:background="@drawable/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<TextView </LinearLayout>
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.Phonograph.Notification" />
<TextView </RelativeLayout>
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.Phonograph.Notification" />
</LinearLayout>
<LinearLayout
android:id="@+id/media_actions"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@+id/media_titles"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_toEndOf="@id/image"
android:layout_toRightOf="@id/image"
android:layoutDirection="ltr"
android:orientation="horizontal"
tools:ignore="UnusedAttribute">
<!-- media buttons will be added here -->
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
<ImageButton
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/notification_selector"
android:gravity="center"
android:padding="8dp"
android:scaleType="fitCenter"
tools:ignore="ContentDescription" />
</LinearLayout>
</RelativeLayout>
</FrameLayout>