]> git.ktnx.net Git - mobile-ledger.git/commitdiff
"Crash app" menu item in the new transaction menu. visible in debug builds only
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 11 Feb 2019 21:43:14 +0000 (23:43 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 11 Feb 2019 21:43:14 +0000 (23:43 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java
app/src/main/res/menu/new_transaction.xml
app/src/main/res/values-bg/strings.xml
app/src/main/res/values/strings.xml

index 04cabd6b7b8275fbb45f1977850b4945525d2a4d..35851770c58b876495c2c5bf85bc6c5a0152991e 100644 (file)
@@ -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<Void, Void, Void>{
+        @Override
+        protected Void doInBackground(Void... voids) {
+            throw new RuntimeException("Simulated crash");
+        }
+    }
 }
index e6e4070dfa1d1bccdeb12830998ecf329d02670f..56c9a61a1b1e323cd9d00ff22c03cc610cd6fa3d 100644 (file)
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-    <!--
+<?xml version="1.0" encoding="utf-8"?><!--
   ~ Copyright © 2018 Damyan Ivanov.
   ~ This file is part of MoLe.
   ~ MoLe is free software: you can distribute it and/or modify it
   -->
 
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
-        xmlns:app="http://schemas.android.com/apk/res-auto">
-        <item
-            android:id="@+id/action_submit_transaction"
-            android:icon="@drawable/ic_save_white_24dp"
-            android:onClick="saveTransactionFromMenu"
-            android:title="@string/action_submit_transaction_title"
-            android:visible="false"
-            app:showAsAction="always" />
-        <item
-            android:id="@+id/action_add_account"
-            android:icon="@drawable/svg_thick_plus_white"
-            android:onClick="addTransactionAccountFromMenu"
-            android:orderInCategory="100"
-            android:title="@string/menu_add_account"
-            android:visible="false"
-            app:showAsAction="never|ifRoom" />
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+    <item
+        android:id="@+id/action_submit_transaction"
+        android:icon="@drawable/ic_save_white_24dp"
+        android:onClick="saveTransactionFromMenu"
+        android:title="@string/action_submit_transaction_title"
+        android:visible="false"
+        app:showAsAction="always" />
+    <item
+        android:id="@+id/action_add_account"
+        android:icon="@drawable/svg_thick_plus_white"
+        android:onClick="addTransactionAccountFromMenu"
+        android:orderInCategory="100"
+        android:title="@string/menu_add_account"
+        android:visible="false"
+        app:showAsAction="never|ifRoom" />
     <item
         android:id="@+id/action_reset_new_transaction_activity"
         android:icon="@drawable/ic_refresh_white_24dp"
         android:onClick="resetTransactionFromMenu"
         android:title="@string/action_reset_new_transaction_activity_title"
         app:showAsAction="never" />
+    <item
+        android:id="@+id/action_simulate_crash"
+        android:title="@string/crash_app_label"
+        android:titleCondensed="@string/crash_app_condensed_label"
+        android:onClick="simulateCrash"
+        android:visible="false"
+        app:showAsAction="never" />
 </menu>
\ No newline at end of file
index 45fdf6ebefd34d5f545b8656e967398f937d6112..91670742a6592e33dadea61d9cd30774fafb5c66 100644 (file)
@@ -93,6 +93,7 @@
     <string name="crash_app_condensed_label">Срив</string>
     <string name="btn_not_now">Не сега</string>
     <string name="btn_send_crash_report">Изпращане...</string>
+    <string name="crash_app_label">Тестов срив</string>
     <string name="crash_dialog_title">MoLe се срина</string>
     <string name="crash_report_contents_label">Съдържание на доклада:</string>
     <string name="profile_subitlte_read_only">(Само за преглед)</string>
index 54db4cc65d91fed75e7c51d9f6c324571f55c160..89a2a4db2fd7ce0230eb5f80a7def5a464c2e8a3 100644 (file)
     <string name="crash_dialog_title">MoLe chashed</string>
     <string name="btn_send_crash_report">Send...</string>
     <string name="btn_not_now">Not now</string>
+    <string name="crash_app_label">Crash app</string>
     <string name="crash_app_condensed_label">Crash</string>
     <string name="crash_send_question">Would you like to send the crash report to the developer? This would help diagnosing and fixing the problem.</string>
     <string name="send_crash_via">Send crash report via:</string>