summaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-10-31 13:12:01 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-10-31 13:12:01 +0000
commitb92eabd38b6c06d598e85dcfc6e2244631efa11f (patch)
tree7e234d07b1f0dd9a7a7344400dfa534c46616130 /android
parent1e47628a9f5d51218d2e385b7f85e09dd75df860 (diff)
downloadrockbox-b92eabd38b6c06d598e85dcfc6e2244631efa11f.tar.gz
rockbox-b92eabd38b6c06d598e85dcfc6e2244631efa11f.tar.bz2
rockbox-b92eabd38b6c06d598e85dcfc6e2244631efa11f.zip
Use a native yes/no dialog instead of rockbox's internal one on android
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28415 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android')
-rw-r--r--android/AndroidManifest.xml3
-rw-r--r--android/res/values/strings.xml2
-rw-r--r--android/src/org/rockbox/KeyboardActivity.java1
-rw-r--r--android/src/org/rockbox/RockboxYesno.java73
-rw-r--r--android/src/org/rockbox/YesnoActivity.java37
5 files changed, 115 insertions, 1 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index c52cac2753..c52d83fd2c 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -17,7 +17,8 @@
</activity>
<service android:name=".RockboxService"/>
- <activity android:name="KeyboardActivity" android:launchMode="singleTop"></activity>
+ <activity android:name="KeyboardActivity"></activity>
+ <activity android:name="YesnoActivity"></activity>
</application>
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml
index b0d41f133d..a2762ddd74 100644
--- a/android/res/values/strings.xml
+++ b/android/res/values/strings.xml
@@ -6,4 +6,6 @@
<string name="OK">OK</string>
<string name="Cancel">Cancel</string>
<string name="KbdInputTitle">Rockbox Keyboard Input</string>
+<string name="Yes">Yes</string>
+<string name="No">No</string>
</resources>
diff --git a/android/src/org/rockbox/KeyboardActivity.java b/android/src/org/rockbox/KeyboardActivity.java
index c77f686780..7436031f9d 100644
--- a/android/src/org/rockbox/KeyboardActivity.java
+++ b/android/src/org/rockbox/KeyboardActivity.java
@@ -23,6 +23,7 @@ public class KeyboardActivity extends Activity
.setTitle(R.string.KbdInputTitle)
.setView(addView)
.setIcon(R.drawable.icon)
+ .setCancelable(false)
.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton) {
diff --git a/android/src/org/rockbox/RockboxYesno.java b/android/src/org/rockbox/RockboxYesno.java
new file mode 100644
index 0000000000..fd43fc6ab4
--- /dev/null
+++ b/android/src/org/rockbox/RockboxYesno.java
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Jonathan Gordon
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+package org.rockbox;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.util.Log;
+
+public class RockboxYesno
+{
+ private boolean result;
+ private boolean have_result;
+
+ public RockboxYesno()
+ {
+ have_result = false;
+ }
+
+ public void yesno_display(String text)
+ {
+ RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity();
+ Intent kbd = new Intent(a, YesnoActivity.class);
+ kbd.putExtra("value", text);
+ a.waitForActivity(kbd, new HostCallback()
+ {
+ public void onComplete(int resultCode, Intent data)
+ {
+ if (resultCode == Activity.RESULT_OK)
+ {
+ result = true;
+ have_result = true;
+ }
+ else {
+ result = false;
+ have_result = true;
+ }
+ }
+ });
+ }
+
+ public boolean result_ready()
+ {
+ return have_result;
+ }
+ public boolean get_result()
+ {
+ return result;
+ }
+
+ public boolean is_usable()
+ {
+ return RockboxService.get_instance().get_activity() != null;
+ }
+}
diff --git a/android/src/org/rockbox/YesnoActivity.java b/android/src/org/rockbox/YesnoActivity.java
new file mode 100644
index 0000000000..5a67ec5ff7
--- /dev/null
+++ b/android/src/org/rockbox/YesnoActivity.java
@@ -0,0 +1,37 @@
+package org.rockbox;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.util.Log;
+
+public class YesnoActivity extends Activity
+{
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.KbdInputTitle)
+ .setIcon(R.drawable.icon)
+ .setCancelable(false)
+ .setMessage(getIntent().getStringExtra("value"))
+ .setPositiveButton(R.string.Yes, new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ setResult(RESULT_OK, getIntent());
+ finish();
+ }
+ })
+
+ .setNegativeButton(R.string.No, new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int whichButton)
+ {
+ setResult(RESULT_CANCELED, getIntent());
+ finish();
+ }
+ })
+ .show();
+ }
+}