forked from len0rd/rockbox
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
This commit is contained in:
parent
93640fc228
commit
739d76cfda
4 changed files with 31 additions and 15 deletions
|
@ -33,12 +33,11 @@ import android.widget.EditText;
|
||||||
|
|
||||||
public class RockboxKeyboardInput
|
public class RockboxKeyboardInput
|
||||||
{
|
{
|
||||||
public void kbd_input(final String text)
|
public void kbd_input(final String text, final String ok, final String cancel)
|
||||||
{
|
{
|
||||||
final Activity c = RockboxService.get_instance().get_activity();
|
final Activity c = RockboxService.get_instance().get_activity();
|
||||||
|
|
||||||
c.runOnUiThread(new Runnable() {
|
c.runOnUiThread(new Runnable() {
|
||||||
@Override
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
LayoutInflater inflater = LayoutInflater.from(c);
|
LayoutInflater inflater = LayoutInflater.from(c);
|
||||||
|
@ -50,7 +49,7 @@ public class RockboxKeyboardInput
|
||||||
.setView(addView)
|
.setView(addView)
|
||||||
.setIcon(R.drawable.icon)
|
.setIcon(R.drawable.icon)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener()
|
.setPositiveButton(ok, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
EditText input = (EditText)((Dialog)dialog)
|
EditText input = (EditText)((Dialog)dialog)
|
||||||
|
@ -59,7 +58,7 @@ public class RockboxKeyboardInput
|
||||||
put_result(true, s.toString());
|
put_result(true, s.toString());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener()
|
.setNegativeButton(cancel, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
public void onClick(DialogInterface dialog, int whichButton)
|
public void onClick(DialogInterface dialog, int whichButton)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,12 +28,11 @@ import android.content.DialogInterface;
|
||||||
public class RockboxYesno
|
public class RockboxYesno
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private void yesno_display(final String text)
|
private void yesno_display(final String text, final String yes, final String no)
|
||||||
{
|
{
|
||||||
final Activity c = RockboxService.get_instance().get_activity();
|
final Activity c = RockboxService.get_instance().get_activity();
|
||||||
|
|
||||||
c.runOnUiThread(new Runnable() {
|
c.runOnUiThread(new Runnable() {
|
||||||
@Override
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
new AlertDialog.Builder(c)
|
new AlertDialog.Builder(c)
|
||||||
|
@ -41,14 +40,14 @@ public class RockboxYesno
|
||||||
.setIcon(R.drawable.icon)
|
.setIcon(R.drawable.icon)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setMessage(text)
|
.setMessage(text)
|
||||||
.setPositiveButton(R.string.Yes, new DialogInterface.OnClickListener()
|
.setPositiveButton(yes, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
public void onClick(DialogInterface dialog, int whichButton)
|
public void onClick(DialogInterface dialog, int whichButton)
|
||||||
{
|
{
|
||||||
put_result(true);
|
put_result(true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.No, new DialogInterface.OnClickListener()
|
.setNegativeButton(no, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
public void onClick(DialogInterface dialog, int whichButton)
|
public void onClick(DialogInterface dialog, int whichButton)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "string-extra.h"
|
#include "string-extra.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "lang.h"
|
||||||
|
|
||||||
extern JNIEnv *env_ptr;
|
extern JNIEnv *env_ptr;
|
||||||
static jclass RockboxKeyboardInput_class;
|
static jclass RockboxKeyboardInput_class;
|
||||||
|
@ -67,7 +68,10 @@ static void kdb_init(void)
|
||||||
RockboxKeyboardInput_class,
|
RockboxKeyboardInput_class,
|
||||||
constructor);
|
constructor);
|
||||||
kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
||||||
"kbd_input", "(Ljava/lang/String;)V");
|
"kbd_input",
|
||||||
|
"(Ljava/lang/String;"
|
||||||
|
"Ljava/lang/String;"
|
||||||
|
"Ljava/lang/String;)V");
|
||||||
kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
||||||
"is_usable", "()Z");
|
"is_usable", "()Z");
|
||||||
}
|
}
|
||||||
|
@ -80,12 +84,15 @@ static void kdb_init(void)
|
||||||
|
|
||||||
int kbd_input(char* text, int buflen)
|
int kbd_input(char* text, int buflen)
|
||||||
{
|
{
|
||||||
JNIEnv e = *env_ptr;
|
JNIEnv e = *env_ptr;
|
||||||
jstring str = e->NewStringUTF(env_ptr, text);
|
jstring str = e->NewStringUTF(env_ptr, text);
|
||||||
|
jstring ok_text = e->NewStringUTF(env_ptr, str(LANG_KBD_OK));
|
||||||
|
jstring cancel_text = e->NewStringUTF(env_ptr, str(LANG_KBD_CANCEL));
|
||||||
const char *utf8_string;
|
const char *utf8_string;
|
||||||
kdb_init();
|
kdb_init();
|
||||||
|
|
||||||
e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance,kbd_inputfunc,str);
|
e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance,kbd_inputfunc,
|
||||||
|
str, ok_text, cancel_text);
|
||||||
|
|
||||||
wakeup_wait(&kbd_wakeup, TIMEOUT_BLOCK);
|
wakeup_wait(&kbd_wakeup, TIMEOUT_BLOCK);
|
||||||
|
|
||||||
|
@ -96,6 +103,9 @@ int kbd_input(char* text, int buflen)
|
||||||
e->ReleaseStringUTFChars(env_ptr, new_string, utf8_string);
|
e->ReleaseStringUTFChars(env_ptr, new_string, utf8_string);
|
||||||
e->DeleteGlobalRef(env_ptr, new_string);
|
e->DeleteGlobalRef(env_ptr, new_string);
|
||||||
}
|
}
|
||||||
|
e->DeleteGlobalRef(env_ptr, str);
|
||||||
|
e->DeleteGlobalRef(env_ptr, ok_text);
|
||||||
|
e->DeleteGlobalRef(env_ptr, cancel_text);
|
||||||
|
|
||||||
return !accepted; /* return 0 on success */
|
return !accepted; /* return 0 on success */
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,10 @@ static void yesno_init(void)
|
||||||
RockboxYesno_class,
|
RockboxYesno_class,
|
||||||
constructor);
|
constructor);
|
||||||
yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class,
|
yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class,
|
||||||
"yesno_display", "(Ljava/lang/String;)V");
|
"yesno_display",
|
||||||
|
"(Ljava/lang/String;"
|
||||||
|
"Ljava/lang/String;"
|
||||||
|
"Ljava/lang/String;)V");
|
||||||
yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class,
|
yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class,
|
||||||
"is_usable", "()Z");
|
"is_usable", "()Z");
|
||||||
}
|
}
|
||||||
|
@ -100,12 +103,17 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
|
||||||
|
|
||||||
JNIEnv e = *env_ptr;
|
JNIEnv e = *env_ptr;
|
||||||
jstring message = build_message(main_message);
|
jstring message = build_message(main_message);
|
||||||
|
jstring yes = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_YES));
|
||||||
e->CallVoidMethod(env_ptr, RockboxYesno_instance, yesno_func, message);
|
jstring no = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_NO));
|
||||||
|
|
||||||
|
e->CallVoidMethod(env_ptr, RockboxYesno_instance, yesno_func,
|
||||||
|
message, yes, no);
|
||||||
|
|
||||||
wakeup_wait(&yesno_wakeup, TIMEOUT_BLOCK);
|
wakeup_wait(&yesno_wakeup, TIMEOUT_BLOCK);
|
||||||
|
|
||||||
e->DeleteLocalRef(env_ptr, message);
|
e->DeleteLocalRef(env_ptr, message);
|
||||||
|
e->DeleteLocalRef(env_ptr, yes);
|
||||||
|
e->DeleteLocalRef(env_ptr, no);
|
||||||
|
|
||||||
return ret ? YESNO_YES : YESNO_NO;
|
return ret ? YESNO_YES : YESNO_NO;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue