forked from len0rd/rockbox
Android: greatly simplify Android YesNo and KeyboardInput widgets
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28513 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
988bdc1cc4
commit
c31a2f3bbb
7 changed files with 69 additions and 144 deletions
|
@ -22,21 +22,40 @@
|
|||
package org.rockbox;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
public class RockboxYesno
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
private void yesno_display(String text)
|
||||
private void yesno_display(final 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)
|
||||
final Activity c = RockboxService.get_instance().get_activity();
|
||||
|
||||
c.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
put_result(resultCode == Activity.RESULT_OK);
|
||||
new AlertDialog.Builder(c)
|
||||
.setTitle(R.string.KbdInputTitle)
|
||||
.setIcon(R.drawable.icon)
|
||||
.setCancelable(false)
|
||||
.setMessage(text)
|
||||
.setPositiveButton(R.string.Yes, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int whichButton)
|
||||
{
|
||||
put_result(true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.No, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int whichButton)
|
||||
{
|
||||
put_result(false);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue