messages + billing

This commit is contained in:
Sergey Solovyev 2012-10-10 21:34:44 +04:00
parent 9e237c1a2c
commit 4bb42eff81
12 changed files with 268 additions and 344 deletions

View File

@ -0,0 +1,9 @@
msg_1=Арифметическая ошибка: {0}
msg_2=Слишком сложное выражение
msg_3=Вычисление выражения занимает слишком много времени - проверьте выражение
msg_4=Вычисление было отменено
msg_5=Для функции {0} не определены параметры
msg_6=В выражении найден Бесконечный цикл - проверьте выражение
syntax_error=Ошибка
result_copied=Результат скопирован в буфер!

View File

@ -0,0 +1,9 @@
msg_1=Арифметична помилка: {0}
msg_2=Надто складний вираз
msg_3=Обчислення виразу займає багато часу - перевірте вираз
msg_4=Обчислення скасовано
msg_5=Параметри не визначені для функції: {0}
msg_6=Нескінченний цикл виявлено у виразі - перевірте вираз
syntax_error=Помилка
result_copied=Результат скопійовано у буфер!

View File

@ -0,0 +1,9 @@
msg_1=計算錯誤: {0}
msg_2=計算式過於複雜
msg_3=執行逾時 - 請檢查計算式
msg_4=計算已取消
msg_5=未指定函數參數: {0}
msg_6=計算式包含無窮迴圈
syntax_error=錯誤
result_copied=答案已複製到剪貼簿!

View File

@ -1,56 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="91" android:versionName="1.3.2" package="org.solovyev.android.calculator">
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- settings must use action bar icon-->
<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"/>
<activity android:label="@string/c_about" android:name=".about.CalculatorAboutActivity"/>
<activity android:label="@string/c_help" android:name=".help.CalculatorHelpActivity"/>
<activity android:label="@string/c_functions" android:name=".math.edit.CalculatorFunctionsActivity"/>
<activity android:label="@string/c_operators" android:name=".math.edit.CalculatorOperatorsActivity"/>
<activity android:label="@string/c_vars_and_constants" android:name=".math.edit.CalculatorVarsActivity"/>
<activity android:label="@string/c_plot_graph" android:name=".plot.CalculatorPlotActivity"/>
<!-- settings must use action bar icon-->
<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"/>
<service android:name="net.robotmedia.billing.BillingService"/>
<receiver android:name="net.robotmedia.billing.BillingReceiver">
<intent-filter>
<action android:name="com.android.vending.billing.IN_APP_NOTIFY"/>
<action android:name="com.android.vending.billing.RESPONSE_CODE"/>
<action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED"/>
</intent-filter>
</receiver>
<activity android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:launchMode="singleInstance" android:name="org.acra.CrashReportDialog" android:theme="@style/Theme.Sherlock.Dialog"/>
</application>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="93" android:versionName="1.3.2" package="org.solovyev.android.calculator">
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- settings must use action bar icon-->
<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"/>
<activity android:label="@string/c_about" android:name=".about.CalculatorAboutActivity"/>
<activity android:label="@string/c_help" android:name=".help.CalculatorHelpActivity"/>
<activity android:label="@string/c_functions" android:name=".math.edit.CalculatorFunctionsActivity"/>
<activity android:label="@string/c_operators" android:name=".math.edit.CalculatorOperatorsActivity"/>
<activity android:label="@string/c_vars_and_constants" android:name=".math.edit.CalculatorVarsActivity"/>
<activity android:label="@string/c_plot_graph" android:name=".plot.CalculatorPlotActivity"/>
<!-- settings must use action bar icon-->
<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"/>
<service android:name="net.robotmedia.billing.BillingService"/>
<receiver android:name="net.robotmedia.billing.BillingReceiver">
<intent-filter>
<action android:name="com.android.vending.billing.IN_APP_NOTIFY"/>
<action android:name="com.android.vending.billing.RESPONSE_CODE"/>
<action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED"/>
</intent-filter>
</receiver>
<activity android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:launchMode="singleInstance" android:name="org.acra.CrashReportDialog" android:theme="@style/Theme.Sherlock.Dialog"/>
</application>
</manifest>

View File

@ -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

View File

@ -1,14 +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="msg_1">Арифметическая ошибка: {0}</string>
<string name="msg_2">Слишком сложное выражение</string>
<string name="msg_3">Вычисление выражения занимает слишком много времени - проверьте выражение</string>
<string name="msg_4">Вычисление было отменено</string>
<string name="msg_5">Для функции {0} не определены параметры</string>
<string name="msg_6">В выражении найден Бесконечный цикл - проверьте выражение</string>
</resources>

View File

@ -1,14 +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="msg_1">Арифметична помилка: {0}</string>
<string name="msg_2">Надто складний вираз</string>
<string name="msg_3">Обчислення виразу займає багато часу - перевірте вираз</string>
<string name="msg_4">Обчислення скасовано</string>
<string name="msg_5">Параметри не визначені для функції: {0}</string>
<string name="msg_6">Нескінченний цикл виявлено у виразі - перевірте вираз</string>
</resources>

View File

@ -1,14 +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="msg_1">計算錯誤: {0}</string>
<string name="msg_2">計算式過於複雜</string>
<string name="msg_3">執行逾時 - 請檢查計算式</string>
<string name="msg_4">計算已取消</string>
<string name="msg_5">未指定函數參數: {0}</string>
<string name="msg_6">計算式包含無窮迴圈</string>
</resources>

View File

@ -1,14 +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="msg_1">Arithmetic error occurred: {0}</string>
<string name="msg_2">Too complex expression</string>
<string name="msg_3">Too long execution time - check the expression</string>
<string name="msg_4">Evaluation was cancelled</string>
<string name="msg_5">No parameters are specified for function: {0}</string>
<string name="msg_6">Infinite loop is detected in expression</string>
</resources>

View File

@ -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));

View File

@ -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)));
}
}

View File

@ -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");
}
}