diff --git a/mobile/android/base/DoorHanger.java b/mobile/android/base/DoorHanger.java
index 372fba2f090..2f4864aa12b 100644
--- a/mobile/android/base/DoorHanger.java
+++ b/mobile/android/base/DoorHanger.java
@@ -43,9 +43,11 @@ import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
+import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -53,6 +55,8 @@ import org.json.JSONObject;
import org.json.JSONException;
public class DoorHanger extends LinearLayout implements Button.OnClickListener {
+ private static final String LOGTAG = "DoorHanger";
+
private Context mContext;
private LinearLayout mChoicesLayout;
private TextView mTextView;
@@ -61,6 +65,9 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
// value used to identify the notification
private String mValue;
+ // Optional checkbox added underneath message text
+ private CheckBox mCheckBox;
+
static private LayoutInflater mInflater;
private int mPersistence = 0;
@@ -99,7 +106,18 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
}
public void onClick(View v) {
- GeckoEvent e = GeckoEvent.createBroadcastEvent("Doorhanger:Reply", v.getTag().toString());
+ JSONObject response = new JSONObject();
+ try {
+ response.put("callback", v.getTag().toString());
+
+ // If the checkbox is being used, pass its value
+ if (mCheckBox != null)
+ response.put("checked", mCheckBox.isChecked());
+ } catch (JSONException ex) {
+ Log.e(LOGTAG, "Error creating onClick response: " + ex);
+ }
+
+ GeckoEvent e = GeckoEvent.createBroadcastEvent("Doorhanger:Reply", response.toString());
GeckoAppShell.sendEventToGecko(e);
mTab.removeDoorHanger(mValue);
@@ -166,6 +184,13 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
mTextView.setText(titleWithLink);
mTextView.setMovementMethod(LinkMovementMethod.getInstance());
} catch (JSONException e) { }
+
+ try {
+ String checkBoxText = options.getString("checkbox");
+ mCheckBox = (CheckBox) findViewById(R.id.doorhanger_checkbox);
+ mCheckBox.setText(checkBoxText);
+ mCheckBox.setVisibility(VISIBLE);
+ } catch (JSONException e) { }
}
// This method checks with persistence and timeout options to see if
diff --git a/mobile/android/base/resources/layout/doorhanger.xml b/mobile/android/base/resources/layout/doorhanger.xml
index 9df165dcdf4..1f851610547 100644
--- a/mobile/android/base/resources/layout/doorhanger.xml
+++ b/mobile/android/base/resources/layout/doorhanger.xml
@@ -9,6 +9,12 @@
android:textColorLink="@color/doorhanger_link"
android:padding="10dp"/>
+
+