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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java

Issue 2019573002: Permissions: Allow control of individual requests in media permission infobars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/infobar/InfoBarControlLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java
index 49aaf9b518c8899d3986287d84d622677b112a95..7ec0de2593f09200d8c5d05582a1bc5055fbd535 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java
@@ -14,6 +14,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
+import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RatingBar;
@@ -273,12 +274,12 @@ public final class InfoBarControlLayout extends ViewGroup {
* If an icon is not provided, the ImageView that would normally show it is hidden.
*
* @param iconResourceId ID of the drawable to use for the icon.
+ * @param iconColorId ID of the tint color for the icon, or 0 for default.
* @param primaryMessage Message to display for the toggle.
* @param secondaryMessage Additional descriptive text for the toggle. May be null.
- * @param iconColorId ID of the tint color for the icon, or 0 for default.
*/
- public View addIcon(int iconResourceId, CharSequence primaryMessage,
- CharSequence secondaryMessage, int iconColorId) {
+ public View addIcon(int iconResourceId, int iconColorId, CharSequence primaryMessage,
+ CharSequence secondaryMessage) {
LinearLayout layout = (LinearLayout) LayoutInflater.from(getContext()).inflate(
R.layout.infobar_control_icon_with_description, this, false);
addView(layout, new ControlLayoutParams());
@@ -314,12 +315,15 @@ public final class InfoBarControlLayout extends ViewGroup {
* If an icon is not provided, the ImageView that would normally show it is hidden.
*
* @param iconResourceId ID of the drawable to use for the icon, or 0 to hide the ImageView.
+ * @param iconColorId ID of the tint color for the icon, or 0 for default.
* @param toggleMessage Message to display for the toggle.
* @param toggleId ID to use for the toggle.
+ * @param toggleListener Listener to attach to checked change events on the toggle.
tsergeant 2016/05/30 04:52:54 dfalcantara@, I'm interested to know your thoughts
gone 2016/05/31 21:20:42 Given that you should only persist settings when t
tsergeant 2016/06/02 07:04:36 Done -- I'm now getting the switch values when the
* @param isChecked Whether the toggle should start off checked.
*/
- public View addSwitch(
- int iconResourceId, CharSequence toggleMessage, int toggleId, boolean isChecked) {
+ public View addSwitch(int iconResourceId, int iconColorId, CharSequence toggleMessage,
+ int toggleId, CompoundButton.OnCheckedChangeListener toggleListener,
+ boolean isChecked) {
LinearLayout switchLayout = (LinearLayout) LayoutInflater.from(getContext()).inflate(
R.layout.infobar_control_toggle, this, false);
addView(switchLayout, new ControlLayoutParams());
@@ -329,6 +333,10 @@ public final class InfoBarControlLayout extends ViewGroup {
switchLayout.removeView(iconView);
} else {
iconView.setImageResource(iconResourceId);
+ if (iconColorId != 0) {
+ iconView.setColorFilter(
+ ApiCompatibilityUtils.getColor(getResources(), iconColorId));
+ }
}
TextView messageView = (TextView) switchLayout.findViewById(R.id.control_message);
@@ -337,6 +345,7 @@ public final class InfoBarControlLayout extends ViewGroup {
SwitchCompat switchView =
(SwitchCompat) switchLayout.findViewById(R.id.control_toggle_switch);
switchView.setId(toggleId);
+ if (toggleListener != null) switchView.setOnCheckedChangeListener(toggleListener);
switchView.setChecked(isChecked);
return switchLayout;

Powered by Google App Engine
This is Rietveld 408576698