Layout for large screens

This commit is contained in:
serso 2016-02-21 14:24:11 +01:00
parent 96b4290260
commit 6339da1b7b
18 changed files with 215 additions and 129 deletions

View File

@ -83,6 +83,9 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
Toolbar toolbar; Toolbar toolbar;
@Bind(R.id.editor) @Bind(R.id.editor)
FrameLayout editor; FrameLayout editor;
@Nullable
@Bind(R.id.card)
CardView card;
private boolean useBackAsPrev; private boolean useBackAsPrev;
public CalculatorActivity() { public CalculatorActivity() {
@ -292,10 +295,9 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
} }
private void prepareCardAndToolbar() { private void prepareCardAndToolbar() {
if (!(editor instanceof CardView)) { if (card == null) {
return; return;
} }
final CardView card = (CardView) editor;
final Resources resources = getResources(); final Resources resources = getResources();
final int cardTopMargin = resources.getDimensionPixelSize(R.dimen.cpp_card_margin); final int cardTopMargin = resources.getDimensionPixelSize(R.dimen.cpp_card_margin);
final int preLollipopCardTopPadding = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? card.getPaddingTop() : 0; final int preLollipopCardTopPadding = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? card.getPaddingTop() : 0;

View File

@ -32,6 +32,7 @@ import android.view.ContextMenu;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.floating.FloatingCalculatorService; import org.solovyev.android.calculator.floating.FloatingCalculatorService;
import org.solovyev.android.calculator.view.EditTextCompat; import org.solovyev.android.calculator.view.EditTextCompat;
import org.solovyev.android.views.Adjuster;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -64,6 +65,7 @@ public class EditorView extends EditTextCompat {
} }
private void init() { private void init() {
Adjuster.adjustText(this, 0.25f);
addTextChangedListener(new MyTextWatcher()); addTextChangedListener(new MyTextWatcher());
dontShowSoftInputOnFocusCompat(); dontShowSoftInputOnFocusCompat();
// changes should only be reported after the view has been set up completely, i.e. now // changes should only be reported after the view has been set up completely, i.e. now

View File

@ -21,7 +21,8 @@
~ Email: se.solovyev@gmail.com ~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org ~ Site: http://se.solovyev.org
--> -->
<LinearLayout a:id="@+id/main" <LinearLayout
a:id="@+id/main"
style="@style/CppMain" style="@style/CppMain"
xmlns:a="http://schemas.android.com/apk/res/android" xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical"> a:orientation="vertical">
@ -69,11 +70,10 @@
</LinearLayout> </LinearLayout>
<LinearLayout <FrameLayout
a:id="@+id/keyboard" a:id="@+id/keyboard"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp" a:layout_height="0dp"
a:layout_weight="3" a:layout_weight="3" />
a:orientation="horizontal" />
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ 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.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout
a:id="@+id/main"
style="@style/CppMain"
xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical">
<FrameLayout
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="3">
<android.support.v7.widget.Toolbar
a:id="@+id/toolbar"
a:layout_width="match_parent"
a:layout_height="?actionBarSize" />
<android.support.v7.widget.CardView
a:id="@+id/card"
style="?attr/cpp_card_style"
a:layout_width="match_parent"
a:layout_height="match_parent"
a:layout_margin="@dimen/cpp_card_margin">
<LinearLayout
a:layout_width="match_parent"
a:layout_height="match_parent"
a:orientation="vertical">
<FrameLayout
a:id="@+id/editor"
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="2" />
<View
a:layout_width="match_parent"
a:layout_height="1px"
a:background="?android:attr/listDivider" />
<FrameLayout
a:id="@+id/display"
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="1" />
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
<FrameLayout
a:id="@+id/keyboard"
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="4" />
</LinearLayout>

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ 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.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="match_parent"
a:layout_height="match_parent"
a:orientation="vertical">
<LinearLayout
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="1"
a:baselineAligned="false"
a:orientation="horizontal">
<include layout="@layout/cpp_app_button_left" />
<include layout="@layout/cpp_app_button_erase" />
<include layout="@layout/cpp_app_button_copy" />
<include layout="@layout/cpp_app_button_paste" />
<include layout="@layout/cpp_app_button_donate" />
<include layout="@layout/cpp_app_button_clear" />
<include layout="@layout/cpp_app_button_right" />
</LinearLayout>
<LinearLayout
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="1"
a:baselineAligned="false"
a:orientation="horizontal">
<include layout="@layout/cpp_app_button_vars" />
<include layout="@layout/cpp_app_button_7" />
<include layout="@layout/cpp_app_button_8" />
<include layout="@layout/cpp_app_button_9" />
<include layout="@layout/cpp_app_button_multiplication" />
<include layout="@layout/cpp_app_button_division" />
<include layout="@layout/cpp_app_button_equals" />
</LinearLayout>
<LinearLayout
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="1"
a:baselineAligned="false"
a:orientation="horizontal">
<include layout="@layout/cpp_app_button_functions" />
<include layout="@layout/cpp_app_button_4" />
<include layout="@layout/cpp_app_button_5" />
<include layout="@layout/cpp_app_button_6" />
<include layout="@layout/cpp_app_button_plus" />
<include layout="@layout/cpp_app_button_minus" />
<include layout="@layout/cpp_app_button_round_brackets" />
</LinearLayout>
<LinearLayout
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="1"
a:baselineAligned="false"
a:orientation="horizontal">
<include layout="@layout/cpp_app_button_operators" />
<include layout="@layout/cpp_app_button_1" />
<include layout="@layout/cpp_app_button_2" />
<include layout="@layout/cpp_app_button_3" />
<include layout="@layout/cpp_app_button_0" />
<include layout="@layout/cpp_app_button_dot" />
<include layout="@layout/cpp_app_button_history" />
</LinearLayout>
</LinearLayout>

View File

@ -53,11 +53,10 @@
</LinearLayout> </LinearLayout>
<LinearLayout <FrameLayout
a:id="@+id/keyboard" a:id="@+id/keyboard"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp" a:layout_height="0dp"
a:layout_weight="5" a:layout_weight="5" />
a:orientation="vertical" />
</LinearLayout> </LinearLayout>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ 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.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<org.solovyev.android.calculator.DisplayView
android:id="@+id/calculator_display"
style="@style/CppText.Display"
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="@dimen/cpp_display_padding" />

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ 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.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/main_fragment_layout"
style="@style/CppFragment"
a:layout_width="match_parent"
a:layout_height="match_parent"
a:padding="@dimen/cpp_editor_padding">
<org.solovyev.android.calculator.EditorView
a:id="@+id/calculator_editor"
style="@style/CppText.Editor.Mobile"
a:hint="@string/c_calc_editor_hint"
a:scrollbars="vertical"
a:singleLine="false"
a:textIsSelectable="true" />
</LinearLayout>

View File

@ -31,12 +31,6 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent"> a:layout_height="match_parent">
<TextView
a:id="@+id/fragmentTitle"
style="@style/CppFragmentTitle"
a:layout_width="match_parent"
a:layout_height="wrap_content" />
<org.solovyev.android.calculator.AdView style="@style/CppAd" /> <org.solovyev.android.calculator.AdView style="@style/CppAd" />
<LinearLayout <LinearLayout

View File

@ -22,10 +22,6 @@
<resources> <resources>
<dimen name="cpp_editor_text_size">20sp</dimen> <dimen name="cpp_editor_text_size">20sp</dimen>
<dimen name="cpp_editor_text_size_mobile">40sp</dimen>
<dimen name="cpp_display_text_size">20sp</dimen> <dimen name="cpp_display_text_size">20sp</dimen>
<dimen name="cpp_display_text_size_mobile">40sp</dimen>
<dimen name="cpp_keyboard_button_text_size">24dp</dimen> <dimen name="cpp_keyboard_button_text_size">24dp</dimen>
</resources> </resources>

View File

@ -22,10 +22,6 @@
<resources> <resources>
<dimen name="cpp_editor_text_size">25sp</dimen> <dimen name="cpp_editor_text_size">25sp</dimen>
<dimen name="cpp_editor_text_size_mobile">45sp</dimen>
<dimen name="cpp_display_text_size">20sp</dimen> <dimen name="cpp_display_text_size">20sp</dimen>
<dimen name="cpp_display_text_size_mobile">35sp</dimen>
<dimen name="cpp_keyboard_button_text_size">35dp</dimen> <dimen name="cpp_keyboard_button_text_size">35dp</dimen>
</resources> </resources>

View File

@ -22,10 +22,6 @@
<resources> <resources>
<dimen name="cpp_editor_text_size">30sp</dimen> <dimen name="cpp_editor_text_size">30sp</dimen>
<dimen name="cpp_editor_text_size_mobile">40sp</dimen>
<dimen name="cpp_display_text_size">30sp</dimen> <dimen name="cpp_display_text_size">30sp</dimen>
<dimen name="cpp_display_text_size_mobile">35sp</dimen>
<dimen name="cpp_keyboard_button_text_size">33dp</dimen> <dimen name="cpp_keyboard_button_text_size">33dp</dimen>
</resources> </resources>

View File

@ -22,11 +22,6 @@
<resources> <resources>
<dimen name="cpp_fragment_text_size">15sp</dimen> <dimen name="cpp_fragment_text_size">15sp</dimen>
<dimen name="cpp_fragment_title_text_size">20sp</dimen>
<dimen name="cpp_editor_text_size">30sp</dimen> <dimen name="cpp_editor_text_size">30sp</dimen>
<dimen name="cpp_editor_text_size_mobile">30sp</dimen>
<dimen name="cpp_display_text_size">30sp</dimen> <dimen name="cpp_display_text_size">30sp</dimen>
<dimen name="cpp_display_text_size_mobile">30sp</dimen>
</resources> </resources>

View File

@ -22,12 +22,7 @@
<resources> <resources>
<dimen name="cpp_fragment_text_size">15sp</dimen> <dimen name="cpp_fragment_text_size">15sp</dimen>
<dimen name="cpp_fragment_title_text_size">20sp</dimen>
<dimen name="cpp_editor_text_size">20sp</dimen> <dimen name="cpp_editor_text_size">20sp</dimen>
<dimen name="cpp_editor_text_size_mobile">20sp</dimen>
<dimen name="cpp_display_text_size">20sp</dimen> <dimen name="cpp_display_text_size">20sp</dimen>
<dimen name="cpp_display_text_size_mobile">20sp</dimen>
<dimen name="cpp_clickable_area_size">40dp</dimen> <dimen name="cpp_clickable_area_size">40dp</dimen>
</resources> </resources>

View File

@ -22,10 +22,6 @@
<resources> <resources>
<dimen name="cpp_editor_text_size">30sp</dimen> <dimen name="cpp_editor_text_size">30sp</dimen>
<dimen name="cpp_editor_text_size_mobile">75sp</dimen>
<dimen name="cpp_display_text_size_mobile">75sp</dimen>
<dimen name="cpp_display_text_size">30sp</dimen> <dimen name="cpp_display_text_size">30sp</dimen>
<dimen name="cpp_keyboard_button_text_size">40dp</dimen> <dimen name="cpp_keyboard_button_text_size">40dp</dimen>
</resources> </resources>

View File

@ -22,10 +22,6 @@
<resources> <resources>
<dimen name="cpp_editor_text_size">40sp</dimen> <dimen name="cpp_editor_text_size">40sp</dimen>
<dimen name="cpp_editor_text_size_mobile">75sp</dimen>
<dimen name="cpp_display_text_size_mobile">75sp</dimen>
<dimen name="cpp_display_text_size">30sp</dimen> <dimen name="cpp_display_text_size">30sp</dimen>
<dimen name="cpp_keyboard_button_text_size">35dp</dimen> <dimen name="cpp_keyboard_button_text_size">35dp</dimen>
</resources> </resources>

View File

@ -16,9 +16,6 @@
<dimen name="cpp_keyboard_button_text_size">30dp</dimen> <dimen name="cpp_keyboard_button_text_size">30dp</dimen>
<dimen name="cpp_keyboard_simple_image_button_padding">12dp</dimen> <dimen name="cpp_keyboard_simple_image_button_padding">12dp</dimen>
<dimen name="cpp_display_text_size_mobile">25sp</dimen>
<dimen name="cpp_editor_text_size_mobile">25sp</dimen>
<dimen name="cpp_display_text_size">25sp</dimen> <dimen name="cpp_display_text_size">25sp</dimen>
<dimen name="cpp_editor_text_size">25sp</dimen> <dimen name="cpp_editor_text_size">25sp</dimen>
<dimen name="cpp_pane_margin">2dp</dimen> <dimen name="cpp_pane_margin">2dp</dimen>

View File

@ -66,10 +66,6 @@
<item name="android:inputType">textMultiLine|textNoSuggestions</item> <item name="android:inputType">textMultiLine|textNoSuggestions</item>
</style> </style>
<style name="CppText.Editor.Mobile" parent="CppText.Editor">
<item name="android:textSize">@dimen/cpp_editor_text_size_mobile</item>
</style>
<style name="CppText.Display" parent="CppText"> <style name="CppText.Display" parent="CppText">
<item name="android:gravity">center_vertical|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>
@ -203,11 +199,6 @@
<item name="android:textAppearance">@android:style/TextAppearance.Medium</item> <item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
</style> </style>
<style name="CppFragmentTitle">
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textSize">@dimen/cpp_fragment_title_text_size</item>
</style>
<style name="CppPane.Multipane.Left" parent="CppPane.Multipane"> <style name="CppPane.Multipane.Left" parent="CppPane.Multipane">
<item name="android:layout_marginLeft">0dp</item> <item name="android:layout_marginLeft">0dp</item>
</style> </style>