forked from len0rd/rockbox
Clean up r28408 coding style a bit to follow our guidelines with regard to
brace placement, tabs and 80 char line width. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28410 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
cc758e42b9
commit
2d05d2f9da
5 changed files with 78 additions and 69 deletions
|
@ -2,6 +2,7 @@ package org.rockbox;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
public interface HostCallback {
|
public interface HostCallback
|
||||||
|
{
|
||||||
public void onComplete(int resultCode, Intent data);
|
public void onComplete(int resultCode, Intent data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,10 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
public class KeyboardActivity extends Activity {
|
public class KeyboardActivity extends Activity
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
{
|
||||||
|
public void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
LayoutInflater inflater=LayoutInflater.from(this);
|
LayoutInflater inflater=LayoutInflater.from(this);
|
||||||
View addView=inflater.inflate(R.layout.keyboardinput, null);
|
View addView=inflater.inflate(R.layout.keyboardinput, null);
|
||||||
|
@ -21,17 +23,22 @@ public class KeyboardActivity extends Activity {
|
||||||
.setTitle(R.string.KbdInputTitle)
|
.setTitle(R.string.KbdInputTitle)
|
||||||
.setView(addView)
|
.setView(addView)
|
||||||
.setIcon(R.drawable.icon)
|
.setIcon(R.drawable.icon)
|
||||||
.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
EditText input = (EditText)((Dialog)dialog).findViewById(R.id.KbdInput);
|
EditText input = (EditText)((Dialog)dialog)
|
||||||
|
.findViewById(R.id.KbdInput);
|
||||||
Editable s = input.getText();
|
Editable s = input.getText();
|
||||||
getIntent().putExtra("value", s.toString());
|
getIntent().putExtra("value", s.toString());
|
||||||
setResult(RESULT_OK, getIntent());
|
setResult(RESULT_OK, getIntent());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
public void onClick(DialogInterface dialog, int whichButton)
|
||||||
|
{
|
||||||
setResult(RESULT_CANCELED, getIntent());
|
setResult(RESULT_CANCELED, getIntent());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ package org.rockbox;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
|
@ -22,13 +22,10 @@
|
||||||
package org.rockbox;
|
package org.rockbox;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class RockboxKeyboardInput
|
public class RockboxKeyboardInput
|
||||||
{
|
{
|
||||||
private BroadcastReceiver b;
|
|
||||||
private String result;
|
private String result;
|
||||||
|
|
||||||
public RockboxKeyboardInput()
|
public RockboxKeyboardInput()
|
||||||
|
@ -41,10 +38,10 @@ public class RockboxKeyboardInput
|
||||||
RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity();
|
RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity();
|
||||||
Intent kbd = new Intent(a, KeyboardActivity.class);
|
Intent kbd = new Intent(a, KeyboardActivity.class);
|
||||||
kbd.putExtra("value", text);
|
kbd.putExtra("value", text);
|
||||||
a.waitForActivity(kbd, new HostCallback(){
|
a.waitForActivity(kbd, new HostCallback()
|
||||||
|
{
|
||||||
@Override
|
public void onComplete(int resultCode, Intent data)
|
||||||
public void onComplete(int resultCode, Intent data) {
|
{
|
||||||
if (resultCode == Activity.RESULT_OK)
|
if (resultCode == Activity.RESULT_OK)
|
||||||
{
|
{
|
||||||
result = data.getStringExtra("value");
|
result = data.getStringExtra("value");
|
||||||
|
@ -64,6 +61,4 @@ public class RockboxKeyboardInput
|
||||||
{
|
{
|
||||||
return RockboxService.get_instance().get_activity() != null;
|
return RockboxService.get_instance().get_activity() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
|
|
||||||
extern JNIEnv *env_ptr;
|
extern JNIEnv *env_ptr;
|
||||||
static jclass RockboxKeyboardInput_class = NULL;
|
static jclass RockboxKeyboardInput_class;
|
||||||
static jobject RockboxKeyboardInput_instance;
|
static jobject RockboxKeyboardInput_instance;
|
||||||
static jmethodID kbd_inputfunc, kbd_result;
|
static jmethodID kbd_inputfunc, kbd_result;
|
||||||
|
|
||||||
|
@ -38,9 +38,14 @@ static void kdb_init(void)
|
||||||
if (RockboxKeyboardInput_class == NULL)
|
if (RockboxKeyboardInput_class == NULL)
|
||||||
{
|
{
|
||||||
/* get the class and its constructor */
|
/* get the class and its constructor */
|
||||||
RockboxKeyboardInput_class = e->FindClass(env_ptr, "org/rockbox/RockboxKeyboardInput");
|
RockboxKeyboardInput_class = e->FindClass(env_ptr,
|
||||||
jmethodID constructor = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, "<init>", "()V");
|
"org/rockbox/RockboxKeyboardInput");
|
||||||
RockboxKeyboardInput_instance = e->NewObject(env_ptr, RockboxKeyboardInput_class, constructor);
|
jmethodID constructor = e->GetMethodID(env_ptr,
|
||||||
|
RockboxKeyboardInput_class,
|
||||||
|
"<init>", "()V");
|
||||||
|
RockboxKeyboardInput_instance = e->NewObject(env_ptr,
|
||||||
|
RockboxKeyboardInput_class,
|
||||||
|
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;)V");
|
||||||
kbd_result = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
kbd_result = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
||||||
|
@ -49,7 +54,8 @@ static void kdb_init(void)
|
||||||
/* need to get it every time incase the activity died/restarted */
|
/* need to get it every time incase the activity died/restarted */
|
||||||
kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
|
||||||
"is_usable", "()Z");
|
"is_usable", "()Z");
|
||||||
while (!e->CallBooleanMethod(env_ptr, RockboxKeyboardInput_instance, kbd_is_usable))
|
while (!e->CallBooleanMethod(env_ptr, RockboxKeyboardInput_instance,
|
||||||
|
kbd_is_usable))
|
||||||
sleep(HZ/10);
|
sleep(HZ/10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +67,12 @@ int kbd_input(char* text, int buflen)
|
||||||
const char* retchars;
|
const char* retchars;
|
||||||
kdb_init();
|
kdb_init();
|
||||||
|
|
||||||
e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance, kbd_inputfunc, str);
|
e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance,kbd_inputfunc,str);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sleep(HZ/10);
|
sleep(HZ/10);
|
||||||
ret = e->CallObjectMethod(env_ptr, RockboxKeyboardInput_instance, kbd_result);
|
ret = e->CallObjectMethod(env_ptr, RockboxKeyboardInput_instance,
|
||||||
|
kbd_result);
|
||||||
} while (!ret);
|
} while (!ret);
|
||||||
|
|
||||||
e->ReleaseStringUTFChars(env_ptr, str, NULL);
|
e->ReleaseStringUTFChars(env_ptr, str, NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue