Improve color picker layout / cleaned up some of the code

- Fixed possible NPE with calling getWindow()
- Remove unnecessary panel of preset colors underneath the color picker
- Changed dialog to AlertDialog to match LED color picker

While this doesn't look EXACTLY like the LED color picker, this along with
the commit below bring it closer than ever before.

http://gerrit.dirtyunicorns.com/#/c/1199/

Change-Id: I13bc40d1882676d92e5c4ae4bfcf25865e88dad1

Signed-off-by: xyyx <xyyx@mail.ru>
This commit is contained in:
Alex Cruz
2017-11-26 00:14:37 -05:00
committed by hungphan2001
parent 8dc8247882
commit 0950761101
3 changed files with 66 additions and 228 deletions

View File

@@ -19,106 +19,54 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_marginStart="36dp"
android:layout_marginEnd="36dp"
android:padding="@dimen/alert_dialog_padding_material"
android:orientation="horizontal">
<net.margaritov.preference.colorpicker.ColorPickerView
android:id="@+id/color_picker_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:tag="landscape" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="3dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="3dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="@string/hex"
android:textSize="20sp"
android:layout_marginRight="10dp" />
android:textSize="20sp" />
<EditText
android:id="@+id/hex"
android:hint="@string/hex_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:hint="@string/hex_hint" />
<ImageButton
android:id="@+id/enter"
android:src="@drawable/ic_action_set"
android:background="@android:color/transparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:orientation="horizontal"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="2dp">
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/white_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/black_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/cyan_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/red_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/green_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/yellow_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
android:layout_marginStart="10dp"
android:background="@android:color/transparent"
android:gravity="center"
android:src="@drawable/ic_action_set" />
</LinearLayout>
<TextView
@@ -126,8 +74,8 @@
android:layout_height="wrap_content"
android:text="@string/press_color_to_apply"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
@@ -156,7 +104,6 @@
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>

View File

@@ -19,97 +19,46 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_marginStart="36dp"
android:layout_marginEnd="36dp"
android:padding="@dimen/alert_dialog_padding_material"
android:orientation="vertical">
<net.margaritov.preference.colorpicker.ColorPickerView
android:id="@+id/color_picker_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="portrait" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="3dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="@string/hex"
android:textSize="20sp"
android:layout_marginRight="10dp" />
android:textSize="20sp" />
<EditText
android:id="@+id/hex"
android:hint="@string/hex_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:hint="@string/hex_hint" />
<ImageButton
android:id="@+id/enter"
android:src="@drawable/ic_action_set"
android:background="@android:color/transparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center" />
</LinearLayout>
<net.margaritov.preference.colorpicker.ColorPickerView
android:id="@+id/color_picker_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:tag="portrait" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:orientation="horizontal"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="2dp">
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/white_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/black_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/cyan_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/red_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/green_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_weight="0.5" />
<net.margaritov.preference.colorpicker.ColorPickerPanelView
android:id="@+id/yellow_panel"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
android:layout_marginStart="10dp"
android:background="@android:color/transparent"
android:gravity="center"
android:src="@drawable/ic_action_set" />
</LinearLayout>
@@ -118,8 +67,8 @@
android:layout_height="wrap_content"
android:text="@string/press_color_to_apply"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout