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