This commit is contained in:
serso 2012-10-03 14:04:50 +04:00
parent 18ad81cc08
commit a145edbd27
5 changed files with 156 additions and 135 deletions

View File

@ -57,5 +57,11 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<activity android:name="org.acra.CrashReportDialog"
android:theme="@android:style/Theme.Dialog"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true" />
</application> </application>
</manifest> </manifest>

View File

@ -85,6 +85,11 @@
</dependency> </dependency>
<!--OTHER--> <!--OTHER-->
<dependency>
<groupId>ch.acra</groupId>
<artifactId>acra</artifactId>
<version>4.3.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.android</groupId> <groupId>com.google.android</groupId>

View File

@ -211,5 +211,12 @@
<string name="result">Result</string> <string name="result">Result</string>
<string name="other">Other</string> <string name="other">Other</string>
<string name="derivatives">Derivatives/Integrals</string> <string name="derivatives">Derivatives/Integrals</string>
<string name="crashed">Calculator++ has been crashed…</string>
<string name="crash_dialog_title">Calculator++ crash report confirmation</string>
<string name="crash_dialog_text">
Unfortunately, Calculator++ has been crashed.\n\n
In order to fix the problem we need some information about it. It\'s highly recommended to send crash report via email (after pressing \'Ok\' button you will see all sent data in the new window).\n\n
Do you want to send crash report via email?
</string>
</resources> </resources>

View File

@ -58,9 +58,6 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
*/ */
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
CalculatorApplication.registerOnRemoteStackTrace();
/*final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);*/ /*final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);*/
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

View File

@ -1,132 +1,138 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import net.robotmedia.billing.BillingController; import net.robotmedia.billing.BillingController;
import org.jetbrains.annotations.NotNull; import org.acra.ACRA;
import org.solovyev.android.ads.AdsController; import org.acra.ReportingInteractionMode;
import org.solovyev.android.calculator.history.AndroidCalculatorHistory; import org.acra.annotation.ReportsCrashes;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.ads.AdsController;
/** import org.solovyev.android.calculator.history.AndroidCalculatorHistory;
* User: serso import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
* Date: 12/1/11
* Time: 1:21 PM /**
*/ * User: serso
public class CalculatorApplication extends android.app.Application { * Date: 12/1/11
* Time: 1:21 PM
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"; */
@ReportsCrashes(formKey = "",
public static final String AD_FREE_PRODUCT_ID = "ad_free"; mailTo = "se.solovyev+programming+calculatorpp+crashes@gmail.com",
public static final String AD_FREE_P_KEY = "org.solovyev.android.calculator_ad_free"; mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.crashed,
public static final String ADMOB_USER_ID = "a14f02cf9c80cbc"; resDialogTitle = R.string.crash_dialog_title,
public static final String REMOTE_STACK_TRACE_URL = "http://calculatorpp.com/crash_reports/upload.php"; resDialogText = R.string.crash_dialog_text)
public class CalculatorApplication extends android.app.Application {
@NotNull
private static CalculatorApplication instance; 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";
public CalculatorApplication() { public static final String AD_FREE_PRODUCT_ID = "ad_free";
instance = this; public static final String AD_FREE_P_KEY = "org.solovyev.android.calculator_ad_free";
}
public static final String ADMOB_USER_ID = "a14f02cf9c80cbc";
@NotNull
public static CalculatorApplication getInstance() { @NotNull
return instance; private static CalculatorApplication instance;
}
public CalculatorApplication() {
@Override instance = this;
public void onCreate() { }
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
@NotNull
setTheme(preferences); public static CalculatorApplication getInstance() {
return instance;
super.onCreate(); }
final AndroidCalculator calculator = new AndroidCalculator(); @Override
public void onCreate() {
CalculatorLocatorImpl.getInstance().init(calculator, ACRA.init(this);
new AndroidCalculatorEngine(this),
new AndroidCalculatorClipboard(this), final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
new AndroidCalculatorNotifier(this),
new AndroidCalculatorHistory(this, calculator)); setTheme(preferences);
CalculatorLocatorImpl.getInstance().getCalculator().init(); super.onCreate();
AdsController.getInstance().init(ADMOB_USER_ID, AD_FREE_PRODUCT_ID, new BillingController.IConfiguration() { final AndroidCalculator calculator = new AndroidCalculator();
@Override CalculatorLocatorImpl.getInstance().init(calculator,
public byte[] getObfuscationSalt() { new AndroidCalculatorEngine(this),
return new byte[]{81, -114, 32, -127, -32, -104, -40, -15, -47, 57, -13, -41, -33, 67, -114, 7, -11, 53, 126, 82}; new AndroidCalculatorClipboard(this),
} new AndroidCalculatorNotifier(this),
new AndroidCalculatorHistory(this, calculator));
@Override
public String getPublicKey() { CalculatorLocatorImpl.getInstance().getCalculator().init();
return CalculatorSecurity.getPK();
} AdsController.getInstance().init(ADMOB_USER_ID, AD_FREE_PRODUCT_ID, new BillingController.IConfiguration() {
});
@Override
CalculatorPreferences.setDefaultValues(preferences); 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};
}
private void setTheme(@NotNull SharedPreferences preferences) {
final CalculatorPreferences.Gui.Theme theme = CalculatorPreferences.Gui.getTheme(preferences); @Override
setTheme(theme.getThemeId()); public String getPublicKey() {
} return CalculatorSecurity.getPK();
}
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); CalculatorPreferences.setDefaultValues(preferences);
}
final TextView donate = (TextView) view.findViewById(R.id.donateText);
donate.setMovementMethod(LinkMovementMethod.getInstance()); private void setTheme(@NotNull SharedPreferences preferences) {
final CalculatorPreferences.Gui.Theme theme = CalculatorPreferences.Gui.getTheme(preferences);
final AlertDialog.Builder builder = new AlertDialog.Builder(context) setTheme(theme.getThemeId());
.setCancelable(true) }
.setNegativeButton(R.string.c_cancel, null)
.setPositiveButton(R.string.c_donate, new DialogInterface.OnClickListener() { public static void showDonationDialog(@NotNull final Context context) {
@Override final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
public void onClick(DialogInterface dialog, int which) { final View view = layoutInflater.inflate(R.layout.donate, null);
final Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(paypalDonateUrl)); final TextView donate = (TextView) view.findViewById(R.id.donateText);
context.startActivity(i); donate.setMovementMethod(LinkMovementMethod.getInstance());
}
}) final AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setView(view); .setCancelable(true)
.setNegativeButton(R.string.c_cancel, null)
builder.create().show(); .setPositiveButton(R.string.c_donate, new DialogInterface.OnClickListener() {
} @Override
public void onClick(DialogInterface dialog, int which) {
public static void registerOnRemoteStackTrace() { final Intent i = new Intent(Intent.ACTION_VIEW);
//Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(null, REMOTE_STACK_TRACE_URL)); i.setData(Uri.parse(paypalDonateUrl));
} context.startActivity(i);
}
@NotNull })
public CalculatorActivityHelper createActivityHelper(int layoutResId, @NotNull String logTag) { .setView(view);
return new CalculatorActivityHelperImpl(layoutResId, logTag);
} builder.create().show();
}
@NotNull
public CalculatorFragmentHelper createFragmentHelper(int layoutId) { @NotNull
return new CalculatorFragmentHelperImpl(layoutId); public CalculatorActivityHelper createActivityHelper(int layoutResId, @NotNull String logTag) {
} return new CalculatorActivityHelperImpl(layoutResId, logTag);
}
@NotNull
public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId) { @NotNull
return new CalculatorFragmentHelperImpl(layoutId, titleResId); public CalculatorFragmentHelper createFragmentHelper(int layoutId) {
} return new CalculatorFragmentHelperImpl(layoutId);
@NotNull }
public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId, boolean listenersOnCreate) {
return new CalculatorFragmentHelperImpl(layoutId, titleResId, listenersOnCreate); @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);
}
}