diff --git a/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_ru.properties b/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_ru.properties new file mode 100644 index 00000000..20b8b24e --- /dev/null +++ b/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_ru.properties @@ -0,0 +1,9 @@ +msg_1=Арифметическая ошибка: {0} +msg_2=Слишком сложное выражение +msg_3=Вычисление выражения занимает слишком много времени - проверьте выражение +msg_4=Вычисление было отменено +msg_5=Для функции {0} не определены параметры +msg_6=В выражении найден Бесконечный цикл - проверьте выражение + +syntax_error=Ошибка +result_copied=Результат скопирован в буфер! \ No newline at end of file diff --git a/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_uk.properties b/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_uk.properties new file mode 100644 index 00000000..cc7a9df8 --- /dev/null +++ b/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_uk.properties @@ -0,0 +1,9 @@ +msg_1=Арифметична помилка: {0} +msg_2=Надто складний вираз +msg_3=Обчислення виразу займає багато часу - перевірте вираз +msg_4=Обчислення скасовано +msg_5=Параметри не визначені для функції: {0} +msg_6=Нескінченний цикл виявлено у виразі - перевірте вираз + +syntax_error=Помилка +result_copied=Результат скопійовано у буфер! \ No newline at end of file diff --git a/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_zh.properties b/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_zh.properties new file mode 100644 index 00000000..b452e2f1 --- /dev/null +++ b/calculatorpp-core/src/main/resources/org/solovyev/android/calculator/messages_zh.properties @@ -0,0 +1,9 @@ +msg_1=計算錯誤: {0} +msg_2=計算式過於複雜 +msg_3=執行逾時 - 請檢查計算式 +msg_4=計算已取消 +msg_5=未指定函數參數: {0} +msg_6=計算式包含無窮迴圈 + +syntax_error=錯誤 +result_copied=答案已複製到剪貼簿! \ No newline at end of file diff --git a/calculatorpp/AndroidManifest.xml b/calculatorpp/AndroidManifest.xml index 3495f60a..60534db9 100644 --- a/calculatorpp/AndroidManifest.xml +++ b/calculatorpp/AndroidManifest.xml @@ -1,56 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/calculatorpp/project.properties b/calculatorpp/project.properties index 03180409..677898c5 100644 --- a/calculatorpp/project.properties +++ b/calculatorpp/project.properties @@ -1,24 +1,24 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-15 -android.library.reference.1=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.0 -android.library.reference.2=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.0 -android.library.reference.3=gen-external-apklibs/org.solovyev.android_billing_0.2 -android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.0 -android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.0 -android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.0 -android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.0 -android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.0 -android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.0 -android.library.reference.10=gen-external-apklibs/com.actionbarsherlock_library_4.1.0 -android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.0 - - +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-15 +android.library.reference.1=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.0 +android.library.reference.2=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.0 +android.library.reference.3=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.0 +android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.0 +android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.0 +android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.0 +android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.0 +android.library.reference.8=gen-external-apklibs/com.actionbarsherlock_library_4.1.0 +android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.0 +android.library.reference.10=gen-external-apklibs/org.solovyev.android_billing_0.2 +android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.0 + + diff --git a/calculatorpp/res/values-ru/text_messages.xml b/calculatorpp/res/values-ru/text_messages.xml deleted file mode 100644 index 4721f662..00000000 --- a/calculatorpp/res/values-ru/text_messages.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - Арифметическая ошибка: {0} - Слишком сложное выражение - Вычисление выражения занимает слишком много времени - проверьте выражение - Вычисление было отменено - Для функции {0} не определены параметры - В выражении найден Бесконечный цикл - проверьте выражение - \ No newline at end of file diff --git a/calculatorpp/res/values-uk/text_messages.xml b/calculatorpp/res/values-uk/text_messages.xml deleted file mode 100644 index 29b00797..00000000 --- a/calculatorpp/res/values-uk/text_messages.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - Арифметична помилка: {0} - Надто складний вираз - Обчислення виразу займає багато часу - перевірте вираз - Обчислення скасовано - Параметри не визначені для функції: {0} - Нескінченний цикл виявлено у виразі - перевірте вираз - diff --git a/calculatorpp/res/values-zh-rtw/text_messages.xml b/calculatorpp/res/values-zh-rtw/text_messages.xml deleted file mode 100644 index f2794afb..00000000 --- a/calculatorpp/res/values-zh-rtw/text_messages.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - 計算錯誤: {0} - 計算式過於複雜 - 執行逾時 - 請檢查計算式 - 計算已取消 - 未指定函數參數: {0} - 計算式包含無窮迴圈 - diff --git a/calculatorpp/res/values/text_messages.xml b/calculatorpp/res/values/text_messages.xml deleted file mode 100644 index fea86ef9..00000000 --- a/calculatorpp/res/values/text_messages.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - Arithmetic error occurred: {0} - Too complex expression - Too long execution time - check the expression - Evaluation was cancelled - No parameters are specified for function: {0} - Infinite loop is detected in expression - \ No newline at end of file diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java index 3520cc9a..23040283 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java @@ -87,15 +87,17 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements @Override public void setState(@NotNull final CalculatorDisplayViewState state) { - final CharSequence text = prepareText(state.getStringResult(), state.isValid()); handler.post(new Runnable() { @Override public void run() { + synchronized (lock) { try { viewStateChange = true; + final CharSequence text = prepareText(state.getStringResult(), state.isValid()); + AndroidCalculatorDisplayView.this.state = state; if (state.isValid()) { setTextColor(getResources().getColor(R.color.default_text_color)); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java index 6ca44bfc..ab76d96f 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java @@ -1,158 +1,159 @@ -package org.solovyev.android.calculator; - -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.Uri; -import android.preference.PreferenceManager; -import net.robotmedia.billing.BillingController; -import net.robotmedia.billing.helper.DefaultBillingObserver; -import net.robotmedia.billing.model.BillingDB; -import org.acra.ACRA; -import org.acra.ReportingInteractionMode; -import org.acra.annotation.ReportsCrashes; -import org.jetbrains.annotations.NotNull; -import org.solovyev.android.ads.AdsController; -import org.solovyev.android.calculator.history.AndroidCalculatorHistory; -import org.solovyev.android.calculator.model.AndroidCalculatorEngine; - -/** - * User: serso - * 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, - resToastText = R.string.crashed, - resDialogTitle = R.string.crash_dialog_title, - resDialogText = R.string.crash_dialog_text) -public class CalculatorApplication extends android.app.Application { - - /* - ********************************************************************** - * - * 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"; - - public static final String ADMOB_USER_ID = "a14f02cf9c80cbc"; - - @NotNull - private static CalculatorApplication instance; - - /* - ********************************************************************** - * - * CONSTRUCTORS - * - ********************************************************************** - */ - - public CalculatorApplication() { - instance = this; - } - - /* - ********************************************************************** - * - * METHODS - * - ********************************************************************** - */ - - @Override - public void onCreate() { - ACRA.init(this); - - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - CalculatorPreferences.setDefaultValues(preferences); - - setTheme(preferences); - - super.onCreate(); - - final AndroidCalculator calculator = new AndroidCalculator(); - - CalculatorLocatorImpl.getInstance().init(calculator, - new AndroidCalculatorEngine(this), - new AndroidCalculatorClipboard(this), - new AndroidCalculatorNotifier(this), - new AndroidCalculatorHistory(this, calculator)); - - CalculatorLocatorImpl.getInstance().getCalculator().init(); - - AdsController.getInstance().init(ADMOB_USER_ID, AD_FREE_PRODUCT_ID, new BillingController.IConfiguration() { - - @Override - public byte[] getObfuscationSalt() { - return new byte[]{81, -114, 32, -127, -32, -104, -40, -15, -47, 57, -13, -41, -33, 67, -114, 7, -11, 53, 126, 82}; - } - - @Override - public String getPublicKey() { - return CalculatorSecurity.getPK(); - } - }); - - BillingController.registerObserver(new DefaultBillingObserver(this, null)); - - // init billing controller - new Thread(new Runnable() { - @Override - public void run() { - BillingDB.init(CalculatorApplication.this); - BillingController.checkBillingSupported(CalculatorApplication.this); - } - }).start(); - } - - private void setTheme(@NotNull SharedPreferences preferences) { - final CalculatorPreferences.Gui.Theme theme = CalculatorPreferences.Gui.getTheme(preferences); - setTheme(theme.getThemeId()); - } - - @NotNull - public CalculatorActivityHelper createActivityHelper(int layoutResId, @NotNull String logTag) { - return new CalculatorActivityHelperImpl(layoutResId, logTag); - } - - @NotNull - public CalculatorFragmentHelper createFragmentHelper(int layoutId) { - return new CalculatorFragmentHelperImpl(layoutId); - } - - @NotNull - public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId) { - return new CalculatorFragmentHelperImpl(layoutId, titleResId); - } - @NotNull - public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId, boolean listenersOnCreate) { - 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))); - } -} +package org.solovyev.android.calculator; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.preference.PreferenceManager; +import net.robotmedia.billing.BillingController; +import net.robotmedia.billing.helper.DefaultBillingObserver; +import net.robotmedia.billing.model.BillingDB; +import org.acra.ACRA; +import org.acra.ReportingInteractionMode; +import org.acra.annotation.ReportsCrashes; +import org.jetbrains.annotations.NotNull; +import org.solovyev.android.ads.AdsController; +import org.solovyev.android.calculator.history.AndroidCalculatorHistory; +import org.solovyev.android.calculator.model.AndroidCalculatorEngine; + +/** + * User: serso + * 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, + resToastText = R.string.crashed, + resDialogTitle = R.string.crash_dialog_title, + resDialogText = R.string.crash_dialog_text) +public class CalculatorApplication extends android.app.Application { + + /* + ********************************************************************** + * + * 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"; + + public static final String ADMOB_USER_ID = "a14f02cf9c80cbc"; + + @NotNull + private static CalculatorApplication instance; + + /* + ********************************************************************** + * + * CONSTRUCTORS + * + ********************************************************************** + */ + + public CalculatorApplication() { + instance = this; + } + + /* + ********************************************************************** + * + * METHODS + * + ********************************************************************** + */ + + @Override + public void onCreate() { + ACRA.init(this); + + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + CalculatorPreferences.setDefaultValues(preferences); + + setTheme(preferences); + + super.onCreate(); + + final AndroidCalculator calculator = new AndroidCalculator(); + + CalculatorLocatorImpl.getInstance().init(calculator, + new AndroidCalculatorEngine(this), + new AndroidCalculatorClipboard(this), + new AndroidCalculatorNotifier(this), + new AndroidCalculatorHistory(this, calculator)); + + CalculatorLocatorImpl.getInstance().getCalculator().init(); + + AdsController.getInstance().init(ADMOB_USER_ID, AD_FREE_PRODUCT_ID, new BillingController.IConfiguration() { + + @Override + public byte[] getObfuscationSalt() { + return new byte[]{81, -114, 32, -127, -32, -104, -40, -15, -47, 57, -13, -41, -33, 67, -114, 7, -11, 53, 126, 82}; + } + + @Override + public String getPublicKey() { + return CalculatorSecurity.getPK(); + } + }); + + BillingController.registerObserver(new DefaultBillingObserver(this, null)); + + // init billing controller + new Thread(new Runnable() { + @Override + public void run() { + BillingDB.init(CalculatorApplication.this); + BillingController.checkBillingSupported(CalculatorApplication.this); + AdsController.getInstance().isAdFree(CalculatorApplication.this); + } + }).start(); + } + + private void setTheme(@NotNull SharedPreferences preferences) { + final CalculatorPreferences.Gui.Theme theme = CalculatorPreferences.Gui.getTheme(preferences); + setTheme(theme.getThemeId()); + } + + @NotNull + public CalculatorActivityHelper createActivityHelper(int layoutResId, @NotNull String logTag) { + return new CalculatorActivityHelperImpl(layoutResId, logTag); + } + + @NotNull + public CalculatorFragmentHelper createFragmentHelper(int layoutId) { + return new CalculatorFragmentHelperImpl(layoutId); + } + + @NotNull + public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId) { + return new CalculatorFragmentHelperImpl(layoutId, titleResId); + } + @NotNull + public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId, boolean listenersOnCreate) { + 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))); + } +} diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/LoggingBillingObserver.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/LoggingBillingObserver.java deleted file mode 100644 index 5cbe4a1a..00000000 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/LoggingBillingObserver.java +++ /dev/null @@ -1,50 +0,0 @@ -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"); - } -}