changes
This commit is contained in:
parent
c8440e18a5
commit
abebb25e53
@ -15,6 +15,6 @@
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/second_pane_background"/>
|
||||
<solid android:color="@color/pane_background"/>
|
||||
<corners android:radius="1dp" />
|
||||
</shape>
|
@ -7,12 +7,9 @@
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:layout_gravity="center"
|
||||
a:background="@color/default_background">
|
||||
style="?mainLayoutStyle">
|
||||
|
||||
<include layout="@layout/main_first_pane"/>
|
||||
|
||||
|
@ -7,12 +7,9 @@
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:background="@color/default_background"
|
||||
a:baselineAligned="false">
|
||||
style="?mainMultiPaneLayoutStyle">
|
||||
|
||||
<LinearLayout
|
||||
a:layout_height="0dp"
|
||||
@ -47,7 +44,7 @@
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:orientation="vertical"
|
||||
style="?secondPaneStyle"/>
|
||||
style="?paneStyle"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -55,6 +52,6 @@
|
||||
a:layout_height="0dp"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_weight="1"
|
||||
style="?fragmentLayoutStyle"/>
|
||||
style="?paneStyleTransparent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:orientation="vertical"
|
||||
a:id="@+id/ad_parent_view"
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="?fragmentLayoutStyle"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
@ -12,8 +12,7 @@
|
||||
a:layout_height="match_parent"
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:layout_gravity="center"
|
||||
a:background="@color/default_background">
|
||||
style="?mainLayoutStyle">
|
||||
|
||||
<LinearLayout a:id="@+id/editorContainer"
|
||||
a:layout_weight="2"
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent">
|
||||
style="?mainLayoutStyle"
|
||||
a:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
14
calculatorpp/res/layout/main_empty_multi_pane.xml
Normal file
14
calculatorpp/res/layout/main_empty_multi_pane.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||
~ For more information, please, contact se.solovyev@gmail.com
|
||||
~ or visit http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:id="@+id/main_layout"
|
||||
style="?mainMultiPaneLayoutStyle"
|
||||
a:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
@ -2,7 +2,7 @@
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:orientation="vertical"
|
||||
a:id="@+id/ad_parent_view"
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="?fragmentLayoutStyle"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
17
calculatorpp/res/layout/math_entities_fragment.xml
Normal file
17
calculatorpp/res/layout/math_entities_fragment.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:orientation="vertical"
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="?fragmentLayoutStyle"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
||||
<TextView a:id="@+id/fragmentTitle"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="?fragmentTitleStyle"/>
|
||||
|
||||
<ListView style="?fragmentListViewStyle"/>
|
||||
|
||||
</LinearLayout>
|
@ -7,11 +7,11 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:orientation="vertical"
|
||||
a:id="@+id/ad_parent_view"
|
||||
style="?fragmentLayoutStyle"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
a:orientation="vertical"
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="?fragmentLayoutStyle"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
||||
<TextView a:id="@+id/fragmentTitle"
|
||||
a:layout_height="wrap_content"
|
||||
@ -20,13 +20,12 @@
|
||||
|
||||
<ListView style="?fragmentListViewStyle"/>
|
||||
|
||||
<!-- todo serso: uncomment button-->
|
||||
<!-- <Button
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_gravity="center_horizontal"
|
||||
a:text="@string/c_add"
|
||||
style="?buttonStyle"
|
||||
a:onClick="addVarButtonClickHandler"/>-->
|
||||
<!--todo serso: uncomment-->
|
||||
<!--<Button
|
||||
a:id="@+id/add_var_button"
|
||||
a:text="@string/c_add"
|
||||
style="?buttonStyle"
|
||||
a:onClick="addVarButtonClickHandler"
|
||||
a:layout_marginBottom="@dimen/pane_padding"/>-->
|
||||
|
||||
</LinearLayout>
|
@ -9,5 +9,6 @@
|
||||
<menu xmlns:a="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item a:id="@+id/var_menu_add_var"
|
||||
a:title="@string/c_add"/>
|
||||
a:title="@string/c_add"
|
||||
a:showAsAction="always"/>
|
||||
</menu>
|
@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<dimen name="button_text_size">20dp</dimen>
|
||||
<dimen name="keyboard_button_text_size">20dp</dimen>
|
||||
</resources>
|
@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<dimen name="button_text_size">40dp</dimen>
|
||||
<dimen name="keyboard_button_text_size">40dp</dimen>
|
||||
</resources>
|
@ -6,10 +6,12 @@
|
||||
<attr name="controlImageButtonStyle" format="reference" />
|
||||
<attr name="operationButtonStyle" format="reference" />
|
||||
<attr name="fragmentLayoutStyle" format="reference" />
|
||||
<attr name="secondPaneStyle" format="reference" />
|
||||
<attr name="fragmentTitleStyle" format="reference" />
|
||||
<attr name="fragmentListViewStyle" format="reference" />
|
||||
<attr name="buttonStyle" format="reference" />
|
||||
<attr name="paneStyle" format="reference" />
|
||||
<attr name="paneStyleTransparent" format="reference" />
|
||||
<attr name="mainLayoutStyle" format="reference" />
|
||||
<attr name="mainMultiPaneLayoutStyle" format="reference" />
|
||||
|
||||
</resources>
|
||||
|
@ -13,6 +13,6 @@
|
||||
<color name="display_error_text_color">#ff393939</color>
|
||||
<color name="selected_angle_unit_text_color">#ffffff99</color>
|
||||
<color name="default_background">#ff000000</color>
|
||||
<color name="second_pane_background">#ff1f1f1f</color>
|
||||
<color name="pane_background">#ff1f1f1f</color>
|
||||
<color name="metro_button_background">#ff1f1f1f</color>
|
||||
</resources>
|
@ -1,7 +1,10 @@
|
||||
<resources>
|
||||
<dimen name="button_margin">0.5dp</dimen>
|
||||
<dimen name="text_size">20sp</dimen>
|
||||
<dimen name="button_text_size">30dp</dimen>
|
||||
<dimen name="keyboard_button_text_size">30dp</dimen>
|
||||
<dimen name="button_text_size">20dp</dimen>
|
||||
<dimen name="display_text_size">25sp</dimen>
|
||||
<dimen name="editor_text_size">25sp</dimen>
|
||||
<dimen name="pane_margin">5dp</dimen>
|
||||
<dimen name="pane_padding">5dp</dimen>
|
||||
</resources>
|
@ -8,19 +8,16 @@
|
||||
<resources>
|
||||
|
||||
<style name="math_entity_text" parent="math_entity_text_parent">
|
||||
<item name="android:paddingTop">6dp</item>
|
||||
<item name="android:paddingLeft">6dp</item>
|
||||
<item name="android:paddingRight">6dp</item>
|
||||
<item name="android:paddingBottom">0dp</item>
|
||||
<item name="android:paddingTop">0dp</item>
|
||||
<item name="android:paddingLeft">0dp</item>
|
||||
<item name="android:paddingRight">0dp</item>
|
||||
<item name="android:paddingBottom">@dimen/pane_padding</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="math_entity_description" parent="math_entity_description_parent">
|
||||
<item name="android:paddingTop">0dp</item>
|
||||
<item name="android:paddingLeft">6dp</item>
|
||||
<item name="android:paddingRight">6dp</item>
|
||||
<item name="android:paddingBottom">0dp</item>
|
||||
<item name="android:padding">0dp</item>
|
||||
<item name="android:textColor">#bebebe</item>
|
||||
</style>
|
||||
|
||||
|
@ -8,13 +8,20 @@
|
||||
<resources>
|
||||
|
||||
<style name="button_style" parent="button_style_parent">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">fill_parent</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:focusable">true</item>
|
||||
<item name="android:background">@drawable/default_button_dark</item>
|
||||
<item name="android:layout_margin">@dimen/button_margin</item>
|
||||
</style>
|
||||
<item name="android:background">@drawable/metro_button_blue</item>
|
||||
</style>
|
||||
|
||||
<style name="keyboard_button_style" parent="keyboard_button_style_parent">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">fill_parent</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:focusable">true</item>
|
||||
<item name="android:background">@drawable/default_button_dark</item>
|
||||
<item name="android:layout_margin">@dimen/button_margin</item>
|
||||
</style>
|
||||
|
||||
<style name="editor_style" parent="editor_style_parent">
|
||||
<item name="android:gravity">left|top</item>
|
||||
|
@ -6,62 +6,91 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="default_digit_button_style" parent="button_style">
|
||||
<item name="android:background">@drawable/default_button</item>
|
||||
</style>
|
||||
<style name="default_digit_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/default_button</item>
|
||||
</style>
|
||||
|
||||
<style name="default_control_button_style" parent="button_style"/>
|
||||
<style name="default_control_button_style" parent="keyboard_button_style"/>
|
||||
|
||||
<style name="default_operation_button_style" parent="default_digit_button_style">
|
||||
<item name="android:textColor">@color/button_operator_text_color</item>
|
||||
</style>
|
||||
<style name="default_operation_button_style" parent="default_digit_button_style">
|
||||
<item name="android:textColor">@color/button_operator_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="default_control_image_button_style" parent="default_control_button_style">
|
||||
<item name="android:padding">6dp</item>
|
||||
</style>
|
||||
|
||||
<style name="default_pane_style" parent="default_fragment_layout_style">
|
||||
<item name="android:background">@drawable/second_pane_background</item>
|
||||
<item name="android:padding">5dp</item>
|
||||
<style name="default_control_image_button_style" parent="default_control_button_style">
|
||||
<item name="android:padding">6dp</item>
|
||||
</style>
|
||||
|
||||
<style name="default_fragment_list_view_style">
|
||||
<item name="android:id">@android:id/list</item>
|
||||
<item name="android:divider">@null</item>
|
||||
<item name="android:dividerHeight">0dp</item>
|
||||
<item name="android:cacheColorHint">@android:color/transparent</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:id">@android:id/list</item>
|
||||
<item name="android:divider">@null</item>
|
||||
<item name="android:dividerHeight">0dp</item>
|
||||
<item name="android:cacheColorHint">@android:color/transparent</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:fadingEdge">none</item>
|
||||
<item name="android:layout_marginBottom">@dimen/pane_padding</item>
|
||||
</style>
|
||||
|
||||
<style name="default_fragment_title_style">
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
<item name="android:textSize">25sp</item>
|
||||
<item name="android:layout_marginLeft">6dp</item>
|
||||
</style>
|
||||
|
||||
<style name="default_button_style" parent="button_style">
|
||||
<item name="android:background">@drawable/metro_button_blue</item>
|
||||
<item name="android:paddingTop">5dp</item>
|
||||
<item name="android:paddingBottom">5dp</item>
|
||||
<item name="android:paddingLeft">10dp</item>
|
||||
<item name="android:paddingRight">10dp</item>
|
||||
</style>
|
||||
|
||||
<style name="default_pane_style_transparent" parent="default_pane_style">
|
||||
<item name="android:background">@android:color/transparent</item>
|
||||
<item name="android:padding">0dp</item>
|
||||
</style>
|
||||
|
||||
<style name="default_pane_style">
|
||||
<item name="android:layout_marginLeft">@dimen/pane_margin</item>
|
||||
<item name="android:layout_marginTop">@dimen/pane_margin</item>
|
||||
<item name="android:padding">@dimen/pane_padding</item>
|
||||
<item name="android:background">@drawable/pane_background</item>
|
||||
</style>
|
||||
|
||||
<style name="default_main_multi_pane_layout_style" parent="default_main_layout_style">
|
||||
<item name="android:paddingRight">@dimen/pane_padding</item>
|
||||
<item name="android:paddingBottom">@dimen/pane_padding</item>
|
||||
</style>
|
||||
|
||||
<style name="default_fragment_multi_pane_layout_style" parent="default_fragment_layout_style">
|
||||
</style>
|
||||
|
||||
<style name="default_fragment_layout_style">
|
||||
<item name="android:layout_marginBottom">0dp</item>
|
||||
<item name="android:layout_marginTop">5dp</item>
|
||||
<item name="android:layout_marginLeft">5dp</item>
|
||||
<item name="android:layout_marginRight">0dp</item>
|
||||
<item name="android:layout_margin">0dp</item>
|
||||
<item name="android:padding">0dp</item>
|
||||
</style>
|
||||
|
||||
<style name="default_theme" parent="Theme.Sherlock">
|
||||
<item name="digitButtonStyle">@style/default_digit_button_style</item>
|
||||
<item name="controlButtonStyle">@style/default_control_button_style</item>
|
||||
<item name="controlImageButtonStyle">@style/default_control_image_button_style</item>
|
||||
<item name="operationButtonStyle">@style/default_operation_button_style</item>
|
||||
<item name="fragmentLayoutStyle">@style/default_fragment_layout_style</item>
|
||||
<item name="paneStyle">@style/default_pane_style</item>
|
||||
<item name="secondPaneStyle">@style/default_pane_style</item>
|
||||
<item name="fragmentTitleStyle">@style/default_fragment_title_style</item>
|
||||
<item name="fragmentListViewStyle">@style/default_fragment_list_view_style</item>
|
||||
<item name="buttonStyle">@style/default_button_style</item>
|
||||
</style>
|
||||
<style name="default_main_layout_style">
|
||||
<item name="android:background">@color/default_background</item>
|
||||
<item name="android:baselineAligned">false</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
</style>
|
||||
|
||||
<style name="default_theme" parent="Theme.Sherlock">
|
||||
<item name="digitButtonStyle">@style/default_digit_button_style</item>
|
||||
<item name="controlButtonStyle">@style/default_control_button_style</item>
|
||||
<item name="controlImageButtonStyle">@style/default_control_image_button_style</item>
|
||||
<item name="operationButtonStyle">@style/default_operation_button_style</item>
|
||||
<item name="fragmentTitleStyle">@style/default_fragment_title_style</item>
|
||||
<item name="fragmentListViewStyle">@style/default_fragment_list_view_style</item>
|
||||
<item name="buttonStyle">@style/default_button_style</item>
|
||||
|
||||
<item name="mainLayoutStyle">@style/default_main_layout_style</item>
|
||||
<item name="mainMultiPaneLayoutStyle">@style/default_main_multi_pane_layout_style</item>
|
||||
|
||||
<item name="fragmentLayoutStyle">@style/default_fragment_layout_style</item>
|
||||
|
||||
<item name="paneStyle">@style/default_pane_style</item>
|
||||
<item name="paneStyleTransparent">@style/default_pane_style_transparent</item>
|
||||
</style>
|
||||
</resources>
|
@ -7,11 +7,11 @@
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="light_blue_digit_button_style" parent="button_style">
|
||||
<style name="light_blue_digit_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/blue_button</item>
|
||||
</style>
|
||||
|
||||
<style name="light_blue_control_button_style" parent="button_style">
|
||||
<style name="light_blue_control_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/blue_button_dark</item>
|
||||
</style>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources>
|
||||
|
||||
<style name="metro_digit_button_style" parent="button_style">
|
||||
<style name="metro_digit_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/metro_button_dark</item>
|
||||
</style>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources>
|
||||
|
||||
<style name="metro_digit_button_style" parent="button_style">
|
||||
<style name="metro_digit_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/metro_button_dark</item>
|
||||
</style>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources>
|
||||
|
||||
<style name="metro_digit_button_style" parent="button_style">
|
||||
<style name="metro_digit_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/metro_button_dark</item>
|
||||
</style>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="violet_digit_button_style" parent="button_style">
|
||||
<style name="violet_digit_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/violet_button</item>
|
||||
</style>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<item name="android:textColor">@color/button_operator_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="violet_control_button_style" parent="button_style">
|
||||
<style name="violet_control_button_style" parent="keyboard_button_style">
|
||||
<item name="android:background">@drawable/violet_button_dark</item>
|
||||
</style>
|
||||
|
||||
|
@ -24,6 +24,11 @@
|
||||
<item name="android:textSize">@dimen/text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="keyboard_button_style_parent">
|
||||
<item name="android:textSize">@dimen/keyboard_button_text_size</item>
|
||||
<item name="android:textColor">@color/button_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="button_style_parent">
|
||||
<item name="android:textSize">@dimen/button_text_size</item>
|
||||
<item name="android:textColor">@color/button_text_color</item>
|
||||
|
@ -17,6 +17,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.text.TextProcessor;
|
||||
import org.solovyev.android.calculator.view.TextHighlighter;
|
||||
import org.solovyev.android.view.AutoResizeTextView;
|
||||
import org.solovyev.common.text.StringUtils;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
|
@ -84,8 +84,6 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
|
||||
CalculatorButtons.processButtons(true, activityHelper.getTheme(), this.getWindow().getDecorView());
|
||||
|
||||
FragmentUtils.createFragment(this, CalculatorEditorFragment.class, R.id.editorContainer, "editor");
|
||||
FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display");
|
||||
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard");
|
||||
|
@ -71,6 +71,8 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
||||
activity.setTheme(this.theme.getThemeId());
|
||||
|
||||
activity.setContentView(layoutId);
|
||||
|
||||
CalculatorButtons.processButtons(true, theme, activity.getWindow().getDecorView());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,7 +116,7 @@ public class CalculatorApplication extends android.app.Application {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CalculatorFragmentHelper createFragmentHelper() {
|
||||
return new CalculatorFragmentHelperImpl();
|
||||
public CalculatorFragmentHelper createFragmentHelper(int layoutId) {
|
||||
return new CalculatorFragmentHelperImpl(layoutId);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.math.edit.AbstractMathEntityListFragment;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@ -15,9 +19,12 @@ public interface CalculatorFragmentHelper {
|
||||
|
||||
void setPaneTitle(@NotNull Fragment fragment, int titleResId);
|
||||
|
||||
void processButtons(@NotNull Fragment fragment, @NotNull View root);
|
||||
|
||||
void onCreate(@NotNull Fragment fragment);
|
||||
|
||||
void onViewCreated(@NotNull Fragment fragment, @NotNull View root);
|
||||
|
||||
void onDestroy(@NotNull Fragment fragment);
|
||||
|
||||
@NotNull
|
||||
View onCreateView(@NotNull Fragment fragment, @NotNull LayoutInflater inflater, @Nullable ViewGroup container);
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import com.google.ads.AdView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.ads.AdsController;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@ -12,6 +19,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper implements CalculatorFragmentHelper {
|
||||
|
||||
@Nullable
|
||||
private AdView adView;
|
||||
|
||||
private int layoutId;
|
||||
|
||||
public CalculatorFragmentHelperImpl(int layoutId) {
|
||||
this.layoutId = layoutId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPane(@NotNull Fragment fragment) {
|
||||
return fragment.getActivity() instanceof CalculatorActivity;
|
||||
@ -28,18 +44,33 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processButtons(@NotNull Fragment fragment, @NotNull View root) {
|
||||
super.processButtons(fragment.getActivity(), root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NotNull Fragment fragment) {
|
||||
super.onCreate(fragment.getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NotNull Fragment fragment, @NotNull View root) {
|
||||
final ViewGroup mainFragmentLayout = (ViewGroup) root.findViewById(R.id.main_fragment_layout);
|
||||
if (mainFragmentLayout != null) {
|
||||
adView = AdsController.getInstance().inflateAd(fragment.getActivity(), mainFragmentLayout, R.id.main_fragment_layout);
|
||||
}
|
||||
|
||||
processButtons(fragment.getActivity(), root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NotNull Fragment fragment) {
|
||||
super.onDestroy(fragment.getActivity());
|
||||
|
||||
if (this.adView != null) {
|
||||
this.adView.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public View onCreateView(@NotNull Fragment fragment, @NotNull LayoutInflater inflater, @Nullable ViewGroup container) {
|
||||
return inflater.inflate(layoutId, container, false);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
||||
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper();
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.calc_keyboard);
|
||||
fragmentHelper.onCreate(this);
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
@ -44,14 +44,14 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.calc_keyboard, container, false);
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
fragmentHelper.processButtons(this, root);
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,10 +16,8 @@ import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import com.google.ads.AdView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.ads.AdsController;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||
import org.solovyev.android.menu.AMenuBuilder;
|
||||
@ -81,9 +79,6 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
||||
@NotNull
|
||||
private ArrayAdapter<CalculatorHistoryState> adapter;
|
||||
|
||||
@Nullable
|
||||
private AdView adView;
|
||||
|
||||
@NotNull
|
||||
private CalculatorFragmentHelper fragmentHelper;
|
||||
|
||||
@ -91,7 +86,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper();
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.history_fragment);
|
||||
fragmentHelper.onCreate(this);
|
||||
|
||||
logDebug("onCreate");
|
||||
@ -103,17 +98,16 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View result = inflater.inflate(R.layout.history_fragment, container, false);
|
||||
logDebug("onCreateView");
|
||||
return result;
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
logDebug("onViewCreated");
|
||||
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
fragmentHelper.setPaneTitle(this, getTitleResId());
|
||||
|
||||
adapter = new HistoryArrayAdapter(this.getActivity(), getItemLayoutId(), R.id.history_item, new ArrayList<CalculatorHistoryState>());
|
||||
@ -163,8 +157,6 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
adView = AdsController.getInstance().inflateAd(this.getActivity(), (ViewGroup)view.findViewById(R.id.ad_parent_view), R.id.ad_parent_view);
|
||||
}
|
||||
|
||||
protected abstract int getTitleResId();
|
||||
@ -173,10 +165,6 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
||||
public void onDestroy() {
|
||||
logDebug("onDestroy");
|
||||
|
||||
if ( this.adView != null ) {
|
||||
this.adView.destroy();
|
||||
}
|
||||
|
||||
fragmentHelper.onDestroy(this);
|
||||
|
||||
super.onDestroy();
|
||||
|
@ -15,10 +15,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import com.google.ads.AdView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.ads.AdsController;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.menu.AMenuBuilder;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
@ -67,18 +65,14 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
@Nullable
|
||||
private String category;
|
||||
|
||||
@Nullable
|
||||
private AdView adView;
|
||||
|
||||
@NotNull
|
||||
private CalculatorFragmentHelper fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper();
|
||||
private CalculatorFragmentHelper fragmentHelper;
|
||||
|
||||
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.math_entities;
|
||||
protected int getLayoutId() {
|
||||
return R.layout.math_entities_fragment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -88,18 +82,20 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
category = bundle.getString(MATH_ENTITY_CATEGORY_EXTRA_STRING);
|
||||
}
|
||||
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(getLayoutId());
|
||||
fragmentHelper.onCreate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(getLayoutResId(), container, false);
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
this.fragmentHelper.setPaneTitle(this, getTitleResId());
|
||||
|
||||
final ListView lv = getListView();
|
||||
@ -112,6 +108,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
final long id) {
|
||||
|
||||
CalculatorLocatorImpl.getInstance().getKeyboard().digitButtonPressed(((MathEntity) parent.getItemAtPosition(position)).getName());
|
||||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
|
||||
@ -130,18 +127,12 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
adView = AdsController.getInstance().inflateAd(this.getActivity(), (ViewGroup)view.findViewById(R.id.ad_parent_view), R.id.ad_parent_view);
|
||||
}
|
||||
|
||||
protected abstract int getTitleResId();
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (this.adView != null) {
|
||||
this.adView.destroy();
|
||||
}
|
||||
|
||||
fragmentHelper.onDestroy(this);
|
||||
|
||||
super.onDestroy();
|
||||
@ -320,7 +311,11 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
@NotNull
|
||||
public static Bundle createBundleFor(@NotNull String categoryId) {
|
||||
final Bundle result = new Bundle(1);
|
||||
result.putString(MATH_ENTITY_CATEGORY_EXTRA_STRING, categoryId);
|
||||
putCategory(result, categoryId);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void putCategory(@NotNull Bundle bundle, @NotNull String categoryId) {
|
||||
bundle.putString(MATH_ENTITY_CATEGORY_EXTRA_STRING, categoryId);
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ public class CalculatorFunctionsFragmentActivity extends SherlockFragmentActivit
|
||||
activityHelper.onCreate(this, savedInstanceState);
|
||||
|
||||
for (AndroidFunctionsMathRegistry.Category category : AndroidFunctionsMathRegistry.Category.getCategoriesByTabOrder()) {
|
||||
activityHelper.addTab(this, category.name(), CalculatorHistoryFragment.class, null, category.getCaptionId(), R.id.main_layout);
|
||||
|
||||
activityHelper.addTab(this, category.name(), CalculatorFunctionsFragment.class, AbstractMathEntityListFragment.createBundleFor(category.name()), category.getCaptionId(), R.id.main_layout);
|
||||
}
|
||||
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this);
|
||||
|
@ -19,6 +19,9 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import jscl.math.function.IConstant;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -45,11 +48,11 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
public static final String CREATE_VAR_EXTRA_STRING = "org.solovyev.android.calculator.math.edit.CalculatorVarsTabActivity_create_var";
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
protected int getLayoutId() {
|
||||
return R.layout.vars_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@ -63,6 +66,8 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
bundle.remove(CREATE_VAR_EXTRA_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -213,15 +218,20 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
return true;
|
||||
}
|
||||
|
||||
// todo serso: menu
|
||||
/* @Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
final MenuInflater menuInflater = getMenuInflater();
|
||||
menuInflater.inflate(R.menu.var_menu, menu);
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* MENU
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.var_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean result;
|
||||
|
||||
@ -235,7 +245,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
}
|
||||
|
||||
return result;
|
||||
}*/
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
|
@ -12,7 +12,6 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistoryFragment;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistoryFragmentActivity;
|
||||
import org.solovyev.android.calculator.model.VarCategory;
|
||||
|
||||
@ -41,12 +40,20 @@ public class CalculatorVarsFragmentActivity extends SherlockFragmentActivity imp
|
||||
bundle = null;
|
||||
}
|
||||
|
||||
|
||||
for (VarCategory category : VarCategory.getCategoriesByTabOrder()) {
|
||||
if (category == VarCategory.my) {
|
||||
activityHelper.addTab(this, category.name(), CalculatorHistoryFragment.class, bundle, category.getCaptionId(), R.id.main_layout);
|
||||
|
||||
final Bundle fragmentParameters;
|
||||
|
||||
if (category == VarCategory.my && bundle != null) {
|
||||
AbstractMathEntityListFragment.putCategory(bundle, category.name());
|
||||
fragmentParameters = bundle;
|
||||
} else {
|
||||
activityHelper.addTab(this, category.name(), CalculatorHistoryFragment.class, null, category.getCaptionId(), R.id.main_layout);
|
||||
fragmentParameters = AbstractMathEntityListFragment.createBundleFor(category.name());
|
||||
}
|
||||
|
||||
activityHelper.addTab(this, category.name(), CalculatorVarsFragment.class, fragmentParameters, category.getCaptionId(), R.id.main_layout);
|
||||
|
||||
}
|
||||
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this);
|
||||
|
Loading…
Reference in New Issue
Block a user