From 191feb60441d170605423428e8826205c809af54 Mon Sep 17 00:00:00 2001 From: serso Date: Sat, 6 Feb 2016 23:57:00 +0100 Subject: [PATCH] Fix text auto resizing in DisplayView --- .../solovyev/android/calculator/DisplayView.java | 15 ++++++++++----- app/src/main/res/layout-large/cpp_app_display.xml | 10 +++------- .../main/res/layout-xlarge/cpp_app_display.xml | 10 +++------- app/src/main/res/layout/cpp_app_display.xml | 10 +++------- .../main/res/layout/cpp_app_display_mobile.xml | 10 +++------- app/src/main/res/layout/onscreen_display.xml | 11 +++-------- .../main/res/layout/onscreen_display_light.xml | 11 +++-------- app/src/main/res/layout/onscreen_layout.xml | 2 +- .../main/res/layout/onscreen_layout_material.xml | 2 +- .../res/layout/onscreen_layout_material_light.xml | 2 +- app/src/main/res/layout/widget_display.xml | 1 - app/src/main/res/layout/widget_display_light.xml | 1 - app/src/main/res/layout/widget_layout.xml | 2 +- .../layout/widget_layout_lockscreen_collapsed.xml | 1 - .../main/res/layout/widget_layout_material.xml | 2 +- .../res/layout/widget_layout_material_light.xml | 2 +- app/src/main/res/values/styles.xml | 5 ++++- 17 files changed, 38 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/DisplayView.java b/app/src/main/java/org/solovyev/android/calculator/DisplayView.java index bbf22f95..e042dfd8 100644 --- a/app/src/main/java/org/solovyev/android/calculator/DisplayView.java +++ b/app/src/main/java/org/solovyev/android/calculator/DisplayView.java @@ -24,18 +24,23 @@ package org.solovyev.android.calculator; import android.app.Service; import android.content.Context; +import android.content.res.Resources; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.AttributeSet; -import android.util.TypedValue; +import hugo.weaving.DebugLog; import org.solovyev.android.Check; import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessorEditorResult; import org.solovyev.android.calculator.view.TextHighlighter; -import org.solovyev.android.view.AutoResizeTextView; +import org.solovyev.android.views.AutoResizeTextView; import javax.annotation.Nonnull; +import static android.util.TypedValue.COMPLEX_UNIT_SP; +import static android.util.TypedValue.applyDimension; + +@DebugLog public class DisplayView extends AutoResizeTextView { @Nonnull @@ -59,15 +64,15 @@ public class DisplayView extends AutoResizeTextView { } private void init(@Nonnull Context context) { + final Resources resources = getResources(); setAddEllipsis(false); - setMinTextSize(10); - + setMinTextSize(applyDimension(COMPLEX_UNIT_SP, 10, resources.getDisplayMetrics())); if (context instanceof Service) { return; } final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(App.getPreferences()); if (!layout.optimized) { - setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.cpp_display_text_size_mobile)); + setTextSize(resources.getDimensionPixelSize(R.dimen.cpp_display_text_size_mobile)); } } diff --git a/app/src/main/res/layout-large/cpp_app_display.xml b/app/src/main/res/layout-large/cpp_app_display.xml index 389bd2b2..40aedda7 100644 --- a/app/src/main/res/layout-large/cpp_app_display.xml +++ b/app/src/main/res/layout-large/cpp_app_display.xml @@ -22,9 +22,9 @@ ~ Site: http://se.solovyev.org --> - @@ -36,10 +36,6 @@ + style="@style/CppText.Display" /> \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/cpp_app_display.xml b/app/src/main/res/layout-xlarge/cpp_app_display.xml index 389bd2b2..40aedda7 100644 --- a/app/src/main/res/layout-xlarge/cpp_app_display.xml +++ b/app/src/main/res/layout-xlarge/cpp_app_display.xml @@ -22,9 +22,9 @@ ~ Site: http://se.solovyev.org --> - @@ -36,10 +36,6 @@ + style="@style/CppText.Display" /> \ No newline at end of file diff --git a/app/src/main/res/layout/cpp_app_display.xml b/app/src/main/res/layout/cpp_app_display.xml index 579d7932..53a8b09d 100644 --- a/app/src/main/res/layout/cpp_app_display.xml +++ b/app/src/main/res/layout/cpp_app_display.xml @@ -23,11 +23,7 @@ --> \ No newline at end of file + xmlns:android="http://schemas.android.com/apk/res/android" + android:padding="@dimen/cpp_display_padding" /> \ No newline at end of file diff --git a/app/src/main/res/layout/cpp_app_display_mobile.xml b/app/src/main/res/layout/cpp_app_display_mobile.xml index 579d7932..53a8b09d 100644 --- a/app/src/main/res/layout/cpp_app_display_mobile.xml +++ b/app/src/main/res/layout/cpp_app_display_mobile.xml @@ -23,11 +23,7 @@ --> \ No newline at end of file + xmlns:android="http://schemas.android.com/apk/res/android" + android:padding="@dimen/cpp_display_padding" /> \ No newline at end of file diff --git a/app/src/main/res/layout/onscreen_display.xml b/app/src/main/res/layout/onscreen_display.xml index 82353aa3..283c9800 100644 --- a/app/src/main/res/layout/onscreen_display.xml +++ b/app/src/main/res/layout/onscreen_display.xml @@ -6,12 +6,7 @@ ~ or visit http://se.solovyev.org --> - \ No newline at end of file + xmlns:a="http://schemas.android.com/apk/res/android" + a:padding="@dimen/cpp_display_padding" /> \ No newline at end of file diff --git a/app/src/main/res/layout/onscreen_display_light.xml b/app/src/main/res/layout/onscreen_display_light.xml index abb892a7..1af8e30b 100644 --- a/app/src/main/res/layout/onscreen_display_light.xml +++ b/app/src/main/res/layout/onscreen_display_light.xml @@ -6,12 +6,7 @@ ~ or visit http://se.solovyev.org --> - \ No newline at end of file + xmlns:a="http://schemas.android.com/apk/res/android" + a:padding="@dimen/cpp_display_padding" /> \ No newline at end of file diff --git a/app/src/main/res/layout/onscreen_layout.xml b/app/src/main/res/layout/onscreen_layout.xml index b63aecba..4f296d24 100644 --- a/app/src/main/res/layout/onscreen_layout.xml +++ b/app/src/main/res/layout/onscreen_layout.xml @@ -35,7 +35,7 @@ diff --git a/app/src/main/res/layout/onscreen_layout_material.xml b/app/src/main/res/layout/onscreen_layout_material.xml index 26a5ad1b..66e36675 100644 --- a/app/src/main/res/layout/onscreen_layout_material.xml +++ b/app/src/main/res/layout/onscreen_layout_material.xml @@ -35,7 +35,7 @@ diff --git a/app/src/main/res/layout/onscreen_layout_material_light.xml b/app/src/main/res/layout/onscreen_layout_material_light.xml index 49176010..2b682313 100644 --- a/app/src/main/res/layout/onscreen_layout_material_light.xml +++ b/app/src/main/res/layout/onscreen_layout_material_light.xml @@ -35,7 +35,7 @@ diff --git a/app/src/main/res/layout/widget_display.xml b/app/src/main/res/layout/widget_display.xml index c79dcb99..9c051c31 100644 --- a/app/src/main/res/layout/widget_display.xml +++ b/app/src/main/res/layout/widget_display.xml @@ -12,5 +12,4 @@ style="@style/CppText.Display.Widget" a:padding="@dimen/cpp_display_padding" a:scrollbars="vertical" - a:singleLine="false" a:textIsSelectable="true" /> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_display_light.xml b/app/src/main/res/layout/widget_display_light.xml index 366e8880..c6336320 100644 --- a/app/src/main/res/layout/widget_display_light.xml +++ b/app/src/main/res/layout/widget_display_light.xml @@ -12,5 +12,4 @@ style="@style/CppText.Display.Widget.Light" a:padding="@dimen/cpp_display_padding" a:scrollbars="vertical" - a:singleLine="false" a:textIsSelectable="true" /> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_layout.xml b/app/src/main/res/layout/widget_layout.xml index b0e077b7..59fc483f 100644 --- a/app/src/main/res/layout/widget_layout.xml +++ b/app/src/main/res/layout/widget_layout.xml @@ -28,7 +28,7 @@ diff --git a/app/src/main/res/layout/widget_layout_lockscreen_collapsed.xml b/app/src/main/res/layout/widget_layout_lockscreen_collapsed.xml index a993fd5d..7f870349 100644 --- a/app/src/main/res/layout/widget_layout_lockscreen_collapsed.xml +++ b/app/src/main/res/layout/widget_layout_lockscreen_collapsed.xml @@ -43,7 +43,6 @@ a:layout_weight="2" a:padding="@dimen/cpp_display_padding" a:scrollbars="vertical" - a:singleLine="false" a:textIsSelectable="true" a:textSize="@dimen/cpp_widget_display_text_size_collapsed" /> diff --git a/app/src/main/res/layout/widget_layout_material.xml b/app/src/main/res/layout/widget_layout_material.xml index fc45baf9..af1d71b6 100644 --- a/app/src/main/res/layout/widget_layout_material.xml +++ b/app/src/main/res/layout/widget_layout_material.xml @@ -28,7 +28,7 @@ diff --git a/app/src/main/res/layout/widget_layout_material_light.xml b/app/src/main/res/layout/widget_layout_material_light.xml index 7b727342..0981daf1 100644 --- a/app/src/main/res/layout/widget_layout_material_light.xml +++ b/app/src/main/res/layout/widget_layout_material_light.xml @@ -28,7 +28,7 @@ diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index dfb6fc90..9ae2e4d8 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -69,10 +69,13 @@