Skip to content

Commit

Permalink
Fix light settings dialog being unusable in landscape.
Browse files Browse the repository at this point in the history
Change-Id: I38eeeafd1d8260ab4a7c8de9099a7e270c1462f2
  • Loading branch information
maniac103 authored and davros- committed Apr 28, 2013
1 parent f0047b0 commit 9fd38bf
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 3 deletions.
111 changes: 111 additions & 0 deletions res/layout-land/dialog_light_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 Daniel Nilsson
Copyright (C) 2012 THe CyanogenMod Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.android.settings.notificationlight.ColorPickerView
android:id="@+id/color_picker_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp" />

<LinearLayout
android:id="@+id/color_panel_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/color_picker_view"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:orientation="horizontal" >

<EditText
android:id="@+id/hex_color_input"
android:layout_width="0dp"
android:maxLength="6"
android:digits="0123456789ABCDEFabcdef"
android:inputType="textNoSuggestions"
android:layout_height="wrap_content"
android:layout_weight="0.5" />

<com.android.settings.notificationlight.ColorPanelView
android:id="@+id/color_panel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" />
</LinearLayout>

<LinearLayout
android:id="@+id/speed_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/color_panel_view"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="4dp"
android:orientation="vertical" >

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:drawable/divider_horizontal_dark" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/pulse_speed_title"
android:textAppearance="?android:attr/textAppearanceSmall" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="4dip" >

<Spinner
android:id="@+id/on_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="0dip"
android:paddingBottom="0dip" />

<View
android:layout_width="8dip"
android:layout_height="match_parent" />

<Spinner
android:id="@+id/off_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="0dip"
android:paddingBottom="0dip" />
</LinearLayout>
</LinearLayout>

</RelativeLayout>
</ScrollView>
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public AlphaPatternDrawable(int rectangleSize) {

@Override
public void draw(Canvas canvas) {
canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
if (mBitmap != null) {
canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

// If calculated height (based on the width) is more than the
// allowed height.
if (height > heightAllowed) {
if (height > heightAllowed && heightMode != MeasureSpec.UNSPECIFIED) {
height = heightAllowed;
width = (int) (height + PANEL_SPACING + HUE_PANEL_WIDTH);
} else {
Expand All @@ -581,7 +581,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

width = (int) (heightAllowed - ALPHA_PANEL_HEIGHT + HUE_PANEL_WIDTH);

if (width > widthAllowed) {
if (width > widthAllowed && widthMode != MeasureSpec.UNSPECIFIED) {
width = widthAllowed;
height = (int) (widthAllowed - HUE_PANEL_WIDTH + ALPHA_PANEL_HEIGHT);
} else {
Expand Down

0 comments on commit 9fd38bf

Please sign in to comment.