This commit is contained in:
Sergey Solovyev 2012-10-10 00:32:33 +04:00
parent 4fd6e94e96
commit ac411a549f
37 changed files with 988 additions and 1032 deletions

View File

@ -13,10 +13,7 @@ import static org.solovyev.android.calculator.CalculatorEventType.*;
public class CalculatorDisplayImpl implements CalculatorDisplay {
@NotNull
private volatile CalculatorEventData lastCalculatorEventData;
@NotNull
private final Object lastCalculatorEventDataLock = new Object();
private final CalculatorEventHolder lastEvent;
@Nullable
private CalculatorDisplayView view;
@ -32,7 +29,7 @@ public class CalculatorDisplayImpl implements CalculatorDisplay {
public CalculatorDisplayImpl(@NotNull Calculator calculator) {
this.calculator = calculator;
this.lastCalculatorEventData = CalculatorUtils.createFirstEventDataId();
this.lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId());
this.calculator.addCalculatorEventListener(this);
}
@ -91,9 +88,7 @@ public class CalculatorDisplayImpl implements CalculatorDisplay {
@Override
@NotNull
public CalculatorEventData getLastEventData() {
synchronized (lastCalculatorEventDataLock) {
return lastCalculatorEventData;
}
return lastEvent.getLastEventData();
}
@Override
@ -102,18 +97,9 @@ public class CalculatorDisplayImpl implements CalculatorDisplay {
@Nullable Object data) {
if (calculatorEventType.isOfType(calculation_result, calculation_failed, calculation_cancelled, conversion_result, conversion_failed)) {
boolean processEvent = false;
boolean sameSequence = false;
final CalculatorEventHolder.Result result = lastEvent.apply(calculatorEventData);
synchronized (lastCalculatorEventDataLock) {
if (calculatorEventData.isAfter(lastCalculatorEventData)) {
sameSequence = calculatorEventData.isSameSequence(lastCalculatorEventData);
lastCalculatorEventData = calculatorEventData;
processEvent = true;
}
}
if (processEvent) {
if (result.isNewAfter()) {
switch (calculatorEventType) {
case conversion_failed:
processConversationFailed((CalculatorConversionEventData) calculatorEventData, (ConversionFailure) data);

View File

@ -26,12 +26,16 @@ public class CalculatorEditorImpl implements CalculatorEditor {
@NotNull
private final Calculator calculator;
@NotNull
private final CalculatorEventHolder lastEventHolder;
@NotNull
private final CursorControlAdapter cursorControlAdapter = new CursorControlAdapter(this);
public CalculatorEditorImpl(@NotNull Calculator calculator) {
this.calculator = calculator;
this.calculator.addCalculatorEventListener(this);
this.lastEventHolder = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId());
}
@Override
@ -80,6 +84,9 @@ public class CalculatorEditorImpl implements CalculatorEditor {
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData,
@NotNull CalculatorEventType calculatorEventType,
@Nullable Object data) {
final CalculatorEventHolder.Result result = lastEventHolder.apply(calculatorEventData);
if (result.isNewAfter()) {
switch (calculatorEventType) {
case use_history_state:
final CalculatorHistoryState calculatorHistoryState = (CalculatorHistoryState)data;
@ -88,6 +95,7 @@ public class CalculatorEditorImpl implements CalculatorEditor {
break;
}
}
}
/*
**********************************************************************

View File

@ -0,0 +1,70 @@
package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* User: serso
* Date: 10/9/12
* Time: 9:59 PM
*/
public class CalculatorEventHolder {
@NotNull
private volatile CalculatorEventData lastEventData;
public CalculatorEventHolder(@NotNull CalculatorEventData lastEventData) {
this.lastEventData = lastEventData;
}
@NotNull
public synchronized CalculatorEventData getLastEventData() {
return lastEventData;
}
@NotNull
public synchronized Result apply(@NotNull CalculatorEventData newEventData) {
final Result result = new Result(lastEventData, newEventData);
if (result.isNewAfter()) {
this.lastEventData = newEventData;
}
return result;
}
public static class Result {
@NotNull
private final CalculatorEventData lastEventData;
@NotNull
private final CalculatorEventData newEventData;
@Nullable
private Boolean after = null;
@Nullable
private Boolean sameSequence = null;
public Result(@NotNull CalculatorEventData lastEventData,
@NotNull CalculatorEventData newEventData) {
this.lastEventData = lastEventData;
this.newEventData = newEventData;
}
public boolean isNewAfter() {
if (after == null) {
after = newEventData.isAfter(lastEventData);
}
return after;
}
public boolean isSameSequence() {
if (sameSequence == null) {
sameSequence = newEventData.isSameSequence(lastEventData);
}
return sameSequence;
}
}
}

View File

@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
public class CalculatorTestUtils {
// in seconds
public static final int TIMEOUT = 1000;
public static final int TIMEOUT = 1;
public static void staticSetUp() throws Exception {
CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class));
@ -53,6 +53,7 @@ public class CalculatorTestUtils {
final TestCalculatorEventListener calculatorEventListener = new TestCalculatorEventListener(latch);
try {
calculator.addCalculatorEventListener(calculatorEventListener);
calculatorEventListener.setCalculatorEventData(calculator.evaluate(operation, expression));
if (latch.await(TIMEOUT, TimeUnit.SECONDS)) {
@ -100,6 +101,11 @@ public class CalculatorTestUtils {
result = displayChange.getNewValue();
try {
// need to sleep a little bit as await
new CountDownLatch(1).await(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
}
latch.countDown();
}
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="81" android:versionName="1.3.2"
package="org.solovyev.android.calculator">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="87" android:versionName="1.3.2" package="org.solovyev.android.calculator">
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
@ -9,7 +8,7 @@
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
<application android:debuggable="true" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication" android:theme="@style/metro_blue_theme">
<application android:debuggable="false" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication" android:theme="@style/metro_blue_theme">
<activity android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
@ -21,7 +20,7 @@
</activity>
<!-- settings must use action bar icon-->
<activity android:label="@string/c_app_settings" android:icon="@drawable/icon_action_bar" android:name=".CalculatorPreferencesActivity"/>
<activity android:icon="@drawable/icon_action_bar" android:label="@string/c_app_settings" android:name=".CalculatorPreferencesActivity"/>
<activity android:label="@string/c_history" android:name=".history.CalculatorHistoryActivity"/>
@ -38,7 +37,7 @@
<activity android:label="@string/c_plot_graph" android:name=".plot.CalculatorPlotActivity"/>
<!-- settings must use action bar icon-->
<activity android:label="@string/c_settings" android:icon="@drawable/icon_action_bar" android:name=".plot.CalculatorPlotPreferenceActivity"/>
<activity android:icon="@drawable/icon_action_bar" android:label="@string/c_settings" android:name=".plot.CalculatorPlotPreferenceActivity"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.ads.AdActivity"/>
@ -51,11 +50,7 @@
</intent-filter>
</receiver>
<activity android:name="org.acra.CrashReportDialog"
android:theme="@style/Theme.Sherlock.Dialog"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true" />
<activity android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:launchMode="singleInstance" android:name="org.acra.CrashReportDialog" android:theme="@style/Theme.Sherlock.Dialog"/>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 B

View File

@ -295,7 +295,7 @@
</manifest>
<proguard>
<skip>true</skip>
<skip>false</skip>
</proguard>
</configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

View File

@ -7,7 +7,7 @@
-->
<org.solovyev.android.view.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/pasteButton"
a:drawableTop="@drawable/kb_heart"
a:id="@+id/likeButton"
a:drawableTop="@drawable/kb_facebook"
style="?controlImageButtonStyle"
a:onClick="donateButtonClickHandler"/>
a:onClick="likeButtonClickHandler"/>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="fill_parent"
a:layout_height="fill_parent">
<TextView a:id="@+id/donateText"
style="@style/about_style"
a:layout_width="fill_parent"
a:text="@string/c_donate_text"
a:layout_height="fill_parent"/>
</LinearLayout>

View File

@ -12,7 +12,7 @@
Este programa es Open Source:\nTodo el código fuente puede encontrarse en\n<a href="https://github.com/serso/android-calculatorpp">http://github.com</a>\n\n
Para más información, por favor,\ncontacte con el autor al mail\n<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n
o visite\n<a href="http://se.solovyev.org">http://se.solovyev.org</a>\n\n
Si desea apoyar el proyecto,\npuede hacer una donación vía\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">\nhttp://paypal.com</a>\n\n
Si desea apoyar el proyecto\n\n
Si le gusta la aplicación\nvalórela con 5 estrellas en\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>\n\n
Gracias a las personas que han traducido Calculadora++ a los diferentes idiomas:\n
Español - Jordi Luna\n

View File

@ -1,17 +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>
<string name="c_donate">Donar</string>
<string name="c_donate_text" formatted="false">Puede dar las gracias por mail al autor de este programa\n\n
<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n\n
donar dinero a través de\n\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
o evaluar el programa con 5 estrellas en\n\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>\n
</string>
</resources>

View File

@ -12,7 +12,7 @@
Questo programma è open source:\ntutto il codice può essere trovato su\n<a href="https://github.com/serso/android-calculatorpp">http://github.com</a>\n\n
Per ulteriori informazioni contatta\nl\'autore via email\n<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>
\no visita\n<a href="http://se.solovyev.org">http://se.solovyev.org</a>\n\n
Se vuoi aiutare il progetto\npuoi effettuare una donazione via\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
Se vuoi aiutare il progetto\n\n
Se ti piace l\'applicazione\nvota 5 stelle nel\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>\n\n
Grazie a persone che traducono Calculator++ in diverse lingue:\n
Italiano - Gabriele Ravanetti\n

View File

@ -1,17 +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>
<string name="c_donate">Dona</string>
<string name="c_donate_text">Puoi ringraziare l\'autore di questo programma per email\n\n
<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n\n
o donando su\n\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
oppure votando l\'applicazione con 5 stelle nell\'\n\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>
</string>
</resources>

View File

@ -9,12 +9,11 @@
<string name="c_about">О программе</string>
<string name="c_about_content">Copyright (c) 2009-2011\n\n<b>Программа создана\nserso aka se.solovyev</b>\n\n
Сайт приложения: <a href="http://calculatorpp.com/forum/">http://calculatorpp.com/forum/</a>\n\n
Сайт приложения: <a href="http://facebook.com/calculatorpp">http://facebook.com/calculatorpp</a>\n\n
Эта программа с открытыми исходным кодом:\nон может быть найден на \n<a href="https://github.com/serso/android-calculatorpp">http://github.com</a>\n\n
За подробной информацией, пожалуйста,\nобращайтесь на почту\n<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n
или посетите сайт \n<a href="http://se.solovyev.org">http://se.solovyev.org</a>\n\n
Если вы хотите поддержать проект материально\nвы можете купить специальную опцию из настроек приложения\n
перевести средства через \n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
Если вы хотите поддержать проект материально\nвы можете купить специальную опцию из настроек приложения\n\n
Если вам понравилось приложение -\nпоставьте 5 звёздочек в\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>\n\n
Спасибо тем, кто переводил Калькулятор++:\n
на итальянский - Gabriele Ravanetti\n
@ -169,7 +168,7 @@
<string name="c_release_notes_for_27">
От разработчика:\n\n
Я рад сообщить, что у Калькулятора++ появился собственный форум: http://calculatorpp.com/forum/.\n
Я рад сообщить, что у Калькулятора++ появился собственный форум: http://facebook.com/calculatorpp.\n
Здесь вы можете найти всю последнюю информацию о приложении, узнать об известных проблемах и внести свои предложения.\n
Для входа вы можете использовать аккаунт социальной сети (Facebook, Twitter или Google).\n\n
1. Добавлены кнопки управления масштаб на графике\n

View File

@ -1,18 +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>
<string name="c_donate">Пожертвовать</string>
<string name="c_donate_text">Вы можете отблагодарить автора по почте\n\n
<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n\n
купить специальную опцию из настроек приложения\n\n
пожертвовать денег через\n\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
или поставить 5 звёздочек в\n\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>
</string>
</resources>

View File

@ -190,7 +190,7 @@
<string name="c_feedback_title">Отзыв</string>
<string name="c_feedback_text">Вы используете Калькулятор++ некоторое время\n
и для нас важно узнать ваше мнение о приложении.\n\n
Пожалуйста, оцените Калькулятор++ \nна <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>,\n оставьте комментарий или \nобсудите приложение \nна нашем <a href="http://calculatorpp.com/forum/">форуме</a>
Пожалуйста, оцените Калькулятор++ \nна <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>,\n оставьте комментарий или \nобсудите приложение \nв <a href="http://facebook.com/calculatorpp">Facebook</a>
</string>
<string name="c_notespp_announce_text">Хорошие новости - я только что выпустил новое приложение под Андроид под названием <a href="https://play.google.com/store/apps/details?id=org.solovyev.android.notes">Заметки++</a>.\n

View File

@ -9,12 +9,11 @@
<string name="c_about">Про програму</string>
<string name="c_about_content">Copyright (c) 2009-2011\n\n<b>Створено serso aka se.solovyev</b>\n\n
Сайт програми: <a href="http://calculatorpp.com/forum/">http://calculatorpp.com/forum/</a>\n\n
Сайт програми: <a href="http://facebook.com/calculatorpp">http://facebook.com/calculatorpp</a>\n\n
Ця програма з відкритим вихідним кодом:\nйого можна знайти на \n<a href="https://github.com/serso/android-calculatorpp">http://github.com</a>\n\n
За детальною інформацією, будь ласка, звертайтеся до автора на пошту\n<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>
\nабо відвідайте сайт\n<a href="http://se.solovyev.org">http://se.solovyev.org</a>\n\n
Якщо хочете підтримати проект фінансово,\nто ви можете купити спеціальну опцію у налаштуваннях програми\n
переказати гроші через \n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
Якщо хочете підтримати проект фінансово,\nто ви можете купити спеціальну опцію у налаштуваннях програми\n\n
Якщо вам сподобалася програма,\n то оцініть її у 5 зірочок на\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>\n\n
Дякую усім, хто переклав Калькулятор++ на інші мови:\n
італійську - Gabriele Ravanetti\n
@ -168,7 +167,7 @@
<string name="c_release_notes_for_27">
Від розробника:\n\n
Я радий повідомити Вас, що запустив форум для Калькулятор++: http://calculatorpp.com/forum/.\n
Я радий повідомити Вас, що запустив форум для Калькулятор++: http://facebook.com/calculatorpp.\n
Тут ви можете знайти усю останню інформацію про програму, дізнатися про відомі проблеми та внести свої пропозиції.\n
Для входу ви можете скористатися обліковим записом соціальної мережі (Facebook, Twitter or Google are supported).\n\n
1. Додано кнопки управління масштабом на графіку\n

View File

@ -1,18 +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>
<string name="c_donate">Пожертви</string>
<string name="c_donate_text">Ви можете подякувати автору цієї програми по пошті\n\n
<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n\n
купити спеціальну опцію у налаштуваннях програми\n\n
пожертвувати гроші через \n\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
або оцінити її у 5 зірочок на \n\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>
</string>
</resources>

View File

@ -190,7 +190,7 @@
<string name="c_feedback_title">Зворотній зв’язок</string>
<string name="c_feedback_text">Ви вже використовуєте Калькулятор++ деякий час \n
і для нас важливо знати вашу думку про програму.\n\n
Будь ласка, оцініть Калькулятор++ \nна <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>,\n залиште коментар або \nобговоріть програму \nна нашому <a href="http://calculatorpp.com/forum/">форумі</a>
Будь ласка, оцініть Калькулятор++ \nна <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>,\n залиште коментар або \nобговоріть програму \nна <a href="http://facebook.com/calculatorpp">Facebook</a>
</string>
<string name="c_angle_units_changed_to">Одиниці виміру кутів змінено на \'%s\'!</string>

View File

@ -9,12 +9,11 @@
<string name="c_about">關於</string>
<string name="c_about_content">Copyright (c) 2009-2011\n\n<b>Created by serso aka se.solovyev</b>\n\n
程式網站: <a href="http://calculatorpp.com/forum/">http://calculatorpp.com/forum/</a>\n\n
程式網站: <a href="http://facebook.com/calculatorpp">http://facebook.com/calculatorpp</a>\n\n
此程式為開放源碼軟體:\n原始碼位於\n<a href="https://github.com/serso/android-calculatorpp">http://github.com</a>\n\n
如果您需要更多資訊\n請寄信至作者信箱\n<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>
\n或是造訪\n<a href="http://se.solovyev.org">http://se.solovyev.org</a>\n\n
如果您想要支持此專案\n\n您可以從程式設定頁面中購買一個特別的選項\n\n
捐款到\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
如果您喜歡這個程式\n請在 <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a> 中將它評等為五顆星\n\n
感謝以下 Calculator++ 的翻譯者:\n
義大利文 - Gabriele Ravanetti\n
@ -166,7 +165,7 @@
<string name="c_release_notes_for_27">
來自開發者的訊息:\n\n
我很高興可以通知您, 我創立了一個 Calculator++ 的論壇: http://calculatorpp.com/forum/.\n
我很高興可以通知您, 我創立了一個 Calculator++ 的論壇: http://facebook.com/calculatorpp.\n
您可以在這裡找到程式最新的資訊、檢查已知問題、提報錯誤和建議新功能.\n
您可以使用常用社群網站的帳號登入 (可用 Facebook, Twitter 和 Google).\n\n
1. 在繪圖介面上顯示縮放按鈕\n

View File

@ -1,18 +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>
<string name="c_donate">捐款</string>
<string name="c_donate_text">您可以向此程式的作者表達謝意, 透過 e-mail:\n\n
<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n\n
購買設定選單中的選項\n\n
透過以下連結捐款\n\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
或是將此程式評等為五顆星:\n\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>
</string>
</resources>

View File

@ -190,7 +190,7 @@
<string name="c_feedback_title">回饋</string>
<string name="c_feedback_text">您已使用 Calculator++ 一段時間了 \n
我們很希望可以瞭解您對這個軟體的意見.\n\n
請在 <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a> 上評等 Calculator++,\n 留下評論訊息 \n或是在 <a href="http://calculatorpp.com/forum/">我們的論壇</a> 上討論.
請在 <a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a> 上評等 Calculator++,\n 留下評論訊息 \n或是在 <a href="http://facebook.com/calculatorpp">Facebook</a> 上討論.
</string>
<string name="c_notespp_announce_text">好消息 - 我剛發行了一個新的 Android 應用程式, 叫做 <a href="https://play.google.com/store/apps/details?id=org.solovyev.android.notes">Notes++</a>.\n

View File

@ -9,12 +9,11 @@
<string name="c_about">About</string>
<string name="c_about_content">Copyright (c) 2009-2011\n\n<b>Created by serso aka se.solovyev</b>\n\n
Application web site: <a href="http://calculatorpp.com/forum/">http://calculatorpp.com/forum/</a>\n\n
Application web site: <a href="http://facebook.com/calculatorpp">http://facebook.com/calculatorpp</a>\n\n
This program is open source:\nall source code can be found on\n<a href="https://github.com/serso/android-calculatorpp">http://github.com</a>\n\n
For more information please\ncontact the author by email\n<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>
\nor visit\n<a href="http://se.solovyev.org">http://se.solovyev.org</a>\n\n
If you want to support the project\n\nyou can buy a special option from application preferences\n\n
donate money via\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
If you like the application\nrank it with 5 stars in\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>\n\n
Thanks to people who translate Calculator++ in different languages:\n
Italian - Gabriele Ravanetti\n
@ -168,7 +167,7 @@
<string name="c_release_notes_for_27">
Note from developer:\n\n
I\'m glad to inform you that I\'ve started a forum for Calculator++: http://calculatorpp.com/forum/.\n
I\'m glad to inform you that I\'ve started a forum for Calculator++: http://facebook.com/calculatorpp.\n
Here you can find latest information about application, check for known issues, submit bugs or suggest new features.\n
You can use your social account to login (Facebook, Twitter or Google are supported).\n\n
1. Zoom buttons on graph plotter\n

View File

@ -1,18 +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>
<string name="c_donate">Donate</string>
<string name="c_donate_text">You can thank the author of this program by email\n\n
<a href="mailto:se.solovyev@gmail.com">se.solovyev@gmail.com</a>\n\n
buying a special option from application preferences\n\n
donating money via\n\n<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=se%2esolovyev%40gmail%2ecom&amp;lc=RU&amp;item_name=Android%20Calculator&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">http://paypal.com</a>\n\n
or setting 5 stars in\n\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">Google Play</a>
</string>
</resources>

View File

@ -190,7 +190,7 @@
<string name="c_feedback_title">Feedback</string>
<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
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 <a href="http://facebook.com/calculatorpp">Facebook</a>
</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

View File

@ -8,16 +8,13 @@ package org.solovyev.android.calculator;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.util.AttributeSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.android.calculator.view.TextHighlighter;
import org.solovyev.android.view.AutoResizeTextView;
import org.solovyev.common.text.StringUtils;
/**
* User: serso
@ -68,18 +65,15 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
public AndroidCalculatorDisplayView(Context context) {
super(context);
this.addTextChangedListener(new TextWatcherImpl());
}
public AndroidCalculatorDisplayView(Context context, AttributeSet attrs) {
super(context, attrs);
this.addTextChangedListener(new TextWatcherImpl());
}
public AndroidCalculatorDisplayView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.addTextChangedListener(new TextWatcherImpl());
}
/*
@ -163,16 +157,6 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
resizeText();
}
public void handleTextChange(Editable s) {
synchronized (lock) {
if (!viewStateChange) {
// external text change => need to notify display
// todo serso: implement
}
}
}
public synchronized void init(@NotNull Context context) {
if (!initialized) {
this.setOnClickListener(new CalculatorDisplayOnClickListener(context));
@ -180,21 +164,4 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
this.initialized = true;
}
}
private final class TextWatcherImpl implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
handleTextChange(s);
}
}
}

View File

@ -130,10 +130,6 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
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);
}
}
private static boolean showSpecialWindow(@NotNull SharedPreferences preferences, @NotNull Preference<Boolean> specialWindowShownPref, int layoutId, int textViewId, @NotNull Context context) {
@ -316,8 +312,8 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
}
@SuppressWarnings({"UnusedDeclaration"})
public void donateButtonClickHandler(@NotNull View v) {
CalculatorApplication.showDonationDialog(this);
public void likeButtonClickHandler(@NotNull View v) {
CalculatorApplication.likeButtonPressed(this);
}
}

View File

@ -1,16 +1,10 @@
package org.solovyev.android.calculator;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import net.robotmedia.billing.BillingController;
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
@ -25,6 +19,8 @@ import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
* Date: 12/1/11
* Time: 1:21 PM
*/
/*@ReportsCrashes(formKey = "dEhDaW1nZU1qcFdsVUpiSnhON0c0ZHc6MQ",
mode = ReportingInteractionMode.TOAST)*/
@ReportsCrashes(formKey = "",
mailTo = "se.solovyev+programming+calculatorpp+crashes@gmail.com",
mode = ReportingInteractionMode.DIALOG,
@ -33,7 +29,15 @@ import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
resDialogText = R.string.crash_dialog_text)
public class CalculatorApplication extends android.app.Application {
private static final String paypalDonateUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=se%2esolovyev%40gmail%2ecom&lc=RU&item_name=Android%20Calculator&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted";
/*
**********************************************************************
*
* CONSTANTS
*
**********************************************************************
*/
public static final String FACEBOOK_APP_URL = "http://www.facebook.com/calculatorpp";
public static final String AD_FREE_PRODUCT_ID = "ad_free";
public static final String AD_FREE_P_KEY = "org.solovyev.android.calculator_ad_free";
@ -43,14 +47,25 @@ public class CalculatorApplication extends android.app.Application {
@NotNull
private static CalculatorApplication instance;
/*
**********************************************************************
*
* CONSTRUCTORS
*
**********************************************************************
*/
public CalculatorApplication() {
instance = this;
}
@NotNull
public static CalculatorApplication getInstance() {
return instance;
}
/*
**********************************************************************
*
* METHODS
*
**********************************************************************
*/
@Override
public void onCreate() {
@ -86,11 +101,10 @@ public class CalculatorApplication extends android.app.Application {
}
});
BillingController.registerObserver(new CalculatorBillingObserver(this));
// init billing controller
BillingController.checkBillingSupported(this);
}
private void setTheme(@NotNull SharedPreferences preferences) {
@ -98,29 +112,6 @@ public class CalculatorApplication extends android.app.Application {
setTheme(theme.getThemeId());
}
public static void showDonationDialog(@NotNull final Context context) {
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
final View view = layoutInflater.inflate(R.layout.donate, null);
final TextView donate = (TextView) view.findViewById(R.id.donateText);
donate.setMovementMethod(LinkMovementMethod.getInstance());
final AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCancelable(true)
.setNegativeButton(R.string.c_cancel, null)
.setPositiveButton(R.string.c_donate, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(paypalDonateUrl));
context.startActivity(i);
}
})
.setView(view);
builder.create().show();
}
@NotNull
public CalculatorActivityHelper createActivityHelper(int layoutResId, @NotNull String logTag) {
return new CalculatorActivityHelperImpl(layoutResId, logTag);
@ -140,4 +131,20 @@ public class CalculatorApplication extends android.app.Application {
return new CalculatorFragmentHelperImpl(layoutId, titleResId, listenersOnCreate);
}
/*
**********************************************************************
*
* STATIC
*
**********************************************************************
*/
@NotNull
public static CalculatorApplication getInstance() {
return instance;
}
public static void likeButtonPressed(@NotNull final Context context) {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(FACEBOOK_APP_URL)));
}
}

View File

@ -0,0 +1,50 @@
package org.solovyev.android.calculator;
import android.app.PendingIntent;
import android.util.Log;
import net.robotmedia.billing.IBillingObserver;
import net.robotmedia.billing.ResponseCode;
import net.robotmedia.billing.model.Transaction;
import org.jetbrains.annotations.NotNull;
/**
* User: serso
* Date: 10/10/12
* Time: 12:27 AM
*/
class LoggingBillingObserver implements IBillingObserver {
@Override
public void onCheckBillingSupportedResponse(boolean supported) {
Log.d("CalculatorppBilling", "onCheckBillingSupportedResponse");
}
@Override
public void onPurchaseIntentOK(@NotNull String productId, @NotNull PendingIntent purchaseIntent) {
Log.d("CalculatorppBilling", "onPurchaseIntentOK");
}
@Override
public void onPurchaseIntentFailure(@NotNull String productId, @NotNull ResponseCode responseCode) {
Log.d("CalculatorppBilling", "onPurchaseIntentFailure");
}
@Override
public void onPurchaseStateChanged(@NotNull String productId, @NotNull Transaction.PurchaseState state) {
Log.d("CalculatorppBilling", "onPurchaseStateChanged");
}
@Override
public void onRequestPurchaseResponse(@NotNull String productId, @NotNull ResponseCode response) {
Log.d("CalculatorppBilling", "onRequestPurchaseResponse");
}
@Override
public void onTransactionsRestored() {
Log.d("CalculatorppBilling", "onTransactionsRestored");
}
@Override
public void onErrorRestoreTransactions(@NotNull ResponseCode responseCode) {
Log.d("CalculatorppBilling", "onErrorRestoreTransactions");
}
}

View File

@ -87,7 +87,7 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul
private Input input;
@NotNull
private CalculatorEventData lastCalculatorEventData = CalculatorUtils.createFirstEventDataId();
private final CalculatorEventHolder lastEventHolder = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId());
private int bgColor;
@ -355,13 +355,12 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable final Object data) {
if (calculatorEventType.isOfType(CalculatorEventType.display_state_changed)) {
if (!preparedInput.isFromInputArgs()) {
if (calculatorEventData.isAfter(this.lastCalculatorEventData)) {
this.lastCalculatorEventData = calculatorEventData;
final CalculatorEventHolder.Result result = this.lastEventHolder.apply(calculatorEventData);
if (result.isNewAfter()) {
this.preparedInput = prepareInputFromDisplay(((CalculatorDisplayChangeEventData) data).getNewValue(), null);
createChart();
uiHandler.post(new Runnable() {
@Override
public void run() {
@ -372,6 +371,7 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul
}
});
}
}
}
}