summaryrefslogtreecommitdiff
path: root/android/src/org/rockbox/RockboxKeyboardInput.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/src/org/rockbox/RockboxKeyboardInput.java')
-rw-r--r--android/src/org/rockbox/RockboxKeyboardInput.java58
1 files changed, 41 insertions, 17 deletions
diff --git a/android/src/org/rockbox/RockboxKeyboardInput.java b/android/src/org/rockbox/RockboxKeyboardInput.java
index 210cbbd258..b7dd812f35 100644
--- a/android/src/org/rockbox/RockboxKeyboardInput.java
+++ b/android/src/org/rockbox/RockboxKeyboardInput.java
@@ -23,33 +23,57 @@ package org.rockbox;
23 23
24 24
25import android.app.Activity; 25import android.app.Activity;
26import android.content.Intent; 26import android.app.AlertDialog;
27import android.app.Dialog;
28import android.content.DialogInterface;
29import android.text.Editable;
30import android.view.LayoutInflater;
31import android.view.View;
32import android.widget.EditText;
27 33
28public class RockboxKeyboardInput 34public class RockboxKeyboardInput
29{ 35{
30 private String result; 36 public void kbd_input(final String text)
31
32 public RockboxKeyboardInput()
33 { 37 {
34 result = null; 38 final Activity c = RockboxService.get_instance().get_activity();
35 }
36 39
37 public void kbd_input(String text) 40 c.runOnUiThread(new Runnable() {
38 { 41 @Override
39 RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity(); 42 public void run()
40 Intent kbd = new Intent(a, KeyboardActivity.class);
41 kbd.putExtra("value", text);
42 a.waitForActivity(kbd, new HostCallback()
43 {
44 public void onComplete(int resultCode, Intent data)
45 { 43 {
46 put_result(resultCode == Activity.RESULT_OK, 44 LayoutInflater inflater = LayoutInflater.from(c);
47 data.getStringExtra("value")); 45 View addView = inflater.inflate(R.layout.keyboardinput, null);
46 EditText input = (EditText) addView.findViewById(R.id.KbdInput);
47 input.setText(text);
48 new AlertDialog.Builder(c)
49 .setTitle(R.string.KbdInputTitle)
50 .setView(addView)
51 .setIcon(R.drawable.icon)
52 .setCancelable(false)
53 .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener()
54 {
55 public void onClick(DialogInterface dialog, int whichButton) {
56 EditText input = (EditText)((Dialog)dialog)
57 .findViewById(R.id.KbdInput);
58 Editable s = input.getText();
59 put_result(true, s.toString());
60 }
61 })
62 .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener()
63 {
64 public void onClick(DialogInterface dialog, int whichButton)
65 {
66 put_result(false, "");
67 }
68 })
69 .show();
48 } 70 }
49 }); 71 });
50 } 72 }
51 73
52 private native void put_result(boolean accepted, String new_string); 74 private native void put_result(boolean accepted, String new_string);
75
76 @SuppressWarnings("unused")
53 public boolean is_usable() 77 public boolean is_usable()
54 { 78 {
55 return RockboxService.get_instance().get_activity() != null; 79 return RockboxService.get_instance().get_activity() != null;