This commit is contained in:
Sergey Solovyev 2012-09-27 23:40:16 +04:00
parent 8df6c0ceab
commit 8882cb32ee
10 changed files with 377 additions and 569 deletions

View File

@ -1,46 +0,0 @@
<!--
~ 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
-->
<resources>
<style name="default_text_size">
<item name="android:textSize">20dp</item>
</style>
<style name="button_style_parent">
<item name="android:textSize">20dp</item>
<item name="android:textColor">@color/button_text_color</item>
</style>
<style name="display_style_parent" parent="default_text">
<item name="android:textSize">25dp</item>
<item name="android:padding">3dp</item>
</style>
<style name="editor_style_parent" parent="default_text">
<item name="android:textSize">25dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="about_style_parent" parent="default_text">
<item name="android:textSize">15dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="math_entity_text_parent">
<item name="android:textSize">20dp</item>
</style>
<style name="math_entity_description_parent">
<item name="android:textSize">15dp</item>
</style>
<style name="add_var_button_parent">
<item name="android:paddingLeft">40dp</item>
<item name="android:paddingRight">40dp</item>
</style>
</resources>

View File

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

View File

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

View File

@ -1,46 +0,0 @@
<!--
~ 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
-->
<resources>
<style name="default_text_size">
<item name="android:textSize">40dp</item>
</style>
<style name="button_style_parent">
<item name="android:textSize">40dp</item>
<item name="android:textColor">@color/button_text_color</item>
</style>
<style name="display_style_parent" parent="default_text">
<item name="android:textSize">35dp</item>
<item name="android:padding">3dp</item>
</style>
<style name="editor_style_parent" parent="default_text">
<item name="android:textSize">35dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="about_style_parent" parent="default_text">
<item name="android:textSize">15dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="math_entity_text_parent">
<item name="android:textSize">20dp</item>
</style>
<style name="math_entity_description_parent">
<item name="android:textSize">15dp</item>
</style>
<style name="add_var_button_parent">
<item name="android:paddingLeft">80dp</item>
<item name="android:paddingRight">80dp</item>
</style>
</resources>

View File

@ -1,46 +0,0 @@
<!--
~ 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
-->
<resources>
<style name="default_text_size">
<item name="android:textSize">30dp</item>
</style>
<style name="button_style_parent">
<item name="android:textSize">30dp</item>
<item name="android:textColor">@color/button_text_color</item>
</style>
<style name="display_style_parent" parent="default_text">
<item name="android:textSize">30dp</item>
<item name="android:padding">3dp</item>
</style>
<style name="editor_style_parent" parent="default_text">
<item name="android:textSize">30dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="about_style_parent" parent="default_text">
<item name="android:textSize">15dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="math_entity_text_parent">
<item name="android:textSize">20dp</item>
</style>
<style name="math_entity_description_parent">
<item name="android:textSize">15dp</item>
</style>
<style name="add_var_button_parent">
<item name="android:paddingLeft">60dp</item>
<item name="android:paddingRight">60dp</item>
</style>
</resources>

View File

@ -1,46 +0,0 @@
<!--
~ 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
-->
<resources>
<style name="default_text_size">
<item name="android:textSize">15dp</item>
</style>
<style name="button_style_parent">
<item name="android:textSize">15dp</item>
<item name="android:textColor">@color/button_text_color</item>
</style>
<style name="display_style_parent" parent="default_text">
<item name="android:textSize">20dp</item>
<item name="android:padding">3dp</item>
</style>
<style name="editor_style_parent" parent="default_text">
<item name="android:textSize">20dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="about_style_parent" parent="default_text">
<item name="android:textSize">10dp</item>
<item name="android:padding">5dp</item>
</style>
<style name="math_entity_text_parent">
<item name="android:textSize">15dp</item>
</style>
<style name="math_entity_description_parent">
<item name="android:textSize">10dp</item>
</style>
<style name="add_var_button_parent">
<item name="android:paddingLeft">30dp</item>
<item name="android:paddingRight">30dp</item>
</style>
</resources>

View File

@ -0,0 +1,7 @@
<resources>
<dimen name="button_margin">0.5dp</dimen>
<dimen name="text_size">20sp</dimen>
<dimen name="button_text_size">30dp</dimen>
<dimen name="display_text_size">25sp</dimen>
<dimen name="editor_text_size">25sp</dimen>
</resources>

View File

@ -1,3 +0,0 @@
<resources>
<dimen name="button_margin">0.5dp</dimen>
</resources>

View File

@ -21,21 +21,21 @@
<style name="default_text_size"> <style name="default_text_size">
<item name="android:textSize">20dp</item> <item name="android:textSize">@dimen/text_size</item>
</style> </style>
<style name="button_style_parent"> <style name="button_style_parent">
<item name="android:textSize">20dp</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>
</style> </style>
<style name="display_style_parent" parent="default_text"> <style name="display_style_parent" parent="default_text">
<item name="android:textSize">25dp</item> <item name="android:textSize">@dimen/display_text_size</item>
<item name="android:padding">3dp</item> <item name="android:padding">3dp</item>
</style> </style>
<style name="editor_style_parent" parent="default_text"> <style name="editor_style_parent" parent="default_text">
<item name="android:textSize">25dp</item> <item name="android:textSize">@dimen/editor_text_size</item>
<item name="android:padding">5dp</item> <item name="android:padding">5dp</item>
</style> </style>

View File

@ -1,379 +1,361 @@
/* /*
* 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
*/ */
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import net.robotmedia.billing.BillingController; import net.robotmedia.billing.BillingController;
import net.robotmedia.billing.IBillingObserver; 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.FontSizeAdjuster; 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; import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment; import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment; import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment; import org.solovyev.android.fragments.FragmentUtils;
import org.solovyev.android.fragments.FragmentUtils; import org.solovyev.android.prefs.Preference;
import org.solovyev.android.prefs.Preference; import org.solovyev.android.view.ColorButton;
import org.solovyev.android.view.ColorButton; import org.solovyev.common.equals.EqualsTool;
import org.solovyev.common.equals.EqualsTool; import org.solovyev.common.history.HistoryAction;
import org.solovyev.common.history.HistoryAction; import org.solovyev.common.text.StringUtils;
import org.solovyev.common.text.StringUtils;
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
public class CalculatorActivity extends SherlockFragmentActivity implements FontSizeAdjuster, SharedPreferences.OnSharedPreferenceChangeListener {
@NotNull
@NotNull public static final String TAG = CalculatorActivity.class.getSimpleName();
public static final String TAG = CalculatorActivity.class.getSimpleName();
@Nullable
private static final int HVGA_WIDTH_PIXELS = 320; private IBillingObserver billingObserver;
@Nullable private boolean useBackAsPrev;
private IBillingObserver billingObserver;
@NotNull
private boolean useBackAsPrev; private CalculatorActivityHelper activityHelper;
@NotNull /**
private CalculatorActivityHelper activityHelper; * Called when the activity is first created.
*/
/** @Override
* Called when the activity is first created. public void onCreate(@Nullable Bundle savedInstanceState) {
*/
@Override CalculatorApplication.registerOnRemoteStackTrace();
public void onCreate(@Nullable Bundle savedInstanceState) {
/*final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);*/
CalculatorApplication.registerOnRemoteStackTrace();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
/*final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);*/
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
activityHelper = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences); activityHelper.logDebug("onCreate");
activityHelper.onCreate(this, savedInstanceState);
activityHelper = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
activityHelper.logDebug("onCreate"); super.onCreate(savedInstanceState);
activityHelper.onCreate(this, savedInstanceState); activityHelper.logDebug("super.onCreate");
super.onCreate(savedInstanceState); if (findViewById(R.id.main_second_pane) != null) {
activityHelper.logDebug("super.onCreate"); activityHelper.addTab(this, "history", CalculatorHistoryFragment.class, null, R.string.c_history, R.id.main_second_pane);
activityHelper.addTab(this, "saved_history", CalculatorSavedHistoryFragment.class, null, R.string.c_saved_history, R.id.main_second_pane);
if (findViewById(R.id.main_second_pane) != null) { activityHelper.addTab(this, "vars", CalculatorVarsFragment.class, null, R.string.c_vars, R.id.main_second_pane);
activityHelper.addTab(this, "history", CalculatorHistoryFragment.class, null, R.string.c_history, R.id.main_second_pane); activityHelper.addTab(this, "functions", CalculatorFunctionsFragment.class, null, R.string.c_functions, 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, "operators", CalculatorOperatorsFragment.class, null, R.string.c_operators, R.id.main_second_pane);
activityHelper.addTab(this, "vars", CalculatorVarsFragment.class, null, R.string.c_vars, R.id.main_second_pane);
activityHelper.addTab(this, "functions", CalculatorFunctionsFragment.class, null, R.string.c_functions, R.id.main_second_pane); activityHelper.restoreSavedTab(this);
activityHelper.addTab(this, "operators", CalculatorOperatorsFragment.class, null, R.string.c_operators, R.id.main_second_pane); } else {
getSupportActionBar().hide();
activityHelper.restoreSavedTab(this); }
} else {
getSupportActionBar().hide(); CalculatorKeyboardFragment.fixThemeParameters(true, activityHelper.getTheme(), this.getWindow().getDecorView());
}
FragmentUtils.createFragment(this, CalculatorEditorFragment.class, R.id.editorContainer, "editor");
CalculatorKeyboardFragment.fixThemeParameters(true, activityHelper.getTheme(), this.getWindow().getDecorView()); FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display");
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard");
FragmentUtils.createFragment(this, CalculatorEditorFragment.class, R.id.editorContainer, "editor");
FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display"); /*if (customTitleSupported) {
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard"); try {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.calc_title);
/*if (customTitleSupported) { final CalculatorAdditionalTitle additionalAdditionalTitleText = (CalculatorAdditionalTitle)findViewById(R.id.additional_title_text);
try { additionalAdditionalTitleText.init(preferences);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.calc_title); preferences.registerOnSharedPreferenceChangeListener(additionalAdditionalTitleText);
final CalculatorAdditionalTitle additionalAdditionalTitleText = (CalculatorAdditionalTitle)findViewById(R.id.additional_title_text); } catch (ClassCastException e) {
additionalAdditionalTitleText.init(preferences); // super fix for issue with class cast in android.view.Window.setFeatureInt() (see app error reports)
preferences.registerOnSharedPreferenceChangeListener(additionalAdditionalTitleText); Log.e(CalculatorActivity.class.getName(), e.getMessage(), e);
} catch (ClassCastException e) { }
// super fix for issue with class cast in android.view.Window.setFeatureInt() (see app error reports) }*/
Log.e(CalculatorActivity.class.getName(), e.getMessage(), e);
} billingObserver = new CalculatorBillingObserver(this);
}*/ BillingController.registerObserver(billingObserver);
billingObserver = new CalculatorBillingObserver(this); this.useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
BillingController.registerObserver(billingObserver); firstTimeInit(preferences, this);
this.useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences); // init billing controller
firstTimeInit(preferences, this); BillingController.checkBillingSupported(this);
// init billing controller toggleOrientationChange(preferences);
BillingController.checkBillingSupported(this);
CalculatorKeyboardFragment.toggleEqualsButton(preferences, this, activityHelper.getTheme(), findViewById(R.id.main_layout));
toggleOrientationChange(preferences);
preferences.registerOnSharedPreferenceChangeListener(this);
CalculatorKeyboardFragment.toggleEqualsButton(preferences, this, activityHelper.getTheme(), findViewById(R.id.main_layout)); }
preferences.registerOnSharedPreferenceChangeListener(this); @NotNull
} private AndroidCalculator getCalculator() {
return ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator());
@NotNull }
private AndroidCalculator getCalculator() {
return ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator()); private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) {
} final Integer appOpenedCounter = CalculatorPreferences.appOpenedCounter.getPreference(preferences);
if (appOpenedCounter != null) {
private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) { CalculatorPreferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1);
final Integer appOpenedCounter = CalculatorPreferences.appOpenedCounter.getPreference(preferences); }
if (appOpenedCounter != null) {
CalculatorPreferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1); final Integer savedVersion = CalculatorPreferences.appVersion.getPreference(preferences);
}
final int appVersion = AndroidUtils.getAppVersionCode(context, CalculatorActivity.class.getPackage().getName());
final Integer savedVersion = CalculatorPreferences.appVersion.getPreference(preferences);
CalculatorPreferences.appVersion.putPreference(preferences, appVersion);
final int appVersion = AndroidUtils.getAppVersionCode(context, CalculatorActivity.class.getPackage().getName());
boolean dialogShown = false;
CalculatorPreferences.appVersion.putPreference(preferences, appVersion); if (EqualsTool.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
// new start
boolean dialogShown = false; final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(R.string.c_first_start_text);
if (EqualsTool.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) { builder.setPositiveButton(android.R.string.ok, null);
// new start builder.setTitle(R.string.c_first_start_text_title);
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(R.string.c_first_start_text); builder.create().show();
builder.setPositiveButton(android.R.string.ok, null); dialogShown = true;
builder.setTitle(R.string.c_first_start_text_title); } else {
builder.create().show(); if (savedVersion < appVersion) {
dialogShown = true; final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences);
} else { if (showReleaseNotes) {
if (savedVersion < appVersion) { final String releaseNotes = CalculatorReleaseNotesActivity.getReleaseNotes(context, savedVersion + 1);
final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences); if (!StringUtils.isEmpty(releaseNotes)) {
if (showReleaseNotes) { final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(Html.fromHtml(releaseNotes));
final String releaseNotes = CalculatorReleaseNotesActivity.getReleaseNotes(context, savedVersion + 1); builder.setPositiveButton(android.R.string.ok, null);
if (!StringUtils.isEmpty(releaseNotes)) { builder.setTitle(R.string.c_release_notes);
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(Html.fromHtml(releaseNotes)); builder.create().show();
builder.setPositiveButton(android.R.string.ok, null); dialogShown = true;
builder.setTitle(R.string.c_release_notes); }
builder.create().show(); }
dialogShown = true; }
} }
}
}
} //Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!");
if (!dialogShown) {
if (appOpenedCounter != null && appOpenedCounter > 10) {
//Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!"); dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.feedbackWindowShown, R.layout.feedback, R.id.feedbackText, context);
if (!dialogShown) { }
if (appOpenedCounter != null && appOpenedCounter > 10) { }
dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.feedbackWindowShown, R.layout.feedback, R.id.feedbackText, context);
} if (!dialogShown) {
} dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.notesppAnnounceShown, R.layout.notespp_announce, R.id.notespp_announce, context);
}
if (!dialogShown) { }
dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.notesppAnnounceShown, R.layout.notespp_announce, R.id.notespp_announce, context);
} private static boolean showSpecialWindow(@NotNull SharedPreferences preferences, @NotNull Preference<Boolean> specialWindowShownPref, int layoutId, int textViewId, @NotNull Context context) {
} boolean result = false;
private static boolean showSpecialWindow(@NotNull SharedPreferences preferences, @NotNull Preference<Boolean> specialWindowShownPref, int layoutId, int textViewId, @NotNull Context context) { final Boolean specialWindowShown = specialWindowShownPref.getPreference(preferences);
boolean result = false; if ( specialWindowShown != null && !specialWindowShown ) {
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
final Boolean specialWindowShown = specialWindowShownPref.getPreference(preferences); final View view = layoutInflater.inflate(layoutId, null);
if ( specialWindowShown != null && !specialWindowShown ) {
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE); final TextView feedbackTextView = (TextView) view.findViewById(textViewId);
final View view = layoutInflater.inflate(layoutId, null); feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance());
final TextView feedbackTextView = (TextView) view.findViewById(textViewId); final AlertDialog.Builder builder = new AlertDialog.Builder(context).setView(view);
feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance()); builder.setPositiveButton(android.R.string.ok, null);
builder.create().show();
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setView(view);
builder.setPositiveButton(android.R.string.ok, null); result = true;
builder.create().show(); specialWindowShownPref.putPreference(preferences, true);
}
result = true;
specialWindowShownPref.putPreference(preferences, true); return result;
} }
return result; @Override
} public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
@Override if (useBackAsPrev) {
public boolean onKeyDown(int keyCode, KeyEvent event) { getCalculator().doHistoryAction(HistoryAction.undo);
if (keyCode == KeyEvent.KEYCODE_BACK) { return true;
if (useBackAsPrev) { }
getCalculator().doHistoryAction(HistoryAction.undo); }
return true; return super.onKeyDown(keyCode, event);
} }
}
return super.onKeyDown(keyCode, event); @SuppressWarnings({"UnusedDeclaration"})
} public void equalsButtonClickHandler(@NotNull View v) {
getCalculator().evaluate();
@SuppressWarnings({"UnusedDeclaration"}) }
public void equalsButtonClickHandler(@NotNull View v) {
getCalculator().evaluate(); @Override
} protected void onPause() {
super.onPause();
/** activityHelper.onPause(this);
* The font sizes in the layout files are specified for a HVGA display. }
* Adjust the font sizes accordingly if we are running on a different
* display. @Override
*/ protected void onResume() {
@Override super.onResume();
public void adjustFontSize(@NotNull TextView view) {
/*float fontPixelSize = view.getTextSize(); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
Display display = getWindowManager().getDefaultDisplay(); final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
int h = Math.min(display.getWidth(), display.getHeight()); if ( newLayout.getLayoutId() != activityHelper.getLayoutId() ) {
float ratio = (float) h / HVGA_WIDTH_PIXELS; AndroidUtils.restartActivity(this);
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontPixelSize * ratio);*/ }
}
this.activityHelper.onResume(this);
@Override }
protected void onPause() {
super.onPause(); @Override
protected void onDestroy() {
activityHelper.onPause(this); if (billingObserver != null) {
} BillingController.unregisterObserver(billingObserver);
}
@Override
protected void onResume() { activityHelper.onDestroy(this);
super.onResume();
super.onDestroy();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); }
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
if ( newLayout.getLayoutId() != activityHelper.getLayoutId() ) { @Override
AndroidUtils.restartActivity(this); public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
} if ( CalculatorPreferences.Gui.usePrevAsBack.getKey().equals(key) ) {
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
this.activityHelper.onResume(this); }
}
if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) {
@Override toggleOrientationChange(preferences);
protected void onDestroy() { }
if (billingObserver != null) { }
BillingController.unregisterObserver(billingObserver);
} @Override
protected void onSaveInstanceState(Bundle outState) {
activityHelper.onDestroy(this); super.onSaveInstanceState(outState);
super.onDestroy(); activityHelper.onSaveInstanceState(this, outState);
} }
@Override private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) { preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
if ( CalculatorPreferences.Gui.usePrevAsBack.getKey().equals(key) ) { if (CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} } else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) { }
toggleOrientationChange(preferences); }
}
} /*
**********************************************************************
@Override *
protected void onSaveInstanceState(Bundle outState) { * BUTTON HANDLERS
super.onSaveInstanceState(outState); *
**********************************************************************
activityHelper.onSaveInstanceState(this, outState); */
}
@SuppressWarnings({"UnusedDeclaration"})
private void toggleOrientationChange(@Nullable SharedPreferences preferences) { public void elementaryButtonClickHandler(@NotNull View v) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences; throw new UnsupportedOperationException("Not implemented yet!");
if (CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) { }
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} else { @SuppressWarnings({"UnusedDeclaration"})
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); public void historyButtonClickHandler(@NotNull View v) {
} CalculatorActivityLauncher.showHistory(this);
} }
/* @SuppressWarnings({"UnusedDeclaration"})
********************************************************************** public void eraseButtonClickHandler(@NotNull View v) {
* CalculatorLocatorImpl.getInstance().getEditor().erase();
* BUTTON HANDLERS }
*
********************************************************************** @SuppressWarnings({"UnusedDeclaration"})
*/ public void simplifyButtonClickHandler(@NotNull View v) {
throw new UnsupportedOperationException("Not implemented yet!");
@SuppressWarnings({"UnusedDeclaration"}) }
public void elementaryButtonClickHandler(@NotNull View v) {
throw new UnsupportedOperationException("Not implemented yet!"); @SuppressWarnings({"UnusedDeclaration"})
} public void moveLeftButtonClickHandler(@NotNull View v) {
getKeyboard().moveCursorLeft();
@SuppressWarnings({"UnusedDeclaration"}) }
public void historyButtonClickHandler(@NotNull View v) {
CalculatorActivityLauncher.showHistory(this); @SuppressWarnings({"UnusedDeclaration"})
} public void moveRightButtonClickHandler(@NotNull View v) {
getKeyboard().moveCursorRight();
@SuppressWarnings({"UnusedDeclaration"}) }
public void eraseButtonClickHandler(@NotNull View v) {
CalculatorLocatorImpl.getInstance().getEditor().erase(); @SuppressWarnings({"UnusedDeclaration"})
} public void pasteButtonClickHandler(@NotNull View v) {
getKeyboard().pasteButtonPressed();
@SuppressWarnings({"UnusedDeclaration"}) }
public void simplifyButtonClickHandler(@NotNull View v) {
throw new UnsupportedOperationException("Not implemented yet!"); @SuppressWarnings({"UnusedDeclaration"})
} public void copyButtonClickHandler(@NotNull View v) {
getKeyboard().copyButtonPressed();
@SuppressWarnings({"UnusedDeclaration"}) }
public void moveLeftButtonClickHandler(@NotNull View v) {
getKeyboard().moveCursorLeft(); @NotNull
} private static CalculatorKeyboard getKeyboard() {
return CalculatorLocatorImpl.getInstance().getKeyboard();
@SuppressWarnings({"UnusedDeclaration"}) }
public void moveRightButtonClickHandler(@NotNull View v) {
getKeyboard().moveCursorRight(); @SuppressWarnings({"UnusedDeclaration"})
} public void clearButtonClickHandler(@NotNull View v) {
getKeyboard().clearButtonPressed();
@SuppressWarnings({"UnusedDeclaration"}) }
public void pasteButtonClickHandler(@NotNull View v) {
getKeyboard().pasteButtonPressed(); @SuppressWarnings({"UnusedDeclaration"})
} public void digitButtonClickHandler(@NotNull View v) {
Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed());
@SuppressWarnings({"UnusedDeclaration"}) if (((ColorButton) v).isShowText()) {
public void copyButtonClickHandler(@NotNull View v) { getKeyboard().digitButtonPressed(((ColorButton) v).getText().toString());
getKeyboard().copyButtonPressed(); }
} }
@NotNull @SuppressWarnings({"UnusedDeclaration"})
private static CalculatorKeyboard getKeyboard() { public void functionsButtonClickHandler(@NotNull View v) {
return CalculatorLocatorImpl.getInstance().getKeyboard(); CalculatorActivityLauncher.showFunctions(this);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void clearButtonClickHandler(@NotNull View v) { public void operatorsButtonClickHandler(@NotNull View v) {
getKeyboard().clearButtonPressed(); CalculatorActivityLauncher.showOperators(this);
} }
@SuppressWarnings({"UnusedDeclaration"}) public static void operatorsButtonClickHandler(@NotNull Activity activity) {
public void digitButtonClickHandler(@NotNull View v) { CalculatorActivityLauncher.showOperators(activity);
Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed()); }
if (((ColorButton) v).isShowText()) {
getKeyboard().digitButtonPressed(((ColorButton) v).getText().toString()); @SuppressWarnings({"UnusedDeclaration"})
} public void varsButtonClickHandler(@NotNull View v) {
} CalculatorActivityLauncher.showVars(this);
}
@SuppressWarnings({"UnusedDeclaration"})
public void functionsButtonClickHandler(@NotNull View v) { @SuppressWarnings({"UnusedDeclaration"})
CalculatorActivityLauncher.showFunctions(this); public void donateButtonClickHandler(@NotNull View v) {
} CalculatorApplication.showDonationDialog(this);
}
@SuppressWarnings({"UnusedDeclaration"})
public void operatorsButtonClickHandler(@NotNull View v) {
CalculatorActivityLauncher.showOperators(this);
}
public static void operatorsButtonClickHandler(@NotNull Activity activity) {
CalculatorActivityLauncher.showOperators(activity);
}
@SuppressWarnings({"UnusedDeclaration"})
public void varsButtonClickHandler(@NotNull View v) {
CalculatorActivityLauncher.showVars(this);
}
@SuppressWarnings({"UnusedDeclaration"})
public void donateButtonClickHandler(@NotNull View v) {
CalculatorApplication.showDonationDialog(this);
}
} }