Add Crash feedback activity

This commit is contained in:
Yogesh Choudhary Paliyal
2021-10-19 20:47:26 +05:30
parent 3fa230252a
commit a9c2df707a
5 changed files with 116 additions and 12 deletions
+1
View File
@@ -6,6 +6,7 @@
<entry key="../../../../layout/custom_preview.xml" value="0.20833333333333334" />
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/drawable/ic_twotone_content_copy_24.xml" value="0.10989583333333333" />
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_add_totpactivity.xml" value="0.16485507246376813" />
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_crash.xml" value="0.14" />
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_dashboard.xml" value="0.2" />
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_scanner.xml" value="0.10416666666666667" />
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/fragment_detail.xml" value="0.1403985507246377" />
+17 -12
View File
@@ -3,29 +3,36 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.yogeshpaliyal.keypass">
<uses-permission android:name="android.permission.CAMERA" />
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:hardwareAccelerated="true"
android:theme="@style/Theme.KeyPass">
<activity
android:name=".ui.CrashActivity"
android:exported="false" />
<activity
android:name=".ui.addTOTP.AddTOTPActivity"
android:exported="false" />
<activity
android:name=".ui.addTOTP.ScannerActivity"
android:exported="false" />
<activity android:name=".ui.backup.BackupActivity"
<activity
android:name=".ui.backup.BackupActivity"
android:exported="false" />
<activity android:name=".ui.generate.GeneratePasswordActivity"
<activity
android:name=".ui.generate.GeneratePasswordActivity"
android:exported="true" />
<activity android:name=".ui.auth.AuthenticationActivity"
<activity
android:name=".ui.auth.AuthenticationActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -37,20 +44,18 @@
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:exported="false"
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:replace="screenOrientation" />
<activity
android:exported="false"
android:name=".ui.nav.DashboardActivity"
android:exported="false"
android:windowSoftInputMode="adjustPan" />
<activity
android:exported="false"
android:name=".ui.detail.DetailActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize" />
<meta-data
@@ -59,8 +64,8 @@
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove"
android:exported="false"/>
android:exported="false"
tools:node="remove" />
</application>
</manifest>
@@ -1,10 +1,14 @@
package com.yogeshpaliyal.keypass
import android.app.Application
import android.content.Intent
import android.util.Log
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import com.yogeshpaliyal.keypass.ui.CrashActivity
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject
import kotlin.system.exitProcess
/*
* @author Yogesh Paliyal
@@ -20,6 +24,13 @@ class MyApplication : Application(), Configuration.Provider {
override fun onCreate() {
super.onCreate()
Thread.setDefaultUncaughtExceptionHandler { thread, throwable ->
Log.d("MyApplication", "crashed ")
val intent = CrashActivity.getIntent(this,throwable.localizedMessage)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
exitProcess(1)
}
}
override fun getWorkManagerConfiguration(): Configuration {
@@ -28,4 +39,5 @@ class MyApplication : Application(), Configuration.Provider {
.setWorkerFactory(workerFactory)
.build()
}
}
@@ -0,0 +1,47 @@
package com.yogeshpaliyal.keypass.ui
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.yogeshpaliyal.keypass.databinding.ActivityCrashBinding
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class CrashActivity : AppCompatActivity() {
private lateinit var binding: ActivityCrashBinding
companion object {
private const val ARG_DATA = "arg_data"
fun getIntent(context: Context,data: String?): Intent {
return Intent(context, CrashActivity::class.java).also {
it.putExtra(ARG_DATA, data)
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityCrashBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.txtCrash.text = intent.extras?.getString(ARG_DATA)
binding.btnSendFeedback.setOnClickListener {
val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("mailto:")
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("yogeshpaliyal.foss@gmail.com"))
intent.putExtra(Intent.EXTRA_SUBJECT, "Crash Report in KeyPass")
intent.putExtra(Intent.EXTRA_TEXT, binding.txtCrash.text.toString())
startActivity(Intent.createChooser(intent, ""))
}
}
}
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.CrashActivity">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/btnSendFeedback"
android:layout_margin="@dimen/grid_4"
app:layout_constrainedWidth="true"
android:id="@+id/txtCrash"
app:layout_constrainedHeight="true"/>
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSendFeedback"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/send_feedback"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>