1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Jonathan Gordon
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 import android
.app
.Activity
;
26 import android
.app
.AlertDialog
;
27 import android
.app
.Dialog
;
28 import android
.content
.DialogInterface
;
29 import android
.text
.Editable
;
30 import android
.view
.LayoutInflater
;
31 import android
.view
.View
;
32 import android
.widget
.EditText
;
34 public class RockboxKeyboardInput
36 public void kbd_input(final String text
, final String ok
, final String cancel
)
38 final Activity c
= RockboxService
.get_instance().get_activity();
40 c
.runOnUiThread(new Runnable() {
43 LayoutInflater inflater
= LayoutInflater
.from(c
);
44 View addView
= inflater
.inflate(R
.layout
.keyboardinput
, null);
45 EditText input
= (EditText
) addView
.findViewById(R
.id
.KbdInput
);
47 new AlertDialog
.Builder(c
)
48 .setTitle(R
.string
.KbdInputTitle
)
50 .setIcon(R
.drawable
.icon
)
52 .setPositiveButton(ok
, new DialogInterface
.OnClickListener()
54 public void onClick(DialogInterface dialog
, int whichButton
) {
55 EditText input
= (EditText
)((Dialog
)dialog
)
56 .findViewById(R
.id
.KbdInput
);
57 Editable s
= input
.getText();
58 put_result(true, s
.toString());
61 .setNegativeButton(cancel
, new DialogInterface
.OnClickListener()
63 public void onClick(DialogInterface dialog
, int whichButton
)
65 put_result(false, "");
73 private native void put_result(boolean accepted
, String new_string
);
75 @SuppressWarnings("unused")
76 public boolean is_usable()
78 return RockboxService
.get_instance().get_activity() != null;