Fix text auto resizing in DisplayView

This commit is contained in:
serso 2016-02-06 23:57:00 +01:00
parent 667583f95f
commit 191feb6044
17 changed files with 38 additions and 59 deletions

View File

@ -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));
}
}

View File

@ -22,9 +22,9 @@
~ Site: http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/main_fragment_layout"
<LinearLayout a:id="@+id/main_fragment_layout"
style="@style/CppFragment"
xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="match_parent"
a:layout_height="match_parent">
@ -36,10 +36,6 @@
<org.solovyev.android.calculator.DisplayView
a:id="@+id/calculator_display"
style="@style/CppText.Display"
a:inputType="textMultiLine"
a:maxLines="3"
a:scrollHorizontally="false"
a:scrollbars="none" />
style="@style/CppText.Display" />
</LinearLayout>

View File

@ -22,9 +22,9 @@
~ Site: http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/main_fragment_layout"
<LinearLayout a:id="@+id/main_fragment_layout"
style="@style/CppFragment"
xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="match_parent"
a:layout_height="match_parent">
@ -36,10 +36,6 @@
<org.solovyev.android.calculator.DisplayView
a:id="@+id/calculator_display"
style="@style/CppText.Display"
a:inputType="textMultiLine"
a:maxLines="3"
a:scrollHorizontally="false"
a:scrollbars="none" />
style="@style/CppText.Display" />
</LinearLayout>

View File

@ -23,11 +23,7 @@
-->
<org.solovyev.android.calculator.DisplayView
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/calculator_display"
android:id="@+id/calculator_display"
style="@style/CppText.Display"
a:inputType="textMultiLine"
a:maxLines="3"
a:padding="@dimen/cpp_display_padding"
a:scrollHorizontally="false"
a:scrollbars="none" />
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="@dimen/cpp_display_padding" />

View File

@ -23,11 +23,7 @@
-->
<org.solovyev.android.calculator.DisplayView
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/calculator_display"
android:id="@+id/calculator_display"
style="@style/CppText.Display"
a:inputType="textMultiLine"
a:maxLines="3"
a:padding="@dimen/cpp_display_padding"
a:scrollHorizontally="false"
a:scrollbars="none" />
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="@dimen/cpp_display_padding" />

View File

@ -6,12 +6,7 @@
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.calculator.DisplayView
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/calculator_display"
<org.solovyev.android.calculator.DisplayView a:id="@+id/calculator_display"
style="@style/CppText.Display.Onscreen"
a:inputType="textMultiLine"
a:maxLines="3"
a:padding="@dimen/cpp_display_padding"
a:scrollHorizontally="false"
a:scrollbars="none" />
xmlns:a="http://schemas.android.com/apk/res/android"
a:padding="@dimen/cpp_display_padding" />

View File

@ -6,12 +6,7 @@
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.calculator.DisplayView
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/calculator_display"
<org.solovyev.android.calculator.DisplayView a:id="@+id/calculator_display"
style="@style/CppText.Display.Onscreen.Light"
a:inputType="textMultiLine"
a:maxLines="3"
a:padding="@dimen/cpp_display_padding"
a:scrollHorizontally="false"
a:scrollbars="none" />
xmlns:a="http://schemas.android.com/apk/res/android"
a:padding="@dimen/cpp_display_padding" />

View File

@ -35,7 +35,7 @@
<include
layout="@layout/onscreen_display"
a:layout_width="0dp"
a:layout_height="wrap_content"
a:layout_height="match_parent"
a:layout_weight="4" />
</LinearLayout>

View File

@ -35,7 +35,7 @@
<include
layout="@layout/onscreen_display"
a:layout_width="0dp"
a:layout_height="wrap_content"
a:layout_height="match_parent"
a:layout_weight="4" />
</LinearLayout>

View File

@ -35,7 +35,7 @@
<include
layout="@layout/onscreen_display_light"
a:layout_width="0dp"
a:layout_height="wrap_content"
a:layout_height="match_parent"
a:layout_weight="4" />
</LinearLayout>

View File

@ -12,5 +12,4 @@
style="@style/CppText.Display.Widget"
a:padding="@dimen/cpp_display_padding"
a:scrollbars="vertical"
a:singleLine="false"
a:textIsSelectable="true" />

View File

@ -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" />

View File

@ -28,7 +28,7 @@
<include
layout="@layout/widget_display"
a:layout_width="0dp"
a:layout_height="wrap_content"
a:layout_height="match_parent"
a:layout_weight="5" />
</LinearLayout>

View File

@ -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" />

View File

@ -28,7 +28,7 @@
<include
layout="@layout/widget_display"
a:layout_width="0dp"
a:layout_height="wrap_content"
a:layout_height="match_parent"
a:layout_weight="5" />
</LinearLayout>

View File

@ -28,7 +28,7 @@
<include
layout="@layout/widget_display_light"
a:layout_width="0dp"
a:layout_height="wrap_content"
a:layout_height="match_parent"
a:layout_weight="5" />
</LinearLayout>

View File

@ -69,10 +69,13 @@
</style>
<style name="CppText.Display" parent="CppText">
<item name="android:gravity">top|right</item>
<item name="android:gravity">center_vertical|right</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:singleLine">false</item>
<item name="android:textSize">@dimen/cpp_display_text_size</item>
<item name="android:scrollHorizontally">false</item>
<item name="android:scrollbars">none</item>
</style>
<style name="CppText.Display.Onscreen" parent="CppText.Display">