-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable troubleshooting dialog box for user guidance
Added a dialog box to provide users with troubleshooting guidance during critical operations. This dialog appears when the user encounters common errors and offers solutions or next steps. Key changes include: - Integrated the new troubleshooting dialog into the main user interface. - Implemented logic to trigger the dialog based on specific error codes. - Updated the UI to support the dialog's appearance and behavior. - Refined error-handling flow to ensure that appropriate guidance is displayed. This feature aims to improve user experience by helping users resolve issues without leaving the app.
- Loading branch information
1 parent
6a3dd81
commit 1a1e138
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
AnkiDroid/src/main/java/com/ichi2/anki/dialogs/TtsPlaybackErrorDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2024 RohanRaj123 <rajrohan88293@gmail.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 3 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program 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 for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.anki.dialogs | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.net.Uri | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.fragment.app.FragmentManager | ||
import com.ichi2.anki.CrashReportService | ||
import com.ichi2.anki.R | ||
import com.ichi2.anki.TtsVoices | ||
import com.ichi2.anki.utils.openUrl | ||
import com.ichi2.libanki.TTSTag | ||
import com.ichi2.utils.show | ||
import timber.log.Timber | ||
|
||
object TtsPlaybackErrorDialog { | ||
|
||
fun ttsPlaybackErrorDialog(activity: Activity, fragmentManager: FragmentManager, ttsTag: TTSTag?) { | ||
Timber.i("Dialog is shown to guide users correctly to troubleshoot the Tts error: Missing voice error") | ||
activity.runOnUiThread { | ||
AlertDialog.Builder(activity).show { | ||
setTitle(activity.getString(R.string.tts_error_dialog_title)) | ||
setMessage(activity.getString(R.string.tts_error_dialog_reason_text, TtsVoices.ttsEngine, ttsTag?.lang)) | ||
setNegativeButton(context.getString(R.string.tts_error_dialog_change_button_text)) { _, _ -> openSettings(activity) } | ||
setPositiveButton(activity.getString(R.string.tts_error_dialog_supported_voices_button_text)) { _, _ -> showVoicesDialog(fragmentManager) } | ||
setNeutralButton(context.getString(R.string.help)) { _, _ -> | ||
activity.openUrl(Uri.parse(context.getString(R.string.link_faq_tts))) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun openSettings(activity: Activity) { | ||
try { | ||
Timber.i("Opening TextToSpeech engine settings to change the engine") | ||
activity.startActivity( | ||
Intent("com.android.settings.TTS_SETTINGS").apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK } | ||
) | ||
} catch (e: Exception) { | ||
CrashReportService.sendExceptionReport(e, e.localizedMessage) | ||
} | ||
} | ||
|
||
private fun showVoicesDialog(fragmentManager: FragmentManager) { | ||
TtsVoicesDialogFragment().show(fragmentManager, "TTS_VOICES_DIALOG_FRAGMENT") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters