summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-11-06 01:40:24 +0000
committerThomas Martitz <kugel@rockbox.org>2010-11-06 01:40:24 +0000
commit739d76cfda5793256e849acd082d90f1e09c9494 (patch)
tree4fb4f027e296040fcd8e36722709f7762285c2d3
parent93640fc22847e70f0070061ed1effc5d063dd600 (diff)
downloadrockbox-739d76cfda5793256e849acd082d90f1e09c9494.tar.gz
rockbox-739d76cfda5793256e849acd082d90f1e09c9494.zip
Android: Use our translations for the yes/no/ok/cancel buttons in the yesno and keyboard dialog.
Second part of FS#11708. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28515 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--android/src/org/rockbox/RockboxKeyboardInput.java7
-rw-r--r--android/src/org/rockbox/RockboxYesno.java7
-rw-r--r--apps/hosted/keyboard.c18
-rw-r--r--apps/hosted/yesno.c14
4 files changed, 31 insertions, 15 deletions
diff --git a/android/src/org/rockbox/RockboxKeyboardInput.java b/android/src/org/rockbox/RockboxKeyboardInput.java
index b7dd812f35..9cb5683a57 100644
--- a/android/src/org/rockbox/RockboxKeyboardInput.java
+++ b/android/src/org/rockbox/RockboxKeyboardInput.java
@@ -33,12 +33,11 @@ import android.widget.EditText;
33 33
34public class RockboxKeyboardInput 34public class RockboxKeyboardInput
35{ 35{
36 public void kbd_input(final String text) 36 public void kbd_input(final String text, final String ok, final String cancel)
37 { 37 {
38 final Activity c = RockboxService.get_instance().get_activity(); 38 final Activity c = RockboxService.get_instance().get_activity();
39 39
40 c.runOnUiThread(new Runnable() { 40 c.runOnUiThread(new Runnable() {
41 @Override
42 public void run() 41 public void run()
43 { 42 {
44 LayoutInflater inflater = LayoutInflater.from(c); 43 LayoutInflater inflater = LayoutInflater.from(c);
@@ -50,7 +49,7 @@ public class RockboxKeyboardInput
50 .setView(addView) 49 .setView(addView)
51 .setIcon(R.drawable.icon) 50 .setIcon(R.drawable.icon)
52 .setCancelable(false) 51 .setCancelable(false)
53 .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() 52 .setPositiveButton(ok, new DialogInterface.OnClickListener()
54 { 53 {
55 public void onClick(DialogInterface dialog, int whichButton) { 54 public void onClick(DialogInterface dialog, int whichButton) {
56 EditText input = (EditText)((Dialog)dialog) 55 EditText input = (EditText)((Dialog)dialog)
@@ -59,7 +58,7 @@ public class RockboxKeyboardInput
59 put_result(true, s.toString()); 58 put_result(true, s.toString());
60 } 59 }
61 }) 60 })
62 .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() 61 .setNegativeButton(cancel, new DialogInterface.OnClickListener()
63 { 62 {
64 public void onClick(DialogInterface dialog, int whichButton) 63 public void onClick(DialogInterface dialog, int whichButton)
65 { 64 {
diff --git a/android/src/org/rockbox/RockboxYesno.java b/android/src/org/rockbox/RockboxYesno.java
index 9481d69d01..df8c54b7d9 100644
--- a/android/src/org/rockbox/RockboxYesno.java
+++ b/android/src/org/rockbox/RockboxYesno.java
@@ -28,12 +28,11 @@ import android.content.DialogInterface;
28public class RockboxYesno 28public class RockboxYesno
29{ 29{
30 @SuppressWarnings("unused") 30 @SuppressWarnings("unused")
31 private void yesno_display(final String text) 31 private void yesno_display(final String text, final String yes, final String no)
32 { 32 {
33 final Activity c = RockboxService.get_instance().get_activity(); 33 final Activity c = RockboxService.get_instance().get_activity();
34 34
35 c.runOnUiThread(new Runnable() { 35 c.runOnUiThread(new Runnable() {
36 @Override
37 public void run() 36 public void run()
38 { 37 {
39 new AlertDialog.Builder(c) 38 new AlertDialog.Builder(c)
@@ -41,14 +40,14 @@ public class RockboxYesno
41 .setIcon(R.drawable.icon) 40 .setIcon(R.drawable.icon)
42 .setCancelable(false) 41 .setCancelable(false)
43 .setMessage(text) 42 .setMessage(text)
44 .setPositiveButton(R.string.Yes, new DialogInterface.OnClickListener() 43 .setPositiveButton(yes, new DialogInterface.OnClickListener()
45 { 44 {
46 public void onClick(DialogInterface dialog, int whichButton) 45 public void onClick(DialogInterface dialog, int whichButton)
47 { 46 {
48 put_result(true); 47 put_result(true);
49 } 48 }
50 }) 49 })
51 .setNegativeButton(R.string.No, new DialogInterface.OnClickListener() 50 .setNegativeButton(no, new DialogInterface.OnClickListener()
52 { 51 {
53 public void onClick(DialogInterface dialog, int whichButton) 52 public void onClick(DialogInterface dialog, int whichButton)
54 { 53 {
diff --git a/apps/hosted/keyboard.c b/apps/hosted/keyboard.c
index 6cc14d654f..ab461cf52d 100644
--- a/apps/hosted/keyboard.c
+++ b/apps/hosted/keyboard.c
@@ -25,6 +25,7 @@
25#include <stdbool.h> 25#include <stdbool.h>
26#include "string-extra.h" 26#include "string-extra.h"
27#include "kernel.h" 27#include "kernel.h"
28#include "lang.h"
28 29
29extern JNIEnv *env_ptr; 30extern JNIEnv *env_ptr;
30static jclass RockboxKeyboardInput_class; 31static jclass RockboxKeyboardInput_class;
@@ -67,7 +68,10 @@ static void kdb_init(void)
67 RockboxKeyboardInput_class, 68 RockboxKeyboardInput_class,
68 constructor); 69 constructor);
69 kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, 70 kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
70 "kbd_input", "(Ljava/lang/String;)V"); 71 "kbd_input",
72 "(Ljava/lang/String;"
73 "Ljava/lang/String;"
74 "Ljava/lang/String;)V");
71 kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, 75 kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
72 "is_usable", "()Z"); 76 "is_usable", "()Z");
73 } 77 }
@@ -80,12 +84,15 @@ static void kdb_init(void)
80 84
81int kbd_input(char* text, int buflen) 85int kbd_input(char* text, int buflen)
82{ 86{
83 JNIEnv e = *env_ptr; 87 JNIEnv e = *env_ptr;
84 jstring str = e->NewStringUTF(env_ptr, text); 88 jstring str = e->NewStringUTF(env_ptr, text);
89 jstring ok_text = e->NewStringUTF(env_ptr, str(LANG_KBD_OK));
90 jstring cancel_text = e->NewStringUTF(env_ptr, str(LANG_KBD_CANCEL));
85 const char *utf8_string; 91 const char *utf8_string;
86 kdb_init(); 92 kdb_init();
87 93
88 e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance,kbd_inputfunc,str); 94 e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance,kbd_inputfunc,
95 str, ok_text, cancel_text);
89 96
90 wakeup_wait(&kbd_wakeup, TIMEOUT_BLOCK); 97 wakeup_wait(&kbd_wakeup, TIMEOUT_BLOCK);
91 98
@@ -96,6 +103,9 @@ int kbd_input(char* text, int buflen)
96 e->ReleaseStringUTFChars(env_ptr, new_string, utf8_string); 103 e->ReleaseStringUTFChars(env_ptr, new_string, utf8_string);
97 e->DeleteGlobalRef(env_ptr, new_string); 104 e->DeleteGlobalRef(env_ptr, new_string);
98 } 105 }
106 e->DeleteGlobalRef(env_ptr, str);
107 e->DeleteGlobalRef(env_ptr, ok_text);
108 e->DeleteGlobalRef(env_ptr, cancel_text);
99 109
100 return !accepted; /* return 0 on success */ 110 return !accepted; /* return 0 on success */
101} 111}
diff --git a/apps/hosted/yesno.c b/apps/hosted/yesno.c
index 2a8c02edd5..d00cb063af 100644
--- a/apps/hosted/yesno.c
+++ b/apps/hosted/yesno.c
@@ -62,7 +62,10 @@ static void yesno_init(void)
62 RockboxYesno_class, 62 RockboxYesno_class,
63 constructor); 63 constructor);
64 yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class, 64 yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class,
65 "yesno_display", "(Ljava/lang/String;)V"); 65 "yesno_display",
66 "(Ljava/lang/String;"
67 "Ljava/lang/String;"
68 "Ljava/lang/String;)V");
66 yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class, 69 yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class,
67 "is_usable", "()Z"); 70 "is_usable", "()Z");
68 } 71 }
@@ -100,12 +103,17 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
100 103
101 JNIEnv e = *env_ptr; 104 JNIEnv e = *env_ptr;
102 jstring message = build_message(main_message); 105 jstring message = build_message(main_message);
103 106 jstring yes = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_YES));
104 e->CallVoidMethod(env_ptr, RockboxYesno_instance, yesno_func, message); 107 jstring no = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_NO));
108
109 e->CallVoidMethod(env_ptr, RockboxYesno_instance, yesno_func,
110 message, yes, no);
105 111
106 wakeup_wait(&yesno_wakeup, TIMEOUT_BLOCK); 112 wakeup_wait(&yesno_wakeup, TIMEOUT_BLOCK);
107 113
108 e->DeleteLocalRef(env_ptr, message); 114 e->DeleteLocalRef(env_ptr, message);
115 e->DeleteLocalRef(env_ptr, yes);
116 e->DeleteLocalRef(env_ptr, no);
109 117
110 return ret ? YESNO_YES : YESNO_NO; 118 return ret ? YESNO_YES : YESNO_NO;
111} 119}