Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/RadioButtonWithDescription.java

Issue 1698043006: Created the dialog offering the user to merge their account data or keep it (Closed) Base URL: maybelle.lon.corp.google.com:/usr/local/google/code/clankium/src@sync_settings
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/RadioButtonWithDescription.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/RadioButtonWithDescription.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/RadioButtonWithDescription.java
new file mode 100644
index 0000000000000000000000000000000000000000..c51f15dc2d579f596118d999404bf9ab8e70d396
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/RadioButtonWithDescription.java
@@ -0,0 +1,107 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.RadioButton;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import org.chromium.chrome.R;
+
+import java.util.List;
+
+/**
+ * A RadioButton with a title and descriptive text to the right.
+ */
+public class RadioButtonWithDescription extends RelativeLayout implements OnClickListener {
+ private RadioButton mRadioButton;
+ private TextView mTitle;
+ private TextView mDescription;
+
+ private List<RadioButtonWithDescription> mGroup;
+
+ /**
+ * Constructor for inflating via XML.
+ */
+ public RadioButtonWithDescription(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ LayoutInflater.from(context).inflate(R.layout.radio_button_with_description, this, true);
+
+ mRadioButton = (RadioButton) findViewById(R.id.radio_button);
+ mTitle = (TextView) findViewById(R.id.title);
+ mDescription = (TextView) findViewById(R.id.description);
+
+ if (attrs != null) applyAttributes(attrs);
+
+ // We want RadioButtonWithDescription to handle the clicks itself.
+ mRadioButton.setClickable(false);
+ setOnClickListener(this);
+ }
+
+ private void applyAttributes(AttributeSet attrs) {
+ TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs,
+ R.styleable.RadioButtonWithDescription, 0, 0);
+
+ String titleText = a.getString(R.styleable.RadioButtonWithDescription_titleText);
+ if (titleText != null) mTitle.setText(titleText);
+
+ a.recycle();
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (mGroup != null) {
+ for (RadioButtonWithDescription button : mGroup) {
+ button.setChecked(false);
+ }
+ }
+
+ setChecked(true);
+ }
+
+ /**
+ * Sets the text shown in the title section.
+ */
+ public void setTitleText(CharSequence text) {
+ mTitle.setText(text);
+ }
+
+ /**
+ * Sets the text shown in the description section.
+ */
+ public void setDescriptionText(CharSequence text) {
+ mDescription.setText(text);
+ }
+
+ /**
+ * Returns true if checked.
+ */
+ public boolean isChecked() {
+ return mRadioButton.isChecked();
+ }
+
+ /**
+ * Sets the checked status.
+ */
+ public void setChecked(boolean checked) {
+ mRadioButton.setChecked(checked);
+ }
+
+ /**
+ * Sets the group of RadioButtonWithDescriptions that should be unchecked when this button is
+ * checked.
+ * @param group A list containing all elements of the group.
+ */
+ public void setRadioButtonGroup(List<RadioButtonWithDescription> group) {
+ mGroup = group;
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698