diff options
-rw-r--r-- | android/AndroidManifest.xml | 8 | ||||
-rw-r--r-- | android/src/org/rockbox/HostCallback.java | 8 | ||||
-rw-r--r-- | android/src/org/rockbox/KeyboardActivity.java | 49 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxActivity.java | 17 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxKeyboardInput.java | 58 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxYesno.java | 37 | ||||
-rw-r--r-- | android/src/org/rockbox/YesnoActivity.java | 36 |
7 files changed, 69 insertions, 144 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index a05f382584..e0fc106ca7 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -19,14 +19,6 @@ </intent-filter> </activity> - <activity android:name="KeyboardActivity" - android:theme="@android:style/Theme.Dialog"> - </activity> - - <activity android:name="YesnoActivity" - android:theme="@android:style/Theme.Dialog"> - </activity> - <service android:name=".RockboxService"/> <receiver android:name=".Helper.MediaButtonReceiver$MediaReceiver" diff --git a/android/src/org/rockbox/HostCallback.java b/android/src/org/rockbox/HostCallback.java deleted file mode 100644 index 8584fedd6a..0000000000 --- a/android/src/org/rockbox/HostCallback.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.rockbox; - -import android.content.Intent; - -public interface HostCallback -{ - public void onComplete(int resultCode, Intent data); -} diff --git a/android/src/org/rockbox/KeyboardActivity.java b/android/src/org/rockbox/KeyboardActivity.java deleted file mode 100644 index 7436031f9d..0000000000 --- a/android/src/org/rockbox/KeyboardActivity.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.rockbox; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.DialogInterface; -import android.os.Bundle; -import android.text.Editable; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.EditText; - -public class KeyboardActivity extends Activity -{ - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - LayoutInflater inflater=LayoutInflater.from(this); - View addView=inflater.inflate(R.layout.keyboardinput, null); - EditText input = (EditText) addView.findViewById(R.id.KbdInput); - input.setText(getIntent().getStringExtra("value")); - new AlertDialog.Builder(this) - .setTitle(R.string.KbdInputTitle) - .setView(addView) - .setIcon(R.drawable.icon) - .setCancelable(false) - .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton) { - EditText input = (EditText)((Dialog)dialog) - .findViewById(R.id.KbdInput); - Editable s = input.getText(); - getIntent().putExtra("value", s.toString()); - setResult(RESULT_OK, getIntent()); - finish(); - } - }) - - .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton) - { - setResult(RESULT_CANCELED, getIntent()); - finish(); - } - }) - .show(); - } -} diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java index c9681e306c..f5c658871f 100644 --- a/android/src/org/rockbox/RockboxActivity.java +++ b/android/src/org/rockbox/RockboxActivity.java @@ -145,23 +145,6 @@ public class RockboxActivity extends Activity super.onDestroy(); rbservice.set_activity(null); } - - private HostCallback hostcallback = null; - public void waitForActivity(Intent i, HostCallback callback) - { - if (hostcallback != null) - { - LOG("Something has gone wrong"); - } - hostcallback = callback; - startActivityForResult(i, 0); - } - - public void onActivityResult(int requestCode, int resultCode, Intent data) - { - hostcallback.onComplete(resultCode, data); - hostcallback = null; - } private void LOG(CharSequence text) { 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; import android.app.Activity; -import android.content.Intent; +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.text.Editable; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; public class RockboxKeyboardInput { - private String result; - - public RockboxKeyboardInput() + public void kbd_input(final String text) { - result = null; - } + final Activity c = RockboxService.get_instance().get_activity(); - public void kbd_input(String text) - { - RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity(); - Intent kbd = new Intent(a, KeyboardActivity.class); - kbd.putExtra("value", text); - a.waitForActivity(kbd, new HostCallback() - { - public void onComplete(int resultCode, Intent data) + c.runOnUiThread(new Runnable() { + @Override + public void run() { - put_result(resultCode == Activity.RESULT_OK, - data.getStringExtra("value")); + LayoutInflater inflater = LayoutInflater.from(c); + View addView = inflater.inflate(R.layout.keyboardinput, null); + EditText input = (EditText) addView.findViewById(R.id.KbdInput); + input.setText(text); + new AlertDialog.Builder(c) + .setTitle(R.string.KbdInputTitle) + .setView(addView) + .setIcon(R.drawable.icon) + .setCancelable(false) + .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int whichButton) { + EditText input = (EditText)((Dialog)dialog) + .findViewById(R.id.KbdInput); + Editable s = input.getText(); + put_result(true, s.toString()); + } + }) + .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int whichButton) + { + put_result(false, ""); + } + }) + .show(); } }); } - + private native void put_result(boolean accepted, String new_string); + + @SuppressWarnings("unused") public boolean is_usable() { return RockboxService.get_instance().get_activity() != null; diff --git a/android/src/org/rockbox/RockboxYesno.java b/android/src/org/rockbox/RockboxYesno.java index aa5e83d749..9481d69d01 100644 --- a/android/src/org/rockbox/RockboxYesno.java +++ b/android/src/org/rockbox/RockboxYesno.java @@ -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(); } }); } diff --git a/android/src/org/rockbox/YesnoActivity.java b/android/src/org/rockbox/YesnoActivity.java deleted file mode 100644 index 35e064fef5..0000000000 --- a/android/src/org/rockbox/YesnoActivity.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.rockbox; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.os.Bundle; - -public class YesnoActivity extends Activity -{ - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - new AlertDialog.Builder(this) - .setTitle(R.string.KbdInputTitle) - .setIcon(R.drawable.icon) - .setCancelable(false) - .setMessage(getIntent().getStringExtra("value")) - .setPositiveButton(R.string.Yes, new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton) { - setResult(RESULT_OK, getIntent()); - finish(); - } - }) - - .setNegativeButton(R.string.No, new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton) - { - setResult(RESULT_CANCELED, getIntent()); - finish(); - } - }) - .show(); - } -} |