Changes
This commit is contained in:
parent
e3f7fd5cb1
commit
a49ca358af
@ -18,7 +18,7 @@
|
||||
style="?fragmentTitleStyle"/>
|
||||
|
||||
<ScrollView a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
a:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
a:text="@string/c_faq_content"
|
||||
|
@ -218,5 +218,8 @@
|
||||
In order to fix the problem we need some information about it. It\'s highly recommended to send crash report via email (after pressing \'Ok\' button you will see all sent data in the new window).\n\n
|
||||
Do you want to send crash report?
|
||||
</string>
|
||||
<string name="c_prefs_graph">Graph preferences</string>
|
||||
<string name="c_show_complex_graph_summary">If checked complex graph will be plotted</string>
|
||||
<string name="c_show_complex_graph_title">Show complex graph</string>
|
||||
|
||||
</resources>
|
@ -10,15 +10,11 @@
|
||||
a:defaultValue="false"
|
||||
/>
|
||||
|
||||
<org.solovyev.android.ads.AdViewPreference
|
||||
a:key="admob_01"
|
||||
a:layout="@layout/admob_pref"/>
|
||||
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
|
||||
|
||||
<PreferenceScreen a:title="@string/c_prefs_calculations_category">
|
||||
|
||||
<org.solovyev.android.ads.AdViewPreference
|
||||
a:key="admob_02"
|
||||
a:layout="@layout/admob_pref"/>
|
||||
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="@string/p_calc_round_result_key"
|
||||
@ -64,14 +60,22 @@
|
||||
a:defaultValue="5"
|
||||
range:boundaries="3;1000"/>
|
||||
|
||||
<!-- <PreferenceScreen a:title="@string/c_prefs_graph">
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="show_complex_graph"
|
||||
a:summary="@string/c_show_complex_graph_summary"
|
||||
a:title="@string/c_show_complex_graph_title"
|
||||
a:defaultValue="false"/>
|
||||
|
||||
</PreferenceScreen>-->
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
a:title="@string/c_prefs_appearance_category">
|
||||
|
||||
<org.solovyev.android.ads.AdViewPreference
|
||||
a:key="admob_03"
|
||||
a:layout="@layout/admob_pref"/>
|
||||
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="@string/p_calc_color_display_key"
|
||||
@ -160,9 +164,7 @@
|
||||
<PreferenceScreen
|
||||
a:title="@string/c_prefs_other_category">
|
||||
|
||||
<org.solovyev.android.ads.AdViewPreference
|
||||
a:key="admob_04"
|
||||
a:layout="@layout/admob_pref"/>
|
||||
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="@string/p_calc_show_release_notes_key"
|
||||
|
@ -181,9 +181,12 @@ public final class CalculatorButtons {
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
final AngleUnit oldAngleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(preferences);
|
||||
if (oldAngleUnits != angleUnits) {
|
||||
AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, angleUnits);
|
||||
|
||||
Toast.makeText(context, context.getString(R.string.c_angle_units_changed_to, angleUnits.name()), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -223,9 +226,13 @@ public final class CalculatorButtons {
|
||||
final NumeralBase numeralBase = NumeralBase.valueOf(directionText);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
final NumeralBase oldNumeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences);
|
||||
if (oldNumeralBase != numeralBase) {
|
||||
AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase);
|
||||
|
||||
Toast.makeText(context, context.getString(R.string.c_numeral_base_changed_to, numeralBase.name()), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -97,6 +97,12 @@ public final class CalculatorPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Graph {
|
||||
public static final Preference<Boolean> showComplexGraph = new BooleanPreference("show_complex_graph", false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void setDefaultValues(@NotNull SharedPreferences preferences) {
|
||||
if (!AndroidCalculatorEngine.Preferences.groupingSeparator.isSet(preferences)) {
|
||||
final Locale locale = Locale.getDefault();
|
||||
|
@ -29,10 +29,8 @@ public enum CalculatorFragmentType {
|
||||
variables(CalculatorVarsFragment.class, R.layout.vars_fragment, R.string.c_vars),
|
||||
functions(CalculatorFunctionsFragment.class, R.layout.math_entities_fragment, R.string.c_functions),
|
||||
operators(CalculatorOperatorsFragment.class, R.layout.math_entities_fragment, R.string.c_operators),
|
||||
plotter(CalculatorPlotFragment.class, R.layout.plot_fragment, R.string.c_plot),
|
||||
plotter(CalculatorPlotFragment.class, R.layout.plot_fragment, R.string.c_graph),
|
||||
about(CalculatorAboutFragment.class, R.layout.about_fragment, R.string.c_about),
|
||||
|
||||
// todo serso: rename and inflate ad
|
||||
faq(CalculatorHelpFaqFragment.class, R.layout.help_faq_fragment, R.string.c_faq),
|
||||
hints(CalculatorHelpHintsFragment.class, R.layout.help_hints_fragment, R.string.c_hints),
|
||||
screens(CalculatorHelpScreensFragment.class, R.layout.help_screens_fragment, R.string.c_screens),
|
||||
|
@ -163,7 +163,7 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
|
||||
@Override
|
||||
public void init() {
|
||||
synchronized (lock) {
|
||||
calculatorEngine.init();
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,11 @@
|
||||
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -56,7 +58,8 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
|
||||
private static final int DEFAULT_MAX_NUMBER = 10;
|
||||
|
||||
public static final String INPUT = "org.solovyev.android.calculator.CalculatorPlotActivity_input";
|
||||
public static final String INPUT = "plotter_input";
|
||||
private static final String PLOT_BOUNDARIES = "plot_boundaries";
|
||||
|
||||
public static final long EVAL_DELAY_MILLIS = 200;
|
||||
|
||||
@ -74,7 +77,7 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
private Constant variable;
|
||||
|
||||
@NotNull
|
||||
private final CalculatorFragmentHelper fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.plot_fragment, R.string.c_plot, false);
|
||||
private final CalculatorFragmentHelper fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.plot_fragment, R.string.c_graph, false);
|
||||
|
||||
@NotNull
|
||||
private final Executor plotExecutor = Executors.newSingleThreadExecutor();
|
||||
@ -113,6 +116,8 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
this.bgColor = getResources().getColor(android.R.color.transparent);
|
||||
prepareData();
|
||||
}
|
||||
|
||||
setRetainInstance(true);
|
||||
}
|
||||
|
||||
private void createInputFromDisplayState(@NotNull CalculatorDisplayViewState displayState) {
|
||||
@ -161,7 +166,25 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
|
||||
this.fragmentHelper.onViewCreated(this, root);
|
||||
|
||||
updateGraphicalView(root);
|
||||
|
||||
PlotBoundaries plotBoundaries = null;
|
||||
/*if ( savedInstanceState != null ) {
|
||||
final Object object = savedInstanceState.getSerializable(PLOT_BOUNDARIES);
|
||||
if ( object instanceof PlotBoundaries) {
|
||||
plotBoundaries = ((PlotBoundaries) object);
|
||||
}
|
||||
}*/
|
||||
|
||||
updateGraphicalView(root, plotBoundaries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle out) {
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
/*if (chart != null) {
|
||||
out.putSerializable(PLOT_BOUNDARIES, new PlotBoundaries(chart.getRenderer()));
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -172,7 +195,7 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
|
||||
if ( !inputFromArgs ) {
|
||||
createInputFromDisplayState(CalculatorLocatorImpl.getInstance().getDisplay().getViewState());
|
||||
updateGraphicalView(getView());
|
||||
updateGraphicalView(getView(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,11 +206,9 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
private void updateGraphicalView(@NotNull View root) {
|
||||
private void updateGraphicalView(@NotNull View root, @Nullable PlotBoundaries plotBoundaries) {
|
||||
if (input != null) {
|
||||
// todo serso
|
||||
final Object lastNonConfigurationInstance = null;//getLastNonConfigurationInstance();
|
||||
setGraphicalView(root, lastNonConfigurationInstance instanceof PlotBoundaries ? (PlotBoundaries) lastNonConfigurationInstance : null);
|
||||
setGraphicalView(root, plotBoundaries);
|
||||
} else {
|
||||
Toast.makeText(this.getActivity(), "Plot is not possible!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
@ -282,6 +303,9 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
}
|
||||
|
||||
private void updateDataSets(@NotNull final XYChart chart, long millisToWait) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
||||
final boolean showComplexGraph = CalculatorPreferences.Graph.showComplexGraph.getPreference(preferences);
|
||||
|
||||
pendingOperation.setObject(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -405,7 +429,7 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
|
||||
public void run() {
|
||||
final View view = getView();
|
||||
if (view != null) {
|
||||
updateGraphicalView(view);
|
||||
updateGraphicalView(view, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -37,7 +37,7 @@ public final class PlotUtils {
|
||||
@NotNull Generic expression,
|
||||
@NotNull Constant variable,
|
||||
@NotNull MyXYSeries realSeries,
|
||||
@NotNull MyXYSeries imagSeries,
|
||||
@Nullable MyXYSeries imagSeries,
|
||||
boolean addExtra,
|
||||
int numberOfSteps) throws ArithmeticException {
|
||||
|
||||
@ -72,7 +72,7 @@ public final class PlotUtils {
|
||||
prevX = x;
|
||||
}
|
||||
|
||||
boolean needToCalculateImagY = imagSeries.needToAdd(step, x);
|
||||
boolean needToCalculateImagY = imagSeries != null && imagSeries.needToAdd(step, x);
|
||||
if (needToCalculateImagY) {
|
||||
y = prepareY(c.imaginaryPart());
|
||||
if (y != null) {
|
||||
@ -86,7 +86,7 @@ public final class PlotUtils {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
boolean needToCalculateImagY = imagSeries.needToAdd(step, x);
|
||||
boolean needToCalculateImagY = imagSeries != null && imagSeries.needToAdd(step, x);
|
||||
if (needToCalculateImagY) {
|
||||
final Complex c = calculatorExpression(expression, variable, x);
|
||||
Double y = prepareY(c.imaginaryPart());
|
||||
|
Loading…
Reference in New Issue
Block a user