summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/AndroidManifest.xml3
-rw-r--r--android/res/layout/keyboardinput.xml4
-rw-r--r--android/res/values/strings.xml3
-rw-r--r--android/src/org/rockbox/HostCallback.java7
-rw-r--r--android/src/org/rockbox/KeyboardActivity.java41
-rw-r--r--android/src/org/rockbox/RockboxActivity.java33
-rw-r--r--android/src/org/rockbox/RockboxFramebuffer.java3
-rw-r--r--android/src/org/rockbox/RockboxKeyboardInput.java69
-rw-r--r--android/src/org/rockbox/RockboxService.java12
9 files changed, 171 insertions, 4 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index 45182418d0..c52cac2753 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -17,7 +17,8 @@
17 </activity> 17 </activity>
18 <service android:name=".RockboxService"/> 18 <service android:name=".RockboxService"/>
19 19
20 </application> 20 <activity android:name="KeyboardActivity" android:launchMode="singleTop"></activity>
21</application>
21<uses-sdk android:minSdkVersion="4" /> 22<uses-sdk android:minSdkVersion="4" />
22<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> 23<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
23</manifest> 24</manifest>
diff --git a/android/res/layout/keyboardinput.xml b/android/res/layout/keyboardinput.xml
new file mode 100644
index 0000000000..124eda8fbe
--- /dev/null
+++ b/android/res/layout/keyboardinput.xml
@@ -0,0 +1,4 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<AbsoluteLayout android:id="@+id/AbsoluteLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"><EditText android:layout_height="wrap_content" android:text="Some Text" android:layout_width="fill_parent" android:id="@+id/KbdInput"></EditText>
4</AbsoluteLayout>
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml
index 9320b2624d..b0d41f133d 100644
--- a/android/res/values/strings.xml
+++ b/android/res/values/strings.xml
@@ -3,4 +3,7 @@
3 3
4 <string name="app_name">Rockbox</string> 4 <string name="app_name">Rockbox</string>
5<string name="notification">Rockbox</string> 5<string name="notification">Rockbox</string>
6<string name="OK">OK</string>
7<string name="Cancel">Cancel</string>
8<string name="KbdInputTitle">Rockbox Keyboard Input</string>
6</resources> 9</resources>
diff --git a/android/src/org/rockbox/HostCallback.java b/android/src/org/rockbox/HostCallback.java
new file mode 100644
index 0000000000..0e69b3f283
--- /dev/null
+++ b/android/src/org/rockbox/HostCallback.java
@@ -0,0 +1,7 @@
1package org.rockbox;
2
3import android.content.Intent;
4
5public interface HostCallback {
6 public void onComplete(int resultCode, Intent data);
7}
diff --git a/android/src/org/rockbox/KeyboardActivity.java b/android/src/org/rockbox/KeyboardActivity.java
new file mode 100644
index 0000000000..f32aae28f8
--- /dev/null
+++ b/android/src/org/rockbox/KeyboardActivity.java
@@ -0,0 +1,41 @@
1package org.rockbox;
2
3import android.app.Activity;
4import android.app.AlertDialog;
5import android.app.Dialog;
6import android.content.DialogInterface;
7import android.os.Bundle;
8import android.text.Editable;
9import android.view.LayoutInflater;
10import android.view.View;
11import android.widget.EditText;
12
13public class KeyboardActivity extends Activity {
14 public void onCreate(Bundle savedInstanceState) {
15 super.onCreate(savedInstanceState);
16 LayoutInflater inflater=LayoutInflater.from(this);
17 View addView=inflater.inflate(R.layout.keyboardinput, null);
18 EditText input = (EditText) addView.findViewById(R.id.KbdInput);
19 input.setText(getIntent().getStringExtra("value"));
20 new AlertDialog.Builder(this)
21 .setTitle(R.string.KbdInputTitle)
22 .setView(addView)
23 .setIcon(R.drawable.icon)
24 .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
25 public void onClick(DialogInterface dialog, int whichButton) {
26 EditText input = (EditText)((Dialog)dialog).findViewById(R.id.KbdInput);
27 Editable s = input.getText();
28 getIntent().putExtra("value", s.toString());
29 setResult(RESULT_OK, getIntent());
30 finish();
31 }
32 })
33 .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
34 public void onClick(DialogInterface dialog, int whichButton) {
35 setResult(RESULT_CANCELED, getIntent());
36 finish();
37 }
38 })
39 .show();
40 }
41}
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java
index f775597d30..9eed3f48dc 100644
--- a/android/src/org/rockbox/RockboxActivity.java
+++ b/android/src/org/rockbox/RockboxActivity.java
@@ -24,7 +24,9 @@ package org.rockbox;
24import android.app.Activity; 24import android.app.Activity;
25import android.app.ProgressDialog; 25import android.app.ProgressDialog;
26import android.content.Intent; 26import android.content.Intent;
27import android.content.IntentFilter;
27import android.os.Bundle; 28import android.os.Bundle;
29import android.util.Log;
28import android.view.ViewGroup; 30import android.view.ViewGroup;
29import android.view.Window; 31import android.view.Window;
30import android.view.WindowManager; 32import android.view.WindowManager;
@@ -41,6 +43,7 @@ public class RockboxActivity extends Activity
41 requestWindowFeature(Window.FEATURE_NO_TITLE); 43 requestWindowFeature(Window.FEATURE_NO_TITLE);
42 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN 44 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
43 ,WindowManager.LayoutParams.FLAG_FULLSCREEN); 45 ,WindowManager.LayoutParams.FLAG_FULLSCREEN);
46 final Activity thisActivity = this;
44 final Intent intent = new Intent(this, RockboxService.class); 47 final Intent intent = new Intent(this, RockboxService.class);
45 /* prepare a please wait dialog in case we need 48 /* prepare a please wait dialog in case we need
46 * to wait for unzipping libmisc.so 49 * to wait for unzipping libmisc.so
@@ -95,7 +98,8 @@ public class RockboxActivity extends Activity
95 loadingdialog.dismiss(); 98 loadingdialog.dismiss();
96 if (rbservice.get_fb() == null) 99 if (rbservice.get_fb() == null)
97 throw new IllegalStateException("FB NULL"); 100 throw new IllegalStateException("FB NULL");
98 setContentView(rbservice.get_fb()); 101 rbservice.set_activity(thisActivity);
102 setContentView(rbservice.get_fb());
99 rbservice.get_fb().invalidate(); 103 rbservice.get_fb().invalidate();
100 } 104 }
101 }); 105 });
@@ -111,6 +115,7 @@ public class RockboxActivity extends Activity
111 115
112 public void onResume() 116 public void onResume()
113 { 117 {
118
114 super.onResume(); 119 super.onResume();
115 if (isRockboxRunning()) 120 if (isRockboxRunning())
116 { 121 {
@@ -123,6 +128,7 @@ public class RockboxActivity extends Activity
123 g.removeView(rbservice.get_fb()); 128 g.removeView(rbservice.get_fb());
124 setContentView(rbservice.get_fb()); 129 setContentView(rbservice.get_fb());
125 } finally { 130 } finally {
131 rbservice.set_activity(this);
126 rbservice.get_fb().resume(); 132 rbservice.get_fb().resume();
127 } 133 }
128 } 134 }
@@ -135,6 +141,7 @@ public class RockboxActivity extends Activity
135 protected void onPause() 141 protected void onPause()
136 { 142 {
137 super.onPause(); 143 super.onPause();
144 rbservice.set_activity(null);
138 rbservice.get_fb().suspend(); 145 rbservice.get_fb().suspend();
139 } 146 }
140 147
@@ -142,6 +149,7 @@ public class RockboxActivity extends Activity
142 protected void onStop() 149 protected void onStop()
143 { 150 {
144 super.onStop(); 151 super.onStop();
152 rbservice.set_activity(null);
145 rbservice.get_fb().suspend(); 153 rbservice.get_fb().suspend();
146 } 154 }
147 155
@@ -149,6 +157,29 @@ public class RockboxActivity extends Activity
149 protected void onDestroy() 157 protected void onDestroy()
150 { 158 {
151 super.onDestroy(); 159 super.onDestroy();
160 rbservice.set_activity(null);
152 rbservice.get_fb().suspend(); 161 rbservice.get_fb().suspend();
153 } 162 }
163
164 private HostCallback hostcallback = null;
165 public void waitForActivity(Intent i, HostCallback callback)
166 {
167 if (hostcallback != null)
168 {
169 LOG("Something has gone wrong");
170 }
171 hostcallback = callback;
172 startActivityForResult(i, 0);
173 }
174
175 public void onActivityResult(int requestCode, int resultCode, Intent data)
176 {
177 hostcallback.onComplete(resultCode, data);
178 hostcallback = null;
179 }
180
181 private void LOG(CharSequence text)
182 {
183 Log.d("Rockbox", (String) text);
184 }
154} 185}
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java
index e90eb86dbd..20311a8790 100644
--- a/android/src/org/rockbox/RockboxFramebuffer.java
+++ b/android/src/org/rockbox/RockboxFramebuffer.java
@@ -118,12 +118,11 @@ public class RockboxFramebuffer extends View
118 setFocusableInTouchMode(true); 118 setFocusableInTouchMode(true);
119 setClickable(true); 119 setClickable(true);
120 requestFocus(); 120 requestFocus();
121 /* make updates again, the underlying function will
122 * send an event */
123 set_lcd_active(1); 121 set_lcd_active(1);
124 } 122 }
125 123
126 public native void set_lcd_active(int active); 124 public native void set_lcd_active(int active);
127 public native void touchHandler(boolean down, int x, int y); 125 public native void touchHandler(boolean down, int x, int y);
128 public native boolean buttonHandler(int keycode, boolean state); 126 public native boolean buttonHandler(int keycode, boolean state);
127
129} 128}
diff --git a/android/src/org/rockbox/RockboxKeyboardInput.java b/android/src/org/rockbox/RockboxKeyboardInput.java
new file mode 100644
index 0000000000..b037f6c4bb
--- /dev/null
+++ b/android/src/org/rockbox/RockboxKeyboardInput.java
@@ -0,0 +1,69 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Jonathan Gordon
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
22package org.rockbox;
23
24import android.app.Activity;
25import android.content.BroadcastReceiver;
26import android.content.Intent;
27import android.util.Log;
28
29public class RockboxKeyboardInput
30{
31 private BroadcastReceiver b;
32 private String result;
33
34 public RockboxKeyboardInput()
35 {
36 result = null;
37 }
38
39 public void kbd_input(String text)
40 {
41 RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity();
42 Intent kbd = new Intent(a, KeyboardActivity.class);
43 kbd.putExtra("value", text);
44 a.waitForActivity(kbd, new HostCallback(){
45
46 @Override
47 public void onComplete(int resultCode, Intent data) {
48 if (resultCode == Activity.RESULT_OK)
49 {
50 result = data.getStringExtra("value");
51 }
52 else {
53 result = "";
54 }
55 }
56 });
57 }
58 public String get_result()
59 {
60 return result;
61 }
62
63 public boolean is_usable()
64 {
65 return RockboxService.get_instance().get_activity() != null;
66 }
67
68
69}
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java
index c403736c72..bbcdfec4a7 100644
--- a/android/src/org/rockbox/RockboxService.java
+++ b/android/src/org/rockbox/RockboxService.java
@@ -35,6 +35,7 @@ import java.util.TimerTask;
35import java.util.zip.ZipEntry; 35import java.util.zip.ZipEntry;
36import java.util.zip.ZipFile; 36import java.util.zip.ZipFile;
37 37
38import android.app.Activity;
38import android.app.Notification; 39import android.app.Notification;
39import android.app.NotificationManager; 40import android.app.NotificationManager;
40import android.app.PendingIntent; 41import android.app.PendingIntent;
@@ -61,6 +62,7 @@ public class RockboxService extends Service
61 /* locals needed for the c code and rockbox state */ 62 /* locals needed for the c code and rockbox state */
62 private RockboxFramebuffer fb = null; 63 private RockboxFramebuffer fb = null;
63 private boolean mRockboxRunning = false; 64 private boolean mRockboxRunning = false;
65 private Activity current_activity = null;
64 66
65 private Notification notification; 67 private Notification notification;
66 private static final Class<?>[] mStartForegroundSignature = 68 private static final Class<?>[] mStartForegroundSignature =
@@ -113,6 +115,16 @@ public class RockboxService extends Service
113 fb = newfb; 115 fb = newfb;
114 mRockboxRunning = true; 116 mRockboxRunning = true;
115 } 117 }
118
119 public Activity get_activity()
120 {
121 return current_activity;
122 }
123 public void set_activity(Activity a)
124 {
125 current_activity = a;
126 }
127
116 128
117 private void do_start(Intent intent) 129 private void do_start(Intent intent)
118 { 130 {