From c2b76737c32b75f5e4bd45f1e7b466f948101ca3 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 11 Feb 2019 23:43:14 +0200 Subject: [PATCH] "Crash app" menu item in the new transaction menu. visible in debug builds only --- .../ui/activity/NewTransactionActivity.java | 16 +++++++ app/src/main/res/menu/new_transaction.xml | 42 +++++++++++-------- app/src/main/res/values-bg/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java index 04cabd6b..35851770 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java @@ -19,6 +19,7 @@ package net.ktnx.mobileledger.ui.activity; import android.annotation.SuppressLint; import android.database.Cursor; +import android.os.AsyncTask; import android.os.Bundle; import android.support.design.widget.BaseTransientBottomBar; import android.support.design.widget.FloatingActionButton; @@ -44,6 +45,7 @@ import android.widget.TableRow; import android.widget.TextView; import android.widget.Toast; +import net.ktnx.mobileledger.BuildConfig; import net.ktnx.mobileledger.R; import net.ktnx.mobileledger.async.DescriptionSelectedCallback; import net.ktnx.mobileledger.async.SaveTransactionTask; @@ -242,10 +244,18 @@ public class NewTransactionActivity extends CrashReportingActivity }); } + public boolean simulateCrash(MenuItem item) { + Log.d("crash", "Will crash intentionally"); + new AsyncCrasher().execute(); + return true; + } public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.new_transaction, menu); + if (BuildConfig.DEBUG) { + menu.findItem(R.id.action_simulate_crash).setVisible(true); + } check_transaction_submittable(); return true; @@ -538,4 +548,10 @@ public class NewTransactionActivity extends CrashReportingActivity return true; } + private class AsyncCrasher extends AsyncTask{ + @Override + protected Void doInBackground(Void... voids) { + throw new RuntimeException("Simulated crash"); + } + } } diff --git a/app/src/main/res/menu/new_transaction.xml b/app/src/main/res/menu/new_transaction.xml index e6e4070d..56c9a61a 100644 --- a/app/src/main/res/menu/new_transaction.xml +++ b/app/src/main/res/menu/new_transaction.xml @@ -1,5 +1,4 @@ - - - - + xmlns:app="http://schemas.android.com/apk/res-auto"> + + + \ No newline at end of file diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 45fdf6eb..91670742 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -93,6 +93,7 @@ Срив Не сега Изпращане... + Тестов срив MoLe се срина Съдържание на доклада: (Само за преглед) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 54db4cc6..89a2a4db 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -137,6 +137,7 @@ MoLe chashed Send... Not now + Crash app Crash Would you like to send the crash report to the developer? This would help diagnosing and fixing the problem. Send crash report via: -- 2.39.5