Release notes + fix for graph and angle units

This commit is contained in:
Sergey Solovyev 2013-01-20 18:12:43 +04:00
parent ff3aa4970f
commit 2e5d35afa7
4 changed files with 58 additions and 17 deletions

View File

@ -251,4 +251,13 @@
3. Исправлено дрожание окна Калькулятора++ 3. Исправлено дрожание окна Калькулятора++
</string> </string>
<string name="c_release_notes_for_115">
1. Полностью переработан графопостроитель\n
2. Добавлена возможность построения нескольких функций на одном графике\n
3. Добавлено построение в 3D\n
4. Добавлена возможность деать скриншоты графика\n
5. Исправлены проблемы с пользовательскими функциями\n
6. Другие исправления
</string>
</resources> </resources>

View File

@ -250,5 +250,13 @@
3. Fixed flicker for Calculator++ in separate window 3. Fixed flicker for Calculator++ in separate window
</string> </string>
<string name="c_release_notes_for_115">
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
</string>
</resources> </resources>

View File

@ -3,6 +3,7 @@ package org.solovyev.android.calculator;
import android.app.Activity; import android.app.Activity;
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;
/** /**
* User: serso * User: serso
@ -17,6 +18,9 @@ public final class Threads {
public static void tryRunOnUiThread(@Nullable final Activity activity, @NotNull final Runnable runnable) { public static void tryRunOnUiThread(@Nullable final Activity activity, @NotNull final Runnable runnable) {
if (activity != null && !activity.isFinishing()) { if (activity != null && !activity.isFinishing()) {
if (AndroidUtils.isUiThread()) {
runnable.run();
} else {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -28,4 +32,5 @@ public final class Threads {
}); });
} }
} }
}
} }

View File

@ -2,10 +2,12 @@ package org.solovyev.android.calculator.plot;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.view.View; import android.view.View;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
@ -16,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils2; import org.solovyev.android.AndroidUtils2;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.ActivityMenu; import org.solovyev.android.menu.ActivityMenu;
import org.solovyev.android.menu.IdentifiableMenuItem; import org.solovyev.android.menu.IdentifiableMenuItem;
@ -38,7 +41,7 @@ import java.util.concurrent.Executors;
* Date: 12/30/12 * Date: 12/30/12
* Time: 3:09 PM * 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 @Override
public void onPause() { public void onPause() {
PreferenceManager.getDefaultSharedPreferences(this.getActivity()).unregisterOnSharedPreferenceChangeListener(this);
final PlotBoundaries plotBoundaries = getPlotBoundaries(); final PlotBoundaries plotBoundaries = getPlotBoundaries();
if (plotBoundaries != null) { if (plotBoundaries != null) {
saveBoundaries(plotBoundaries); saveBoundaries(plotBoundaries);
@ -113,26 +118,40 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
PreferenceManager.getDefaultSharedPreferences(this.getActivity()).registerOnSharedPreferenceChangeListener(this);
plotData = Locator.getInstance().getPlotter().getPlotData(); plotData = Locator.getInstance().getPlotter().getPlotData();
createChart(plotData); updateChart(plotData, getSherlockActivity());
createGraphicalView(getView(), plotData); }
getSherlockActivity().invalidateOptionsMenu();
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (AndroidCalculatorEngine.Preferences.angleUnit.getKey().equals(key)) {
updateChart(this.plotData, getSherlockActivity());
}
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable final Object data) { public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable final Object data) {
if (calculatorEventType.isOfType(CalculatorEventType.plot_data_changed)) { switch (calculatorEventType) {
case plot_data_changed:
final CalculatorEventHolder.Result result = this.lastEventHolder.apply(calculatorEventData); final CalculatorEventHolder.Result result = this.lastEventHolder.apply(calculatorEventData);
if (result.isNewAfter()) { if (result.isNewAfter()) {
onNewPlotData((PlotData) data); onNewPlotData((PlotData) data);
} }
break;
} }
} }
private void onNewPlotData(@NotNull final PlotData plotData) { private void onNewPlotData(@NotNull final PlotData plotData) {
this.plotData = plotData; this.plotData = plotData;
final SherlockFragmentActivity activity = getSherlockActivity(); final SherlockFragmentActivity activity = getSherlockActivity();
updateChart(plotData, activity);
}
private void updateChart(@NotNull final PlotData plotData, @Nullable final SherlockFragmentActivity activity) {
Threads.tryRunOnUiThread(activity, new Runnable() { Threads.tryRunOnUiThread(activity, new Runnable() {
@Override @Override
public void run() { public void run() {