Bug 830175 - Turn buttons in the prompt service from objects with labels to just strings. r=wesj

This commit is contained in:
Kartikaya Gupta 2013-01-15 15:31:24 -05:00
parent c98b3e717b
commit 52974dc71c
4 changed files with 13 additions and 35 deletions

View File

@ -83,15 +83,6 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
return new SimpleDateFormat(dateFormat).format(calendar.getTime()); return new SimpleDateFormat(dateFormat).format(calendar.getTime());
} }
private class PromptButton {
public String label = "";
PromptButton(JSONObject aJSONButton) {
try {
label = aJSONButton.getString("label");
} catch(Exception ex) { }
}
}
private class PromptInput { private class PromptInput {
private String label = ""; private String label = "";
private String type = ""; private String type = "";
@ -474,17 +465,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
text = geckoObject.getString("text"); text = geckoObject.getString("text");
} catch(Exception ex) { } } catch(Exception ex) { }
JSONArray buttons = new JSONArray(); mButtons = getStringArray(geckoObject, "buttons");
try {
buttons = geckoObject.getJSONArray("buttons");
} catch(Exception ex) { }
int length = buttons.length();
mButtons = new String[length];
for (int i = 0; i < length; i++) {
try {
mButtons[i] = buttons.getJSONObject(i).getString("label");
} catch(Exception ex) { }
}
JSONArray inputs = new JSONArray(); JSONArray inputs = new JSONArray();
try { try {

View File

@ -27,9 +27,9 @@ var InputWidgetHelper = {
type: "Prompt:Show", type: "Prompt:Show",
title: Strings.browser.GetStringFromName("inputWidgetHelper." + aElement.getAttribute('type')), title: Strings.browser.GetStringFromName("inputWidgetHelper." + aElement.getAttribute('type')),
buttons: [ buttons: [
{ label: Strings.browser.GetStringFromName("inputWidgetHelper.set") }, Strings.browser.GetStringFromName("inputWidgetHelper.set"),
{ label: Strings.browser.GetStringFromName("inputWidgetHelper.clear") }, Strings.browser.GetStringFromName("inputWidgetHelper.clear"),
{ label: Strings.browser.GetStringFromName("inputWidgetHelper.cancel") } Strings.browser.GetStringFromName("inputWidgetHelper.cancel")
], ],
inputs: [ inputs: [
{ type: type, value: aElement.value } { type: type, value: aElement.value }

View File

@ -66,7 +66,7 @@ var SelectHelper = {
if (aElement.multiple) { if (aElement.multiple) {
result.buttons = [ result.buttons = [
{ label: Strings.browser.GetStringFromName("selectHelper.closeMultipleSelectDialog") }, Strings.browser.GetStringFromName("selectHelper.closeMultipleSelectDialog")
]; ];
} }

View File

@ -134,8 +134,8 @@ Prompt.prototype = {
if (aTitle) msg.title = aTitle; if (aTitle) msg.title = aTitle;
if (aText) msg.text = aText; if (aText) msg.text = aText;
msg.buttons = aButtons || [ msg.buttons = aButtons || [
{ label: PromptUtils.getLocaleString("OK") }, PromptUtils.getLocaleString("OK"),
{ label: PromptUtils.getLocaleString("Cancel") } PromptUtils.getLocaleString("Cancel")
]; ];
msg.inputs = aInputs; msg.inputs = aInputs;
return PromptUtils.sendMessageToJava(msg); return PromptUtils.sendMessageToJava(msg);
@ -181,17 +181,17 @@ Prompt.prototype = {
/* ---------- nsIPrompt ---------- */ /* ---------- nsIPrompt ---------- */
alert: function alert(aTitle, aText) { alert: function alert(aTitle, aText) {
this.commonPrompt(aTitle, aText, [{ label: PromptUtils.getLocaleString("OK") }], "", {value: false}, []); this.commonPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], "", { value: false }, []);
}, },
alertCheck: function alertCheck(aTitle, aText, aCheckMsg, aCheckState) { alertCheck: function alertCheck(aTitle, aText, aCheckMsg, aCheckState) {
let data = this.commonPrompt(aTitle, aText, [{ label: PromptUtils.getLocaleString("OK") }], aCheckMsg, aCheckState, []); let data = this.commonPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], aCheckMsg, aCheckState, []);
if (aCheckMsg) if (aCheckMsg)
aCheckState.value = data.checkbox == "true"; aCheckState.value = data.checkbox == "true";
}, },
confirm: function confirm(aTitle, aText) { confirm: function confirm(aTitle, aText) {
let data = this.commonPrompt(aTitle, aText, null, "", {value: false}, []); let data = this.commonPrompt(aTitle, aText, null, "", { value: false }, []);
return (data.button == 0); return (data.button == 0);
}, },
@ -237,7 +237,7 @@ Prompt.prototype = {
} }
if (bTitle) if (bTitle)
buttons.push({label:bTitle}); buttons.push(bTitle);
aButtonFlags >>= 8; aButtonFlags >>= 8;
} }
@ -289,11 +289,8 @@ Prompt.prototype = {
}, },
select: function select(aTitle, aText, aCount, aSelectList, aOutSelection) { select: function select(aTitle, aText, aCount, aSelectList, aOutSelection) {
let data = this.commonPrompt(aTitle, aText, [ let data = this.commonPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], "",
{ label: PromptUtils.getLocaleString("OK") } { value: false }, [{ type: "menulist", values: aSelectList }]);
], "", {value: false}, [
{ type: "menulist", values: aSelectList },
]);
let ok = data.button == 0; let ok = data.button == 0;
if (ok) if (ok)