Fix text auto resizing in DisplayView
This commit is contained in:
parent
667583f95f
commit
191feb6044
@ -24,18 +24,23 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.TypedValue;
|
import hugo.weaving.DebugLog;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.text.TextProcessor;
|
import org.solovyev.android.calculator.text.TextProcessor;
|
||||||
import org.solovyev.android.calculator.text.TextProcessorEditorResult;
|
import org.solovyev.android.calculator.text.TextProcessorEditorResult;
|
||||||
import org.solovyev.android.calculator.view.TextHighlighter;
|
import org.solovyev.android.calculator.view.TextHighlighter;
|
||||||
import org.solovyev.android.view.AutoResizeTextView;
|
import org.solovyev.android.views.AutoResizeTextView;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import static android.util.TypedValue.COMPLEX_UNIT_SP;
|
||||||
|
import static android.util.TypedValue.applyDimension;
|
||||||
|
|
||||||
|
@DebugLog
|
||||||
public class DisplayView extends AutoResizeTextView {
|
public class DisplayView extends AutoResizeTextView {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -59,15 +64,15 @@ public class DisplayView extends AutoResizeTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init(@Nonnull Context context) {
|
private void init(@Nonnull Context context) {
|
||||||
|
final Resources resources = getResources();
|
||||||
setAddEllipsis(false);
|
setAddEllipsis(false);
|
||||||
setMinTextSize(10);
|
setMinTextSize(applyDimension(COMPLEX_UNIT_SP, 10, resources.getDisplayMetrics()));
|
||||||
|
|
||||||
if (context instanceof Service) {
|
if (context instanceof Service) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(App.getPreferences());
|
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(App.getPreferences());
|
||||||
if (!layout.optimized) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
~ Site: http://se.solovyev.org
|
~ Site: http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
<LinearLayout a:id="@+id/main_fragment_layout"
|
||||||
a:id="@+id/main_fragment_layout"
|
|
||||||
style="@style/CppFragment"
|
style="@style/CppFragment"
|
||||||
|
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
a:layout_height="match_parent">
|
a:layout_height="match_parent">
|
||||||
|
|
||||||
@ -36,10 +36,6 @@
|
|||||||
|
|
||||||
<org.solovyev.android.calculator.DisplayView
|
<org.solovyev.android.calculator.DisplayView
|
||||||
a:id="@+id/calculator_display"
|
a:id="@+id/calculator_display"
|
||||||
style="@style/CppText.Display"
|
style="@style/CppText.Display" />
|
||||||
a:inputType="textMultiLine"
|
|
||||||
a:maxLines="3"
|
|
||||||
a:scrollHorizontally="false"
|
|
||||||
a:scrollbars="none" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -22,9 +22,9 @@
|
|||||||
~ Site: http://se.solovyev.org
|
~ Site: http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
<LinearLayout a:id="@+id/main_fragment_layout"
|
||||||
a:id="@+id/main_fragment_layout"
|
|
||||||
style="@style/CppFragment"
|
style="@style/CppFragment"
|
||||||
|
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
a:layout_height="match_parent">
|
a:layout_height="match_parent">
|
||||||
|
|
||||||
@ -36,10 +36,6 @@
|
|||||||
|
|
||||||
<org.solovyev.android.calculator.DisplayView
|
<org.solovyev.android.calculator.DisplayView
|
||||||
a:id="@+id/calculator_display"
|
a:id="@+id/calculator_display"
|
||||||
style="@style/CppText.Display"
|
style="@style/CppText.Display" />
|
||||||
a:inputType="textMultiLine"
|
|
||||||
a:maxLines="3"
|
|
||||||
a:scrollHorizontally="false"
|
|
||||||
a:scrollbars="none" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -23,11 +23,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.calculator.DisplayView
|
<org.solovyev.android.calculator.DisplayView
|
||||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
android:id="@+id/calculator_display"
|
||||||
a:id="@+id/calculator_display"
|
|
||||||
style="@style/CppText.Display"
|
style="@style/CppText.Display"
|
||||||
a:inputType="textMultiLine"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
a:maxLines="3"
|
android:padding="@dimen/cpp_display_padding" />
|
||||||
a:padding="@dimen/cpp_display_padding"
|
|
||||||
a:scrollHorizontally="false"
|
|
||||||
a:scrollbars="none" />
|
|
@ -23,11 +23,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.calculator.DisplayView
|
<org.solovyev.android.calculator.DisplayView
|
||||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
android:id="@+id/calculator_display"
|
||||||
a:id="@+id/calculator_display"
|
|
||||||
style="@style/CppText.Display"
|
style="@style/CppText.Display"
|
||||||
a:inputType="textMultiLine"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
a:maxLines="3"
|
android:padding="@dimen/cpp_display_padding" />
|
||||||
a:padding="@dimen/cpp_display_padding"
|
|
||||||
a:scrollHorizontally="false"
|
|
||||||
a:scrollbars="none" />
|
|
@ -6,12 +6,7 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.calculator.DisplayView
|
<org.solovyev.android.calculator.DisplayView a:id="@+id/calculator_display"
|
||||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
|
||||||
a:id="@+id/calculator_display"
|
|
||||||
style="@style/CppText.Display.Onscreen"
|
style="@style/CppText.Display.Onscreen"
|
||||||
a:inputType="textMultiLine"
|
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
a:maxLines="3"
|
a:padding="@dimen/cpp_display_padding" />
|
||||||
a:padding="@dimen/cpp_display_padding"
|
|
||||||
a:scrollHorizontally="false"
|
|
||||||
a:scrollbars="none" />
|
|
@ -6,12 +6,7 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.calculator.DisplayView
|
<org.solovyev.android.calculator.DisplayView a:id="@+id/calculator_display"
|
||||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
|
||||||
a:id="@+id/calculator_display"
|
|
||||||
style="@style/CppText.Display.Onscreen.Light"
|
style="@style/CppText.Display.Onscreen.Light"
|
||||||
a:inputType="textMultiLine"
|
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
a:maxLines="3"
|
a:padding="@dimen/cpp_display_padding" />
|
||||||
a:padding="@dimen/cpp_display_padding"
|
|
||||||
a:scrollHorizontally="false"
|
|
||||||
a:scrollbars="none" />
|
|
@ -35,7 +35,7 @@
|
|||||||
<include
|
<include
|
||||||
layout="@layout/onscreen_display"
|
layout="@layout/onscreen_display"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="match_parent"
|
||||||
a:layout_weight="4" />
|
a:layout_weight="4" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<include
|
<include
|
||||||
layout="@layout/onscreen_display"
|
layout="@layout/onscreen_display"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="match_parent"
|
||||||
a:layout_weight="4" />
|
a:layout_weight="4" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<include
|
<include
|
||||||
layout="@layout/onscreen_display_light"
|
layout="@layout/onscreen_display_light"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="match_parent"
|
||||||
a:layout_weight="4" />
|
a:layout_weight="4" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -12,5 +12,4 @@
|
|||||||
style="@style/CppText.Display.Widget"
|
style="@style/CppText.Display.Widget"
|
||||||
a:padding="@dimen/cpp_display_padding"
|
a:padding="@dimen/cpp_display_padding"
|
||||||
a:scrollbars="vertical"
|
a:scrollbars="vertical"
|
||||||
a:singleLine="false"
|
|
||||||
a:textIsSelectable="true" />
|
a:textIsSelectable="true" />
|
@ -12,5 +12,4 @@
|
|||||||
style="@style/CppText.Display.Widget.Light"
|
style="@style/CppText.Display.Widget.Light"
|
||||||
a:padding="@dimen/cpp_display_padding"
|
a:padding="@dimen/cpp_display_padding"
|
||||||
a:scrollbars="vertical"
|
a:scrollbars="vertical"
|
||||||
a:singleLine="false"
|
|
||||||
a:textIsSelectable="true" />
|
a:textIsSelectable="true" />
|
@ -28,7 +28,7 @@
|
|||||||
<include
|
<include
|
||||||
layout="@layout/widget_display"
|
layout="@layout/widget_display"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="match_parent"
|
||||||
a:layout_weight="5" />
|
a:layout_weight="5" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
a:layout_weight="2"
|
a:layout_weight="2"
|
||||||
a:padding="@dimen/cpp_display_padding"
|
a:padding="@dimen/cpp_display_padding"
|
||||||
a:scrollbars="vertical"
|
a:scrollbars="vertical"
|
||||||
a:singleLine="false"
|
|
||||||
a:textIsSelectable="true"
|
a:textIsSelectable="true"
|
||||||
a:textSize="@dimen/cpp_widget_display_text_size_collapsed" />
|
a:textSize="@dimen/cpp_widget_display_text_size_collapsed" />
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<include
|
<include
|
||||||
layout="@layout/widget_display"
|
layout="@layout/widget_display"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="match_parent"
|
||||||
a:layout_weight="5" />
|
a:layout_weight="5" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<include
|
<include
|
||||||
layout="@layout/widget_display_light"
|
layout="@layout/widget_display_light"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="match_parent"
|
||||||
a:layout_weight="5" />
|
a:layout_weight="5" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -69,10 +69,13 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CppText.Display" parent="CppText">
|
<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_width">match_parent</item>
|
||||||
<item name="android:layout_height">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:textSize">@dimen/cpp_display_text_size</item>
|
||||||
|
<item name="android:scrollHorizontally">false</item>
|
||||||
|
<item name="android:scrollbars">none</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CppText.Display.Onscreen" parent="CppText.Display">
|
<style name="CppText.Display.Onscreen" parent="CppText.Display">
|
||||||
|
Loading…
Reference in New Issue
Block a user