diff options
Diffstat (limited to 'subsonic-android')
18 files changed, 680 insertions, 111 deletions
diff --git a/subsonic-android/AndroidManifest.xml b/subsonic-android/AndroidManifest.xml index d85ee7cf..76677dbe 100644 --- a/subsonic-android/AndroidManifest.xml +++ b/subsonic-android/AndroidManifest.xml @@ -98,11 +98,37 @@ </intent-filter>
</receiver>
- <receiver android:name="github.daneren2005.dsub.provider.DSubWidgetProvider" >
+ <receiver
+ android:name="github.daneren2005.dsub.provider.DSubWidget4x1"
+ android:label="@string/widget.4x1">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
- <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget_info"/>
+ <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget4x1"/>
+ </receiver>
+ <receiver
+ android:name="github.daneren2005.dsub.provider.DSubWidget4x2"
+ android:label="@string/widget.4x2">
+ <intent-filter>
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
+ </intent-filter>
+ <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget4x2"/>
+ </receiver>
+ <receiver
+ android:name="github.daneren2005.dsub.provider.DSubWidget4x3"
+ android:label="@string/widget.4x3">
+ <intent-filter>
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
+ </intent-filter>
+ <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget4x3"/>
+ </receiver>
+ <receiver
+ android:name="github.daneren2005.dsub.provider.DSubWidget4x4"
+ android:label="@string/widget.4x4">
+ <intent-filter>
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
+ </intent-filter>
+ <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget4x4"/>
</receiver>
<provider android:name="github.daneren2005.dsub.provider.DSubSearchProvider"
diff --git a/subsonic-android/res/layout/appwidget.xml b/subsonic-android/res/layout/appwidget.xml deleted file mode 100644 index fa47a7b9..00000000 --- a/subsonic-android/res/layout/appwidget.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="horizontal" - android:background="@drawable/appwidget_bg"> - - <ImageView - android:id="@+id/appwidget_coverart" - android:layout_height="fill_parent" - android:layout_width="81dip" - android:scaleType="fitXY" - android:src="@drawable/appwidget_art_default" - android:clickable="true" - android:focusable="true" - android:background="@drawable/media_button"/> - <LinearLayout - android:id="@+id/appwidget_top" - android:layout_height="fill_parent" - android:layout_width="fill_parent" - android:orientation="vertical" - android:clickable="true" - android:focusable="true" - android:background="@drawable/media_button"> - - <TextView - android:id="@+id/title" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:minHeight="16sp" - android:textColor="@color/appwidget_text" - android:textStyle="bold" - android:textSize="16sp" - android:singleLine="true" - android:paddingLeft="5dip" - android:paddingRight="5dip" - android:fadingEdge="horizontal" - android:fadingEdgeLength="20dip" - android:ellipsize="none"/> - <TextView - android:id="@+id/artist" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textColor="@color/cyan" - android:minHeight="12sp" - android:textSize="12sp" - android:singleLine="true" - android:paddingLeft="5dip" - android:paddingBottom="2dip" - android:fadingEdge="horizontal" - android:fadingEdgeLength="10dip" - android:ellipsize="none"/> - - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="1.0dip" - android:background="#33ffffff"/> - - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="horizontal"> - <ImageButton - android:id="@+id/control_previous" - android:layout_width="0dip" - android:layout_weight="1" - android:layout_height="fill_parent" - android:src="@drawable/ic_appwidget_music_previous" - android:background="@drawable/media_button" - android:scaleType="center"/> - <ImageButton - android:id="@+id/control_play" - android:layout_width="0dip" - android:layout_weight="1" - android:layout_height="fill_parent" - android:src="@drawable/ic_appwidget_music_play" - android:background="@drawable/media_button" - android:scaleType="center"/> - <ImageButton - android:id="@+id/control_next" - android:layout_width="0dip" - android:layout_weight="1" - android:layout_height="fill_parent" - android:src="@drawable/ic_appwidget_music_next" - android:background="@drawable/media_button" - android:scaleType="center"/> - </LinearLayout> - </LinearLayout> -</LinearLayout> diff --git a/subsonic-android/res/layout/appwidget4x1.xml b/subsonic-android/res/layout/appwidget4x1.xml new file mode 100644 index 00000000..5e55aa37 --- /dev/null +++ b/subsonic-android/res/layout/appwidget4x1.xml @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:minWidth="250dp" + android:minHeight="40dp" + android:background="@drawable/appwidget_bg" + android:orientation="horizontal" > + + <ImageView + android:id="@+id/appwidget_coverart" + android:layout_width="80dp" + android:layout_height="80dp" + android:layout_gravity="center_vertical" + android:clickable="true" + android:focusable="true" + android:src="@drawable/appwidget_art_default" /> + + <LinearLayout + android:id="@+id/linearLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <LinearLayout + android:id="@+id/appwidget_top" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:clickable="true" + android:focusable="true" + android:orientation="vertical" + android:background="@drawable/media_button"> + + <TextView + android:id="@+id/title" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="20dip" + android:minHeight="16sp" + android:paddingLeft="4dip" + android:paddingRight="4dip" + android:paddingTop="4dip" + android:singleLine="true" + android:gravity="center_horizontal" + android:text="Title" + android:textColor="@color/appwidget_text" + android:textSize="16sp" + android:textStyle="bold" /> + + <TextView + android:id="@+id/artist" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="10dip" + android:minHeight="12sp" + android:paddingBottom="4dip" + android:paddingLeft="4dip" + android:paddingRight="4dip" + android:singleLine="true" + android:gravity="center_horizontal" + android:text="Artist" + android:textColor="@color/appwidget_text" + android:textSize="12sp" /> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="horizontal" + android:paddingBottom="4dip" + android:paddingTop="4dip" > + + <ImageButton + android:id="@+id/control_previous" + android:layout_width="0dip" + android:layout_height="fill_parent" + android:layout_weight="1" + android:scaleType="center" + android:background="@drawable/media_button" + android:src="@drawable/ic_appwidget_music_previous" /> + + <ImageButton + android:id="@+id/control_play" + android:layout_width="0dip" + android:layout_height="fill_parent" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_play" + android:background="@drawable/media_button" /> + + <ImageButton + android:id="@+id/control_next" + android:layout_width="0dip" + android:layout_height="fill_parent" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_next" + android:background="@drawable/media_button" /> + </LinearLayout> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/res/layout/appwidget4x2.xml b/subsonic-android/res/layout/appwidget4x2.xml new file mode 100644 index 00000000..575ae1c2 --- /dev/null +++ b/subsonic-android/res/layout/appwidget4x2.xml @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:minWidth="250dp" + android:minHeight="110dp" + android:background="@drawable/appwidget_bg" + android:orientation="horizontal" > + + <ImageView + android:id="@+id/appwidget_coverart" + android:layout_width="120dp" + android:layout_height="120dp" + android:layout_gravity="center_vertical" + android:clickable="true" + android:focusable="true" + android:src="@drawable/appwidget_art_default" /> + + <LinearLayout + android:id="@+id/linearLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <LinearLayout + android:id="@+id/appwidget_top" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:clickable="true" + android:focusable="true" + android:orientation="vertical" + android:paddingTop="4dip" + android:paddingBottom="4dip" + android:background="@drawable/media_button"> + + <TextView + android:id="@+id/title" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="20dip" + android:minHeight="16sp" + android:paddingLeft="4dip" + android:paddingRight="4dip" + android:paddingTop="4dip" + android:paddingBottom="2dip" + android:singleLine="true" + android:gravity="center_horizontal" + android:text="Title" + android:textColor="@color/appwidget_text" + android:textSize="16sp" + android:textStyle="bold" /> + + <TextView + android:id="@+id/artist" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="10dip" + android:minHeight="12sp" + android:paddingLeft="4dip" + android:paddingRight="4dip" + android:paddingBottom="2dip" + android:singleLine="true" + android:gravity="center_horizontal" + android:text="Artist" + android:textColor="@color/appwidget_text" + android:textSize="12sp" /> + + <TextView + android:id="@+id/album" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="10dip" + android:minHeight="12sp" + android:paddingBottom="2dip" + android:paddingLeft="4dip" + android:paddingRight="4dip" + android:singleLine="true" + android:gravity="center_horizontal" + android:text="Album" + android:textColor="@color/appwidget_text" + android:textSize="12sp" /> + + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_gravity="bottom" + android:gravity="bottom" + android:paddingBottom="4dip" + android:paddingTop="4dip" >" + + <ImageButton + android:id="@+id/control_previous" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="1" + android:scaleType="center" + android:background="@drawable/media_button" + android:src="@drawable/ic_appwidget_music_previous" /> + + <ImageButton + android:id="@+id/control_play" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_play" + android:background="@drawable/media_button" /> + + <ImageButton + android:id="@+id/control_next" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_next" + android:background="@drawable/media_button" /> + </LinearLayout> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/res/layout/appwidget4x3.xml b/subsonic-android/res/layout/appwidget4x3.xml new file mode 100644 index 00000000..b4f685bc --- /dev/null +++ b/subsonic-android/res/layout/appwidget4x3.xml @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@drawable/appwidget_bg" + android:orientation="vertical" > + + <ImageView + android:id="@+id/appwidget_coverart" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:scaleType="fitCenter" + android:layout_weight="1" + android:layout_gravity="center_horizontal" + android:clickable="true" + android:focusable="true" + android:paddingTop="6dip" + android:paddingBottom="6dip" + android:src="@drawable/appwidget_art_default" /> + + <LinearLayout + android:id="@+id/linearLayout1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <LinearLayout + android:id="@+id/appwidget_top" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:clickable="true" + android:focusable="true" + android:orientation="vertical" + android:paddingBottom="4dip" + android:paddingTop="4dip" + android:background="@drawable/media_button"> + + <TextView + android:id="@+id/title" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="20dip" + android:minHeight="16sp" + android:paddingLeft="5dip" + android:paddingRight="5dip" + android:singleLine="true" + android:textColor="@color/appwidget_text" + android:textSize="16sp" + android:text="Title" + android:layout_gravity="center_horizontal" + android:gravity="center" + android:textStyle="bold" /> + + <TextView + android:id="@+id/artist" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="10dip" + android:minHeight="12sp" + android:paddingBottom="2dip" + android:paddingLeft="5dip" + android:singleLine="true" + android:text="Artist" + android:layout_gravity="center_horizontal" + android:gravity="center" + android:textColor="@color/appwidget_text" + android:textSize="12sp" /> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:gravity="bottom" + android:orientation="horizontal" + android:paddingBottom="4dip"> + + <ImageButton + android:id="@+id/control_previous" + android:layout_width="0dip" + android:layout_height="56dip" + android:layout_weight="1" + android:scaleType="center" + android:background="@drawable/media_button" + android:src="@drawable/ic_appwidget_music_previous" /> + + <ImageButton + android:id="@+id/control_play" + android:layout_width="0dip" + android:layout_height="56dip" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_play" + android:background="@drawable/media_button" /> + + <ImageButton + android:id="@+id/control_next" + android:layout_width="0dip" + android:layout_height="56dip" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_next" + android:background="@drawable/media_button" /> + </LinearLayout> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/res/layout/appwidget4x4.xml b/subsonic-android/res/layout/appwidget4x4.xml new file mode 100644 index 00000000..6e6c12ab --- /dev/null +++ b/subsonic-android/res/layout/appwidget4x4.xml @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" + android:background="@drawable/appwidget_bg" > + + <ImageView + android:id="@+id/appwidget_coverart" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:scaleType="fitCenter" + android:layout_weight="1" + android:layout_gravity="center_horizontal" + android:clickable="true" + android:focusable="true" + android:layout_margin="6dip" + android:paddingTop="6dip" + android:paddingBottom="6dip" + android:src="@drawable/appwidget_art_default" /> + + <LinearLayout + android:id="@+id/linearLayout1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <LinearLayout + android:id="@+id/appwidget_top" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:clickable="true" + android:focusable="true" + android:orientation="vertical" + android:paddingTop="4dip" + android:paddingBottom="4dip" + android:background="@drawable/media_button"> + + <TextView + android:id="@+id/title" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="20dip" + android:minHeight="16sp" + android:paddingLeft="5dip" + android:paddingRight="5dip" + android:singleLine="true" + android:textColor="@color/appwidget_text" + android:textSize="16sp" + android:text="Title" + android:layout_gravity="center_horizontal" + android:gravity="center" + android:textStyle="bold" /> + + <TextView + android:id="@+id/artist" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:fadingEdge="horizontal" + android:fadingEdgeLength="10dip" + android:minHeight="12sp" + android:paddingBottom="2dip" + android:paddingLeft="5dip" + android:singleLine="true" + android:text="Artist" + android:layout_gravity="center_horizontal" + android:gravity="center" + android:textColor="@color/appwidget_text" + android:textSize="12sp" /> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:gravity="bottom" + android:orientation="horizontal" + android:paddingBottom="4dip" + android:paddingTop="4dip" > + + <ImageButton + android:id="@+id/control_previous" + android:layout_width="0dip" + android:layout_height="56dip" + android:layout_weight="1" + android:scaleType="center" + android:background="@drawable/media_button" + android:src="@drawable/ic_appwidget_music_previous" /> + + <ImageButton + android:id="@+id/control_play" + android:layout_width="0dip" + android:layout_height="56dip" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_play" + android:background="@drawable/media_button" /> + + <ImageButton + android:id="@+id/control_next" + android:layout_width="0dip" + android:layout_height="56dip" + android:layout_weight="1" + android:scaleType="center" + android:src="@drawable/ic_appwidget_music_next" + android:background="@drawable/media_button" /> + </LinearLayout> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 790bc8de..b5e8f3e1 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -315,6 +315,10 @@ <string name="equalizer.enabled">Enabled</string>
<string name="equalizer.preset">Select preset</string>
+ <string name="widget.4x1">DSub (4x1)</string>
+ <string name="widget.4x2">DSub (4x2)</string>
+ <string name="widget.4x3">DSub (4x3)</string>
+ <string name="widget.4x4">DSub (4x4)</string>
<string name="widget.initial_text">Touch to select music</string>
<string name="widget.sdcard_busy">SD card unavailable</string>
<string name="widget.sdcard_missing">No SD card</string>
diff --git a/subsonic-android/res/xml/appwidget4x1.xml b/subsonic-android/res/xml/appwidget4x1.xml new file mode 100644 index 00000000..65f47dba --- /dev/null +++ b/subsonic-android/res/xml/appwidget4x1.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" + android:minWidth="272dip" + android:minHeight="56dip" + android:updatePeriodMillis="0" + android:resizeMode="horizontal|vertical" + android:initialLayout="@layout/appwidget4x1"/>
\ No newline at end of file diff --git a/subsonic-android/res/xml/appwidget4x2.xml b/subsonic-android/res/xml/appwidget4x2.xml new file mode 100644 index 00000000..f40204a7 --- /dev/null +++ b/subsonic-android/res/xml/appwidget4x2.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" + android:minWidth="272dip" + android:minHeight="110dip" + android:updatePeriodMillis="0" + android:resizeMode="horizontal|vertical" + android:initialLayout="@layout/appwidget4x2"/>
\ No newline at end of file diff --git a/subsonic-android/res/xml/appwidget4x3.xml b/subsonic-android/res/xml/appwidget4x3.xml new file mode 100644 index 00000000..51ae97ed --- /dev/null +++ b/subsonic-android/res/xml/appwidget4x3.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" + android:minWidth="272dip" + android:minHeight="180dp" + android:updatePeriodMillis="0" + android:resizeMode="horizontal|vertical" + android:initialLayout="@layout/appwidget4x3"/>
\ No newline at end of file diff --git a/subsonic-android/res/xml/appwidget4x4.xml b/subsonic-android/res/xml/appwidget4x4.xml new file mode 100644 index 00000000..40956dcf --- /dev/null +++ b/subsonic-android/res/xml/appwidget4x4.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" + android:minWidth="272dip" + android:minHeight="250dp" + android:updatePeriodMillis="0" + android:resizeMode="horizontal|vertical" + android:initialLayout="@layout/appwidget4x4"/>
\ No newline at end of file diff --git a/subsonic-android/res/xml/appwidget_info.xml b/subsonic-android/res/xml/appwidget_info.xml deleted file mode 100644 index 7ad17ef9..00000000 --- a/subsonic-android/res/xml/appwidget_info.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" - android:minWidth="272dip" - android:minHeight="56dip" - android:updatePeriodMillis="0" - android:resizeMode="horizontal|vertical" - android:initialLayout="@layout/appwidget"/>
\ No newline at end of file diff --git a/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x1.java b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x1.java new file mode 100644 index 00000000..e00bf02d --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x1.java @@ -0,0 +1,29 @@ +/*
+ This file is part of Subsonic.
+
+ Subsonic 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.
+
+ Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.provider;
+
+import android.appwidget.AppWidgetManager;
+import github.daneren2005.dsub.R;
+
+public class DSubWidget4x1 extends DSubWidgetProvider {
+ @Override
+ protected int getLayout() {
+ return R.layout.appwidget4x1;
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x2.java b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x2.java new file mode 100644 index 00000000..4908f632 --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x2.java @@ -0,0 +1,29 @@ +/*
+ This file is part of Subsonic.
+
+ Subsonic 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.
+
+ Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.provider;
+
+import android.appwidget.AppWidgetManager;
+import github.daneren2005.dsub.R;
+
+public class DSubWidget4x2 extends DSubWidgetProvider {
+ @Override
+ protected int getLayout() {
+ return R.layout.appwidget4x2;
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x3.java b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x3.java new file mode 100644 index 00000000..f1908d0d --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x3.java @@ -0,0 +1,29 @@ +/*
+ This file is part of Subsonic.
+
+ Subsonic 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.
+
+ Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.provider;
+
+import android.appwidget.AppWidgetManager;
+import github.daneren2005.dsub.R;
+
+public class DSubWidget4x3 extends DSubWidgetProvider {
+ @Override
+ protected int getLayout() {
+ return R.layout.appwidget4x3;
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x4.java b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x4.java new file mode 100644 index 00000000..7fee2747 --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidget4x4.java @@ -0,0 +1,29 @@ +/*
+ This file is part of Subsonic.
+
+ Subsonic 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.
+
+ Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.provider;
+
+import android.appwidget.AppWidgetManager;
+import github.daneren2005.dsub.R;
+
+public class DSubWidget4x4 extends DSubWidgetProvider {
+ @Override
+ protected int getLayout() {
+ return R.layout.appwidget4x4;
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java index c61e215a..321b0f88 100644 --- a/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java +++ b/subsonic-android/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java @@ -45,6 +45,7 @@ import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.DownloadServiceImpl; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; +import java.util.HashMap; /** * Simple widget to show currently playing album art along @@ -55,21 +56,40 @@ import github.daneren2005.dsub.util.FileUtil; * @author Sindre Mehus */ public class DSubWidgetProvider extends AppWidgetProvider { - - private static DSubWidgetProvider instance; private static final String TAG = DSubWidgetProvider.class.getSimpleName(); + private static DSubWidget4x1 instance4x1; + private static DSubWidget4x2 instance4x2; + private static DSubWidget4x3 instance4x3; + private static DSubWidget4x4 instance4x4; - public static synchronized DSubWidgetProvider getInstance() { - if (instance == null) { - instance = new DSubWidgetProvider(); - } - return instance; - } + public static synchronized void notifyInstances(Context context, DownloadService service, boolean playing) { + if(instance4x1 == null) { + instance4x1 = new DSubWidget4x1(); + } + if(instance4x2 == null) { + instance4x2 = new DSubWidget4x2(); + } + if(instance4x3 == null) { + instance4x3 = new DSubWidget4x3(); + } + if(instance4x4 == null) { + instance4x4 = new DSubWidget4x4(); + } + + instance4x1.notifyChange(context, service, playing); + instance4x2.notifyChange(context, service, playing); + instance4x3.notifyChange(context, service, playing); + instance4x4.notifyChange(context, service, playing); + } @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { defaultAppWidget(context, appWidgetIds); } + + protected int getLayout() { + return 0; + } /** * Initialize given widgets to default state, where we launch Subsonic on default click @@ -77,9 +97,12 @@ public class DSubWidgetProvider extends AppWidgetProvider { */ private void defaultAppWidget(Context context, int[] appWidgetIds) { final Resources res = context.getResources(); - final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget); + final RemoteViews views = new RemoteViews(context.getPackageName(), getLayout()); views.setTextViewText(R.id.artist, res.getText(R.string.widget_initial_text)); + if(getLayout() == R.layout.appwidget4x2) { + views.setTextViewText(R.id.album, ""); + } linkButtons(context, views, false); pushUpdate(context, appWidgetIds, views); @@ -118,11 +141,12 @@ public class DSubWidgetProvider extends AppWidgetProvider { */ private void performUpdate(Context context, DownloadService service, int[] appWidgetIds, boolean playing) { final Resources res = context.getResources(); - final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget); + final RemoteViews views = new RemoteViews(context.getPackageName(), getLayout()); MusicDirectory.Entry currentPlaying = service.getCurrentPlaying() == null ? null : service.getCurrentPlaying().getSong(); String title = currentPlaying == null ? null : currentPlaying.getTitle(); CharSequence artist = currentPlaying == null ? null : currentPlaying.getArtist(); + CharSequence album = currentPlaying == null ? null : currentPlaying.getAlbum(); CharSequence errorState = null; // Show error message? @@ -140,11 +164,17 @@ public class DSubWidgetProvider extends AppWidgetProvider { // Show error state to user views.setTextViewText(R.id.title,null); views.setTextViewText(R.id.artist, errorState); - views.setImageViewResource(R.id.appwidget_coverart, R.drawable.appwidget_art_default); + views.setTextViewText(R.id.album, ""); + if(getLayout() != R.layout.appwidget4x1) { + views.setImageViewResource(R.id.appwidget_coverart, R.drawable.appwidget_art_default); + } } else { // No error, so show normal titles views.setTextViewText(R.id.title, title); views.setTextViewText(R.id.artist, artist); + if(getLayout() != R.layout.appwidget4x1) { + views.setTextViewText(R.id.album, album); + } } // Set correct drawable for pause state diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 93acfcb8..a8918923 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -730,7 +730,7 @@ public final class Util { }); // Update widget - DSubWidgetProvider.getInstance().notifyChange(context, downloadService, true); + DSubWidgetProvider.notifyInstances(context, downloadService, true); } private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing){ @@ -812,7 +812,7 @@ public final class Util { }); // Update widget - DSubWidgetProvider.getInstance().notifyChange(context, downloadService, false); + DSubWidgetProvider.notifyInstances(context, downloadService, false); } public static void sleepQuietly(long millis) { |