diff --git a/android-app-core/res/values-ru/text_about.xml b/android-app-core/res/values-ru/text_about.xml index 1c0d6872..4537b879 100644 --- a/android-app-core/res/values-ru/text_about.xml +++ b/android-app-core/res/values-ru/text_about.xml @@ -251,4 +251,13 @@ 3. Исправлено дрожание окна Калькулятора++ + + 1. Полностью переработан графопостроитель\n + 2. Добавлена возможность построения нескольких функций на одном графике\n + 3. Добавлено построение в 3D\n + 4. Добавлена возможность деать скриншоты графика\n + 5. Исправлены проблемы с пользовательскими функциями\n + 6. Другие исправления + + \ No newline at end of file diff --git a/android-app-core/res/values/text_about.xml b/android-app-core/res/values/text_about.xml index d3448dfc..c8a57c53 100644 --- a/android-app-core/res/values/text_about.xml +++ b/android-app-core/res/values/text_about.xml @@ -250,5 +250,13 @@ 3. Fixed flicker for Calculator++ in separate window + + 1. Graph plotter completely reworked\n + 2. Added support for graphing several functions\n + 3. Added 3D graphing capability\n + 4. Added support for graph screenshots\n + 5. Fixed issues with user defined functions\n + 6. Other fixes + \ No newline at end of file diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/Threads.java b/android-app-core/src/main/java/org/solovyev/android/calculator/Threads.java index 7a547641..fa4d0225 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/Threads.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/Threads.java @@ -3,6 +3,7 @@ package org.solovyev.android.calculator; import android.app.Activity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.solovyev.android.AndroidUtils; /** * User: serso @@ -17,15 +18,19 @@ public final class Threads { public static void tryRunOnUiThread(@Nullable final Activity activity, @NotNull final Runnable runnable) { if (activity != null && !activity.isFinishing()) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - // some time may pass and activity might be closing - if (!activity.isFinishing()) { - runnable.run(); + if (AndroidUtils.isUiThread()) { + runnable.run(); + } else { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + // some time may pass and activity might be closing + if (!activity.isFinishing()) { + runnable.run(); + } } - } - }); + }); + } } } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java index 111bf3a8..3672377c 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java @@ -2,10 +2,12 @@ package org.solovyev.android.calculator.plot; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.Paint; import android.os.Bundle; import android.os.Environment; +import android.preference.PreferenceManager; import android.support.v4.app.FragmentActivity; import android.view.View; import com.actionbarsherlock.app.SherlockFragmentActivity; @@ -16,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.solovyev.android.AndroidUtils2; import org.solovyev.android.calculator.*; +import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.ActivityMenu; import org.solovyev.android.menu.IdentifiableMenuItem; @@ -38,7 +41,7 @@ import java.util.concurrent.Executors; * Date: 12/30/12 * Time: 3:09 PM */ -public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment implements CalculatorEventListener { +public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment implements CalculatorEventListener, SharedPreferences.OnSharedPreferenceChangeListener { /* ********************************************************************** @@ -101,6 +104,8 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment @Override public void onPause() { + PreferenceManager.getDefaultSharedPreferences(this.getActivity()).unregisterOnSharedPreferenceChangeListener(this); + final PlotBoundaries plotBoundaries = getPlotBoundaries(); if (plotBoundaries != null) { saveBoundaries(plotBoundaries); @@ -113,26 +118,40 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment public void onResume() { super.onResume(); + PreferenceManager.getDefaultSharedPreferences(this.getActivity()).registerOnSharedPreferenceChangeListener(this); + plotData = Locator.getInstance().getPlotter().getPlotData(); - createChart(plotData); - createGraphicalView(getView(), plotData); - getSherlockActivity().invalidateOptionsMenu(); + updateChart(plotData, getSherlockActivity()); + } + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (AndroidCalculatorEngine.Preferences.angleUnit.getKey().equals(key)) { + updateChart(this.plotData, getSherlockActivity()); + } } @Override public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable final Object data) { - if (calculatorEventType.isOfType(CalculatorEventType.plot_data_changed)) { - final CalculatorEventHolder.Result result = this.lastEventHolder.apply(calculatorEventData); - if (result.isNewAfter()) { - onNewPlotData((PlotData) data); - } + switch (calculatorEventType) { + case plot_data_changed: + final CalculatorEventHolder.Result result = this.lastEventHolder.apply(calculatorEventData); + if (result.isNewAfter()) { + onNewPlotData((PlotData) data); + } + break; } + } private void onNewPlotData(@NotNull final PlotData plotData) { this.plotData = plotData; final SherlockFragmentActivity activity = getSherlockActivity(); + updateChart(plotData, activity); + } + + private void updateChart(@NotNull final PlotData plotData, @Nullable final SherlockFragmentActivity activity) { Threads.tryRunOnUiThread(activity, new Runnable() { @Override public void run() {