Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01fa0d7a authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Date and time pickers do not show properly on phone

1. Copied the default NumberPicker layout to sw-600dip
   i.e. in the layouts for tablets and changed the
   layout to fit on the screen. No mini calendar on
   phones - you need an microsope to see it.

2. Fixed a two pixel off erroro in NumberPicker noticable
   when the scroll wheel fades away.

bug:4259424

Change-Id: I07a73faff1e95dffd30424cc8addd35f2fe30e8f
parent f1bfa84c
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -549,11 +549,13 @@ public class NumberPicker extends LinearLayout {
        final ValueAnimator fadeScroller = ObjectAnimator.ofInt(this, "selectorPaintAlpha", 255, 0);
        final ObjectAnimator showIncrementButton = ObjectAnimator.ofFloat(mIncrementButton,
                "alpha", 0, 1);
        final ObjectAnimator showInputText = ObjectAnimator.ofFloat(mInputText,
                "alpha", 0, 1);
        final ObjectAnimator showDecrementButton = ObjectAnimator.ofFloat(mDecrementButton,
                "alpha", 0, 1);
        mShowInputControlsAnimator = new AnimatorSet();
        mShowInputControlsAnimator.playTogether(fadeScroller, showIncrementButton,
                showDecrementButton);
                showInputText, showDecrementButton);
        mShowInputControlsAnimator.addListener(new AnimatorListenerAdapter() {
            private boolean mCanceled = false;

@@ -1205,13 +1207,11 @@ public class NumberPicker extends LinearLayout {
        }
        int[] selectorIndices = getSelectorIndices();
        int totalTextHeight = selectorIndices.length * mTextSize;
        int totalTextGapHeight = (mBottom - mTop) - totalTextHeight;
        int textGapCount = selectorIndices.length - 1;
        int selectorTextGapHeight = totalTextGapHeight / textGapCount;
        // compensate for integer division loss of the components used to
        // calculate the text gap
        int integerDivisionLoss = (mTextSize + mBottom - mTop) % textGapCount;
        mInitialScrollOffset = mCurrentScrollOffset = mTextSize - integerDivisionLoss / 2;
        float totalTextGapHeight = (mBottom - mTop) - totalTextHeight;
        float textGapCount = selectorIndices.length - 1;
        int selectorTextGapHeight = (int) (totalTextGapHeight / textGapCount + 0.5f);
        // Compensate if text size is odd since every time we get its middle a pixel is lost.
        mInitialScrollOffset = mCurrentScrollOffset = mTextSize - (3 * (mTextSize % 2));
        mSelectorElementHeight = mTextSize + selectorTextGapHeight;
        updateInputTextView();
    }
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2007, The Android Open Source 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.
*/
-->

<DatePicker xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/datePicker"
    android:layout_gravity="center_horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
+39 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, The Android Open Source 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.
*/
-->

<merge xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageButton android:id="@+id/increment"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/numberPickerUpButtonStyle"
        android:contentDescription="@string/number_picker_increment_button" />

    <EditText android:id="@+id/numberpicker_input"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/numberPickerInputTextStyle" />

    <ImageButton android:id="@+id/decrement"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/numberPickerDownButtonStyle"
        android:contentDescription="@string/number_picker_decrement_button" />

</merge>
+2 −0
Original line number Diff line number Diff line
@@ -22,4 +22,6 @@
    android:layout_gravity="center_horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:spinnersShown="true"
    android:calendarViewShown="false"
    />
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/numberPickerUpButtonStyle"
        android:paddingTop="22dip"
        android:paddingBottom="22dip"
        android:contentDescription="@string/number_picker_increment_button" />

    <EditText android:id="@+id/numberpicker_input"
@@ -34,6 +36,8 @@
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/numberPickerDownButtonStyle"
        android:paddingTop="22dip"
        android:paddingBottom="22dip"
        android:contentDescription="@string/number_picker_decrement_button" />

</merge>