add material-design notification layout
This commit is contained in:
parent
a606b69909
commit
cb76c98e2f
BIN
orig/notification_close_dark.svgz
Normal file
BIN
orig/notification_close_dark.svgz
Normal file
Binary file not shown.
BIN
res/drawable-hdpi/notification_close_dark.png
Normal file
BIN
res/drawable-hdpi/notification_close_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 306 B |
BIN
res/drawable-mdpi/notification_close_dark.png
Normal file
BIN
res/drawable-mdpi/notification_close_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 193 B |
BIN
res/drawable-xhdpi/notification_close_dark.png
Normal file
BIN
res/drawable-xhdpi/notification_close_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 316 B |
88
res/layout-v21/notification.xml
Normal file
88
res/layout-v21/notification.xml
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/cover"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:layout_width="64dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:contentDescription="@string/cover_art" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0px"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Notification.Title"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/artist"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Notification.Line2"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
</LinearLayout>
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/play_pause"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/widget_play"
|
||||||
|
android:contentDescription="@string/play_pause" />
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/next"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/widget_next"
|
||||||
|
android:contentDescription="@string/next_song" />
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/close"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/notification_close_dark"
|
||||||
|
android:contentDescription="@string/close_notification" />
|
||||||
|
</LinearLayout>
|
130
res/layout-v21/notification_expanded.xml
Normal file
130
res/layout-v21/notification_expanded.xml
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2014 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/cover"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:layout_width="128dp"
|
||||||
|
android:layout_height="128dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:contentDescription="@string/cover_art" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:layout_width="0px"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Notification.Title"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/artist"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Notification.Line2"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/album"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Notification.Line2"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/close"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:layout_width="32dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:src="@drawable/notification_close_dark"
|
||||||
|
android:contentDescription="@string/close_notification" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- start controll buttons -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/previous"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/widget_previous"
|
||||||
|
android:contentDescription="@string/next_song" />
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/play_pause"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/widget_play"
|
||||||
|
android:contentDescription="@string/play_pause" />
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/next"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/widget_next"
|
||||||
|
android:contentDescription="@string/next_song" />
|
||||||
|
</LinearLayout>
|
||||||
|
<!-- end controll buttons -->
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1860,7 +1860,14 @@ public final class PlaybackService extends Service
|
|||||||
|
|
||||||
String title = song.title;
|
String title = song.title;
|
||||||
|
|
||||||
int playButton = playing ? R.drawable.pause : R.drawable.play;
|
int playButton = 0;
|
||||||
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
// Android >= 5.0 uses the dark version of this drawable
|
||||||
|
playButton = playing ? R.drawable.widget_pause : R.drawable.widget_play;
|
||||||
|
} else {
|
||||||
|
playButton = playing ? R.drawable.pause : R.drawable.play;
|
||||||
|
}
|
||||||
|
|
||||||
views.setImageViewResource(R.id.play_pause, playButton);
|
views.setImageViewResource(R.id.play_pause, playButton);
|
||||||
expanded.setImageViewResource(R.id.play_pause, playButton);
|
expanded.setImageViewResource(R.id.play_pause, playButton);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user