OmniControl: rework color select dialog
Change-Id: I6cf1635dd0adfed68fd150e2b1fc37b69253399b
diff --git a/app/src/main/java/org/omnirom/control/widget/ColorSelectDialog.java b/app/src/main/java/org/omnirom/control/widget/ColorSelectDialog.java
index ff5eba8..b6e01ce 100644
--- a/app/src/main/java/org/omnirom/control/widget/ColorSelectDialog.java
+++ b/app/src/main/java/org/omnirom/control/widget/ColorSelectDialog.java
@@ -19,6 +19,7 @@
import android.app.Activity;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
@@ -42,6 +43,8 @@
import androidx.appcompat.app.AlertDialog;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+
public class ColorSelectDialog extends AlertDialog implements
ColorPickerView.OnColorChangedListener, TextWatcher, OnFocusChangeListener {
@@ -96,7 +99,15 @@
View colorPresetItem = mInflater.inflate(R.layout.color_preset_item, null);
colorPresetItem.findViewById(R.id.color_preset_item_view).setBackground(new ColorDrawable(presetColor));
int colorPresetItemSize = getContext().getResources().getDimensionPixelSize(R.dimen.color_preset_item_size);
- mColorPresetView.addView(colorPresetItem, colorPresetItemSize, colorPresetItemSize);
+ if (getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(colorPresetItemSize, colorPresetItemSize);
+ colorPresetItem.setLayoutParams(lp);
+ } else {
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, colorPresetItemSize);
+ lp.weight = 0.1f;
+ colorPresetItem.setLayoutParams(lp);
+ }
+ mColorPresetView.addView(colorPresetItem);
colorPresetItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/app/src/main/res/layout-land/color_preset_item.xml b/app/src/main/res/layout-land/color_preset_item.xml
new file mode 100644
index 0000000..f45ae48
--- /dev/null
+++ b/app/src/main/res/layout-land/color_preset_item.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="@dimen/color_preset_item_size"
+ android:layout_height="@dimen/color_preset_item_size"
+ android:background="?android:attr/selectableItemBackground">
+
+ <View
+ android:id="@+id/color_preset_item_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_margin="2dp"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout-land/color_select_dialog.xml b/app/src/main/res/layout-land/color_select_dialog.xml
index 09f76e7..6d39048 100644
--- a/app/src/main/res/layout-land/color_select_dialog.xml
+++ b/app/src/main/res/layout-land/color_select_dialog.xml
@@ -21,38 +21,48 @@
<org.omnirom.control.widget.ColorPickerView
android:id="@+id/color_picker_view"
- android:layout_width="280dp"
- android:layout_height="280dp" />
-
- <GridLayout
- android:id="@+id/color_preset_view"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="top"
- android:layout_margin="3dp"
- android:columnCount="2"
- android:rowCount="4"
- android:visibility="gone" />
+ android:layout_width="300dp"
+ android:layout_height="match_parent" />
<LinearLayout
- android:id="@+id/color_panel_view"
- android:layout_width="wrap_content"
+ android:layout_width="300dp"
android:layout_height="match_parent"
- android:layout_gravity="top"
- android:layout_margin="3dp"
- android:orientation="vertical">
+ android:orientation="horizontal">
- <EditText
- android:id="@+id/hex_color_input"
- android:layout_width="150dp"
- android:layout_height="40dp"
- android:digits="0123456789ABCDEFabcdef"
- android:inputType="textNoSuggestions"
- android:maxLength="6" />
+ <GridLayout
+ android:id="@+id/color_preset_view"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="top"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp"
+ android:layout_weight="2"
+ android:columnCount="2"
+ android:rowCount="4"
+ android:visibility="gone" />
- <org.omnirom.control.widget.ColorPanelView
- android:id="@+id/color_panel"
- android:layout_width="150dp"
- android:layout_height="40dp" />
+ <LinearLayout
+ android:id="@+id/color_panel_view"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="top"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp"
+ android:layout_weight="3"
+ android:orientation="vertical">
+
+ <EditText
+ android:id="@+id/hex_color_input"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/color_preset_item_size"
+ android:digits="0123456789ABCDEFabcdef"
+ android:inputType="textNoSuggestions"
+ android:maxLength="6" />
+
+ <org.omnirom.control.widget.ColorPanelView
+ android:id="@+id/color_panel"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/color_preset_item_size" />
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
diff --git a/app/src/main/res/layout/color_preset_item.xml b/app/src/main/res/layout/color_preset_item.xml
index 9885f1e..f7e108c 100644
--- a/app/src/main/res/layout/color_preset_item.xml
+++ b/app/src/main/res/layout/color_preset_item.xml
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/color_preset_item_size"
- android:layout_height="@dimen/color_preset_item_size"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
android:background="?android:attr/selectableItemBackground">
<View
android:id="@+id/color_preset_item_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_margin="5dp"/>
+ android:layout_margin="2dp"/>
</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/color_select_dialog.xml b/app/src/main/res/layout/color_select_dialog.xml
index c527437..f17a54c 100644
--- a/app/src/main/res/layout/color_select_dialog.xml
+++ b/app/src/main/res/layout/color_select_dialog.xml
@@ -21,41 +21,42 @@
<org.omnirom.control.widget.ColorPickerView
android:id="@+id/color_picker_view"
- android:layout_width="330dp"
- android:layout_height="330dp" />
+ android:layout_width="match_parent"
+ android:layout_height="300dp" />
- <GridLayout
+ <LinearLayout
android:id="@+id/color_preset_view"
- android:layout_width="wrap_content"
- android:layout_height="40dp"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/color_preset_item_size"
android:layout_marginStart="3dp"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="10dp"
- android:columnCount="8"
- android:rowCount="1"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp"
+ android:orientation="horizontal"
android:visibility="gone" />
<LinearLayout
android:id="@+id/color_panel_view"
android:layout_width="wrap_content"
- android:layout_height="40dp"
+ android:layout_height="@dimen/color_preset_item_size"
android:layout_marginStart="3dp"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="10dp"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp"
android:orientation="horizontal">
<EditText
android:id="@+id/hex_color_input"
- android:layout_width="155dp"
+ android:layout_width="0dp"
android:layout_height="match_parent"
+ android:layout_weight="1"
android:digits="0123456789ABCDEFabcdef"
android:inputType="textNoSuggestions"
android:maxLength="6" />
<org.omnirom.control.widget.ColorPanelView
android:id="@+id/color_panel"
- android:layout_width="155dp"
+ android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_marginStart="10dp" />
+ android:layout_marginStart="10dp"
+ android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 825dc10..903bb4f 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -22,7 +22,7 @@
<dimen name="color_item_column_height">140dp</dimen>
<dimen name="overlay_fragment_side_margin">10dp</dimen>
<dimen name="alert_dialog_padding_material">20dp</dimen>
- <dimen name="color_preset_item_size">40dp</dimen>
+ <dimen name="color_preset_item_size">44dp</dimen>
<dimen name="title_text_size">20sp</dimen>
<dimen name="summary_text_size">14sp</dimen>
<dimen name="pref_title_text_size">18sp</dimen>