Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.ui; | 5 package org.chromium.ui; |
| 6 | 6 |
| 7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
| 8 import android.app.Dialog; | 8 import android.app.Dialog; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.DialogInterface; | 10 import android.content.DialogInterface; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 private final OnColorChangedListener mListener; | 30 private final OnColorChangedListener mListener; |
| 31 | 31 |
| 32 private final int mInitialColor; | 32 private final int mInitialColor; |
| 33 | 33 |
| 34 private int mCurrentColor; | 34 private int mCurrentColor; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * @param context The context the dialog is to run in. | 37 * @param context The context the dialog is to run in. |
| 38 * @param theme The theme to display the dialog in. | 38 * @param theme The theme to display the dialog in. |
| 39 * @param listener The object to notify when the color is set. | 39 * @param listener The object to notify when the color is set. |
| 40 * @param color The initial color to set. | 40 * @param color The initial color to set. |
|
newt (away)
2013/08/19 23:18:19
update javadoc
keishi
2013/08/26 05:28:54
Done.
| |
| 41 */ | 41 */ |
| 42 public ColorPickerDialog(Context context, OnColorChangedListener listener, i nt color) { | 42 public ColorPickerDialog(Context context, |
| 43 OnColorChangedListener listener, | |
| 44 int color, | |
| 45 int[] suggestions, | |
| 46 String[] suggestionLabels) { | |
| 43 super(context, 0); | 47 super(context, 0); |
| 44 | 48 |
| 45 mListener = listener; | 49 mListener = listener; |
| 46 mInitialColor = color; | 50 mInitialColor = color; |
| 47 mCurrentColor = mInitialColor; | 51 mCurrentColor = mInitialColor; |
| 48 | 52 |
| 49 // Initialize title | 53 // Initialize title |
| 50 LayoutInflater inflater = (LayoutInflater) context | 54 LayoutInflater inflater = (LayoutInflater) context |
| 51 .getSystemService(Context.LAYOUT_INFLATER_SERVICE); | 55 .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 52 View title = inflater.inflate(R.layout.color_picker_dialog_title, null); | 56 View title = inflater.inflate(R.layout.color_picker_dialog_title, null); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 } | 107 } |
| 104 }); | 108 }); |
| 105 | 109 |
| 106 // Initialize advanced color view (hidden initially). | 110 // Initialize advanced color view (hidden initially). |
| 107 mAdvancedColorPicker = | 111 mAdvancedColorPicker = |
| 108 (ColorPickerAdvanced) content.findViewById(R.id.color_picker_adv anced); | 112 (ColorPickerAdvanced) content.findViewById(R.id.color_picker_adv anced); |
| 109 mAdvancedColorPicker.setVisibility(View.GONE); | 113 mAdvancedColorPicker.setVisibility(View.GONE); |
| 110 | 114 |
| 111 // Initialize simple color view (default view). | 115 // Initialize simple color view (default view). |
| 112 mSimpleColorPicker = (ColorPickerSimple) content.findViewById(R.id.color _picker_simple); | 116 mSimpleColorPicker = (ColorPickerSimple) content.findViewById(R.id.color _picker_simple); |
| 113 mSimpleColorPicker.init(this); | 117 mSimpleColorPicker.init(suggestions, suggestionLabels, this); |
| 114 | 118 |
| 115 updateCurrentColor(mInitialColor); | 119 updateCurrentColor(mInitialColor); |
| 116 } | 120 } |
| 117 | 121 |
| 118 /** | 122 /** |
| 119 * Listens to the ColorPicker for when the user has changed the selected col or, and | 123 * Listens to the ColorPicker for when the user has changed the selected col or, and |
| 120 * updates the current color (the color shown in the title) accordingly. | 124 * updates the current color (the color shown in the title) accordingly. |
| 121 * | 125 * |
| 122 * @param color The new color chosen by the user. | 126 * @param color The new color chosen by the user. |
| 123 */ | 127 */ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 * Updates the internal cache of the currently selected color, updating the colorful little | 161 * Updates the internal cache of the currently selected color, updating the colorful little |
| 158 * box in the title at the same time. | 162 * box in the title at the same time. |
| 159 */ | 163 */ |
| 160 private void updateCurrentColor(int color) { | 164 private void updateCurrentColor(int color) { |
| 161 mCurrentColor = color; | 165 mCurrentColor = color; |
| 162 if (mCurrentColorView != null) { | 166 if (mCurrentColorView != null) { |
| 163 mCurrentColorView.setBackgroundColor(color); | 167 mCurrentColorView.setBackgroundColor(color); |
| 164 } | 168 } |
| 165 } | 169 } |
| 166 } | 170 } |
| OLD | NEW |