mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 19:52:46 +01:00
Show check for updates
dialog before report a bug (#834)
This commit is contained in:
parent
3308d7fe6f
commit
0c4364609b
@ -9,6 +9,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.HorizontalScrollView
|
import android.widget.HorizontalScrollView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import android.widget.Toast.LENGTH_LONG
|
import android.widget.Toast.LENGTH_LONG
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.databinding.DialogErrorBinding
|
import io.github.wulkanowy.databinding.DialogErrorBinding
|
||||||
@ -17,6 +18,7 @@ import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
|||||||
import io.github.wulkanowy.sdk.exception.ServiceUnavailableException
|
import io.github.wulkanowy.sdk.exception.ServiceUnavailableException
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.getString
|
import io.github.wulkanowy.utils.getString
|
||||||
|
import io.github.wulkanowy.utils.openAppInMarket
|
||||||
import io.github.wulkanowy.utils.openEmailClient
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import java.io.InterruptedIOException
|
import java.io.InterruptedIOException
|
||||||
@ -74,7 +76,9 @@ class ErrorDialog : BaseDialogFragment<DialogErrorBinding>() {
|
|||||||
Toast.makeText(context, R.string.all_copied, LENGTH_LONG).show()
|
Toast.makeText(context, R.string.all_copied, LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
errorDialogCancel.setOnClickListener { dismiss() }
|
errorDialogCancel.setOnClickListener { dismiss() }
|
||||||
errorDialogReport.setOnClickListener { openEmailClient(stringWriter.toString()) }
|
errorDialogReport.setOnClickListener {
|
||||||
|
openConfirmDialog { openEmailClient(stringWriter.toString()) }
|
||||||
|
}
|
||||||
errorDialogMessage.text = resources.getString(error)
|
errorDialogMessage.text = resources.getString(error)
|
||||||
errorDialogReport.isEnabled = when (error) {
|
errorDialogReport.isEnabled = when (error) {
|
||||||
is UnknownHostException,
|
is UnknownHostException,
|
||||||
@ -88,6 +92,17 @@ class ErrorDialog : BaseDialogFragment<DialogErrorBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openConfirmDialog(callback: () -> Unit) {
|
||||||
|
AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.dialog_error_check_update)
|
||||||
|
.setMessage(R.string.dialog_error_check_update_message)
|
||||||
|
.setNeutralButton(R.string.about_feedback) { _, _ -> callback() }
|
||||||
|
.setPositiveButton(R.string.dialog_error_check_update) { _, _ ->
|
||||||
|
requireContext().openAppInMarket(::showMessage)
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
private fun openEmailClient(content: String) {
|
private fun openEmailClient(content: String) {
|
||||||
requireContext().openEmailClient(
|
requireContext().openEmailClient(
|
||||||
chooserTitle = getString(R.string.about_feedback),
|
chooserTitle = getString(R.string.about_feedback),
|
||||||
|
@ -14,6 +14,7 @@ import io.github.wulkanowy.ui.modules.main.MainActivity
|
|||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.getCompatDrawable
|
import io.github.wulkanowy.utils.getCompatDrawable
|
||||||
|
import io.github.wulkanowy.utils.openAppInMarket
|
||||||
import io.github.wulkanowy.utils.openEmailClient
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -98,8 +99,12 @@ class AboutFragment : BaseFragment<FragmentAboutBinding>(R.layout.fragment_about
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun openAppInMarket() {
|
||||||
|
context?.openAppInMarket(::showMessage)
|
||||||
|
}
|
||||||
|
|
||||||
override fun openLogViewer() {
|
override fun openLogViewer() {
|
||||||
if (appInfo.isDebug) (activity as? MainActivity)?.pushView(LogViewerFragment.newInstance())
|
(activity as? MainActivity)?.pushView(LogViewerFragment.newInstance())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openDiscordInvite() {
|
override fun openDiscordInvite() {
|
||||||
@ -115,7 +120,7 @@ class AboutFragment : BaseFragment<FragmentAboutBinding>(R.layout.fragment_about
|
|||||||
chooserTitle = getString(R.string.about_feedback),
|
chooserTitle = getString(R.string.about_feedback),
|
||||||
email = "wulkanowyinc@gmail.com",
|
email = "wulkanowyinc@gmail.com",
|
||||||
subject = "Zgłoszenie błędu",
|
subject = "Zgłoszenie błędu",
|
||||||
body = requireContext().getString(R.string.about_feedback_template,
|
body = getString(R.string.about_feedback_template,
|
||||||
"${appInfo.systemManufacturer} ${appInfo.systemModel}", appInfo.systemVersion.toString(), appInfo.versionName
|
"${appInfo.systemManufacturer} ${appInfo.systemModel}", appInfo.systemVersion.toString(), appInfo.versionName
|
||||||
),
|
),
|
||||||
onActivityNotFound = {
|
onActivityNotFound = {
|
||||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.modules.about
|
|||||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||||
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||||
import io.github.wulkanowy.utils.SchedulersProvider
|
import io.github.wulkanowy.utils.SchedulersProvider
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -12,6 +13,7 @@ class AboutPresenter @Inject constructor(
|
|||||||
schedulers: SchedulersProvider,
|
schedulers: SchedulersProvider,
|
||||||
errorHandler: ErrorHandler,
|
errorHandler: ErrorHandler,
|
||||||
studentRepository: StudentRepository,
|
studentRepository: StudentRepository,
|
||||||
|
private val appInfo: AppInfo,
|
||||||
private val analytics: FirebaseAnalyticsHelper
|
private val analytics: FirebaseAnalyticsHelper
|
||||||
) : BasePresenter<AboutView>(errorHandler, studentRepository, schedulers) {
|
) : BasePresenter<AboutView>(errorHandler, studentRepository, schedulers) {
|
||||||
|
|
||||||
@ -27,7 +29,8 @@ class AboutPresenter @Inject constructor(
|
|||||||
when (name) {
|
when (name) {
|
||||||
versionRes?.first -> {
|
versionRes?.first -> {
|
||||||
Timber.i("Opening log viewer")
|
Timber.i("Opening log viewer")
|
||||||
openLogViewer()
|
if (appInfo.isDebug) openLogViewer()
|
||||||
|
else openAppInMarket()
|
||||||
analytics.logEvent("about_open", "name" to "log_viewer")
|
analytics.logEvent("about_open", "name" to "log_viewer")
|
||||||
}
|
}
|
||||||
feedbackRes?.first -> {
|
feedbackRes?.first -> {
|
||||||
|
@ -25,6 +25,8 @@ interface AboutView : BaseView {
|
|||||||
|
|
||||||
fun updateData(data: List<Triple<String, String, Drawable?>>)
|
fun updateData(data: List<Triple<String, String, Drawable?>>)
|
||||||
|
|
||||||
|
fun openAppInMarket()
|
||||||
|
|
||||||
fun openLogViewer()
|
fun openLogViewer()
|
||||||
|
|
||||||
fun openDiscordInvite()
|
fun openDiscordInvite()
|
||||||
|
@ -10,7 +10,7 @@ import androidx.annotation.ColorRes
|
|||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.BuildConfig.APPLICATION_ID
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun Context.getThemeAttrColor(@AttrRes colorAttr: Int): Int {
|
fun Context.getThemeAttrColor(@AttrRes colorAttr: Int): Int {
|
||||||
@ -39,6 +39,12 @@ fun Context.openInternetBrowser(uri: String, onActivityNotFound: (uri: String) -
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.openAppInMarket(onActivityNotFound: (uri: String) -> Unit) {
|
||||||
|
openInternetBrowser("market://details?id=${APPLICATION_ID}") {
|
||||||
|
openInternetBrowser("https://github.com/wulkanowy/wulkanowy/releases", onActivityNotFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Context.openEmailClient(chooserTitle: String, email: String, subject: String, body: String, onActivityNotFound: () -> Unit = {}) {
|
fun Context.openEmailClient(chooserTitle: String, email: String, subject: String, body: String, onActivityNotFound: () -> Unit = {}) {
|
||||||
val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:")).apply {
|
val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:")).apply {
|
||||||
putExtra(Intent.EXTRA_EMAIL, arrayOf(email))
|
putExtra(Intent.EXTRA_EMAIL, arrayOf(email))
|
||||||
|
@ -269,6 +269,9 @@
|
|||||||
<!--Log viewer-->
|
<!--Log viewer-->
|
||||||
<string name="logviewer_share">Logs teilen</string>
|
<string name="logviewer_share">Logs teilen</string>
|
||||||
<string name="logviewer_refresh">Aktualisieren</string>
|
<string name="logviewer_refresh">Aktualisieren</string>
|
||||||
|
<!--Error dialog-->
|
||||||
|
<string name="dialog_error_check_update">Check for updates</string>
|
||||||
|
<string name="dialog_error_check_update_message">Before reporting a bug, check first if an update with the bug fix is available</string>
|
||||||
<!--Generic-->
|
<!--Generic-->
|
||||||
<string name="all_content">Inhalt</string>
|
<string name="all_content">Inhalt</string>
|
||||||
<string name="all_retry">Wiederhol</string>
|
<string name="all_retry">Wiederhol</string>
|
||||||
|
@ -289,6 +289,9 @@
|
|||||||
<!--Log viewer-->
|
<!--Log viewer-->
|
||||||
<string name="logviewer_share">Udostępnij logi</string>
|
<string name="logviewer_share">Udostępnij logi</string>
|
||||||
<string name="logviewer_refresh">Odśwież</string>
|
<string name="logviewer_refresh">Odśwież</string>
|
||||||
|
<!--Error dialog-->
|
||||||
|
<string name="dialog_error_check_update">Sprawdź aktualizację</string>
|
||||||
|
<string name="dialog_error_check_update_message">Przed zgłoszeniem błędu sprawdź wcześniej, czy dostępna jest już aktualizacja z poprawką błędu</string>
|
||||||
<!--Generic-->
|
<!--Generic-->
|
||||||
<string name="all_content">Treść</string>
|
<string name="all_content">Treść</string>
|
||||||
<string name="all_retry">Ponów</string>
|
<string name="all_retry">Ponów</string>
|
||||||
|
@ -289,6 +289,9 @@
|
|||||||
<!--Log viewer-->
|
<!--Log viewer-->
|
||||||
<string name="logviewer_share">Поделиться логами</string>
|
<string name="logviewer_share">Поделиться логами</string>
|
||||||
<string name="logviewer_refresh">Обновить</string>
|
<string name="logviewer_refresh">Обновить</string>
|
||||||
|
<!--Error dialog-->
|
||||||
|
<string name="dialog_error_check_update">Check for updates</string>
|
||||||
|
<string name="dialog_error_check_update_message">Before reporting a bug, check first if an update with the bug fix is available</string>
|
||||||
<!--Generic-->
|
<!--Generic-->
|
||||||
<string name="all_content">Содержание</string>
|
<string name="all_content">Содержание</string>
|
||||||
<string name="all_retry">Повторить</string>
|
<string name="all_retry">Повторить</string>
|
||||||
|
@ -289,6 +289,9 @@
|
|||||||
<!--Log viewer-->
|
<!--Log viewer-->
|
||||||
<string name="logviewer_share">Поділитися логами</string>
|
<string name="logviewer_share">Поділитися логами</string>
|
||||||
<string name="logviewer_refresh">Оновити</string>
|
<string name="logviewer_refresh">Оновити</string>
|
||||||
|
<!--Error dialog-->
|
||||||
|
<string name="dialog_error_check_update">Check for updates</string>
|
||||||
|
<string name="dialog_error_check_update_message">Before reporting a bug, check first if an update with the bug fix is available</string>
|
||||||
<!--Generic-->
|
<!--Generic-->
|
||||||
<string name="all_content">Зміст</string>
|
<string name="all_content">Зміст</string>
|
||||||
<string name="all_retry">Повторити</string>
|
<string name="all_retry">Повторити</string>
|
||||||
|
@ -317,6 +317,11 @@
|
|||||||
<string name="logviewer_refresh">Refresh</string>
|
<string name="logviewer_refresh">Refresh</string>
|
||||||
|
|
||||||
|
|
||||||
|
<!--Error dialog-->
|
||||||
|
<string name="dialog_error_check_update">Check for updates</string>
|
||||||
|
<string name="dialog_error_check_update_message">Before reporting a bug, check first if an update with the bug fix is available</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Generic-->
|
<!--Generic-->
|
||||||
<string name="all_content">Content</string>
|
<string name="all_content">Content</string>
|
||||||
<string name="all_retry">Retry</string>
|
<string name="all_retry">Retry</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user