This commit is contained in:
serso 2012-10-03 12:23:41 +04:00
parent 0b100efcf0
commit f2eca251f8
14 changed files with 1089 additions and 834 deletions

View File

@ -20,28 +20,27 @@
</activity> </activity>
<!--NOTE: a:configChanges="orientation|keyboardHidden" is needed to correct work of dialog windows (not to close them on orientation change) --> <activity android:label="@string/c_app_settings" android:name=".CalculatorPreferencesActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_app_settings" android:name=".CalculatorPreferencesActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_history" android:name=".history.CalculatorHistoryFragmentActivity"/> <activity android:label="@string/c_history" android:name=".history.CalculatorHistoryFragmentActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_about" android:name=".about.CalculatorAboutTabActivity"/> <activity android:label="@string/c_about" android:name=".about.CalculatorAboutTabActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_about" android:name=".about.CalculatorAboutActivity"/> <activity android:label="@string/c_about" android:name=".about.CalculatorAboutActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_about" android:name=".about.CalculatorReleaseNotesActivity"/> <activity android:label="@string/c_about" android:name=".about.CalculatorReleaseNotesActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_help" android:name=".help.CalculatorHelpTabActivity"/> <activity android:label="@string/c_help" android:name=".help.CalculatorHelpTabActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_help" android:name=".help.HelpFaqActivity"/> <activity android:label="@string/c_help" android:name=".help.HelpFaqActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_help" android:name=".help.HelpHintsActivity"/> <activity android:label="@string/c_help" android:name=".help.HelpHintsActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_help" android:name=".help.HelpScreensActivity"/> <activity android:label="@string/c_help" android:name=".help.HelpScreensActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_functions" android:name=".math.edit.CalculatorFunctionsFragmentActivity"/> <activity android:label="@string/c_functions" android:name=".math.edit.CalculatorFunctionsFragmentActivity"/>
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_operators" android:name=".math.edit.CalculatorOperatorsFragmentActivity"/> <activity android:label="@string/c_operators" android:name=".math.edit.CalculatorOperatorsFragmentActivity"/>
<activity android:label="@string/c_vars_and_constants" android:name=".math.edit.CalculatorVarsFragmentActivity"/> <activity android:label="@string/c_vars_and_constants" android:name=".math.edit.CalculatorVarsFragmentActivity"/>

View File

@ -1,213 +1,215 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev. ~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com ~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org ~ or visit http://se.solovyev.org
--> -->
<resources> <resources>
<string name="c_app_name">Calculator++</string> <string name="c_app_name">Calculator++</string>
<string name="c_app_name_free">Calculator++ Free</string> <string name="c_app_name_free">Calculator++ Free</string>
<string name="c_app_icon_name">Calc++</string> <string name="c_app_icon_name">Calc++</string>
<string name="c_app_settings">Settings</string> <string name="c_app_settings">Settings</string>
<string name="c_syntax_error">Error</string> <string name="c_syntax_error">Error</string>
<string name="c_result_copied">Result copied to clipboard!</string> <string name="c_result_copied">Result copied to clipboard!</string>
<string name="c_settings">Settings</string> <string name="c_settings">Settings</string>
<string name="c_help">Help</string> <string name="c_help">Help</string>
<string name="c_vars_and_constants">Variables And Constants</string> <string name="c_vars_and_constants">Variables And Constants</string>
<!--PREFERENCE ACTIVITY--> <!--PREFERENCE ACTIVITY-->
<string name="c_prefs_main_category">Main settings</string> <string name="c_prefs_main_category">Main settings</string>
<string name="c_prefs_calculations_category">Calculation settings</string> <string name="c_prefs_calculations_category">Calculation settings</string>
<string name="c_prefs_appearance_category">Appearance settings</string> <string name="c_prefs_appearance_category">Appearance settings</string>
<string name="c_prefs_other_category">Other settings</string> <string name="c_prefs_other_category">Other settings</string>
<string name="c_prefs_drag_button_category">Drag buttons settings</string> <string name="c_prefs_drag_button_category">Drag buttons settings</string>
<string name="c_down">Down</string> <string name="c_down">Down</string>
<string name="c_up">Up</string> <string name="c_up">Up</string>
<string name="c_restart">Restart</string> <string name="c_restart">Restart</string>
<string name="c_undo">undo</string> <string name="c_undo">undo</string>
<string name="c_redo">redo</string> <string name="c_redo">redo</string>
<string name="c_clear">C</string> <string name="c_clear">C</string>
<string name="c_erase">clear</string> <string name="c_erase">clear</string>
<string name="c_paste">paste</string> <string name="c_paste">paste</string>
<string name="c_vars">vars</string> <string name="c_vars">vars</string>
<string name="c_copy">Copy</string> <string name="c_copy">Copy</string>
<string name="c_plot">Plot graph</string> <string name="c_plot">Plot graph</string>
<string name="c_graph">Graph</string> <string name="c_graph">Graph</string>
<string name="c_calc_color_display_title">Highlight expressions</string> <string name="c_calc_color_display_title">Highlight expressions</string>
<string name="c_calc_round_result_title">Round result</string> <string name="c_calc_round_result_title">Round result</string>
<string name="c_calc_round_result_summary">Toggles rounding of the result</string> <string name="c_calc_round_result_summary">Toggles rounding of the result</string>
<string name="c_calc_science_notation_title">Always scientific notation</string> <string name="c_calc_science_notation_title">Always scientific notation</string>
<string name="c_calc_science_notation_summary">If turned on forces to use only scientific notation of output (12.34E-12)</string> <string name="c_calc_science_notation_summary">If turned on forces to use only scientific notation of output (12.34E-12)</string>
<string name="p_calc_result_precision_title">Precision of result</string> <string name="p_calc_result_precision_title">Precision of result</string>
<string name="p_calc_max_calculation_time_title">Maximum calculation time</string> <string name="p_calc_max_calculation_time_title">Maximum calculation time</string>
<string name="p_calc_max_calculation_time_summary">If calculations exceed specified limit - calculator halts with error</string> <string name="p_calc_max_calculation_time_summary">If calculations exceed specified limit - calculator halts with error</string>
<string name="c_exit">Exit</string> <string name="c_exit">Exit</string>
<string name="c_add">Add</string> <string name="c_add">Add</string>
<string name="c_cancel">Cancel</string> <string name="c_cancel">Cancel</string>
<string name="c_save">Save</string> <string name="c_save">Save</string>
<string name="c_remove">Remove</string> <string name="c_remove">Remove</string>
<string name="c_yes">Yes</string> <string name="c_yes">Yes</string>
<string name="c_no">No</string> <string name="c_no">No</string>
<string name="c_var_removal_confirmation">Removal confirmation</string> <string name="c_var_removal_confirmation">Removal confirmation</string>
<string name="c_var_removal_confirmation_question">Do you really want to delete \'%s\' variable?</string> <string name="c_var_removal_confirmation_question">Do you really want to delete \'%s\' variable?</string>
<string name="c_var_name">Name</string> <string name="c_var_name">Name</string>
<string name="c_var_value">Value</string> <string name="c_var_value">Value</string>
<string name="c_var_description">Description</string> <string name="c_var_description">Description</string>
<string name="c_var_create_var">Create variable</string> <string name="c_var_create_var">Create variable</string>
<string name="c_var_edit_var">Edit variable</string> <string name="c_var_edit_var">Edit variable</string>
<string name="c_value.is.not.a.number">Value must be either number or empty!</string> <string name="c_value.is.not.a.number">Value must be either number or empty!</string>
<string name="c_var.name.clashes">Variable name clashes with function name!</string> <string name="c_var.name.clashes">Variable name clashes with function name!</string>
<string name="c_var.already.exists">Variable with same name already exists!</string> <string name="c_var.already.exists">Variable with same name already exists!</string>
<string name="c_name.is.not.valid">Name of constant is not valid: name must start with letter, can contain letters, digits and underscore.</string> <string name="c_name.is.not.valid">Name of constant is not valid: name must start with letter, can contain letters, digits and underscore.</string>
<string name="c_sys.var.cannot.be.changed">System variable cannot be changed!</string> <string name="c_sys.var.cannot.be.changed">System variable cannot be changed!</string>
<string name="c_calc_editor_hint">Enter new expression</string> <string name="c_calc_editor_hint">Enter new expression</string>
<string name="c_press_to_copy">Press to copy</string> <string name="c_press_to_copy">Press to copy</string>
<string name="c_continue">Continue</string> <string name="c_continue">Continue</string>
<string name="c_history">History</string> <string name="c_history">History</string>
<string name="c_history_button">M</string> <string name="c_history_button">M</string>
<string name="c_history_is_empty">History is empty!</string> <string name="c_history_is_empty">History is empty!</string>
<string name="c_app_history">History</string> <string name="c_app_history">History</string>
<string name="c_char_is_not_accepted">Character \'%s\' is not accepted in variable name!</string> <string name="c_char_is_not_accepted">Character \'%s\' is not accepted in variable name!</string>
<string name="c_calc_angle_units">Angle Units</string> <string name="c_calc_angle_units">Angle Units</string>
<string name="p_deg">Degrees</string> <string name="p_deg">Degrees</string>
<string name="p_rad">Radians</string> <string name="p_rad">Radians</string>
<string name="p_grad">Gradians</string> <string name="p_grad">Gradians</string>
<string name="p_turns">Turns</string> <string name="p_turns">Turns</string>
<string name="c_angle_units_summary">Defines the default units for angles.</string> <string name="c_angle_units_summary">Defines the default units for angles.</string>
<string name="c_calc_numeral_bases">Numeral systems</string> <string name="c_calc_numeral_bases">Numeral systems</string>
<string name="c_numeral_bases_summary">Defines the default numeral system for all input numbers.</string> <string name="c_numeral_bases_summary">Defines the default numeral system for all input numbers.</string>
<string name="p_dec">Decimal</string> <string name="p_dec">Decimal</string>
<string name="p_hex">Hexadecimal</string> <string name="p_hex">Hexadecimal</string>
<string name="p_oct">Octal</string> <string name="p_oct">Octal</string>
<string name="p_bin">Binary</string> <string name="p_bin">Binary</string>
<string name="c_calc_theme">Theme</string> <string name="c_calc_theme">Theme</string>
<string name="p_default_theme">Grey</string> <string name="p_default_theme">Grey</string>
<string name="p_violet_theme">Violet</string> <string name="p_violet_theme">Violet</string>
<string name="p_light_blue_theme">Light Blue</string> <string name="p_light_blue_theme">Light Blue</string>
<string name="p_metro_blue_theme">Metro Blue (Default)</string> <string name="p_metro_blue_theme">Metro Blue (Default)</string>
<string name="p_metro_green_theme">Metro Green</string> <string name="p_metro_green_theme">Metro Green</string>
<string name="p_metro_purple_theme">Metro Purple</string> <string name="p_metro_purple_theme">Metro Purple</string>
<string name="c_calc_result_precision_summary">Precision of result value (all calculations are done with maximum precision regardless of the value of this option)</string> <string name="c_calc_result_precision_summary">Precision of result value (all calculations are done with maximum precision regardless of the value of this option)</string>
<string name="c_calc_color_display_summary">Toggles colouring and styling in calculator editor</string> <string name="c_calc_color_display_summary">Toggles colouring and styling in calculator editor</string>
<string name="c_calc_theme_summary">Sets the theme for calculator</string> <string name="c_calc_theme_summary">Sets the theme for calculator</string>
<string name="c_clear_history">Clear history</string> <string name="c_clear_history">Clear history</string>
<string name="c_simplify_instead_of_numeric">Next constants are undefined: {0}!</string> <string name="c_simplify_instead_of_numeric">Next constants are undefined: {0}!</string>
<string name="p_grouping_separator_no">No grouping separator</string> <string name="p_grouping_separator_no">No grouping separator</string>
<string name="p_grouping_separator_apostrophe">Apostrophe (\')</string> <string name="p_grouping_separator_apostrophe">Apostrophe (\')</string>
<string name="p_grouping_separator_space">Space ( )</string> <string name="p_grouping_separator_space">Space ( )</string>
<string name="c_calc_grouping_separator">Grouping separator</string> <string name="c_calc_grouping_separator">Grouping separator</string>
<string name="c_calc_grouping_separator_summary">Sets grouping separator</string> <string name="c_calc_grouping_separator_summary">Sets grouping separator</string>
<string name="c_calc_multiplication_sign">Multiplication sign</string> <string name="c_calc_multiplication_sign">Multiplication sign</string>
<string name="c_calc_multiplication_sign_summary">Sets multiplication sign</string> <string name="c_calc_multiplication_sign_summary">Sets multiplication sign</string>
<string name="c_calc_layout">Layout</string> <string name="c_calc_layout">Layout</string>
<string name="p_layout_cellphone">Scientific (cellphone)</string> <string name="p_layout_cellphone">Scientific (cellphone)</string>
<string name="p_layout_calculator">Scientific</string> <string name="p_layout_calculator">Scientific</string>
<string name="p_layout_simple">Simple</string> <string name="p_layout_simple">Simple</string>
<string name="c_calc_layout_summary">Sets layout of buttons</string> <string name="c_calc_layout_summary">Sets layout of buttons</string>
<string name="c_calc_haptic_feedback_title">Haptic feedback</string> <string name="c_calc_haptic_feedback_title">Haptic feedback</string>
<string name="c_calc_haptic_feedback_summary">Toggles vibration on button click</string> <string name="c_calc_haptic_feedback_summary">Toggles vibration on button click</string>
<string name="p_calc_haptic_feedback_strength_short">Short</string> <string name="p_calc_haptic_feedback_strength_short">Short</string>
<string name="p_calc_haptic_feedback_strength_middle">Middle</string> <string name="p_calc_haptic_feedback_strength_middle">Middle</string>
<string name="p_calc_haptic_feedback_strength_long">Long</string> <string name="p_calc_haptic_feedback_strength_long">Long</string>
<string name="p_calc_haptic_feedback_duration_title">Haptic feedback duration</string> <string name="p_calc_haptic_feedback_duration_title">Haptic feedback duration</string>
<string name="p_calc_haptic_feedback_duration_summary">Duration vibration on button click</string> <string name="p_calc_haptic_feedback_duration_summary">Duration vibration on button click</string>
<string name="c_empty_var_error">Unable to create empty constant!</string> <string name="c_empty_var_error">Unable to create empty constant!</string>
<string name="c_not_valid_result">Current result is not valid!</string> <string name="c_not_valid_result">Current result is not valid!</string>
<string name="c_plot_graph">Graph</string> <string name="c_plot_graph">Graph</string>
<string name="c_min_x_value">From</string> <string name="c_min_x_value">From</string>
<string name="c_max_x_value">To</string> <string name="c_max_x_value">To</string>
<string name="c_swipe_distance">Swipe distance for buttons</string> <string name="c_swipe_distance">Swipe distance for buttons</string>
<string name="c_swipe_distance_summary">Sets swipe distance for buttons that support additional swipe actions</string> <string name="c_swipe_distance_summary">Sets swipe distance for buttons that support additional swipe actions</string>
<string name="c_comment">Comment</string> <string name="c_comment">Comment</string>
<string name="c_history_item_saved">Saved</string> <string name="c_history_item_saved">Saved</string>
<string name="c_history_item_not_saved">Not saved</string> <string name="c_history_item_not_saved">Not saved</string>
<string name="c_expression_copied">Expression copied to the clipboard!</string> <string name="c_expression_copied">Expression copied to the clipboard!</string>
<string name="c_history_item_status">Status: </string> <string name="c_history_item_status">Status: </string>
<string name="c_history_item_comment">Comment: </string> <string name="c_history_item_comment">Comment: </string>
<string name="c_use">Use</string> <string name="c_use">Use</string>
<string name="c_use_short">Use</string> <string name="c_use_short">Use</string>
<string name="c_copy_expression">Copy expression</string> <string name="c_copy_expression">Copy expression</string>
<string name="c_copy_result">Copy result</string> <string name="c_copy_result">Copy result</string>
<string name="c_history_expression">Value</string> <string name="c_history_expression">Value</string>
<string name="c_history_item_already_saved">Saved (see \'Saved history\' tab)</string> <string name="c_history_item_already_saved">Saved (see \'Saved history\' tab)</string>
<string name="c_history_comment">Comment</string> <string name="c_history_comment">Comment</string>
<string name="c_save_history">Save history</string> <string name="c_save_history">Save history</string>
<string name="c_edit_history">Modify history</string> <string name="c_edit_history">Modify history</string>
<string name="c_edit">Modify</string> <string name="c_edit">Modify</string>
<string name="c_saved_history">Saved history</string> <string name="c_saved_history">Saved history</string>
<string name="c_history_already_saved">History was already saved!</string> <string name="c_history_already_saved">History was already saved!</string>
<string name="c_history_must_be_saved">History must be saved before editing!</string> <string name="c_history_must_be_saved">History must be saved before editing!</string>
<string name="c_history_was_removed">History was successfully removed!</string> <string name="c_history_was_removed">History was successfully removed!</string>
<string name="c_history_saved">History was successfully saved!</string> <string name="c_history_saved">History was successfully saved!</string>
<string name="c_copy_description">Copy description</string> <string name="c_copy_description">Copy description</string>
<string name="c_copy_value">Copy value</string> <string name="c_copy_value">Copy value</string>
<string name="c_first_start_text">Thank you for choosing Calculator++!\n\nCalculator++ is a powerful tool for making everyday calculations.\n\nTo remove the ads and support the project you can use special option from application settings.\n\nIt\'s highly recommended to read the FAQ and hints before the work to use all the features of application (press Menu button and then Help)</string> <string name="c_first_start_text">Thank you for choosing Calculator++!\n\nCalculator++ is a powerful tool for making everyday calculations.\n\nTo remove the ads and support the project you can use special option from application settings.\n\nIt\'s highly recommended to read the FAQ and hints before the work to use all the features of application (press Menu button and then Help)</string>
<string name="c_first_start_text_title">Welcome</string> <string name="c_first_start_text_title">Welcome</string>
<string name="c_calc_show_release_notes_title">Show release notes</string> <string name="c_calc_show_release_notes_title">Show release notes</string>
<string name="c_calc_show_release_notes_summary">Defines if release notes popup window should appear after update to the new version</string> <string name="c_calc_show_release_notes_summary">Defines if release notes popup window should appear after update to the new version</string>
<string name="c_calc_use_back_button_as_prev_summary">Defines the behaviour of the Back button</string> <string name="c_calc_use_back_button_as_prev_summary">Defines the behaviour of the Back button</string>
<string name="c_calc_use_back_button_as_prev_title">Use Back button as history prev</string> <string name="c_calc_use_back_button_as_prev_title">Use Back button as history prev</string>
<string name="c_clear_billing_info_summary">Billing information will be reloaded from the server</string> <string name="c_clear_billing_info_summary">Billing information will be reloaded from the server</string>
<string name="c_clear_billing_info_title">Clear billing information</string> <string name="c_clear_billing_info_title">Clear billing information</string>
<string name="c_warning">Warning</string> <string name="c_warning">Warning</string>
<string name="c_error">Error</string> <string name="c_error">Error</string>
<string name="c_billing_error">Billing is not supported: you must have Google Checkout account linked to your Google account and must be connected to the internet.</string> <string name="c_billing_error">Billing is not supported: you must have Google Checkout account linked to your Google account and must be connected to the internet.</string>
<string name="c_calc_ad_free_title">Support the project</string> <string name="c_calc_ad_free_title">Support the project</string>
<string name="c_calc_ad_free_summary">And remove the advertisement</string> <string name="c_calc_ad_free_summary">And remove the advertisement</string>
<string name="c_calc_already_purchased">Ad free option has been already purchased!</string> <string name="c_calc_already_purchased">Ad free option has been already purchased!</string>
<string name="c_calc_purchasing">Purchasing…</string> <string name="c_calc_purchasing">Purchasing…</string>
<string name="c_calc_clearing">Clearing…</string> <string name="c_calc_clearing">Clearing…</string>
<string name="c_feedback_title">Feedback</string> <string name="c_feedback_title">Feedback</string>
<string name="c_feedback_text">You have been using Calculator++ for some time \n <string name="c_feedback_text">You have been using Calculator++ for some time \n
and it\'s important for us to know your opinion about application.\n\n and it\'s important for us to know your opinion about application.\n\n
Please rate Calculator++ \non <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>,\n leave a comment or \ndiscuss application \non our <a href="http://calculatorpp.com/forum/">forum</a> Please rate Calculator++ \non <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>,\n leave a comment or \ndiscuss application \non our <a href="http://calculatorpp.com/forum/">forum</a>
</string> </string>
<string name="c_notespp_announce_text">Good news - I just released new application for Android called <a href="https://play.google.com/store/apps/details?id=org.solovyev.android.notes">Notes++</a>.\n <string name="c_notespp_announce_text">Good news - I just released new application for Android called <a href="https://play.google.com/store/apps/details?id=org.solovyev.android.notes">Notes++</a>.\n
If you\'re interesting in fast and easy way of making notes please follow the <a href="https://play.google.com/store/apps/details?id=org.solovyev.android.notes">link</a> and try Notes++! If you\'re interesting in fast and easy way of making notes please follow the <a href="https://play.google.com/store/apps/details?id=org.solovyev.android.notes">link</a> and try Notes++!
</string> </string>
<string name="c_angle_units_changed_to">Angle units changed to \'%s\'!</string> <string name="c_angle_units_changed_to">Angle units changed to \'%s\'!</string>
<string name="c_numeral_base_changed_to">Numeral base changed to \'%s\'!</string> <string name="c_numeral_base_changed_to">Numeral base changed to \'%s\'!</string>
<string name="c_conversion_tool">Conversion tool</string> <string name="c_conversion_tool">Conversion tool</string>
<string name="c_convert">Convert to…</string> <string name="c_convert">Convert to…</string>
<string name="convert_to_hex">Convert to hex</string> <string name="convert_to_hex">Convert to hex</string>
<string name="convert_to_bin">Convert to bin</string> <string name="convert_to_bin">Convert to bin</string>
<string name="convert_to_dec">Convert to dec</string> <string name="convert_to_dec">Convert to dec</string>
<string name="editor">Editor</string> <string name="editor">Editor</string>
<string name="result">Result</string> <string name="result">Result</string>
<string name="other">Other</string>
<string name="derivatives">Derivatives/Integrals</string>
</resources> </resources>

View File

@ -25,6 +25,7 @@ import net.robotmedia.billing.IBillingObserver;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils; import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesActivity; import org.solovyev.android.calculator.about.CalculatorReleaseNotesActivity;
import org.solovyev.android.calculator.history.CalculatorHistoryFragment; import org.solovyev.android.calculator.history.CalculatorHistoryFragment;
import org.solovyev.android.calculator.history.CalculatorSavedHistoryFragment; import org.solovyev.android.calculator.history.CalculatorSavedHistoryFragment;
@ -44,7 +45,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
@NotNull @NotNull
public static final String TAG = CalculatorActivity.class.getSimpleName(); public static final String TAG = CalculatorActivity.class.getSimpleName();
@Nullable @Nullable
private IBillingObserver billingObserver; private IBillingObserver billingObserver;
private boolean useBackAsPrev; private boolean useBackAsPrev;
@ -74,14 +75,12 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
activityHelper.logDebug("super.onCreate"); activityHelper.logDebug("super.onCreate");
if (findViewById(R.id.main_second_pane) != null) { if (findViewById(R.id.main_second_pane) != null) {
activityHelper.addTab(this, "history", CalculatorHistoryFragment.class, null, R.string.c_history, R.id.main_second_pane); activityHelper.addTab(this, CalculatorFragmentType.history, null, R.id.main_second_pane);
activityHelper.addTab(this, "saved_history", CalculatorSavedHistoryFragment.class, null, R.string.c_saved_history, R.id.main_second_pane); activityHelper.addTab(this, CalculatorFragmentType.saved_history, null, R.id.main_second_pane);
activityHelper.addTab(this, "vars", CalculatorVarsFragment.class, null, R.string.c_vars, R.id.main_second_pane); activityHelper.addTab(this, CalculatorFragmentType.variables, null, R.id.main_second_pane);
activityHelper.addTab(this, "functions", CalculatorFunctionsFragment.class, null, R.string.c_functions, R.id.main_second_pane); activityHelper.addTab(this, CalculatorFragmentType.functions, null, R.id.main_second_pane);
activityHelper.addTab(this, "operators", CalculatorOperatorsFragment.class, null, R.string.c_operators, R.id.main_second_pane); activityHelper.addTab(this, CalculatorFragmentType.operators, null, R.id.main_second_pane);
activityHelper.addTab(this, "plot", CalculatorPlotFragment.class, null, R.string.c_plot, R.id.main_second_pane); activityHelper.addTab(this, CalculatorFragmentType.plotter, null, R.id.main_second_pane);
activityHelper.restoreSavedTab(this);
} else { } else {
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
@ -208,6 +207,13 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
getCalculator().evaluate(); getCalculator().evaluate();
} }
@Override
protected void onPause() {
this.activityHelper.onPause(this);
super.onPause();
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();

View File

@ -1,46 +1,56 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.View; import android.view.View;
import com.actionbarsherlock.app.SherlockFragmentActivity; 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.about.CalculatorFragmentType;
/**
* User: serso /**
* Date: 9/25/12 * User: serso
* Time: 10:31 PM * Date: 9/25/12
*/ * Time: 10:31 PM
public interface CalculatorActivityHelper { */
public interface CalculatorActivityHelper {
void onCreate(@NotNull SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState);
void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState); void onCreate(@NotNull SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState);
void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState);
void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState);
void onSaveInstanceState(@NotNull Activity activity, @NotNull Bundle outState); void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState);
void onSaveInstanceState(@NotNull Activity activity, @NotNull Bundle outState);
int getLayoutId();
int getLayoutId();
@NotNull
CalculatorPreferences.Gui.Theme getTheme(); @NotNull
CalculatorPreferences.Gui.Theme getTheme();
void onResume(@NotNull SherlockFragmentActivity activity);
void onResume(@NotNull Activity activity); void onResume(@NotNull SherlockFragmentActivity activity);
void onResume(@NotNull Activity activity);
void onDestroy(@NotNull SherlockFragmentActivity activity);
void onDestroy(@NotNull Activity activity); void onPause(@NotNull Activity activity);
void onPause(@NotNull SherlockFragmentActivity activity);
void addTab(@NotNull SherlockFragmentActivity activity,
@NotNull String tag, void onDestroy(@NotNull SherlockFragmentActivity activity);
@NotNull Class<? extends Fragment> fragmentClass, void onDestroy(@NotNull Activity activity);
@Nullable Bundle fragmentArgs,
int captionResId, int parentViewId); void addTab(@NotNull SherlockFragmentActivity activity,
@NotNull String tag,
void restoreSavedTab(@NotNull SherlockFragmentActivity activity); @NotNull Class<? extends Fragment> fragmentClass,
@Nullable Bundle fragmentArgs,
void logDebug(@NotNull String message); int captionResId,
int parentViewId);
void processButtons(@NotNull Activity activity, @NotNull View root);
} void addTab(@NotNull SherlockFragmentActivity activity,
@NotNull CalculatorFragmentType fragmentType,
@Nullable Bundle fragmentArgs,
int parentViewId);
void logDebug(@NotNull String message);
void processButtons(@NotNull Activity activity, @NotNull View root);
}

View File

@ -13,6 +13,7 @@ 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.AndroidUtils; import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener; import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,7 +33,6 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
* *
********************************************************************** **********************************************************************
*/ */
private static final String SELECTED_NAV = "selected_nav";
/* /*
********************************************************************** **********************************************************************
@ -51,8 +51,8 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
@NotNull @NotNull
private CalculatorPreferences.Gui.Theme theme; private CalculatorPreferences.Gui.Theme theme;
private int navPosition = 0;
private int selectedNavigationIndex = 0;
public CalculatorActivityHelperImpl(int layoutId, @NotNull String logTag) { public CalculatorActivityHelperImpl(int layoutId, @NotNull String logTag) {
super(logTag); super(logTag);
@ -68,8 +68,8 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
public void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState) { public void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState) {
super.onCreate(activity); super.onCreate(activity);
if ( activity instanceof CalculatorEventListener) { if (activity instanceof CalculatorEventListener) {
CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener)activity); CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) activity);
} }
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
@ -85,10 +85,6 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} else { } else {
Log.e(CalculatorActivityHelperImpl.class.getSimpleName(), "Root is null for " + activity.getClass().getName()); Log.e(CalculatorActivityHelperImpl.class.getSimpleName(), "Root is null for " + activity.getClass().getName());
} }
if (savedInstanceState != null) {
navPosition = savedInstanceState.getInt(SELECTED_NAV, 0);
}
} }
@Override @Override
@ -101,29 +97,34 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
actionBar.setHomeButtonEnabled(false); actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowHomeEnabled(true);
if (activity instanceof CalculatorActivity) { toggleTitle(activity, true);
if ( AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT ) {
actionBar.setDisplayShowTitleEnabled(true);
} else {
}
} else {
actionBar.setDisplayShowTitleEnabled(true);
}
actionBar.setIcon(R.drawable.icon_action_bar); actionBar.setIcon(R.drawable.icon_action_bar);
} }
@Override private void toggleTitle(@NotNull SherlockFragmentActivity activity, boolean showTitle) {
final ActionBar actionBar = activity.getSupportActionBar();
if (activity instanceof CalculatorActivity) {
if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) {
actionBar.setDisplayShowTitleEnabled(true);
} else {
actionBar.setDisplayShowTitleEnabled(false);
}
} else {
actionBar.setDisplayShowTitleEnabled(showTitle);
}
}
public void restoreSavedTab(@NotNull SherlockFragmentActivity activity) { public void restoreSavedTab(@NotNull SherlockFragmentActivity activity) {
final ActionBar actionBar = activity.getSupportActionBar(); final ActionBar actionBar = activity.getSupportActionBar();
if (navPosition >= 0 && navPosition < actionBar.getTabCount()) { if (selectedNavigationIndex >= 0 && selectedNavigationIndex < actionBar.getTabCount()) {
activity.getSupportActionBar().setSelectedNavigationItem(navPosition); actionBar.setSelectedNavigationItem(selectedNavigationIndex);
} }
} }
@Override @Override
public void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState) { public void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState) {
onSaveInstanceState((Activity) activity, outState); onSaveInstanceState((Activity) activity, outState);
outState.putInt(SELECTED_NAV, activity.getSupportActionBar().getSelectedNavigationIndex());
} }
@Override @Override
@ -140,18 +141,41 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
} }
@Override
public void onPause(@NotNull Activity activity) {
}
@Override
public void onPause(@NotNull SherlockFragmentActivity activity) {
onPause((Activity) activity);
final int selectedNavigationIndex = activity.getSupportActionBar().getSelectedNavigationIndex();
if (selectedNavigationIndex >= 0) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
final SharedPreferences.Editor editor = preferences.edit();
editor.putInt(getSavedTabPreferenceName(activity), selectedNavigationIndex);
editor.commit();
}
}
@NotNull
private String getSavedTabPreferenceName(@NotNull Activity activity) {
return "tab_" + activity.getClass().getSimpleName();
}
@Override @Override
public void onDestroy(@NotNull Activity activity) { public void onDestroy(@NotNull Activity activity) {
super.onDestroy(activity); super.onDestroy(activity);
if ( activity instanceof CalculatorEventListener) { if (activity instanceof CalculatorEventListener) {
CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener)activity); CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) activity);
} }
} }
@Override @Override
public void onDestroy(@NotNull SherlockFragmentActivity activity) { public void onDestroy(@NotNull SherlockFragmentActivity activity) {
this.onDestroy((Activity)activity); this.onDestroy((Activity) activity);
} }
@Override @Override
@ -161,9 +185,10 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
@Nullable Bundle fragmentArgs, @Nullable Bundle fragmentArgs,
int captionResId, int captionResId,
int parentViewId) { int parentViewId) {
activity.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
final ActionBar actionBar = activity.getSupportActionBar(); final ActionBar actionBar = activity.getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
final ActionBar.Tab tab = actionBar.newTab(); final ActionBar.Tab tab = actionBar.newTab();
tab.setTag(tag); tab.setTag(tag);
tab.setText(captionResId); tab.setText(captionResId);
@ -173,8 +198,11 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
actionBar.addTab(tab); actionBar.addTab(tab);
fragmentTags.add(tag); fragmentTags.add(tag);
}
restoreSavedTab(activity); @Override
public void addTab(@NotNull SherlockFragmentActivity activity, @NotNull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) {
addTab(activity, fragmentType.getFragmentTag(), fragmentType.getFragmentClass(), fragmentArgs, fragmentType.getDefaultTitleResId(), parentViewId);
} }
@Override @Override
@ -191,5 +219,9 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
@Override @Override
public void onResume(@NotNull SherlockFragmentActivity activity) { public void onResume(@NotNull SherlockFragmentActivity activity) {
onResume((Activity) activity); onResume((Activity) activity);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
selectedNavigationIndex = preferences.getInt(getSavedTabPreferenceName(activity), -1);
restoreSavedTab(activity);
} }
} }

View File

@ -0,0 +1,59 @@
package org.solovyev.android.calculator.about;
import android.support.v4.app.Fragment;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.history.CalculatorHistoryFragment;
import org.solovyev.android.calculator.history.CalculatorSavedHistoryFragment;
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
import org.solovyev.android.calculator.plot.CalculatorPlotFragment;
/**
* User: Solovyev_S
* Date: 03.10.12
* Time: 11:30
*/
public enum CalculatorFragmentType {
history(CalculatorHistoryFragment.class, "history", R.string.c_history),
saved_history(CalculatorSavedHistoryFragment.class, "saved_history", R.string.c_saved_history),
variables(CalculatorVarsFragment.class, "vars", R.string.c_vars),
functions(CalculatorFunctionsFragment.class, "functions", R.string.c_functions),
operators(CalculatorOperatorsFragment.class, "operators", R.string.c_operators),
plotter(CalculatorPlotFragment.class, "plotter", R.string.c_plot);
@NotNull
private Class<? extends Fragment> fragmentClass;
@NotNull
private final String fragmentTag;
private int defaultTitleResId;
private CalculatorFragmentType(@NotNull Class<? extends Fragment> fragmentClass, @NotNull String fragmentTag, int defaultTitleResId) {
this.fragmentClass = fragmentClass;
this.fragmentTag = fragmentTag;
this.defaultTitleResId = defaultTitleResId;
}
@NotNull
public String getFragmentTag() {
return fragmentTag;
}
public int getDefaultTitleResId() {
return defaultTitleResId;
}
@NotNull
public Class<? extends Fragment> getFragmentClass() {
return fragmentClass;
}
@NotNull
public String createSubFragmentTag(@NotNull String subFragmentTag) {
return this.fragmentTag + "_" + subFragmentTag;
}
}

View File

@ -1,62 +1,71 @@
/* /*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev. * Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com * For more information, please, contact se.solovyev@gmail.com
* or visit http://se.solovyev.org * or visit http://se.solovyev.org
*/ */
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; 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.about.CalculatorFragmentType;
/**
* User: serso /**
* Date: 12/18/11 * User: serso
* Time: 7:37 PM * Date: 12/18/11
*/ * Time: 7:37 PM
public class CalculatorHistoryFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener { */
public class CalculatorHistoryFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName()); @NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName());
@Override
public void onCreate(@Nullable Bundle savedInstanceState) { @Override
super.onCreate(savedInstanceState); public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
activityHelper.addTab(this, "history", CalculatorHistoryFragment.class, null, R.string.c_history, R.id.main_layout);
activityHelper.addTab(this, "saved_history", CalculatorSavedHistoryFragment.class, null, R.string.c_saved_history, R.id.main_layout); activityHelper.addTab(this, CalculatorFragmentType.history, null, R.id.main_layout);
} activityHelper.addTab(this, CalculatorFragmentType.saved_history, null, R.id.main_layout);
}
@Override
protected void onSaveInstanceState(Bundle outState) { @Override
super.onSaveInstanceState(outState); protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
activityHelper.onSaveInstanceState(this, outState);
} activityHelper.onSaveInstanceState(this, outState);
}
@Override
protected void onResume() { @Override
super.onResume(); protected void onResume() {
super.onResume();
activityHelper.onResume(this);
} activityHelper.onResume(this);
}
@Override
protected void onDestroy() { @Override
super.onDestroy(); protected void onPause() {
this.activityHelper.onPause(this);
activityHelper.onDestroy(this);
} super.onPause();
}
@Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
if ( calculatorEventType == CalculatorEventType.use_history_state ) { @Override
this.finish(); protected void onDestroy() {
} super.onDestroy();
}
} activityHelper.onDestroy(this);
}
@Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
if ( calculatorEventType == CalculatorEventType.use_history_state ) {
this.finish();
}
}
}

View File

@ -1,67 +1,79 @@
/* /*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev. * Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com * For more information, please, contact se.solovyev@gmail.com
* or visit http://se.solovyev.org * or visit http://se.solovyev.org
*/ */
package org.solovyev.android.calculator.math.edit; package org.solovyev.android.calculator.math.edit;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; 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.CalculatorHistoryFragmentActivity; import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.calculator.model.AndroidFunctionsMathRegistry; import org.solovyev.android.calculator.history.CalculatorHistoryFragmentActivity;
import org.solovyev.android.calculator.model.AndroidFunctionsMathRegistry;
/**
* User: serso /**
* Date: 12/21/11 * User: serso
* Time: 10:33 PM * Date: 12/21/11
*/ * Time: 10:33 PM
public class CalculatorFunctionsFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener { */
public class CalculatorFunctionsFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName()); @NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName());
@Override
public void onCreate(@Nullable Bundle savedInstanceState) { @Override
super.onCreate(savedInstanceState); public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
for (AndroidFunctionsMathRegistry.Category category : AndroidFunctionsMathRegistry.Category.getCategoriesByTabOrder()) {
activityHelper.addTab(this, category.name(), CalculatorFunctionsFragment.class, AbstractMathEntityListFragment.createBundleFor(category.name()), category.getCaptionId(), R.id.main_layout); final CalculatorFragmentType fragmentType = CalculatorFragmentType.functions;
}
} for (AndroidFunctionsMathRegistry.Category category : AndroidFunctionsMathRegistry.Category.getCategoriesByTabOrder()) {
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), category.getCaptionId(), R.id.main_layout);
@Override }
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); }
activityHelper.onSaveInstanceState(this, outState); @Override
} protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@Override
protected void onResume() { activityHelper.onSaveInstanceState(this, outState);
super.onResume(); }
activityHelper.onResume(this); @Override
} protected void onResume() {
super.onResume();
@Override
protected void onDestroy() { activityHelper.onResume(this);
super.onDestroy(); }
this.activityHelper.onDestroy(this); @Override
} protected void onPause() {
this.activityHelper.onPause(this);
@Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { super.onPause();
switch (calculatorEventType) { }
case use_function:
this.finish();
break; @Override
} protected void onDestroy() {
} super.onDestroy();
}
this.activityHelper.onDestroy(this);
}
@Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) {
case use_function:
this.finish();
break;
}
}
}

View File

@ -1,64 +1,79 @@
/* /*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev. * Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com * For more information, please, contact se.solovyev@gmail.com
* or visit http://se.solovyev.org * or visit http://se.solovyev.org
*/ */
package org.solovyev.android.calculator.math.edit; package org.solovyev.android.calculator.math.edit;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; 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.CalculatorHistoryFragmentActivity; import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.calculator.history.CalculatorHistoryFragmentActivity;
/** import org.solovyev.android.calculator.model.AndroidFunctionsMathRegistry;
* User: serso import org.solovyev.android.calculator.model.AndroidOperatorsMathRegistry;
* Date: 12/21/11
* Time: 10:33 PM /**
*/ * User: serso
public class CalculatorOperatorsFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener { * Date: 12/21/11
* Time: 10:33 PM
@NotNull */
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName()); public class CalculatorOperatorsFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@Override @NotNull
public void onCreate(@Nullable Bundle savedInstanceState) { private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName());
super.onCreate(savedInstanceState);
@Override
activityHelper.onCreate(this, savedInstanceState); public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityHelper.addTab(this, "operators", CalculatorOperatorsFragment.class, null, R.string.c_operators, R.id.main_layout);
} activityHelper.onCreate(this, savedInstanceState);
@Override final CalculatorFragmentType fragmentType = CalculatorFragmentType.operators;
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); for (AndroidOperatorsMathRegistry.Category category : AndroidOperatorsMathRegistry.Category.getCategoriesByTabOrder()) {
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), category.getCaptionId(), R.id.main_layout);
activityHelper.onSaveInstanceState(this, outState); }
} }
@Override @Override
protected void onResume() { protected void onSaveInstanceState(Bundle outState) {
super.onResume(); super.onSaveInstanceState(outState);
activityHelper.onResume(this); activityHelper.onSaveInstanceState(this, outState);
} }
@Override @Override
protected void onDestroy() { protected void onResume() {
super.onDestroy(); super.onResume();
this.activityHelper.onDestroy(this); activityHelper.onResume(this);
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { protected void onPause() {
switch (calculatorEventType) { this.activityHelper.onPause(this);
case use_operator:
this.finish(); super.onPause();
break; }
}
}
} @Override
protected void onDestroy() {
super.onDestroy();
this.activityHelper.onDestroy(this);
}
@Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) {
case use_operator:
this.finish();
break;
}
}
}

View File

@ -1,89 +1,100 @@
/* /*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev. * Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com * For more information, please, contact se.solovyev@gmail.com
* or visit http://se.solovyev.org * or visit http://se.solovyev.org
*/ */
package org.solovyev.android.calculator.math.edit; package org.solovyev.android.calculator.math.edit;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; 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.CalculatorHistoryFragmentActivity; import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.calculator.model.VarCategory; import org.solovyev.android.calculator.history.CalculatorHistoryFragmentActivity;
import org.solovyev.android.calculator.model.VarCategory;
/**
* User: serso /**
* Date: 12/21/11 * User: serso
* Time: 11:05 PM * Date: 12/21/11
*/ * Time: 11:05 PM
public class CalculatorVarsFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener { */
public class CalculatorVarsFragmentActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName()); @NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryFragmentActivity.class.getSimpleName());
@Override
public void onCreate(@Nullable Bundle savedInstanceState) { @Override
super.onCreate(savedInstanceState); public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
final Bundle bundle;
final Bundle bundle;
final Intent intent = getIntent();
if (intent != null) { final Intent intent = getIntent();
bundle = intent.getExtras(); if (intent != null) {
} else { bundle = intent.getExtras();
bundle = null; } else {
} bundle = null;
}
for (VarCategory category : VarCategory.getCategoriesByTabOrder()) { final CalculatorFragmentType fragmentType = CalculatorFragmentType.variables;
final Bundle fragmentParameters; for (VarCategory category : VarCategory.getCategoriesByTabOrder()) {
if (category == VarCategory.my && bundle != null) { final Bundle fragmentParameters;
AbstractMathEntityListFragment.putCategory(bundle, category.name());
fragmentParameters = bundle; if (category == VarCategory.my && bundle != null) {
} else { AbstractMathEntityListFragment.putCategory(bundle, category.name());
fragmentParameters = AbstractMathEntityListFragment.createBundleFor(category.name()); fragmentParameters = bundle;
} } else {
fragmentParameters = AbstractMathEntityListFragment.createBundleFor(category.name());
activityHelper.addTab(this, category.name(), CalculatorVarsFragment.class, fragmentParameters, category.getCaptionId(), R.id.main_layout); }
}
} activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), fragmentParameters, category.getCaptionId(), R.id.main_layout);
@Override }
protected void onSaveInstanceState(Bundle outState) { }
super.onSaveInstanceState(outState);
@Override
activityHelper.onSaveInstanceState(this, outState); protected void onSaveInstanceState(Bundle outState) {
} super.onSaveInstanceState(outState);
@Override activityHelper.onSaveInstanceState(this, outState);
protected void onResume() { }
super.onResume();
@Override
activityHelper.onResume(this); protected void onResume() {
} super.onResume();
@Override activityHelper.onResume(this);
protected void onDestroy() { }
super.onDestroy();
@Override
this.activityHelper.onDestroy(this); protected void onPause() {
} this.activityHelper.onPause(this);
@Override super.onPause();
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { }
switch (calculatorEventType) {
case use_constant:
this.finish(); @Override
break; protected void onDestroy() {
} super.onDestroy();
}
} this.activityHelper.onDestroy(this);
}
@Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) {
case use_constant:
this.finish();
break;
}
}
}

View File

@ -2,9 +2,7 @@ package org.solovyev.android.calculator.math.edit;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;

View File

@ -1,92 +1,180 @@
/* /*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev. * Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com * For more information, please, contact se.solovyev@gmail.com
* or visit http://se.solovyev.org * or visit http://se.solovyev.org
*/ */
package org.solovyev.android.calculator.model; package org.solovyev.android.calculator.model;
import android.app.Application; import android.app.Application;
import jscl.math.operator.Operator; import jscl.math.function.ArcTrigonometric;
import org.jetbrains.annotations.NotNull; import jscl.math.function.Comparison;
import org.solovyev.common.JBuilder; import jscl.math.function.Trigonometric;
import org.solovyev.common.math.MathRegistry; import jscl.math.operator.*;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import org.solovyev.android.calculator.R;
import java.util.Map; import org.solovyev.common.JBuilder;
import org.solovyev.common.collections.CollectionsUtils;
/** import org.solovyev.common.math.MathRegistry;
* User: serso
* Date: 11/17/11 import java.util.*;
* Time: 11:29 PM
*/ /**
public class AndroidOperatorsMathRegistry extends AbstractAndroidMathRegistry<Operator, MathPersistenceEntity> { * User: serso
* Date: 11/17/11
@NotNull * Time: 11:29 PM
private static final Map<String, String> substitutes = new HashMap<String, String>(); */
static { public class AndroidOperatorsMathRegistry extends AbstractAndroidMathRegistry<Operator, MathPersistenceEntity> {
substitutes.put("Σ", "sum");
substitutes.put("", "product"); @NotNull
substitutes.put("", "derivative"); private static final Map<String, String> substitutes = new HashMap<String, String>();
substitutes.put("∫ab", "integral_ab"); static {
substitutes.put("", "integral"); substitutes.put("Σ", "sum");
substitutes.put("Σ", "sum"); substitutes.put("", "product");
} substitutes.put("", "derivative");
substitutes.put("∫ab", "integral_ab");
@NotNull substitutes.put("", "integral");
private static final String OPERATOR_DESCRIPTION_PREFIX = "c_op_description_"; substitutes.put("Σ", "sum");
}
protected AndroidOperatorsMathRegistry(@NotNull MathRegistry<Operator> functionsRegistry,
@NotNull Application application) { @NotNull
super(functionsRegistry, OPERATOR_DESCRIPTION_PREFIX, application); private static final String OPERATOR_DESCRIPTION_PREFIX = "c_op_description_";
}
protected AndroidOperatorsMathRegistry(@NotNull MathRegistry<Operator> functionsRegistry,
@NotNull @NotNull Application application) {
@Override super(functionsRegistry, OPERATOR_DESCRIPTION_PREFIX, application);
protected Map<String, String> getSubstitutes() { }
return substitutes;
} @NotNull
@Override
@Override protected Map<String, String> getSubstitutes() {
public String getCategory(@NotNull Operator mathEntity) { return substitutes;
return null; }
}
@Override
@Override public String getCategory(@NotNull Operator operator) {
public void load() { for (Category category : Category.values()) {
// not supported yet if ( category.isInCategory(operator) ) {
} return category.name();
}
@NotNull }
@Override return null;
protected JBuilder<? extends Operator> createBuilder(@NotNull MathPersistenceEntity entity) { }
return null; //To change body of implemented methods use File | Settings | File Templates.
} @Override
public void load() {
@NotNull // not supported yet
@Override }
protected Class<? extends MathEntityPersistenceContainer<MathPersistenceEntity>> getPersistenceContainerClass() {
return null; //To change body of implemented methods use File | Settings | File Templates. @NotNull
} @Override
protected JBuilder<? extends Operator> createBuilder(@NotNull MathPersistenceEntity entity) {
@Override return null; //To change body of implemented methods use File | Settings | File Templates.
protected Integer getPreferenceStringId() { }
return null; //To change body of implemented methods use File | Settings | File Templates.
} @NotNull
@Override
@Override protected Class<? extends MathEntityPersistenceContainer<MathPersistenceEntity>> getPersistenceContainerClass() {
public void save() { return null; //To change body of implemented methods use File | Settings | File Templates.
// not supported yet }
}
@Override
@Override protected Integer getPreferenceStringId() {
protected MathPersistenceEntity transform(@NotNull Operator entity) { return null; //To change body of implemented methods use File | Settings | File Templates.
return null; //To change body of implemented methods use File | Settings | File Templates. }
}
@Override
@NotNull public void save() {
@Override // not supported yet
protected MathEntityPersistenceContainer<MathPersistenceEntity> createPersistenceContainer() { }
return null; //To change body of implemented methods use File | Settings | File Templates.
} @Override
} protected MathPersistenceEntity transform(@NotNull Operator entity) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@NotNull
@Override
protected MathEntityPersistenceContainer<MathPersistenceEntity> createPersistenceContainer() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
/*
**********************************************************************
*
* STATIC
*
**********************************************************************
*/
public static enum Category {
derivatives(R.string.derivatives, 100){
@Override
boolean isInCategory(@NotNull Operator operator) {
return operator instanceof Derivative || operator instanceof Integral || operator instanceof IndefiniteIntegral;
}
},
other(R.string.other, 200) {
@Override
boolean isInCategory(@NotNull Operator operator) {
return operator instanceof Sum || operator instanceof Product;
}
},
my(R.string.c_fun_category_my, 0) {
@Override
boolean isInCategory(@NotNull Operator operator) {
return !operator.isSystem();
}
},
common(R.string.c_fun_category_common, 50) {
@Override
boolean isInCategory(@NotNull Operator operator) {
for (Category category : values()) {
if ( category != this ) {
if ( category.isInCategory(operator) ) {
return false;
}
}
}
return true;
}
};
private final int captionId;
private final int tabOrder;
Category(int captionId, int tabOrder) {
this.captionId = captionId;
this.tabOrder = tabOrder;
}
public int getCaptionId() {
return captionId;
}
abstract boolean isInCategory(@NotNull Operator operator);
@NotNull
public static List<Category> getCategoriesByTabOrder() {
final List<Category> result = CollectionsUtils.asList(Category.values());
Collections.sort(result, new Comparator<Category>() {
@Override
public int compare(Category category, Category category1) {
return category.tabOrder - category1.tabOrder;
}
});
// todo serso: current solution (as creating operators is not implemented yet)
result.remove(my);
return result;
}
}
}

View File

@ -1,91 +1,96 @@
/* /*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev. * Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com * For more information, please, contact se.solovyev@gmail.com
* or visit http://se.solovyev.org * or visit http://se.solovyev.org
*/ */
package org.solovyev.android.calculator.model; package org.solovyev.android.calculator.model;
import android.app.Application; import android.app.Application;
import jscl.math.operator.Operator; import jscl.math.operator.Operator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.common.JBuilder; import org.solovyev.common.JBuilder;
import org.solovyev.common.math.MathRegistry; import org.solovyev.common.math.MathRegistry;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* User: serso * User: serso
* Date: 11/19/11 * Date: 11/19/11
* Time: 1:48 PM * Time: 1:48 PM
*/ */
public class AndroidPostfixFunctionsRegistry extends AbstractAndroidMathRegistry<Operator, MathPersistenceEntity> { public class AndroidPostfixFunctionsRegistry extends AbstractAndroidMathRegistry<Operator, MathPersistenceEntity> {
@NotNull @NotNull
private static final Map<String, String> substitutes = new HashMap<String, String>(); private static final Map<String, String> substitutes = new HashMap<String, String>();
static { static {
substitutes.put("%", "percent"); substitutes.put("%", "percent");
substitutes.put("!", "factorial"); substitutes.put("!", "factorial");
substitutes.put("!!", "double_factorial"); substitutes.put("!!", "double_factorial");
substitutes.put("°", "degree"); substitutes.put("°", "degree");
} }
@NotNull @NotNull
private static final String POSTFIX_FUNCTION_DESCRIPTION_PREFIX = "c_pf_description_"; private static final String POSTFIX_FUNCTION_DESCRIPTION_PREFIX = "c_pf_description_";
protected AndroidPostfixFunctionsRegistry(@NotNull MathRegistry<Operator> functionsRegistry, protected AndroidPostfixFunctionsRegistry(@NotNull MathRegistry<Operator> functionsRegistry,
@NotNull Application application) { @NotNull Application application) {
super(functionsRegistry, POSTFIX_FUNCTION_DESCRIPTION_PREFIX, application); super(functionsRegistry, POSTFIX_FUNCTION_DESCRIPTION_PREFIX, application);
} }
@NotNull @NotNull
@Override @Override
protected Map<String, String> getSubstitutes() { protected Map<String, String> getSubstitutes() {
return substitutes; return substitutes;
} }
@Override @Override
public String getCategory(@NotNull Operator mathEntity) { public String getCategory(@NotNull Operator operator) {
return null; for (AndroidOperatorsMathRegistry.Category category : AndroidOperatorsMathRegistry.Category.values()) {
} if ( category.isInCategory(operator) ) {
return category.name();
@Override }
public void load() { }
// not supported yet return null;
} }
@NotNull @Override
@Override public void load() {
protected JBuilder<? extends Operator> createBuilder(@NotNull MathPersistenceEntity entity) { // not supported yet
return null; //To change body of implemented methods use File | Settings | File Templates. }
}
@NotNull
@NotNull @Override
@Override protected JBuilder<? extends Operator> createBuilder(@NotNull MathPersistenceEntity entity) {
protected Class<? extends MathEntityPersistenceContainer<MathPersistenceEntity>> getPersistenceContainerClass() { return null; //To change body of implemented methods use File | Settings | File Templates.
return null; //To change body of implemented methods use File | Settings | File Templates. }
}
@NotNull
@Override @Override
protected Integer getPreferenceStringId() { protected Class<? extends MathEntityPersistenceContainer<MathPersistenceEntity>> getPersistenceContainerClass() {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
@Override @Override
public void save() { protected Integer getPreferenceStringId() {
// not supported yet return null; //To change body of implemented methods use File | Settings | File Templates.
} }
@Override @Override
protected MathPersistenceEntity transform(@NotNull Operator entity) { public void save() {
return null; //To change body of implemented methods use File | Settings | File Templates. // not supported yet
} }
@NotNull @Override
@Override protected MathPersistenceEntity transform(@NotNull Operator entity) {
protected MathEntityPersistenceContainer<MathPersistenceEntity> createPersistenceContainer() { return null; //To change body of implemented methods use File | Settings | File Templates.
return null; //To change body of implemented methods use File | Settings | File Templates. }
}
} @NotNull
@Override
protected MathEntityPersistenceContainer<MathPersistenceEntity> createPersistenceContainer() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
}

View File

@ -1,62 +1,71 @@
package org.solovyev.android.calculator.plot; package org.solovyev.android.calculator.plot;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; 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.CalculatorActivityHelper; import org.solovyev.android.calculator.CalculatorActivityHelper;
import org.solovyev.android.calculator.CalculatorApplication; import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.about.CalculatorFragmentType;
/**
* User: serso /**
* Date: 9/30/12 * User: serso
* Time: 4:56 PM * Date: 9/30/12
*/ * Time: 4:56 PM
public class CalculatorPlotActivity extends SherlockFragmentActivity { */
public class CalculatorPlotActivity extends SherlockFragmentActivity {
@NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorPlotActivity.class.getSimpleName()); @NotNull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorPlotActivity.class.getSimpleName());
@Override
public void onCreate(@Nullable Bundle savedInstanceState) { @Override
super.onCreate(savedInstanceState); public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
activityHelper.onCreate(this, savedInstanceState);
final Intent intent = getIntent();
final Intent intent = getIntent();
final Bundle arguments;
if (intent != null) { final Bundle arguments;
arguments = intent.getExtras(); if (intent != null) {
} else { arguments = intent.getExtras();
arguments = null; } else {
} arguments = null;
}
activityHelper.addTab(this, "plot", CalculatorPlotFragment.class, arguments, R.string.c_plot, R.id.main_layout);
} activityHelper.addTab(this, CalculatorFragmentType.plotter, arguments, R.id.main_layout);
}
@Override
protected void onSaveInstanceState(Bundle outState) { @Override
super.onSaveInstanceState(outState); protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
activityHelper.onSaveInstanceState(this, outState);
} activityHelper.onSaveInstanceState(this, outState);
}
@Override
protected void onResume() { @Override
super.onResume(); protected void onResume() {
super.onResume();
activityHelper.onResume(this);
} activityHelper.onResume(this);
}
@Override
protected void onDestroy() { @Override
super.onDestroy(); protected void onPause() {
this.activityHelper.onPause(this);
activityHelper.onDestroy(this);
} super.onPause();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
activityHelper.onDestroy(this);
}
}