diff options
author | Antoine Cellerier <dionoea@videolan.org> | 2011-01-29 20:47:32 +0000 |
---|---|---|
committer | Antoine Cellerier <dionoea@videolan.org> | 2011-01-29 20:47:32 +0000 |
commit | c0c769c5a86c56c2ab2c9e88515a64da98575182 (patch) | |
tree | 24e84b2d146bf3da39d93983d5656061e3c88ecb /android | |
parent | e9749d1b93f23b3bc36305ad1d39ca5e5c0cb3a8 (diff) | |
download | rockbox-c0c769c5a86c56c2ab2c9e88515a64da98575182.tar.gz rockbox-c0c769c5a86c56c2ab2c9e88515a64da98575182.zip |
Add widgets to android port.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29170 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android')
35 files changed, 756 insertions, 3 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 0eab90ff81..41a662fdfa 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml | |||
@@ -29,6 +29,37 @@ | |||
29 | </intent-filter> | 29 | </intent-filter> |
30 | </receiver> | 30 | </receiver> |
31 | 31 | ||
32 | <!-- Widgets --> | ||
33 | <receiver android:name=".widgets.RockboxWidgetProvider4x1" | ||
34 | android:label="@string/appwidget_label_4x1"> | ||
35 | <intent-filter> | ||
36 | <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> | ||
37 | <action android:name="org.rockbox.TrackUpdateInfo" /> | ||
38 | <action android:name="org.rockbox.TrackFinish" /> | ||
39 | <action android:name="org.rockbox.UpdateState" /> | ||
40 | </intent-filter> | ||
41 | <meta-data android:name="android.appwidget.provider" | ||
42 | android:resource="@xml/appwidget_provider_4x1" /> | ||
43 | </receiver> | ||
44 | |||
45 | <receiver android:name=".widgets.RockboxWidgetProvider2x2" | ||
46 | android:label="@string/appwidget_label_2x2"> | ||
47 | <intent-filter> | ||
48 | <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> | ||
49 | <action android:name="org.rockbox.TrackUpdateInfo" /> | ||
50 | <action android:name="org.rockbox.TrackFinish" /> | ||
51 | <action android:name="org.rockbox.UpdateState" /> | ||
52 | </intent-filter> | ||
53 | <meta-data android:name="android.appwidget.provider" | ||
54 | android:resource="@xml/appwidget_provider_2x2" /> | ||
55 | </receiver> | ||
56 | |||
57 | <!-- Widget configuration --> | ||
58 | <activity android:name=".widgets.RockboxWidgetConfigure"> | ||
59 | <intent-filter> | ||
60 | <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> | ||
61 | </intent-filter> | ||
62 | </activity> | ||
32 | 63 | ||
33 | </application> | 64 | </application> |
34 | 65 | ||
diff --git a/android/android.make b/android/android.make index 82a8dedf24..53d5d46bbf 100644 --- a/android/android.make +++ b/android/android.make | |||
@@ -40,6 +40,7 @@ R_OBJ := $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class | |||
40 | 40 | ||
41 | JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java) | 41 | JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java) |
42 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java) | 42 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java) |
43 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/widgets/*.java) | ||
43 | JAVA_OBJ := $(call java2class,$(subst $(ANDROID)/src/$(PACKAGE_PATH),$(ANDROID)/bin/$(PACKAGE_PATH),$(JAVA_SRC))) | 44 | JAVA_OBJ := $(call java2class,$(subst $(ANDROID)/src/$(PACKAGE_PATH),$(ANDROID)/bin/$(PACKAGE_PATH),$(JAVA_SRC))) |
44 | 45 | ||
45 | 46 | ||
diff --git a/android/res/drawable/appwidget_background.xml b/android/res/drawable/appwidget_background.xml new file mode 100644 index 0000000000..a9a23495a9 --- /dev/null +++ b/android/res/drawable/appwidget_background.xml | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | <item android:drawable="@drawable/appwidget_background_normal" /> | ||
5 | </selector> | ||
6 | |||
diff --git a/android/res/drawable/appwidget_background_normal.9.png b/android/res/drawable/appwidget_background_normal.9.png new file mode 100644 index 0000000000..c06f285be3 --- /dev/null +++ b/android/res/drawable/appwidget_background_normal.9.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_ff_normal.png b/android/res/drawable/appwidget_ff_normal.png new file mode 100644 index 0000000000..82a90dd6aa --- /dev/null +++ b/android/res/drawable/appwidget_ff_normal.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_infodisplay_background.xml b/android/res/drawable/appwidget_infodisplay_background.xml new file mode 100644 index 0000000000..e6ed34c994 --- /dev/null +++ b/android/res/drawable/appwidget_infodisplay_background.xml | |||
@@ -0,0 +1,8 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | <item android:state_pressed="true" android:drawable="@drawable/appwidget_selection_clicked" /> | ||
5 | <item android:state_focused="true" android:drawable="@drawable/appwidget_selection_over" /> | ||
6 | <item android:drawable="@drawable/appwidget_selection_transparent" /> | ||
7 | </selector> | ||
8 | |||
diff --git a/android/res/drawable/appwidget_next.xml b/android/res/drawable/appwidget_next.xml new file mode 100644 index 0000000000..34d6a6952b --- /dev/null +++ b/android/res/drawable/appwidget_next.xml | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | <item android:drawable="@drawable/appwidget_ff_normal" /> | ||
5 | </selector> | ||
6 | |||
diff --git a/android/res/drawable/appwidget_pause.xml b/android/res/drawable/appwidget_pause.xml new file mode 100644 index 0000000000..72df5a857a --- /dev/null +++ b/android/res/drawable/appwidget_pause.xml | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | <item android:drawable="@drawable/appwidget_pause_normal" /> | ||
5 | </selector> | ||
6 | |||
diff --git a/android/res/drawable/appwidget_pause_normal.png b/android/res/drawable/appwidget_pause_normal.png new file mode 100644 index 0000000000..835c5e7e5e --- /dev/null +++ b/android/res/drawable/appwidget_pause_normal.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_play.xml b/android/res/drawable/appwidget_play.xml new file mode 100644 index 0000000000..5fa0f5beac --- /dev/null +++ b/android/res/drawable/appwidget_play.xml | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | <item android:drawable="@drawable/appwidget_play_normal" /> | ||
5 | </selector> | ||
6 | |||
diff --git a/android/res/drawable/appwidget_play_normal.png b/android/res/drawable/appwidget_play_normal.png new file mode 100644 index 0000000000..73d48c94db --- /dev/null +++ b/android/res/drawable/appwidget_play_normal.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_prev.xml b/android/res/drawable/appwidget_prev.xml new file mode 100644 index 0000000000..df56f77f05 --- /dev/null +++ b/android/res/drawable/appwidget_prev.xml | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | <item android:drawable="@drawable/appwidget_rew_normal" /> | ||
5 | </selector> | ||
6 | |||
diff --git a/android/res/drawable/appwidget_rew_normal.png b/android/res/drawable/appwidget_rew_normal.png new file mode 100644 index 0000000000..b5e18a7362 --- /dev/null +++ b/android/res/drawable/appwidget_rew_normal.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_selection_clicked.9.png b/android/res/drawable/appwidget_selection_clicked.9.png new file mode 100644 index 0000000000..7d39e88396 --- /dev/null +++ b/android/res/drawable/appwidget_selection_clicked.9.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_selection_over.9.png b/android/res/drawable/appwidget_selection_over.9.png new file mode 100644 index 0000000000..da96c6a831 --- /dev/null +++ b/android/res/drawable/appwidget_selection_over.9.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_selection_transparent.9.png b/android/res/drawable/appwidget_selection_transparent.9.png new file mode 100644 index 0000000000..535eb0b561 --- /dev/null +++ b/android/res/drawable/appwidget_selection_transparent.9.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/appwidget_stop.xml b/android/res/drawable/appwidget_stop.xml new file mode 100644 index 0000000000..895c8b622d --- /dev/null +++ b/android/res/drawable/appwidget_stop.xml | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | <item android:drawable="@drawable/appwidget_stop_normal" /> | ||
5 | </selector> | ||
6 | |||
diff --git a/android/res/drawable/appwidget_stop_normal.png b/android/res/drawable/appwidget_stop_normal.png new file mode 100644 index 0000000000..56932254da --- /dev/null +++ b/android/res/drawable/appwidget_stop_normal.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/rockbox.png b/android/res/drawable/rockbox.png new file mode 100644 index 0000000000..84d940abe9 --- /dev/null +++ b/android/res/drawable/rockbox.png | |||
Binary files differ | |||
diff --git a/android/res/drawable/source/appwidget_background.svg b/android/res/drawable/source/appwidget_background.svg new file mode 100644 index 0000000000..1404bde947 --- /dev/null +++ b/android/res/drawable/source/appwidget_background.svg | |||
@@ -0,0 +1,119 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | ||
3 | |||
4 | <svg | ||
5 | xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
6 | xmlns:cc="http://creativecommons.org/ns#" | ||
7 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
8 | xmlns:svg="http://www.w3.org/2000/svg" | ||
9 | xmlns="http://www.w3.org/2000/svg" | ||
10 | xmlns:xlink="http://www.w3.org/1999/xlink" | ||
11 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | ||
12 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | ||
13 | width="46" | ||
14 | height="116" | ||
15 | id="svg2" | ||
16 | version="1.1" | ||
17 | inkscape:version="0.47 r22583" | ||
18 | sodipodi:docname="appwidget_background.svg" | ||
19 | inkscape:export-filename="/home/antoine/rockbox/rockbox-svn/android/res/drawable/appwidget_background_normal.9.png" | ||
20 | inkscape:export-xdpi="90" | ||
21 | inkscape:export-ydpi="90"> | ||
22 | <defs | ||
23 | id="defs4"> | ||
24 | <linearGradient | ||
25 | id="linearGradient3594"> | ||
26 | <stop | ||
27 | style="stop-color:#000000;stop-opacity:1;" | ||
28 | offset="0" | ||
29 | id="stop3596" /> | ||
30 | <stop | ||
31 | style="stop-color:#545454;stop-opacity:1;" | ||
32 | offset="1" | ||
33 | id="stop3598" /> | ||
34 | </linearGradient> | ||
35 | <inkscape:perspective | ||
36 | sodipodi:type="inkscape:persp3d" | ||
37 | inkscape:vp_x="0 : 526.18109 : 1" | ||
38 | inkscape:vp_y="0 : 1000 : 0" | ||
39 | inkscape:vp_z="744.09448 : 526.18109 : 1" | ||
40 | inkscape:persp3d-origin="372.04724 : 350.78739 : 1" | ||
41 | id="perspective10" /> | ||
42 | <linearGradient | ||
43 | inkscape:collect="always" | ||
44 | xlink:href="#linearGradient3594" | ||
45 | id="linearGradient3600" | ||
46 | x1="149.28572" | ||
47 | y1="442.29074" | ||
48 | x2="149.28572" | ||
49 | y2="345.29074" | ||
50 | gradientUnits="userSpaceOnUse" | ||
51 | gradientTransform="translate(-1.940295e-8,-15)" /> | ||
52 | <inkscape:perspective | ||
53 | id="perspective3612" | ||
54 | inkscape:persp3d-origin="0.5 : 0.33333333 : 1" | ||
55 | inkscape:vp_z="1 : 0.5 : 1" | ||
56 | inkscape:vp_y="0 : 1000 : 0" | ||
57 | inkscape:vp_x="0 : 0.5 : 1" | ||
58 | sodipodi:type="inkscape:persp3d" /> | ||
59 | </defs> | ||
60 | <sodipodi:namedview | ||
61 | id="base" | ||
62 | pagecolor="#ffffff" | ||
63 | bordercolor="#bd0000" | ||
64 | borderopacity="0.75686275" | ||
65 | inkscape:pageopacity="0.0" | ||
66 | inkscape:pageshadow="2" | ||
67 | inkscape:zoom="14.651253" | ||
68 | inkscape:cx="0.54030499" | ||
69 | inkscape:cy="14.631532" | ||
70 | inkscape:document-units="px" | ||
71 | inkscape:current-layer="layer1" | ||
72 | showgrid="false" | ||
73 | showguides="true" | ||
74 | inkscape:guide-bbox="true" | ||
75 | inkscape:window-width="1280" | ||
76 | inkscape:window-height="725" | ||
77 | inkscape:window-x="0" | ||
78 | inkscape:window-y="25" | ||
79 | inkscape:window-maximized="1" | ||
80 | inkscape:snap-page="false" | ||
81 | inkscape:snap-grids="true" | ||
82 | inkscape:snap-to-guides="false" /> | ||
83 | <metadata | ||
84 | id="metadata7"> | ||
85 | <rdf:RDF> | ||
86 | <cc:Work | ||
87 | rdf:about=""> | ||
88 | <dc:format>image/svg+xml</dc:format> | ||
89 | <dc:type | ||
90 | rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | ||
91 | <dc:title /> | ||
92 | </cc:Work> | ||
93 | </rdf:RDF> | ||
94 | </metadata> | ||
95 | <g | ||
96 | inkscape:label="Layer 1" | ||
97 | inkscape:groupmode="layer" | ||
98 | id="layer1" | ||
99 | transform="translate(-133.78572,-328.29074)"> | ||
100 | <rect | ||
101 | style="fill:url(#linearGradient3600);fill-opacity:1;fill-rule:evenodd;stroke:#8d8d8d;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" | ||
102 | id="rect2816" | ||
103 | width="25" | ||
104 | height="99" | ||
105 | x="144.28572" | ||
106 | y="334.79074" | ||
107 | ry="4.8042979" | ||
108 | rx="4.3476572" /> | ||
109 | <path | ||
110 | style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" | ||
111 | d="m 150.28573,328.79074 13.00097,0" | ||
112 | id="path3602" | ||
113 | clip-path="none" /> | ||
114 | <path | ||
115 | style="fill:none;stroke:#000000;stroke-width:0.99999994;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" | ||
116 | d="m 134.28572,340.75091 0,87.06367" | ||
117 | id="path3602-1" /> | ||
118 | </g> | ||
119 | </svg> | ||
diff --git a/android/res/layout/appwidget_2x2.xml b/android/res/layout/appwidget_2x2.xml new file mode 100644 index 0000000000..a29f416b3d --- /dev/null +++ b/android/res/layout/appwidget_2x2.xml | |||
@@ -0,0 +1,42 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | android:layout_width="fill_parent" | ||
5 | android:layout_height="fill_parent" | ||
6 | android:orientation="vertical" | ||
7 | android:gravity="center" | ||
8 | android:background="@drawable/appwidget_background"> | ||
9 | <!-- style="@style/appwidget_background"--> | ||
10 | |||
11 | <ImageView android:id="@+id/logo" | ||
12 | android:layout_width="fill_parent" | ||
13 | android:layout_height="40dp" | ||
14 | android:scaleType="centerInside" | ||
15 | android:src="@drawable/rockbox" /> | ||
16 | <Button android:id="@+id/infoDisplay" | ||
17 | style="@style/appwidget_infodisplay" | ||
18 | android:layout_width="fill_parent" | ||
19 | android:text="@string/appwidget_infoDisplay" /> | ||
20 | <LinearLayout android:layout_width="fill_parent" | ||
21 | android:layout_height="wrap_content" | ||
22 | android:layout_weight="0" | ||
23 | android:gravity="center" | ||
24 | android:orientation="horizontal"> | ||
25 | <ImageButton android:id="@+id/prev" | ||
26 | style="@style/appwidget_button" | ||
27 | android:layout_weight="1" | ||
28 | android:src="@drawable/appwidget_prev" /> | ||
29 | <ImageButton android:id="@+id/stop" | ||
30 | style="@style/appwidget_button" | ||
31 | android:layout_weight="1" | ||
32 | android:src="@drawable/appwidget_stop" /> | ||
33 | <ImageButton android:id="@+id/playPause" | ||
34 | style="@style/appwidget_button" | ||
35 | android:layout_weight="1" | ||
36 | android:src="@drawable/appwidget_play" /> | ||
37 | <ImageButton android:id="@+id/next" | ||
38 | style="@style/appwidget_button" | ||
39 | android:layout_weight="1" | ||
40 | android:src="@drawable/appwidget_next" /> | ||
41 | </LinearLayout> | ||
42 | </LinearLayout> | ||
diff --git a/android/res/layout/appwidget_4x1.xml b/android/res/layout/appwidget_4x1.xml new file mode 100644 index 0000000000..0d2d6df010 --- /dev/null +++ b/android/res/layout/appwidget_4x1.xml | |||
@@ -0,0 +1,31 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | android:layout_width="fill_parent" | ||
5 | android:layout_height="fill_parent" | ||
6 | android:orientation="horizontal" | ||
7 | android:gravity="center" | ||
8 | android:background="@drawable/appwidget_background"> | ||
9 | <!-- style="@style/appwidget_background"--> | ||
10 | |||
11 | <Button android:id="@+id/infoDisplay" | ||
12 | style="@style/appwidget_infodisplay" | ||
13 | android:layout_height="fill_parent" | ||
14 | android:text="@string/appwidget_infoDisplay" /> | ||
15 | <ImageButton android:id="@+id/prev" | ||
16 | style="@style/appwidget_button" | ||
17 | android:layout_height="fill_parent" | ||
18 | android:src="@drawable/appwidget_prev" /> | ||
19 | <ImageButton android:id="@+id/stop" | ||
20 | style="@style/appwidget_button" | ||
21 | android:layout_height="fill_parent" | ||
22 | android:src="@drawable/appwidget_stop" /> | ||
23 | <ImageButton android:id="@+id/playPause" | ||
24 | style="@style/appwidget_button" | ||
25 | android:layout_height="fill_parent" | ||
26 | android:src="@drawable/appwidget_play" /> | ||
27 | <ImageButton android:id="@+id/next" | ||
28 | style="@style/appwidget_button" | ||
29 | android:layout_height="fill_parent" | ||
30 | android:src="@drawable/appwidget_next" /> | ||
31 | </LinearLayout> | ||
diff --git a/android/res/layout/appwidget_configure.xml b/android/res/layout/appwidget_configure.xml new file mode 100644 index 0000000000..8dd0ff2144 --- /dev/null +++ b/android/res/layout/appwidget_configure.xml | |||
@@ -0,0 +1,40 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | android:layout_width="fill_parent" | ||
5 | android:layout_height="wrap_content" | ||
6 | android:orientation="vertical"> | ||
7 | |||
8 | <ImageView android:id="@+id/logo" | ||
9 | android:layout_width="fill_parent" | ||
10 | android:layout_height="wrap_content" | ||
11 | android:scaleType="centerInside" | ||
12 | android:src="@drawable/rockbox" /> | ||
13 | |||
14 | <TextView android:layout_width="fill_parent" | ||
15 | android:layout_height="wrap_content" | ||
16 | android:text="@string/appwidget_configure_instructions"/> | ||
17 | |||
18 | <CheckBox android:id="@+id/enable_prev" | ||
19 | android:layout_width="fill_parent" | ||
20 | android:layout_height="wrap_content" | ||
21 | android:text="@string/appwidget_configure_prev"/> | ||
22 | <CheckBox android:id="@+id/enable_stop" | ||
23 | android:layout_width="fill_parent" | ||
24 | android:layout_height="wrap_content" | ||
25 | android:text="@string/appwidget_configure_stop"/> | ||
26 | <CheckBox android:id="@+id/enable_playpause" | ||
27 | android:layout_width="fill_parent" | ||
28 | android:layout_height="wrap_content" | ||
29 | android:text="@string/appwidget_configure_playpause"/> | ||
30 | <CheckBox android:id="@+id/enable_next" | ||
31 | android:layout_width="fill_parent" | ||
32 | android:layout_height="wrap_content" | ||
33 | android:text="@string/appwidget_configure_next"/> | ||
34 | |||
35 | <Button android:id="@+id/confirm" | ||
36 | android:layout_width="fill_parent" | ||
37 | android:layout_height="wrap_content" | ||
38 | android:text="@string/appwidget_configure_confirm"/> | ||
39 | </LinearLayout> | ||
40 | |||
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 8034eab086..5ff2a6dc20 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml | |||
@@ -10,4 +10,18 @@ | |||
10 | <string name="No">No</string> | 10 | <string name="No">No</string> |
11 | <string name="error_extraction">Error occured during extraction!</string> | 11 | <string name="error_extraction">Error occured during extraction!</string> |
12 | <string name="rockbox_extracting">Rockbox is loading. Please wait...</string> | 12 | <string name="rockbox_extracting">Rockbox is loading. Please wait...</string> |
13 | </resources> \ No newline at end of file | 13 | |
14 | <!-- Widget --> | ||
15 | <string name="appwidget_label_4x1">Rockbox (line)</string> | ||
16 | <string name="appwidget_label_2x2">Rockbox (square)</string> | ||
17 | <string name="appwidget_infoDisplay">Touch to launch app</string> | ||
18 | |||
19 | <!-- Widget configuration --> | ||
20 | <string name="appwidget_configure_instructions">Please chose elements to display in widget.</string> | ||
21 | <string name="appwidget_configure_prev">Prev Button</string> | ||
22 | <string name="appwidget_configure_stop">Stop Button</string> | ||
23 | <string name="appwidget_configure_playpause">Play/Pause Button</string> | ||
24 | <string name="appwidget_configure_next">Next Button</string> | ||
25 | <string name="appwidget_configure_confirm">Create Widget</string> | ||
26 | |||
27 | </resources> | ||
diff --git a/android/res/values/style.xml b/android/res/values/style.xml new file mode 100644 index 0000000000..201b478d19 --- /dev/null +++ b/android/res/values/style.xml | |||
@@ -0,0 +1,18 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <resources> | ||
4 | <style name="appwidget_infodisplay"> | ||
5 | <item name="android:layout_width">1dp</item> | ||
6 | <item name="android:layout_height">1dp</item> | ||
7 | <item name="android:layout_weight">1</item> | ||
8 | <item name="android:textColor">#cecfce</item> | ||
9 | <item name="android:background">@drawable/appwidget_infodisplay_background</item> | ||
10 | </style> | ||
11 | <style name="appwidget_button"> | ||
12 | <item name="android:layout_width">40dp</item> | ||
13 | <item name="android:layout_height">40dp</item> | ||
14 | <item name="android:scaleType">fitCenter</item> | ||
15 | <item name="android:background">@drawable/appwidget_infodisplay_background</item> | ||
16 | </style> | ||
17 | </resources> | ||
18 | |||
diff --git a/android/res/xml/appwidget_provider_2x2.xml b/android/res/xml/appwidget_provider_2x2.xml new file mode 100644 index 0000000000..981b4f1b3d --- /dev/null +++ b/android/res/xml/appwidget_provider_2x2.xml | |||
@@ -0,0 +1,8 @@ | |||
1 | <!-- cell size is (number of cells * 74) - 2 dp according to http://developer.android.com/guide/topics/appwidgets/index.html#MetaData --> | ||
2 | <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:minWidth="146dp" | ||
4 | android:minHeight="146dp" | ||
5 | android:updatePeriodMillis="86400000" | ||
6 | android:initialLayout="@layout/appwidget_2x2" | ||
7 | android:configure="org.rockbox.widgets.RockboxWidgetConfigure"> | ||
8 | </appwidget-provider> | ||
diff --git a/android/res/xml/appwidget_provider_4x1.xml b/android/res/xml/appwidget_provider_4x1.xml new file mode 100644 index 0000000000..9a29901f5e --- /dev/null +++ b/android/res/xml/appwidget_provider_4x1.xml | |||
@@ -0,0 +1,8 @@ | |||
1 | <!-- cell size is (number of cells * 74) - 2 dp according to http://developer.android.com/guide/topics/appwidgets/index.html#MetaData --> | ||
2 | <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:minWidth="294dp" | ||
4 | android:minHeight="72dp" | ||
5 | android:updatePeriodMillis="86400000" | ||
6 | android:initialLayout="@layout/appwidget_4x1" | ||
7 | android:configure="org.rockbox.widgets.RockboxWidgetConfigure"> | ||
8 | </appwidget-provider> | ||
diff --git a/android/src/org/rockbox/Helper/RunForegroundManager.java b/android/src/org/rockbox/Helper/RunForegroundManager.java index 6c5f2deb14..99ac66b686 100644 --- a/android/src/org/rockbox/Helper/RunForegroundManager.java +++ b/android/src/org/rockbox/Helper/RunForegroundManager.java | |||
@@ -11,6 +11,7 @@ import android.app.NotificationManager; | |||
11 | import android.app.PendingIntent; | 11 | import android.app.PendingIntent; |
12 | import android.app.Service; | 12 | import android.app.Service; |
13 | import android.content.Intent; | 13 | import android.content.Intent; |
14 | import android.net.Uri; | ||
14 | import android.util.Log; | 15 | import android.util.Log; |
15 | import android.widget.RemoteViews; | 16 | import android.widget.RemoteViews; |
16 | 17 | ||
@@ -92,6 +93,19 @@ public class RunForegroundManager | |||
92 | else | 93 | else |
93 | mNotification.tickerText = title+" - "+artist; | 94 | mNotification.tickerText = title+" - "+artist; |
94 | mNM.notify(R.string.notification, mNotification); | 95 | mNM.notify(R.string.notification, mNotification); |
96 | |||
97 | Intent widgetUpdate = new Intent("org.rockbox.TrackUpdateInfo"); | ||
98 | widgetUpdate.putExtra("title", title); | ||
99 | widgetUpdate.putExtra("artist", artist); | ||
100 | widgetUpdate.putExtra("album", album); | ||
101 | mCurrentService.sendBroadcast(widgetUpdate); | ||
102 | } | ||
103 | |||
104 | public void finishNotification() | ||
105 | { | ||
106 | Log.d("Rockbox", "TrackFinish"); | ||
107 | Intent widgetUpdate = new Intent("org.rockbox.TrackFinish"); | ||
108 | mCurrentService.sendBroadcast(widgetUpdate); | ||
95 | } | 109 | } |
96 | 110 | ||
97 | private interface IRunForeground | 111 | private interface IRunForeground |
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java index 18415562f3..05d2b11184 100644 --- a/android/src/org/rockbox/RockboxFramebuffer.java +++ b/android/src/org/rockbox/RockboxFramebuffer.java | |||
@@ -147,5 +147,5 @@ public class RockboxFramebuffer extends View | |||
147 | private native void post_update_done(); | 147 | private native void post_update_done(); |
148 | private native void set_lcd_active(int active); | 148 | private native void set_lcd_active(int active); |
149 | private native void touchHandler(boolean down, int x, int y); | 149 | private native void touchHandler(boolean down, int x, int y); |
150 | private native boolean buttonHandler(int keycode, boolean state); | 150 | private native static boolean buttonHandler(int keycode, boolean state); |
151 | } | 151 | } |
diff --git a/android/src/org/rockbox/RockboxPCM.java b/android/src/org/rockbox/RockboxPCM.java index 146e639a08..c1fecbcc15 100644 --- a/android/src/org/rockbox/RockboxPCM.java +++ b/android/src/org/rockbox/RockboxPCM.java | |||
@@ -23,9 +23,11 @@ package org.rockbox; | |||
23 | 23 | ||
24 | import java.util.Arrays; | 24 | import java.util.Arrays; |
25 | 25 | ||
26 | import android.content.Intent; | ||
26 | import android.media.AudioFormat; | 27 | import android.media.AudioFormat; |
27 | import android.media.AudioManager; | 28 | import android.media.AudioManager; |
28 | import android.media.AudioTrack; | 29 | import android.media.AudioTrack; |
30 | import android.net.Uri; | ||
29 | import android.os.Handler; | 31 | import android.os.Handler; |
30 | import android.os.HandlerThread; | 32 | import android.os.HandlerThread; |
31 | import android.os.Process; | 33 | import android.os.Process; |
@@ -80,10 +82,16 @@ public class RockboxPCM extends AudioTrack | |||
80 | private void play_pause(boolean pause) { | 82 | private void play_pause(boolean pause) { |
81 | if (pause) | 83 | if (pause) |
82 | { | 84 | { |
85 | Intent widgetUpdate = new Intent("org.rockbox.UpdateState"); | ||
86 | widgetUpdate.putExtra("state", "pause"); | ||
87 | RockboxService.get_instance().sendBroadcast(widgetUpdate); | ||
83 | pause(); | 88 | pause(); |
84 | } | 89 | } |
85 | else | 90 | else |
86 | { | 91 | { |
92 | Intent widgetUpdate = new Intent("org.rockbox.UpdateState"); | ||
93 | widgetUpdate.putExtra("state", "play"); | ||
94 | RockboxService.get_instance().sendBroadcast(widgetUpdate); | ||
87 | if (getPlayState() == AudioTrack.PLAYSTATE_STOPPED) | 95 | if (getPlayState() == AudioTrack.PLAYSTATE_STOPPED) |
88 | { | 96 | { |
89 | RockboxService.get_instance().startForeground(); | 97 | RockboxService.get_instance().startForeground(); |
@@ -114,6 +122,9 @@ public class RockboxPCM extends AudioTrack | |||
114 | throw new IllegalStateException(e); | 122 | throw new IllegalStateException(e); |
115 | } | 123 | } |
116 | RockboxService.get_instance().stopForeground(); | 124 | RockboxService.get_instance().stopForeground(); |
125 | Intent widgetUpdate = new Intent("org.rockbox.UpdateState"); | ||
126 | widgetUpdate.putExtra("state", "stop"); | ||
127 | RockboxService.get_instance().sendBroadcast(widgetUpdate); | ||
117 | } | 128 | } |
118 | 129 | ||
119 | @SuppressWarnings("unused") | 130 | @SuppressWarnings("unused") |
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index 23086eae29..de90999783 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java | |||
@@ -43,6 +43,7 @@ import android.os.Bundle; | |||
43 | import android.os.IBinder; | 43 | import android.os.IBinder; |
44 | import android.os.ResultReceiver; | 44 | import android.os.ResultReceiver; |
45 | import android.util.Log; | 45 | import android.util.Log; |
46 | import android.view.KeyEvent; | ||
46 | 47 | ||
47 | /* This class is used as the main glue between java and c. | 48 | /* This class is used as the main glue between java and c. |
48 | * All access should be done through RockboxService.get_instance() for safety. | 49 | * All access should be done through RockboxService.get_instance() for safety. |
@@ -76,7 +77,7 @@ public class RockboxService extends Service | |||
76 | @Override | 77 | @Override |
77 | public void onCreate() | 78 | public void onCreate() |
78 | { | 79 | { |
79 | instance = this; | 80 | instance = this; |
80 | } | 81 | } |
81 | 82 | ||
82 | public static RockboxService get_instance() | 83 | public static RockboxService get_instance() |
@@ -115,6 +116,31 @@ public class RockboxService extends Service | |||
115 | if (!rbLibLoaded) | 116 | if (!rbLibLoaded) |
116 | startservice(); | 117 | startservice(); |
117 | 118 | ||
119 | if (intent != null && intent.getAction() != null) | ||
120 | { | ||
121 | Log.d("RockboxService", intent.getAction()); | ||
122 | if (intent.getAction().equals("org.rockbox.PlayPause")) | ||
123 | { | ||
124 | if (fb != null) | ||
125 | fb.onKeyUp(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, null); | ||
126 | } | ||
127 | else if (intent.getAction().equals("org.rockbox.Prev")) | ||
128 | { | ||
129 | if (fb != null) | ||
130 | fb.onKeyUp(KeyEvent.KEYCODE_MEDIA_PREVIOUS, null); | ||
131 | } | ||
132 | else if (intent.getAction().equals("org.rockbox.Next")) | ||
133 | { | ||
134 | if (fb != null) | ||
135 | fb.onKeyUp(KeyEvent.KEYCODE_MEDIA_NEXT, null); | ||
136 | } | ||
137 | else if (intent.getAction().equals("org.rockbox.Stop")) | ||
138 | { | ||
139 | if (fb != null) | ||
140 | fb.onKeyUp(KeyEvent.KEYCODE_MEDIA_STOP, null); | ||
141 | } | ||
142 | } | ||
143 | |||
118 | /* Display a notification about us starting. | 144 | /* Display a notification about us starting. |
119 | * We put an icon in the status bar. */ | 145 | * We put an icon in the status bar. */ |
120 | if (fg_runner == null) | 146 | if (fg_runner == null) |
diff --git a/android/src/org/rockbox/widgets/RockboxWidgetConfigure.java b/android/src/org/rockbox/widgets/RockboxWidgetConfigure.java new file mode 100644 index 0000000000..82adb97126 --- /dev/null +++ b/android/src/org/rockbox/widgets/RockboxWidgetConfigure.java | |||
@@ -0,0 +1,121 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Antoine Cellerier <dionoea at videolan dot org> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | package org.rockbox.widgets; | ||
23 | |||
24 | import org.rockbox.R; | ||
25 | |||
26 | import android.app.Activity; | ||
27 | import android.appwidget.AppWidgetManager; | ||
28 | import android.content.Context; | ||
29 | import android.content.Intent; | ||
30 | import android.content.SharedPreferences; | ||
31 | import android.os.Bundle; | ||
32 | import android.util.Log; | ||
33 | import android.view.View; | ||
34 | import android.widget.CheckBox; | ||
35 | |||
36 | |||
37 | public class RockboxWidgetConfigure extends Activity | ||
38 | { | ||
39 | int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; | ||
40 | |||
41 | public RockboxWidgetConfigure() | ||
42 | { | ||
43 | super(); | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public void onCreate(Bundle savedInstanceState) | ||
48 | { | ||
49 | super.onCreate(savedInstanceState); | ||
50 | |||
51 | setResult(RESULT_CANCELED); | ||
52 | setContentView(R.layout.appwidget_configure); | ||
53 | |||
54 | ((CheckBox)findViewById(R.id.enable_prev)).setChecked(false); | ||
55 | ((CheckBox)findViewById(R.id.enable_stop)).setChecked(true); | ||
56 | ((CheckBox)findViewById(R.id.enable_playpause)).setChecked(true); | ||
57 | ((CheckBox)findViewById(R.id.enable_next)).setChecked(false); | ||
58 | |||
59 | findViewById(R.id.confirm).setOnClickListener(mCreateWidget); | ||
60 | |||
61 | Intent intent = getIntent(); | ||
62 | Bundle extras = intent.getExtras(); | ||
63 | if (extras != null) | ||
64 | mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); | ||
65 | |||
66 | if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) | ||
67 | finish(); | ||
68 | } | ||
69 | |||
70 | View.OnClickListener mCreateWidget = new View.OnClickListener() | ||
71 | { | ||
72 | public void onClick(View v) | ||
73 | { | ||
74 | final Context context = RockboxWidgetConfigure.this; | ||
75 | |||
76 | WidgetPref state = new WidgetPref(); | ||
77 | state.enablePrev = ((CheckBox)findViewById(R.id.enable_prev)).isChecked(); | ||
78 | state.enableStop = ((CheckBox)findViewById(R.id.enable_stop)).isChecked(); | ||
79 | state.enablePlayPause = ((CheckBox)findViewById(R.id.enable_playpause)).isChecked(); | ||
80 | state.enableNext = ((CheckBox)findViewById(R.id.enable_next)).isChecked(); | ||
81 | saveWidgetPref(context, mAppWidgetId, state); | ||
82 | |||
83 | AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); | ||
84 | RockboxWidgetProvider.updateAppWidget(context, appWidgetManager, mAppWidgetId, null); | ||
85 | |||
86 | Intent result = new Intent(); | ||
87 | result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); | ||
88 | setResult(RESULT_OK, result); | ||
89 | finish(); | ||
90 | } | ||
91 | }; | ||
92 | |||
93 | static public class WidgetPref | ||
94 | { | ||
95 | public boolean enablePrev = true; | ||
96 | public boolean enableStop = true; | ||
97 | public boolean enablePlayPause = true; | ||
98 | public boolean enableNext = true; | ||
99 | } | ||
100 | |||
101 | static void saveWidgetPref(Context context, int appWidgetId, WidgetPref state) | ||
102 | { | ||
103 | SharedPreferences.Editor prefs = context.getSharedPreferences("org.rockbox.RockboxWidgetConfigure", 0).edit(); | ||
104 | prefs.putBoolean("prev"+appWidgetId, state.enablePrev); | ||
105 | prefs.putBoolean("stop"+appWidgetId, state.enableStop); | ||
106 | prefs.putBoolean("playpause"+appWidgetId, state.enablePlayPause); | ||
107 | prefs.putBoolean("next"+appWidgetId, state.enableNext); | ||
108 | prefs.commit(); | ||
109 | } | ||
110 | |||
111 | static WidgetPref loadWidgetPref(Context context, int appWidgetId) | ||
112 | { | ||
113 | SharedPreferences prefs = context.getSharedPreferences("org.rockbox.RockboxWidgetConfigure", 0); | ||
114 | WidgetPref state = new WidgetPref(); | ||
115 | state.enablePrev = prefs.getBoolean("prev"+appWidgetId, true); | ||
116 | state.enableStop = prefs.getBoolean("stop"+appWidgetId, true); | ||
117 | state.enablePlayPause = prefs.getBoolean("playpause"+appWidgetId, true); | ||
118 | state.enableNext = prefs.getBoolean("next"+appWidgetId, true); | ||
119 | return state; | ||
120 | } | ||
121 | } | ||
diff --git a/android/src/org/rockbox/widgets/RockboxWidgetProvider.java b/android/src/org/rockbox/widgets/RockboxWidgetProvider.java new file mode 100644 index 0000000000..756d9f9a13 --- /dev/null +++ b/android/src/org/rockbox/widgets/RockboxWidgetProvider.java | |||
@@ -0,0 +1,171 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Antoine Cellerier <dionoea at videolan dot org> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | package org.rockbox.widgets; | ||
23 | |||
24 | import org.rockbox.R; | ||
25 | import org.rockbox.RockboxActivity; | ||
26 | import org.rockbox.RockboxService; | ||
27 | |||
28 | import android.app.PendingIntent; | ||
29 | import android.appwidget.AppWidgetManager; | ||
30 | import android.appwidget.AppWidgetProvider; | ||
31 | import android.appwidget.AppWidgetProviderInfo; | ||
32 | import android.content.ComponentName; | ||
33 | import android.content.Context; | ||
34 | import android.content.Intent; | ||
35 | import android.content.pm.PackageManager; | ||
36 | import android.net.Uri; | ||
37 | import android.util.Log; | ||
38 | import android.view.View; | ||
39 | import android.view.KeyEvent; | ||
40 | import android.widget.RemoteViews; | ||
41 | |||
42 | import java.util.ArrayList; | ||
43 | |||
44 | public class RockboxWidgetProvider extends AppWidgetProvider | ||
45 | { | ||
46 | @Override | ||
47 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) | ||
48 | { | ||
49 | final int N = appWidgetIds.length; | ||
50 | for (int i = 0; i < N; i++) | ||
51 | { | ||
52 | int appWidgetId = appWidgetIds[i]; | ||
53 | updateAppWidget(context, appWidgetManager, appWidgetId, null); | ||
54 | |||
55 | } | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | public void onDeleted(Context context, int[] appWidgetIds) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public void onEnabled(Context context) | ||
65 | { | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | public void onDisabled(Context context) | ||
70 | { | ||
71 | } | ||
72 | |||
73 | @Override | ||
74 | public void onReceive(Context context, Intent intent) | ||
75 | { | ||
76 | String action = intent.getAction(); | ||
77 | if (intent.getAction().equals("org.rockbox.TrackUpdateInfo") || | ||
78 | intent.getAction().equals("org.rockbox.TrackFinish") || | ||
79 | intent.getAction().equals("org.rockbox.UpdateState")) | ||
80 | { | ||
81 | AppWidgetManager gm = AppWidgetManager.getInstance(context); | ||
82 | int[] appWidgetIds = gm.getAppWidgetIds(new ComponentName(context, this.getClass())); | ||
83 | final int N = appWidgetIds.length; | ||
84 | for (int i = 0; i < N; i++) | ||
85 | { | ||
86 | updateAppWidget(context, gm, appWidgetIds[i], intent); | ||
87 | } | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | super.onReceive(context, intent); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | public static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Intent args) | ||
96 | { | ||
97 | AppWidgetProviderInfo provider = appWidgetManager.getAppWidgetInfo(appWidgetId); | ||
98 | RemoteViews views = null; | ||
99 | views = new RemoteViews(context.getPackageName(), provider.initialLayout); | ||
100 | |||
101 | Intent intent = new Intent(context, RockboxActivity.class); | ||
102 | PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); | ||
103 | views.setOnClickPendingIntent(R.id.infoDisplay, pendingIntent); | ||
104 | |||
105 | RockboxWidgetConfigure.WidgetPref state = RockboxWidgetConfigure.loadWidgetPref(context, appWidgetId); | ||
106 | |||
107 | if (state.enablePrev) | ||
108 | { | ||
109 | intent = new Intent("org.rockbox.Prev", Uri.EMPTY, context, RockboxService.class); | ||
110 | pendingIntent = PendingIntent.getService(context, 0, intent, 0); | ||
111 | views.setOnClickPendingIntent(R.id.prev, pendingIntent); | ||
112 | } | ||
113 | else | ||
114 | views.setViewVisibility(R.id.prev, View.GONE); | ||
115 | |||
116 | if (state.enablePlayPause) | ||
117 | { | ||
118 | intent = new Intent("org.rockbox.PlayPause", Uri.EMPTY, context, RockboxService.class); | ||
119 | pendingIntent = PendingIntent.getService(context, 0, intent, 0); | ||
120 | views.setOnClickPendingIntent(R.id.playPause, pendingIntent); | ||
121 | } | ||
122 | else | ||
123 | views.setViewVisibility(R.id.playPause, View.GONE); | ||
124 | |||
125 | if (state.enableNext) | ||
126 | { | ||
127 | intent = new Intent("org.rockbox.Next", Uri.EMPTY, context, RockboxService.class); | ||
128 | pendingIntent = PendingIntent.getService(context, 0, intent, 0); | ||
129 | views.setOnClickPendingIntent(R.id.next, pendingIntent); | ||
130 | } | ||
131 | else | ||
132 | views.setViewVisibility(R.id.next, View.GONE); | ||
133 | |||
134 | if (state.enableStop) | ||
135 | { | ||
136 | intent = new Intent("org.rockbox.Stop", Uri.EMPTY, context, RockboxService.class); | ||
137 | pendingIntent = PendingIntent.getService(context, 0, intent, 0); | ||
138 | views.setOnClickPendingIntent(R.id.stop, pendingIntent); | ||
139 | } | ||
140 | else | ||
141 | views.setViewVisibility(R.id.stop, View.GONE); | ||
142 | |||
143 | if (args != null) | ||
144 | { | ||
145 | if (args.getAction().equals("org.rockbox.TrackUpdateInfo")) | ||
146 | { | ||
147 | CharSequence title = args.getCharSequenceExtra("title"); | ||
148 | CharSequence artist = args.getCharSequenceExtra("artist"); | ||
149 | CharSequence album = args.getCharSequenceExtra("album"); | ||
150 | views.setTextViewText(R.id.infoDisplay, title+"\n"+artist+"\n"+album); | ||
151 | } | ||
152 | else if (args.getAction().equals("org.rockbox.TrackFinish")) | ||
153 | { | ||
154 | // FIXME: looks like this event is always fired earlier than | ||
155 | // the actual track change (a few seconds) | ||
156 | views.setTextViewText(R.id.infoDisplay, context.getString(R.string.appwidget_infoDisplay)); | ||
157 | } | ||
158 | else if (args.getAction().equals("org.rockbox.UpdateState")) | ||
159 | { | ||
160 | CharSequence playstate = args.getCharSequenceExtra("state"); | ||
161 | if (playstate.equals("play")) | ||
162 | views.setImageViewResource(R.id.playPause, R.drawable.appwidget_pause); | ||
163 | else /* pause or stop */ | ||
164 | views.setImageViewResource(R.id.playPause, R.drawable.appwidget_play); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | appWidgetManager.updateAppWidget(appWidgetId, views); | ||
169 | } | ||
170 | } | ||
171 | |||
diff --git a/android/src/org/rockbox/widgets/RockboxWidgetProvider2x2.java b/android/src/org/rockbox/widgets/RockboxWidgetProvider2x2.java new file mode 100644 index 0000000000..183c4273ec --- /dev/null +++ b/android/src/org/rockbox/widgets/RockboxWidgetProvider2x2.java | |||
@@ -0,0 +1,27 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Antoine Cellerier <dionoea at videolan dot org> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | package org.rockbox.widgets; | ||
23 | |||
24 | public class RockboxWidgetProvider2x2 extends RockboxWidgetProvider | ||
25 | { | ||
26 | } | ||
27 | |||
diff --git a/android/src/org/rockbox/widgets/RockboxWidgetProvider4x1.java b/android/src/org/rockbox/widgets/RockboxWidgetProvider4x1.java new file mode 100644 index 0000000000..303c54c92b --- /dev/null +++ b/android/src/org/rockbox/widgets/RockboxWidgetProvider4x1.java | |||
@@ -0,0 +1,27 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Antoine Cellerier <dionoea at videolan dot org> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | package org.rockbox.widgets; | ||
23 | |||
24 | public class RockboxWidgetProvider4x1 extends RockboxWidgetProvider | ||
25 | { | ||
26 | } | ||
27 | |||