From 35a95617fd467b823a6c1c66f0f5d9651752f2ef Mon Sep 17 00:00:00 2001 From: Noah Wang Date: Fri, 15 Apr 2016 13:49:12 -0700 Subject: [PATCH] Fix preview screen crashing and glitches for Display / Font size Bug: 28223545 Bug: 28223533 Bug: 28210654 Bug: 28210242 Bug: 28208955 Bug: 27699996 Change-Id: I80339dabbd089db8a6c6a80645baabb9b4cad00e --- AndroidManifest.xml | 3 +- .../font_size_activity.xml | 58 +++++---- .../screen_zoom_activity.xml | 55 +++++---- res/layout/conversation_message_content.xml | 1 - res/layout/conversation_message_icon.xml | 4 +- res/layout/font_size_activity.xml | 114 ++++++++++-------- res/layout/preview_seek_bar_view_pager.xml | 1 - res/layout/screen_zoom_activity.xml | 112 +++++++++-------- res/values/dimens.xml | 6 - .../PreviewSeekBarPreferenceFragment.java | 34 +++--- .../display/ConversationMessageView.java | 8 +- .../settings/widget/LabeledSeekBar.java | 21 +++- 12 files changed, 232 insertions(+), 185 deletions(-) rename res/{layout-h360dp => layout-land}/font_size_activity.xml (73%) rename res/{layout-h360dp => layout-land}/screen_zoom_activity.xml (74%) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2eb27609f84..eca1cb4ea39 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1478,8 +1478,7 @@ + android:taskAffinity="com.android.wizard" > diff --git a/res/layout-h360dp/font_size_activity.xml b/res/layout-land/font_size_activity.xml similarity index 73% rename from res/layout-h360dp/font_size_activity.xml rename to res/layout-land/font_size_activity.xml index aa3930cbdcd..69abac1ad9a 100644 --- a/res/layout-h360dp/font_size_activity.xml +++ b/res/layout-land/font_size_activity.xml @@ -14,18 +14,34 @@ limitations under the License. --> - + android:orientation="horizontal"> + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="match_parent"> + + + + + - - - + + + android:gravity="center_vertical"> - - - + - - + + diff --git a/res/layout-h360dp/screen_zoom_activity.xml b/res/layout-land/screen_zoom_activity.xml similarity index 74% rename from res/layout-h360dp/screen_zoom_activity.xml rename to res/layout-land/screen_zoom_activity.xml index 0141019f591..8d6e735b9fb 100644 --- a/res/layout-h360dp/screen_zoom_activity.xml +++ b/res/layout-land/screen_zoom_activity.xml @@ -14,18 +14,34 @@ limitations under the License. --> - + android:orientation="horizontal"> + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="match_parent" > + + + + + - - - + + @@ -60,6 +74,7 @@ android:id="@+id/smaller" android:layout_width="48dp" android:layout_height="48dp" + android:layout_alignParentStart="true" android:background="?android:attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_remove_24dp" android:tint="?android:attr/textColorPrimary" @@ -68,17 +83,11 @@ android:focusable="true" android:contentDescription="@string/screen_zoom_make_smaller_desc" /> - - - + - - + + diff --git a/res/layout/conversation_message_content.xml b/res/layout/conversation_message_content.xml index 7bc53e5074a..bdb0ea73632 100644 --- a/res/layout/conversation_message_content.xml +++ b/res/layout/conversation_message_content.xml @@ -25,7 +25,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" - android:minHeight="@dimen/conversation_message_contact_icon_size" android:layout_marginTop="0dp" > + android:layout_height="wrap_content" > - + + android:paddingTop="16dp" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> - + - + - + + + + + + + + + + - - diff --git a/res/layout/preview_seek_bar_view_pager.xml b/res/layout/preview_seek_bar_view_pager.xml index e24b674e4f8..5524d8a8e62 100644 --- a/res/layout/preview_seek_bar_view_pager.xml +++ b/res/layout/preview_seek_bar_view_pager.xml @@ -19,7 +19,6 @@ android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical" - android:minHeight="@dimen/preview_pager_min_height" android:padding="@dimen/preview_pager_padding" android:background="@drawable/preview_seek_bar_outline" > diff --git a/res/layout/screen_zoom_activity.xml b/res/layout/screen_zoom_activity.xml index 36dd9fa0c47..0141019f591 100644 --- a/res/layout/screen_zoom_activity.xml +++ b/res/layout/screen_zoom_activity.xml @@ -22,62 +22,78 @@ + android:layout_height="wrap_content" > - + + android:paddingTop="16dp" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> - + - + - + + + + + + + + + + - - diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 0ddb5d836a3..c904f2d8366 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -261,10 +261,8 @@ 8dp - 240dp 88dp 10dp - 42dp 32sp 16sp 12sp @@ -280,9 +278,6 @@ 24dp 18dp - - 240dp - 750dp 383dp @@ -295,7 +290,6 @@ 8dp - 240dp 16dp diff --git a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java b/src/com/android/settings/PreviewSeekBarPreferenceFragment.java index ff9e0352128..9d4a09e68dd 100644 --- a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java +++ b/src/com/android/settings/PreviewSeekBarPreferenceFragment.java @@ -156,21 +156,19 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc } mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager); - if (mPreviewPager != null) { - mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, - mPreviewSampleResIds, configurations); - mPreviewPager.setAdapter(mPreviewPagerAdapter); - mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0); - mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener); + mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, + mPreviewSampleResIds, configurations); + mPreviewPager.setAdapter(mPreviewPagerAdapter); + mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0); + mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener); - mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator); - if (mPreviewSampleResIds.length > 1) { - mPageIndicator.setViewPager(mPreviewPager); - mPageIndicator.setVisibility(View.VISIBLE); - mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener); - } else { - mPageIndicator.setVisibility(View.GONE); - } + mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator); + if (mPreviewSampleResIds.length > 1) { + mPageIndicator.setViewPager(mPreviewPager); + mPageIndicator.setVisibility(View.VISIBLE); + mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener); + } else { + mPageIndicator.setVisibility(View.GONE); } setPreviewLayer(mInitialIndex, false); @@ -191,11 +189,9 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc mLabel.setText(mEntries[index]); mSmaller.setEnabled(index > 0); mLarger.setEnabled(index < mEntries.length - 1); - if (mPreviewPager != null) { - setPagerIndicatorContentDescription(mPreviewPager.getCurrentItem()); - mPreviewPagerAdapter.setPreviewLayer(index, mCurrentIndex, - mPreviewPager.getCurrentItem(), animate); - } + setPagerIndicatorContentDescription(mPreviewPager.getCurrentItem()); + mPreviewPagerAdapter.setPreviewLayer(index, mCurrentIndex, + mPreviewPager.getCurrentItem(), animate); mCurrentIndex = index; } diff --git a/src/com/android/settings/display/ConversationMessageView.java b/src/com/android/settings/display/ConversationMessageView.java index a0889c4ecf7..06e7b9b2bec 100644 --- a/src/com/android/settings/display/ConversationMessageView.java +++ b/src/com/android/settings/display/ConversationMessageView.java @@ -96,13 +96,15 @@ public class ConversationMessageView extends FrameLayout { updateViewAppearance(); final int horizontalSpace = MeasureSpec.getSize(widthMeasureSpec); - final int iconSize = getResources() - .getDimensionPixelSize(R.dimen.conversation_message_contact_icon_size); final int unspecifiedMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int iconMeasureSpec = MeasureSpec.makeMeasureSpec(iconSize, MeasureSpec.EXACTLY); + int iconMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); mContactIconView.measure(iconMeasureSpec, iconMeasureSpec); + iconMeasureSpec = MeasureSpec.makeMeasureSpec( + Math.max(mContactIconView.getMeasuredWidth(), mContactIconView.getMeasuredHeight()), + MeasureSpec.EXACTLY); + mContactIconView.measure(iconMeasureSpec, iconMeasureSpec); final int arrowWidth = getResources().getDimensionPixelSize(R.dimen.message_bubble_arrow_width); diff --git a/src/com/android/settings/widget/LabeledSeekBar.java b/src/com/android/settings/widget/LabeledSeekBar.java index bf6983ece6d..f1a678815a2 100644 --- a/src/com/android/settings/widget/LabeledSeekBar.java +++ b/src/com/android/settings/widget/LabeledSeekBar.java @@ -17,6 +17,7 @@ package com.android.settings.widget; import android.content.Context; +import android.content.res.Configuration; import android.graphics.Rect; import android.os.Bundle; import android.support.v4.view.ViewCompat; @@ -24,6 +25,7 @@ import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; import android.support.v4.widget.ExploreByTouchHelper; import android.util.AttributeSet; import android.view.MotionEvent; +import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.widget.RadioButton; import android.widget.RadioGroup; @@ -121,8 +123,12 @@ public class LabeledSeekBar extends SeekBar { private class LabeledSeekBarExploreByTouchHelper extends ExploreByTouchHelper { + private boolean mIsLayoutRtl; + public LabeledSeekBarExploreByTouchHelper(LabeledSeekBar forView) { super(forView); + mIsLayoutRtl = forView.getResources().getConfiguration() + .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } @Override @@ -192,20 +198,23 @@ public class LabeledSeekBar extends SeekBar { } private int getVirtualViewIdIndexFromX(float x) { - final int posBase = Math.max(0, + int posBase = Math.max(0, ((int) x - LabeledSeekBar.this.getPaddingStart()) / getHalfVirtualViewWidth()); - return (posBase + 1) / 2; + posBase = (posBase + 1) / 2; + return mIsLayoutRtl ? LabeledSeekBar.this.getMax() - posBase : posBase; } private Rect getBoundsInParentFromVirtualViewId(int virtualViewId) { - int left = (virtualViewId * 2 - 1) * getHalfVirtualViewWidth() + final int updatedVirtualViewId = mIsLayoutRtl + ? LabeledSeekBar.this.getMax() - virtualViewId : virtualViewId; + int left = (updatedVirtualViewId * 2 - 1) * getHalfVirtualViewWidth() + LabeledSeekBar.this.getPaddingStart(); - int right = (virtualViewId * 2 + 1) * getHalfVirtualViewWidth() + int right = (updatedVirtualViewId * 2 + 1) * getHalfVirtualViewWidth() + LabeledSeekBar.this.getPaddingStart(); // Edge case - left = virtualViewId == 0 ? 0 : left; - right = virtualViewId == LabeledSeekBar.this.getMax() + left = updatedVirtualViewId == 0 ? 0 : left; + right = updatedVirtualViewId == LabeledSeekBar.this.getMax() ? LabeledSeekBar.this.getWidth() : right; final Rect r = new Rect();