This commit is contained in:
serso 2012-09-28 14:44:49 +04:00
parent c8440e18a5
commit abebb25e53
37 changed files with 2421 additions and 2317 deletions

View File

@ -15,6 +15,6 @@
--> -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <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" /> <corners android:radius="1dp" />
</shape> </shape>

View File

@ -7,12 +7,9 @@
--> -->
<LinearLayout <LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android" 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:id="@+id/main_layout"
a:orientation="vertical" a:orientation="vertical"
a:layout_gravity="center" style="?mainLayoutStyle">
a:background="@color/default_background">
<include layout="@layout/main_first_pane"/> <include layout="@layout/main_first_pane"/>

View File

@ -7,12 +7,9 @@
--> -->
<LinearLayout <LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android" 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:id="@+id/main_layout"
a:orientation="vertical" a:orientation="vertical"
a:background="@color/default_background" style="?mainMultiPaneLayoutStyle">
a:baselineAligned="false">
<LinearLayout <LinearLayout
a:layout_height="0dp" a:layout_height="0dp"
@ -47,7 +44,7 @@
a:layout_width="0dp" a:layout_width="0dp"
a:layout_weight="1" a:layout_weight="1"
a:orientation="vertical" a:orientation="vertical"
style="?secondPaneStyle"/> style="?paneStyle"/>
</LinearLayout> </LinearLayout>
@ -55,6 +52,6 @@
a:layout_height="0dp" a:layout_height="0dp"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_weight="1" a:layout_weight="1"
style="?fragmentLayoutStyle"/> style="?paneStyleTransparent"/>
</LinearLayout> </LinearLayout>

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical" a:orientation="vertical"
a:id="@+id/ad_parent_view" a:id="@+id/main_fragment_layout"
style="?fragmentLayoutStyle" style="?fragmentLayoutStyle"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent"> a:layout_height="match_parent">

View File

@ -12,8 +12,7 @@
a:layout_height="match_parent" a:layout_height="match_parent"
a:id="@+id/main_layout" a:id="@+id/main_layout"
a:orientation="vertical" a:orientation="vertical"
a:layout_gravity="center" style="?mainLayoutStyle">
a:background="@color/default_background">
<LinearLayout a:id="@+id/editorContainer" <LinearLayout a:id="@+id/editorContainer"
a:layout_weight="2" a:layout_weight="2"

View File

@ -8,8 +8,7 @@
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/main_layout" a:id="@+id/main_layout"
a:orientation="vertical" style="?mainLayoutStyle"
a:layout_width="fill_parent" a:orientation="vertical">
a:layout_height="fill_parent">
</LinearLayout> </LinearLayout>

View 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>

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical" a:orientation="vertical"
a:id="@+id/ad_parent_view" a:id="@+id/main_fragment_layout"
style="?fragmentLayoutStyle" style="?fragmentLayoutStyle"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent"> a:layout_height="match_parent">

View 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>

View File

@ -8,7 +8,7 @@
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical" a:orientation="vertical"
a:id="@+id/ad_parent_view" a:id="@+id/main_fragment_layout"
style="?fragmentLayoutStyle" style="?fragmentLayoutStyle"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent"> a:layout_height="match_parent">
@ -20,13 +20,12 @@
<ListView style="?fragmentListViewStyle"/> <ListView style="?fragmentListViewStyle"/>
<!-- todo serso: uncomment button--> <!--todo serso: uncomment-->
<!--<Button <!--<Button
a:layout_width="wrap_content" a:id="@+id/add_var_button"
a:layout_height="wrap_content"
a:layout_gravity="center_horizontal"
a:text="@string/c_add" a:text="@string/c_add"
style="?buttonStyle" style="?buttonStyle"
a:onClick="addVarButtonClickHandler"/>--> a:onClick="addVarButtonClickHandler"
a:layout_marginBottom="@dimen/pane_padding"/>-->
</LinearLayout> </LinearLayout>

View File

@ -9,5 +9,6 @@
<menu xmlns:a="http://schemas.android.com/apk/res/android"> <menu xmlns:a="http://schemas.android.com/apk/res/android">
<item a:id="@+id/var_menu_add_var" <item a:id="@+id/var_menu_add_var"
a:title="@string/c_add"/> a:title="@string/c_add"
a:showAsAction="always"/>
</menu> </menu>

View File

@ -1,3 +1,3 @@
<resources> <resources>
<dimen name="button_text_size">20dp</dimen> <dimen name="keyboard_button_text_size">20dp</dimen>
</resources> </resources>

View File

@ -1,3 +1,3 @@
<resources> <resources>
<dimen name="button_text_size">40dp</dimen> <dimen name="keyboard_button_text_size">40dp</dimen>
</resources> </resources>

View File

@ -6,10 +6,12 @@
<attr name="controlImageButtonStyle" format="reference" /> <attr name="controlImageButtonStyle" format="reference" />
<attr name="operationButtonStyle" format="reference" /> <attr name="operationButtonStyle" format="reference" />
<attr name="fragmentLayoutStyle" format="reference" /> <attr name="fragmentLayoutStyle" format="reference" />
<attr name="secondPaneStyle" format="reference" />
<attr name="fragmentTitleStyle" format="reference" /> <attr name="fragmentTitleStyle" format="reference" />
<attr name="fragmentListViewStyle" format="reference" /> <attr name="fragmentListViewStyle" format="reference" />
<attr name="buttonStyle" format="reference" /> <attr name="buttonStyle" format="reference" />
<attr name="paneStyle" format="reference" /> <attr name="paneStyle" format="reference" />
<attr name="paneStyleTransparent" format="reference" />
<attr name="mainLayoutStyle" format="reference" />
<attr name="mainMultiPaneLayoutStyle" format="reference" />
</resources> </resources>

View File

@ -13,6 +13,6 @@
<color name="display_error_text_color">#ff393939</color> <color name="display_error_text_color">#ff393939</color>
<color name="selected_angle_unit_text_color">#ffffff99</color> <color name="selected_angle_unit_text_color">#ffffff99</color>
<color name="default_background">#ff000000</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> <color name="metro_button_background">#ff1f1f1f</color>
</resources> </resources>

View File

@ -1,7 +1,10 @@
<resources> <resources>
<dimen name="button_margin">0.5dp</dimen> <dimen name="button_margin">0.5dp</dimen>
<dimen name="text_size">20sp</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="display_text_size">25sp</dimen>
<dimen name="editor_text_size">25sp</dimen> <dimen name="editor_text_size">25sp</dimen>
<dimen name="pane_margin">5dp</dimen>
<dimen name="pane_padding">5dp</dimen>
</resources> </resources>

View File

@ -8,19 +8,16 @@
<resources> <resources>
<style name="math_entity_text" parent="math_entity_text_parent"> <style name="math_entity_text" parent="math_entity_text_parent">
<item name="android:paddingTop">6dp</item> <item name="android:paddingTop">0dp</item>
<item name="android:paddingLeft">6dp</item> <item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">6dp</item> <item name="android:paddingRight">0dp</item>
<item name="android:paddingBottom">0dp</item> <item name="android:paddingBottom">@dimen/pane_padding</item>
<item name="android:textStyle">bold</item> <item name="android:textStyle">bold</item>
<item name="android:textColor">@android:color/white</item> <item name="android:textColor">@android:color/white</item>
</style> </style>
<style name="math_entity_description" parent="math_entity_description_parent"> <style name="math_entity_description" parent="math_entity_description_parent">
<item name="android:paddingTop">0dp</item> <item name="android:padding">0dp</item>
<item name="android:paddingLeft">6dp</item>
<item name="android:paddingRight">6dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:textColor">#bebebe</item> <item name="android:textColor">#bebebe</item>
</style> </style>

View File

@ -8,6 +8,13 @@
<resources> <resources>
<style name="button_style" parent="button_style_parent"> <style name="button_style" parent="button_style_parent">
<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/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_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item> <item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item> <item name="android:layout_weight">1</item>

View File

@ -6,11 +6,11 @@
--> -->
<resources> <resources>
<style name="default_digit_button_style" parent="button_style"> <style name="default_digit_button_style" parent="keyboard_button_style">
<item name="android:background">@drawable/default_button</item> <item name="android:background">@drawable/default_button</item>
</style> </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"> <style name="default_operation_button_style" parent="default_digit_button_style">
<item name="android:textColor">@color/button_operator_text_color</item> <item name="android:textColor">@color/button_operator_text_color</item>
@ -20,11 +20,6 @@
<item name="android:padding">6dp</item> <item name="android:padding">6dp</item>
</style> </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>
<style name="default_fragment_list_view_style"> <style name="default_fragment_list_view_style">
<item name="android:id">@android:id/list</item> <item name="android:id">@android:id/list</item>
<item name="android:divider">@null</item> <item name="android:divider">@null</item>
@ -33,23 +28,52 @@
<item name="android:layout_height">match_parent</item> <item name="android:layout_height">match_parent</item>
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_weight">1</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>
<style name="default_fragment_title_style"> <style name="default_fragment_title_style">
<item name="android:textColor">@android:color/white</item> <item name="android:textColor">@android:color/white</item>
<item name="android:textSize">25sp</item> <item name="android:textSize">25sp</item>
<item name="android:layout_marginLeft">6dp</item>
</style> </style>
<style name="default_button_style" parent="button_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>
<style name="default_fragment_layout_style"> <style name="default_fragment_layout_style">
<item name="android:layout_marginBottom">0dp</item> <item name="android:layout_margin">0dp</item>
<item name="android:layout_marginTop">5dp</item> <item name="android:padding">0dp</item>
<item name="android:layout_marginLeft">5dp</item> </style>
<item name="android:layout_marginRight">0dp</item>
<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>
<style name="default_theme" parent="Theme.Sherlock"> <style name="default_theme" parent="Theme.Sherlock">
@ -57,11 +81,16 @@
<item name="controlButtonStyle">@style/default_control_button_style</item> <item name="controlButtonStyle">@style/default_control_button_style</item>
<item name="controlImageButtonStyle">@style/default_control_image_button_style</item> <item name="controlImageButtonStyle">@style/default_control_image_button_style</item>
<item name="operationButtonStyle">@style/default_operation_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="fragmentTitleStyle">@style/default_fragment_title_style</item>
<item name="fragmentListViewStyle">@style/default_fragment_list_view_style</item> <item name="fragmentListViewStyle">@style/default_fragment_list_view_style</item>
<item name="buttonStyle">@style/default_button_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> </style>
</resources> </resources>

View File

@ -7,11 +7,11 @@
<resources> <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> <item name="android:background">@drawable/blue_button</item>
</style> </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> <item name="android:background">@drawable/blue_button_dark</item>
</style> </style>

View File

@ -1,6 +1,6 @@
<resources> <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> <item name="android:background">@drawable/metro_button_dark</item>
</style> </style>

View File

@ -1,6 +1,6 @@
<resources> <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> <item name="android:background">@drawable/metro_button_dark</item>
</style> </style>

View File

@ -1,6 +1,6 @@
<resources> <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> <item name="android:background">@drawable/metro_button_dark</item>
</style> </style>

View File

@ -6,7 +6,7 @@
--> -->
<resources> <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> <item name="android:background">@drawable/violet_button</item>
</style> </style>
@ -14,7 +14,7 @@
<item name="android:textColor">@color/button_operator_text_color</item> <item name="android:textColor">@color/button_operator_text_color</item>
</style> </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> <item name="android:background">@drawable/violet_button_dark</item>
</style> </style>

View File

@ -24,6 +24,11 @@
<item name="android:textSize">@dimen/text_size</item> <item name="android:textSize">@dimen/text_size</item>
</style> </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"> <style name="button_style_parent">
<item name="android:textSize">@dimen/button_text_size</item> <item name="android:textSize">@dimen/button_text_size</item>
<item name="android:textColor">@color/button_text_color</item> <item name="android:textColor">@color/button_text_color</item>

View File

@ -17,6 +17,7 @@ import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.android.calculator.view.TextHighlighter; import org.solovyev.android.calculator.view.TextHighlighter;
import org.solovyev.android.view.AutoResizeTextView; import org.solovyev.android.view.AutoResizeTextView;
import org.solovyev.common.text.StringUtils;
/** /**
* User: serso * User: serso

View File

@ -84,8 +84,6 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
CalculatorButtons.processButtons(true, activityHelper.getTheme(), this.getWindow().getDecorView());
FragmentUtils.createFragment(this, CalculatorEditorFragment.class, R.id.editorContainer, "editor"); FragmentUtils.createFragment(this, CalculatorEditorFragment.class, R.id.editorContainer, "editor");
FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display"); FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display");
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard"); FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard");

View File

@ -71,6 +71,8 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
activity.setTheme(this.theme.getThemeId()); activity.setTheme(this.theme.getThemeId());
activity.setContentView(layoutId); activity.setContentView(layoutId);
CalculatorButtons.processButtons(true, theme, activity.getWindow().getDecorView());
} }
@Override @Override

View File

@ -116,7 +116,7 @@ public class CalculatorApplication extends android.app.Application {
} }
@NotNull @NotNull
public CalculatorFragmentHelper createFragmentHelper() { public CalculatorFragmentHelper createFragmentHelper(int layoutId) {
return new CalculatorFragmentHelperImpl(); return new CalculatorFragmentHelperImpl(layoutId);
} }
} }

View File

@ -1,8 +1,12 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.math.edit.AbstractMathEntityListFragment;
/** /**
* User: serso * User: serso
@ -15,9 +19,12 @@ public interface CalculatorFragmentHelper {
void setPaneTitle(@NotNull Fragment fragment, int titleResId); void setPaneTitle(@NotNull Fragment fragment, int titleResId);
void processButtons(@NotNull Fragment fragment, @NotNull View root);
void onCreate(@NotNull Fragment fragment); void onCreate(@NotNull Fragment fragment);
void onViewCreated(@NotNull Fragment fragment, @NotNull View root);
void onDestroy(@NotNull Fragment fragment); void onDestroy(@NotNull Fragment fragment);
@NotNull
View onCreateView(@NotNull Fragment fragment, @NotNull LayoutInflater inflater, @Nullable ViewGroup container);
} }

View File

@ -1,9 +1,16 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.google.ads.AdView;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.ads.AdsController;
/** /**
* User: serso * User: serso
@ -12,6 +19,15 @@ import org.jetbrains.annotations.NotNull;
*/ */
public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper implements CalculatorFragmentHelper { public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper implements CalculatorFragmentHelper {
@Nullable
private AdView adView;
private int layoutId;
public CalculatorFragmentHelperImpl(int layoutId) {
this.layoutId = layoutId;
}
@Override @Override
public boolean isPane(@NotNull Fragment fragment) { public boolean isPane(@NotNull Fragment fragment) {
return fragment.getActivity() instanceof CalculatorActivity; 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 @Override
public void onCreate(@NotNull Fragment fragment) { public void onCreate(@NotNull Fragment fragment) {
super.onCreate(fragment.getActivity()); 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 @Override
public void onDestroy(@NotNull Fragment fragment) { public void onDestroy(@NotNull Fragment fragment) {
super.onDestroy(fragment.getActivity()); 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);
} }
} }

View File

@ -33,7 +33,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.calc_keyboard);
fragmentHelper.onCreate(this); fragmentHelper.onCreate(this);
preferences.registerOnSharedPreferenceChangeListener(this); preferences.registerOnSharedPreferenceChangeListener(this);
@ -44,14 +44,14 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 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 @Override
public void onViewCreated(View root, Bundle savedInstanceState) { public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState); super.onViewCreated(root, savedInstanceState);
fragmentHelper.processButtons(this, root); fragmentHelper.onViewCreated(this, root);
} }
@Override @Override

View File

@ -16,10 +16,8 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import com.actionbarsherlock.app.SherlockListFragment; import com.actionbarsherlock.app.SherlockListFragment;
import com.google.ads.AdView;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.menu.AMenuBuilder; import org.solovyev.android.menu.AMenuBuilder;
@ -81,9 +79,6 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
@NotNull @NotNull
private ArrayAdapter<CalculatorHistoryState> adapter; private ArrayAdapter<CalculatorHistoryState> adapter;
@Nullable
private AdView adView;
@NotNull @NotNull
private CalculatorFragmentHelper fragmentHelper; private CalculatorFragmentHelper fragmentHelper;
@ -91,7 +86,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.history_fragment);
fragmentHelper.onCreate(this); fragmentHelper.onCreate(this);
logDebug("onCreate"); logDebug("onCreate");
@ -103,17 +98,16 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View result = inflater.inflate(R.layout.history_fragment, container, false); return fragmentHelper.onCreateView(this, inflater, container);
logDebug("onCreateView");
return result;
} }
@Override @Override
public void onViewCreated(View view, Bundle savedInstanceState) { public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(root, savedInstanceState);
logDebug("onViewCreated"); logDebug("onViewCreated");
fragmentHelper.onViewCreated(this, root);
fragmentHelper.setPaneTitle(this, getTitleResId()); fragmentHelper.setPaneTitle(this, getTitleResId());
adapter = new HistoryArrayAdapter(this.getActivity(), getItemLayoutId(), R.id.history_item, new ArrayList<CalculatorHistoryState>()); 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; 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(); protected abstract int getTitleResId();
@ -173,10 +165,6 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
public void onDestroy() { public void onDestroy() {
logDebug("onDestroy"); logDebug("onDestroy");
if ( this.adView != null ) {
this.adView.destroy();
}
fragmentHelper.onDestroy(this); fragmentHelper.onDestroy(this);
super.onDestroy(); super.onDestroy();

View File

@ -15,10 +15,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.*; import android.widget.*;
import com.actionbarsherlock.app.SherlockListFragment; import com.actionbarsherlock.app.SherlockListFragment;
import com.google.ads.AdView;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.menu.AMenuBuilder; import org.solovyev.android.menu.AMenuBuilder;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
@ -67,18 +65,14 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
@Nullable @Nullable
private String category; private String category;
@Nullable
private AdView adView;
@NotNull @NotNull
private CalculatorFragmentHelper fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(); private CalculatorFragmentHelper fragmentHelper;
protected int getLayoutResId() { protected int getLayoutId() {
return R.layout.math_entities; return R.layout.math_entities_fragment;
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -88,18 +82,20 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
category = bundle.getString(MATH_ENTITY_CATEGORY_EXTRA_STRING); category = bundle.getString(MATH_ENTITY_CATEGORY_EXTRA_STRING);
} }
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(getLayoutId());
fragmentHelper.onCreate(this); fragmentHelper.onCreate(this);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(getLayoutResId(), container, false); return fragmentHelper.onCreateView(this, inflater, container);
} }
@Override @Override
public void onViewCreated(View view, Bundle savedInstanceState) { public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(root, savedInstanceState);
fragmentHelper.onViewCreated(this, root);
this.fragmentHelper.setPaneTitle(this, getTitleResId()); this.fragmentHelper.setPaneTitle(this, getTitleResId());
final ListView lv = getListView(); final ListView lv = getListView();
@ -112,6 +108,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
final long id) { final long id) {
CalculatorLocatorImpl.getInstance().getKeyboard().digitButtonPressed(((MathEntity) parent.getItemAtPosition(position)).getName()); 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; 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(); protected abstract int getTitleResId();
@Override @Override
public void onDestroy() { public void onDestroy() {
if (this.adView != null) {
this.adView.destroy();
}
fragmentHelper.onDestroy(this); fragmentHelper.onDestroy(this);
super.onDestroy(); super.onDestroy();
@ -320,7 +311,11 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
@NotNull @NotNull
public static Bundle createBundleFor(@NotNull String categoryId) { public static Bundle createBundleFor(@NotNull String categoryId) {
final Bundle result = new Bundle(1); final Bundle result = new Bundle(1);
result.putString(MATH_ENTITY_CATEGORY_EXTRA_STRING, categoryId); putCategory(result, categoryId);
return result; return result;
} }
static void putCategory(@NotNull Bundle bundle, @NotNull String categoryId) {
bundle.putString(MATH_ENTITY_CATEGORY_EXTRA_STRING, categoryId);
}
} }

View File

@ -32,8 +32,7 @@ public class CalculatorFunctionsFragmentActivity extends SherlockFragmentActivit
activityHelper.onCreate(this, savedInstanceState); activityHelper.onCreate(this, savedInstanceState);
for (AndroidFunctionsMathRegistry.Category category : AndroidFunctionsMathRegistry.Category.getCategoriesByTabOrder()) { 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); CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this);

View File

@ -19,6 +19,9 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; 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 jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -45,7 +48,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
public static final String CREATE_VAR_EXTRA_STRING = "org.solovyev.android.calculator.math.edit.CalculatorVarsTabActivity_create_var"; public static final String CREATE_VAR_EXTRA_STRING = "org.solovyev.android.calculator.math.edit.CalculatorVarsTabActivity_create_var";
@Override @Override
protected int getLayoutResId() { protected int getLayoutId() {
return R.layout.vars_fragment; return R.layout.vars_fragment;
} }
@ -63,6 +66,8 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
bundle.remove(CREATE_VAR_EXTRA_STRING); bundle.remove(CREATE_VAR_EXTRA_STRING);
} }
} }
setHasOptionsMenu(true);
} }
@Override @Override
@ -213,12 +218,17 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
return true; return true;
} }
// todo serso: menu /*
/* @Override **********************************************************************
public boolean onCreateOptionsMenu(Menu menu) { *
final MenuInflater menuInflater = getMenuInflater(); * MENU
menuInflater.inflate(R.menu.var_menu, menu); *
return true; **********************************************************************
*/
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.var_menu, menu);
} }
@Override @Override
@ -235,7 +245,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
} }
return result; return result;
}*/ }
/* /*
********************************************************************** **********************************************************************

View File

@ -12,7 +12,6 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.history.CalculatorHistoryFragment;
import org.solovyev.android.calculator.history.CalculatorHistoryFragmentActivity; import org.solovyev.android.calculator.history.CalculatorHistoryFragmentActivity;
import org.solovyev.android.calculator.model.VarCategory; import org.solovyev.android.calculator.model.VarCategory;
@ -41,12 +40,20 @@ public class CalculatorVarsFragmentActivity extends SherlockFragmentActivity imp
bundle = null; bundle = null;
} }
for (VarCategory category : VarCategory.getCategoriesByTabOrder()) { 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 { } 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); CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this);