Unverified Commit eda075ad authored by ColinTree's avatar ColinTree Committed by Jeffrey I. Schiller

Implement ChoosingCanceled and TextInputCanceled

Signal an event when the cancel button is used in ShowTextDialog and
ShowChooseDialog. Implement issue #877

Change-Id: I817e1b8d4e08aa6b69968baca96d3741fd852e6b
parent 1bd4ff3b
......@@ -4561,6 +4561,14 @@ public interface OdeMessages extends Messages {
@Description("")
String AfterTextInputEvents();
@DefaultMessage("ChoosingCanceled")
@Description("")
String ChoosingCanceledEvents();
@DefaultMessage("TextInputCanceled")
@Description("")
String TextInputCanceledEvents();
@DefaultMessage("AboveRange")
@Description("")
String AboveRangeEvents();
......
......@@ -851,6 +851,8 @@ LocationChangedEvents = 位置被更改
StatusChangedEvents = 状态被改变
AfterChoosingEvents = 选择完成
AfterTextInputEvents = 输入完成
ChoosingCanceledEvents = 选择取消
TextInputCanceledEvents = 输入取消
AboveRangeEvents = 超出上限
BelowRangeEvents = 超出下限
ColorChangedEvents = 颜色被改变
......
......@@ -1349,6 +1349,10 @@ public final class YoungAndroidFormUpgrader {
// dismiss the dialog was also added.
srcCompVersion = 4;
}
if (srcCompVersion < 5) {
// Added TextInputCanceled & ChoosingCanceled event
srcCompVersion = 5;
}
return srcCompVersion;
}
......
......@@ -1894,7 +1894,10 @@ Blockly.Versioning.AllUpgradeMaps =
// Added a ProgressDialog, a dialog that cannot be dismissed by the user.
// The ShowProgressDialog will show the dialog, and DismissProgressDialog is the only way to dismiss it
4: "noUpgrade"
4: "noUpgrade",
// Added TextInputCanceled & ChoosingCanceled event
5: "noUpgrade"
}, // End Notifier upgraders
......
......@@ -423,8 +423,10 @@ public class YaVersion {
// - FORM_COMPONENT_VERSION was incremented to 23
// For YOUNG_ANDROID_VERSION 168:
// - BLOCKS_LANGUAGE_VERSION was incremented to 22
// For YOUNG_ANDROID_VERSION 169:
// - NOTIFIER_COMPONENT_VERSION was incremented to 5
public static final int YOUNG_ANDROID_VERSION = 168;
public static final int YOUNG_ANDROID_VERSION = 169;
// ............................... Blocks Language Version Number ...............................
......@@ -871,7 +873,9 @@ public class YaVersion {
// - Added NotifierColor, TextColor and NotifierLength options
// For NOTIFIER_COMPONENT_VERSION 4:
// - Added a ShowProgressDialog method, and a DismissProgressDialog method
public static final int NOTIFIER_COMPONENT_VERSION = 4;
// For NOTIFIER_COMPONENT_VERSION 5:
// - Added TextInputCanceled & ChoosingCanceled event
public static final int NOTIFIER_COMPONENT_VERSION = 5;
public static final int NXT_COLORSENSOR_COMPONENT_VERSION = 1;
......
......@@ -217,7 +217,12 @@ public final class Notifier extends AndroidNonvisibleComponent implements Compon
cancelable,
new Runnable() {public void run() {AfterChoosing(button1Text);}},
new Runnable() {public void run() {AfterChoosing(button2Text);}},
new Runnable() {public void run() {AfterChoosing(activity.getString(android.R.string.cancel));}}
new Runnable() {
public void run() {
ChoosingCanceled();
AfterChoosing(activity.getString(android.R.string.cancel)); // backward compatible
}
}
);
}
......@@ -270,11 +275,21 @@ public final class Notifier extends AndroidNonvisibleComponent implements Compon
* Event after the user has made a selection for ShowChooseDialog.
* @param choice is the text on the button the user pressed
*/
@SimpleEvent
@SimpleEvent(
description = "Event after the user has made a selection for ShowChooseDialog.")
public void AfterChoosing(String choice) {
EventDispatcher.dispatchEvent(this, "AfterChoosing", choice);
}
/**
* Event raised when the user canceled ShowChooseDialog.
*/
@SimpleEvent(
description = "Event raised when the user canceled ShowChooseDialog.")
public void ChoosingCanceled() {
EventDispatcher.dispatchEvent(this, "ChoosingCanceled");
}
/**
* Shows a dialog box in which the user can enter text, after which the
* AfterTextInput event is raised.
......@@ -332,6 +347,7 @@ public final class Notifier extends AndroidNonvisibleComponent implements Compon
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
HideKeyboard((View) input);
TextInputCanceled();
//User pressed CANCEL. Raise AfterTextInput with CANCEL
AfterTextInput(cancelButtonText);
}
......@@ -354,11 +370,23 @@ public final class Notifier extends AndroidNonvisibleComponent implements Compon
* Event raised after the user has responded to ShowTextDialog.
* @param response is the text that was entered
*/
@SimpleEvent
@SimpleEvent(
description = "Event raised after the user has responded to ShowTextDialog.")
public void AfterTextInput(String response) {
EventDispatcher.dispatchEvent(this, "AfterTextInput", response);
}
/**
* Event raised when the user canceled ShowTextDialog.
*/
@SimpleEvent(
description = "Event raised when the user canceled ShowTextDialog.")
public void TextInputCanceled() {
EventDispatcher.dispatchEvent(this, "TextInputCanceled");
}
/**
* Display a temporary notification
*
......
......@@ -851,6 +851,10 @@ none
<dd>Event after the user has made a selection for ShowChooseDialog.</dd>
<dt><code>AfterTextInput(text response)</code></dt>
<dd>Event raised after the user has responded to ShowTextDialog.</dd>
<dt><code>ChoosingCanceled()</code></dt>
<dd>Event raised when the user canceled ShowChooseDialog.</dd>
<dt><code>TextInputCanceled()</code></dt>
<dd>Event raised when the user canceled ShowTextDialog.</dd>
</dl>
<h3>Methods</h3>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment