X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FCrashReportingActivity.java;h=183a5e9184d84ad0ec847a507e013d17f75ff791;hp=0d72499d008945dd7f6cd849dc2d668b516181a2;hb=9444b6123710997425d2f311d5dd97c6590aebca;hpb=0974c053bfa714958b1ce911865907085232a6d9 diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java index 0d72499d..183a5e91 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java @@ -1,16 +1,38 @@ +/* + * Copyright © 2019 Damyan Ivanov. + * This file is part of MoLe. + * MoLe is free software: you can distribute it and/or modify it + * under the term of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your opinion), any later version. + * + * MoLe is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License terms for details. + * + * You should have received a copy of the GNU General Public License + * along with MoLe. If not, see . + */ + package net.ktnx.mobileledger.ui.activity; +import android.content.pm.PackageInfo; +import android.os.Build; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; import android.util.Log; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + import net.ktnx.mobileledger.ui.CrashReportDialogFragment; import java.io.PrintWriter; import java.io.StringWriter; -public class CrashReportingActivity extends AppCompatActivity { +import static net.ktnx.mobileledger.utils.Logger.debug; + +public abstract class CrashReportingActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -20,6 +42,19 @@ public class CrashReportingActivity extends AppCompatActivity { public void uncaughtException(Thread t, Throwable e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + try { + PackageInfo pi = getApplicationContext().getPackageManager() + .getPackageInfo(getPackageName(), 0); + pw.format("MoLe version: %s\n", pi.versionName); + } + catch (Exception oh) { + pw.print("Error getting package version:\n"); + oh.printStackTrace(pw); + pw.print("\n"); + } + pw.format("OS version: %s; API level %d\n\n", Build.VERSION.RELEASE, + Build.VERSION.SDK_INT); e.printStackTrace(pw); Log.e(null, sw.toString()); @@ -29,6 +64,6 @@ public class CrashReportingActivity extends AppCompatActivity { df.show(getSupportFragmentManager(), "crash_report"); } }); - Log.d("crash", "Uncaught exception handler set"); + debug("crash", "Uncaught exception handler set"); } }