Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 package org.mozilla.gecko.prompts;
8 import org.json.JSONObject;
9 import org.mozilla.gecko.R;
10 import org.mozilla.gecko.widget.BasicColorPicker;
12 import android.content.Context;
13 import android.graphics.Color;
14 import android.view.LayoutInflater;
15 import android.view.View;
17 public class ColorPickerInput extends PromptInput {
18 public static final String INPUT_TYPE = "color";
19 public static final String LOGTAG = "GeckoColorPickerInput";
21 private boolean mShowAdvancedButton = true;
22 private int mInitialColor;
24 public ColorPickerInput(JSONObject obj) {
25 super(obj);
26 String init = obj.optString("value");
27 mInitialColor = Color.rgb(Integer.parseInt(init.substring(1,3), 16),
28 Integer.parseInt(init.substring(3,5), 16),
29 Integer.parseInt(init.substring(5,7), 16));
30 }
32 @Override
33 public View getView(Context context) throws UnsupportedOperationException {
34 LayoutInflater inflater = LayoutInflater.from(context);
35 mView = inflater.inflate(R.layout.basic_color_picker_dialog, null);
37 BasicColorPicker cp = (BasicColorPicker) mView.findViewById(R.id.colorpicker);
38 cp.setColor(mInitialColor);
40 return mView;
41 }
43 @Override
44 public Object getValue() {
45 BasicColorPicker cp = (BasicColorPicker) mView.findViewById(R.id.colorpicker);
46 int color = cp.getColor();
47 return "#" + Integer.toHexString(color).substring(2);
48 }
50 @Override
51 public boolean getScrollable() {
52 return true;
53 }
55 @Override
56 public boolean canApplyInputStyle() {
57 return false;
58 }
59 }