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

Unified Diff: ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java

Issue 2398543003: Move Android view based ColorPicker from ui/ to components/ (Closed)
Patch Set: add owners Created 4 years, 1 month 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: ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java
diff --git a/ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java b/ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java
deleted file mode 100644
index 75fd709305c7dfe97da12571a2432436a3a3a0e7..0000000000000000000000000000000000000000
--- a/ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2013 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.ui;
-
-import android.content.Context;
-import android.graphics.drawable.GradientDrawable;
-import android.view.View;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-import org.chromium.base.ApiCompatibilityUtils;
-
-/**
- * Encapsulates a single gradient view of the HSV color display, including its label, gradient
- * view and seek bar.
- *
- * Mirrors a "color_picker_advanced_component" layout.
- */
-public class ColorPickerAdvancedComponent {
- // The view that displays the gradient.
- private final View mGradientView;
- // The seek bar that allows the user to change the value of this component.
- private final SeekBar mSeekBar;
- // The set of colors to interpolate the gradient through.
- private int[] mGradientColors;
- // The Drawable that represents the gradient.
- private GradientDrawable mGradientDrawable;
- // The text label for the component.
- private final TextView mText;
-
- /**
- * Initializes the views.
- *
- * @param rootView View that contains all the content, such as the label, gradient view, etc.
- * @param textResourceId The resource ID of the text to show on the label.
- * @param seekBarMax The range of the seek bar.
- * @param seekBarListener The listener for when the seek bar value changes.
- */
- ColorPickerAdvancedComponent(final View rootView,
- final int textResourceId,
- final int seekBarMax,
- final OnSeekBarChangeListener seekBarListener) {
- mGradientView = rootView.findViewById(R.id.gradient);
- mText = (TextView) rootView.findViewById(R.id.text);
- mText.setText(textResourceId);
- mGradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null);
- mSeekBar = (SeekBar) rootView.findViewById(R.id.seek_bar);
- mSeekBar.setOnSeekBarChangeListener(seekBarListener);
- mSeekBar.setMax(seekBarMax);
- // Setting the thumb offset means the seek bar thumb can move all the way to each end
- // of the gradient view.
- Context context = rootView.getContext();
- int offset = ApiCompatibilityUtils.getDrawable(context.getResources(),
- R.drawable.color_picker_advanced_select_handle).getIntrinsicWidth();
- mSeekBar.setThumbOffset(offset / 2);
- }
-
- /**
- * @return The value represented by this component, maintained by the seek bar progress.
- */
- public float getValue() {
- return mSeekBar.getProgress();
- }
-
- /**
- * Sets the value of the component (by setting the seek bar value).
- *
- * @param newValue The value to give the component.
- */
- public void setValue(float newValue) {
- mSeekBar.setProgress((int) newValue);
- }
-
- /**
- * Sets the colors for the gradient view to interpolate through.
- *
- * @param newColors The set of colors representing the interpolation points for the gradient.
- */
- public void setGradientColors(int[] newColors) {
- mGradientColors = newColors.clone();
- mGradientDrawable.setColors(mGradientColors);
- mGradientView.setBackground(mGradientDrawable);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698