Skip to content

Commit

Permalink
Color Picker for <input type=color>
Browse files Browse the repository at this point in the history
Thanks for all the review comments!  I think this is now ready.  :-)

I've replied to as many comments as possible, I hope my replies make
sense.  Thanks again, I'm learning a lot!  :-)
    
References:
 - The mockup I'm following is here:
https://docs.google.com/a/google.com/file/d/0B2S_KwX0QwGFb2JVTlhPYlRqaEE/edit
 - There's an APK here:
https://drive.google.com/a/google.com/folderview?id=0B8nL-JlqpL9nLURUVnJsdTFDYjQ

BUG=135771

Review URL: https://chromiumcodereview.appspot.com/14170009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203195 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
paulnavin@google.com committed May 30, 2013
1 parent 34697d6 commit d9ef486
Show file tree
Hide file tree
Showing 12 changed files with 808 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.chromium.base.JNINamespace;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.ui.ColorPickerDialog;
import org.chromium.ui.OnColorChangedListener;

/**
* ColorChooserAndroid communicates with the java ColorPickerDialog and the
Expand All @@ -22,11 +23,9 @@ public class ColorChooserAndroid {

private ColorChooserAndroid(int nativeColorChooserAndroid,
Context context, int initialColor) {
ColorPickerDialog.OnColorChangedListener listener =
new ColorPickerDialog.OnColorChangedListener() {

OnColorChangedListener listener = new OnColorChangedListener() {
@Override
public void colorChanged(int color) {
public void onColorChanged(int color) {
mDialog.dismiss();
nativeOnColorChosen(mNativeColorChooserAndroid, color);
}
Expand Down
10 changes: 10 additions & 0 deletions ui/android/java/res/drawable/color_picker_border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00000000"/>
<stroke android:width="1px" android:color="#D0D0D0" />
</shape>
46 changes: 46 additions & 0 deletions ui/android/java/res/layout/color_picker_advanced_component.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/color_picker_gradient_margin"
android:layout_marginEnd="@dimen/color_picker_gradient_margin"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textIsSelectable="false" />

<FrameLayout
android:id="@+id/gradient_border"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/text"
android:layout_marginStart="@dimen/color_picker_gradient_margin"
android:layout_marginEnd="@dimen/color_picker_gradient_margin"
android:layout_marginTop="3dp"
android:background="@drawable/color_picker_border"
android:padding="1dp" >

<View
android:id="@+id/gradient"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_below="@id/text"
android:progressDrawable="@android:color/transparent"
android:thumb="@drawable/color_picker_advanced_select_handle"
android:translationY="25dp" />

</RelativeLayout>
48 changes: 48 additions & 0 deletions ui/android/java/res/layout/color_picker_dialog_content.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="15dp">

<org.chromium.ui.ColorPickerAdvanced
android:id="@+id/color_picker_advanced"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<FrameLayout
android:id="@+id/color_picker_simple_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/color_picker_border"
android:padding="1dp">

<org.chromium.ui.ColorPickerSimple
android:id="@+id/color_picker_simple"
android:layout_width="match_parent"
android:layout_height="100dp"/>
</FrameLayout>

<FrameLayout
android:id="@+id/more_colors_button_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/color_picker_simple_border"
android:background="@drawable/color_picker_border"
android:padding="1dp">

<Button
android:id="@+id/more_colors_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dip"
android:text="@string/color_picker_button_more" />
</FrameLayout>

</RelativeLayout>
40 changes: 40 additions & 0 deletions ui/android/java/res/layout/color_picker_dialog_title.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="15dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:paddingTop="15dp" >

<TextView
android:id="@+id/title"
style="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/selected_color_view_border"
android:layout_centerVertical="true"
android:ellipsize="end"
android:singleLine="true" />

<FrameLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:id="@+id/selected_color_view_border"
android:background="@drawable/color_picker_border"
android:padding="1dp">

<View
android:id="@+id/selected_color_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black" />
</FrameLayout>

</RelativeLayout>
15 changes: 15 additions & 0 deletions ui/android/java/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<resources>

<!--
14.5 = Seekbar thumb width - border width, but it depends on the width
of the seek bar icon.
-->
<dimen name="color_picker_gradient_margin">14.5dp</dimen>

</resources>
Loading

0 comments on commit d9ef486

Please sign in to comment.