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

Unified Diff: ui/android/java/src/org/chromium/ui/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
« no previous file with comments | « ui/android/java/res/values/attrs.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/widget/RadioButtonWithDescription.java
diff --git a/ui/android/java/src/org/chromium/ui/widget/RadioButtonWithDescription.java b/ui/android/java/src/org/chromium/ui/widget/RadioButtonWithDescription.java
new file mode 100644
index 0000000000000000000000000000000000000000..e55a5f0034617ebcd8eacc1b182a544b04d7e022
--- /dev/null
+++ b/ui/android/java/src/org/chromium/ui/widget/RadioButtonWithDescription.java
@@ -0,0 +1,128 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
newt (away) 2016/02/19 19:47:13 ui/android is for UI components that will be used
PEConn 2016/02/22 18:13:42 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.ui.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.LinearLayout;
+import android.widget.RadioButton;
+import android.widget.TextView;
+
+import org.chromium.ui.R;
+
+import java.util.List;
+
+/**
+ * A RadioButton with a title and descriptive text to the right.
+ */
+public class RadioButtonWithDescription extends LinearLayout implements OnClickListener {
+ private RadioButton mRadioButton;
+ private TextView mTitle;
+ private TextView mDescription;
+
+ private List<RadioButtonWithDescription> mGroup;
+
+ public RadioButtonWithDescription(Context context) {
+ super(context);
+ init(null);
+ }
+
+ public RadioButtonWithDescription(Context context, AttributeSet attrs) {
newt (away) 2016/02/19 19:47:13 Typically, we only define the constructor that's a
PEConn 2016/02/22 18:13:42 Done.
+ super(context, attrs);
+ init(attrs);
+ }
+
+ public RadioButtonWithDescription(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(attrs);
+ }
+
+ private void init(AttributeSet attrs) {
+ LayoutInflater.from(getContext())
+ .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);
+
+ try {
+ String titleText = a.getString(R.styleable.RadioButtonWithDescription_titleText);
+ if (titleText != null) mTitle.setText(titleText);
+
+ String descText = a.getString(R.styleable.RadioButtonWithDescription_descriptionText);
+ if (descText != null) mDescription.setText(descText);
+ } finally {
+ 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.
+ * @param text
+ */
+ public void setTitleText(CharSequence text) {
+ mTitle.setText(text);
+ }
+
+ /**
+ * Sets the text shown in the description section.
+ * @param text
+ */
+ public void setDescriptionText(CharSequence text) {
+ mDescription.setText(text);
+ }
+
+ /**
+ * Returns true if checked.
+ * @return If checked.
+ */
+ public boolean isChecked() {
+ return mRadioButton.isChecked();
+ }
+
+ /**
+ * Sets the checked status.
+ * @param checked
+ */
+ public void setChecked(boolean checked) {
+ mRadioButton.setChecked(checked);
+ }
+
+ /**
+ * Sets the group of RadioButtonWithDescriptions that should be unchecked when this button is
+ * checked.
+ * @param group
+ */
+ public void setRadioButtonGroup(List<RadioButtonWithDescription> group) {
+ mGroup = group;
+ }
+}
+
« no previous file with comments | « ui/android/java/res/values/attrs.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698