mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2026-01-08 16:37:39 -06:00
Crashes Fix and Add more details in crash activity (#416)
This commit is contained in:
committed by
GitHub
parent
141100517a
commit
019d14e449
@@ -33,6 +33,12 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
debug {
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
|
||||
@@ -15,6 +15,6 @@ import dagger.hilt.android.HiltAndroidApp
|
||||
class MyApplication : CommonMyApplication() {
|
||||
|
||||
override fun getCrashActivityIntent(throwable: Throwable): Intent {
|
||||
return CrashActivity.getIntent(this, throwable.localizedMessage)
|
||||
return CrashActivity.getIntent(this, throwable.stackTraceToString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ class CrashActivity : AppCompatActivity() {
|
||||
binding.btnSendFeedback.setOnClickListener {
|
||||
|
||||
val deviceInfo = StringBuilder()
|
||||
deviceInfo.append(binding.txtCrash.text.toString())
|
||||
try {
|
||||
deviceInfo.append("\n")
|
||||
deviceInfo.append("App Version: " + BuildConfig.VERSION_NAME)
|
||||
@@ -57,7 +58,7 @@ class CrashActivity : AppCompatActivity() {
|
||||
|
||||
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() + "$deviceInfo")
|
||||
intent.putExtra(Intent.EXTRA_TEXT, deviceInfo.toString())
|
||||
|
||||
startActivity(Intent.createChooser(intent, ""))
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package com.yogeshpaliyal.keypass.ui.settings
|
||||
import android.app.Activity
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.ContentResolver
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -15,6 +18,7 @@ import androidx.preference.PreferenceFragmentCompat
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.yogeshpaliyal.common.dbhelper.createBackup
|
||||
import com.yogeshpaliyal.common.dbhelper.restoreBackup
|
||||
import com.yogeshpaliyal.common.utils.BACKUP_KEY_LENGTH
|
||||
import com.yogeshpaliyal.common.utils.email
|
||||
import com.yogeshpaliyal.common.utils.getOrCreateBackupKey
|
||||
import com.yogeshpaliyal.common.utils.setBackupDirectory
|
||||
@@ -116,37 +120,77 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
val binding = LayoutRestoreKeypharseBinding.inflate(layoutInflater)
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext()).setView(binding.root)
|
||||
val dialog = MaterialAlertDialogBuilder(requireContext()).setView(binding.root)
|
||||
.setNegativeButton(
|
||||
"Cancel"
|
||||
R.string.cancel
|
||||
) { dialog, which ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setPositiveButton(
|
||||
"Restore"
|
||||
R.string.restore
|
||||
) { dialog, which ->
|
||||
lifecycleScope.launch {
|
||||
val result = appDb.restoreBackup(
|
||||
binding.etKeyPhrase.text.toString(),
|
||||
contentResolver,
|
||||
selectedFile
|
||||
)
|
||||
if (result) {
|
||||
dialog?.dismiss()
|
||||
Toast.makeText(
|
||||
context,
|
||||
getString(R.string.backup_restored),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
Toast.makeText(
|
||||
context,
|
||||
getString(R.string.invalid_keyphrase),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
dialog.dismiss()
|
||||
}.create()
|
||||
|
||||
dialog.setOnShowListener {
|
||||
val positiveBtn = dialog.getButton(DialogInterface.BUTTON_POSITIVE)
|
||||
positiveBtn.setOnClickListener {
|
||||
restore(
|
||||
dialog,
|
||||
binding.etKeyPhrase.text.toString(),
|
||||
contentResolver,
|
||||
selectedFile
|
||||
)
|
||||
}
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun restore(
|
||||
dialog: AlertDialog,
|
||||
keyphrase: String,
|
||||
contentResolver: ContentResolver,
|
||||
selectedFile: Uri
|
||||
) {
|
||||
if (keyphrase.isEmpty()) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
R.string.alert_blank_keyphrase,
|
||||
Toast.LENGTH_SHORT
|
||||
)
|
||||
.show()
|
||||
return
|
||||
}
|
||||
|
||||
if (keyphrase.length != BACKUP_KEY_LENGTH) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
R.string.alert_invalid_keyphrase,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
val result = appDb.restoreBackup(
|
||||
keyphrase,
|
||||
contentResolver,
|
||||
selectedFile
|
||||
)
|
||||
if (result) {
|
||||
dialog.dismiss()
|
||||
Toast.makeText(
|
||||
context,
|
||||
getString(R.string.backup_restored),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
Toast.makeText(
|
||||
context,
|
||||
getString(R.string.invalid_keyphrase),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
app:boxBackgroundColor="@android:color/transparent"
|
||||
android:layout_marginTop="@dimen/grid_2"
|
||||
android:hint="@string/enter_keyphrase"
|
||||
android:layout_marginHorizontal="@dimen/grid_3">
|
||||
android:layout_marginHorizontal="@dimen/grid_3"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="16">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yogeshpaliyal.common.data
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
@@ -14,6 +15,7 @@ import com.yogeshpaliyal.common.utils.getRandomString
|
||||
* https://techpaliyal.com
|
||||
* created on 30-01-2021 20:38
|
||||
*/
|
||||
@Keep
|
||||
@Entity(tableName = "account")
|
||||
data class AccountModel(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yogeshpaliyal.common.data
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.google.gson.annotations.Expose
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@@ -9,6 +10,7 @@ import com.google.gson.annotations.SerializedName
|
||||
* https://techpaliyal.com
|
||||
* created on 23-02-2021 20:48
|
||||
*/
|
||||
@Keep
|
||||
data class BackupData(
|
||||
@SerializedName("version")
|
||||
@Expose
|
||||
|
||||
Reference in New Issue
Block a user