From 316bc6698a302b3b9479301e2c7a7a60afd1cb06 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 6 Jun 2025 11:44:17 +0200 Subject: [PATCH] Added user guide link in Help section, factorized code for URL opening, added missing ScrollView to help & debug layouts --- .../ui/assistant/fragment/LandingFragment.kt | 70 +-- .../chat/fragment/ConversationFragment.kt | 8 + .../ui/main/fragment/DrawerMenuFragment.kt | 4 + .../ui/main/help/fragment/HelpFragment.kt | 92 +-- app/src/main/res/drawable/book_open_text.xml | 9 + .../main/res/layout/help_debug_fragment.xml | 514 ++++++++-------- app/src/main/res/layout/help_fragment.xml | 576 ++++++++++-------- app/src/main/res/values-fr/strings.xml | 4 + app/src/main/res/values/strings.xml | 7 +- 9 files changed, 671 insertions(+), 613 deletions(-) create mode 100644 app/src/main/res/drawable/book_open_text.xml diff --git a/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt b/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt index e25239872..fc6bfdd47 100644 --- a/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt +++ b/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt @@ -104,22 +104,7 @@ class LandingFragment : GenericFragment() { binding.setForgottenPasswordClickListener { val url = getString(R.string.web_platform_forgotten_password_url) - try { - val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - startActivity(browserIntent) - } catch (ise: IllegalStateException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" - ) - } catch (anfe: ActivityNotFoundException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" - ) - } catch (e: Exception) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" - ) - } + openUrlInBrowser(url) } viewModel.showPassword.observe(viewLifecycleOwner) { @@ -215,47 +200,36 @@ class LandingFragment : GenericFragment() { model.privacyPolicyClickedEvent.observe(viewLifecycleOwner) { it.consume { val url = getString(R.string.website_privacy_policy_url) - try { - val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - startActivity(browserIntent) - } catch (ise: IllegalStateException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" - ) - } catch (anfe: ActivityNotFoundException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" - ) - } catch (e: Exception) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" - ) - } + openUrlInBrowser(url) } } model.generalTermsClickedEvent.observe(viewLifecycleOwner) { it.consume { val url = getString(R.string.website_terms_and_conditions_url) - try { - val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - startActivity(browserIntent) - } catch (ise: IllegalStateException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" - ) - } catch (anfe: ActivityNotFoundException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" - ) - } catch (e: Exception) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" - ) - } + openUrlInBrowser(url) } } dialog.show() } + + private fun openUrlInBrowser(url: String) { + try { + val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) + startActivity(browserIntent) + } catch (ise: IllegalStateException) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" + ) + } catch (anfe: ActivityNotFoundException) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" + ) + } catch (e: Exception) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" + ) + } + } } diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt index 1fe062ec8..85b6caea0 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt @@ -796,6 +796,14 @@ open class ConversationFragment : SlidingPaneChildFragment() { try { val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) startActivity(browserIntent) + } catch (ise: IllegalStateException) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" + ) + } catch (anfe: ActivityNotFoundException) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" + ) } catch (e: Exception) { Log.e( "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" diff --git a/app/src/main/java/org/linphone/ui/main/fragment/DrawerMenuFragment.kt b/app/src/main/java/org/linphone/ui/main/fragment/DrawerMenuFragment.kt index a85fa4785..ce762f7de 100644 --- a/app/src/main/java/org/linphone/ui/main/fragment/DrawerMenuFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/fragment/DrawerMenuFragment.kt @@ -157,6 +157,10 @@ class DrawerMenuFragment : GenericMainFragment() { Log.e( "$TAG Can't start ACTION_VIEW intent for URL [$link], ActivityNotFoundException: $anfe" ) + } catch (e: Exception) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$link]: $e" + ) } } } diff --git a/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt b/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt index 4413b92b0..4281c1160 100644 --- a/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt @@ -76,64 +76,24 @@ class HelpFragment : GenericMainFragment() { } } + binding.setUserGuideClickListener { + val url = getString(R.string.website_user_guide_url) + openUrlInBrowser(url) + } + binding.setPrivacyPolicyClickListener { val url = getString(R.string.website_privacy_policy_url) - try { - val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - startActivity(browserIntent) - } catch (ise: IllegalStateException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" - ) - } catch (anfe: ActivityNotFoundException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" - ) - } catch (e: Exception) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" - ) - } + openUrlInBrowser(url) } binding.setLicensesClickListener { val url = getString(R.string.website_open_source_licences_usage_url) - try { - val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - startActivity(browserIntent) - } catch (ise: IllegalStateException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" - ) - } catch (anfe: ActivityNotFoundException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" - ) - } catch (e: Exception) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" - ) - } + openUrlInBrowser(url) } binding.setTranslateClickListener { val url = getString(R.string.website_translate_weblate_url) - try { - val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - startActivity(browserIntent) - } catch (ise: IllegalStateException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" - ) - } catch (anfe: ActivityNotFoundException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" - ) - } catch (e: Exception) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" - ) - } + openUrlInBrowser(url) } viewModel.newVersionAvailableEvent.observe(viewLifecycleOwner) { @@ -181,26 +141,30 @@ class HelpFragment : GenericMainFragment() { model.confirmEvent.observe(viewLifecycleOwner) { it.consume { - try { - val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - startActivity(browserIntent) - } catch (ise: IllegalStateException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" - ) - } catch (anfe: ActivityNotFoundException) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" - ) - } catch (e: Exception) { - Log.e( - "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" - ) - } + openUrlInBrowser(url) dialog.dismiss() } } dialog.show() } + + private fun openUrlInBrowser(url: String) { + try { + val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri()) + startActivity(browserIntent) + } catch (ise: IllegalStateException) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise" + ) + } catch (anfe: ActivityNotFoundException) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url], ActivityNotFoundException: $anfe" + ) + } catch (e: Exception) { + Log.e( + "$TAG Can't start ACTION_VIEW intent for URL [$url]: $e" + ) + } + } } diff --git a/app/src/main/res/drawable/book_open_text.xml b/app/src/main/res/drawable/book_open_text.xml new file mode 100644 index 000000000..2c0c55c30 --- /dev/null +++ b/app/src/main/res/drawable/book_open_text.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/help_debug_fragment.xml b/app/src/main/res/layout/help_debug_fragment.xml index 56e9745b1..9d38cae41 100644 --- a/app/src/main/res/layout/help_debug_fragment.xml +++ b/app/src/main/res/layout/help_debug_fragment.xml @@ -54,263 +54,271 @@ app:layout_constraintStart_toEndOf="@id/back" app:layout_constraintTop_toTopOf="parent"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_constraintTop_toBottomOf="@id/back" + app:layout_constraintBottom_toBottomOf="parent"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -318,6 +326,6 @@ layout="@layout/operation_in_progress" bind:visibility="@{viewModel.logsUploadInProgress}" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/help_fragment.xml b/app/src/main/res/layout/help_fragment.xml index f8fd0e312..5e3f4711f 100644 --- a/app/src/main/res/layout/help_fragment.xml +++ b/app/src/main/res/layout/help_fragment.xml @@ -8,6 +8,9 @@ + @@ -25,15 +28,14 @@ type="org.linphone.ui.main.help.viewmodel.HelpViewModel" /> - + android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/color_background_contrast_in_dark_mode"> - + app:layout_constraintTop_toBottomOf="@id/back" + app:layout_constraintBottom_toBottomOf="parent"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 6e8c8a474..bb5a546ef 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -153,11 +153,14 @@ Aide À propos de &appName; + Guide utilisateur &appName; + Apprenez à maîtriser toutes les fonctionnalités de l\'application, pas à pas. Politique de confidentialité Quelles informations &appName; collecte et utilise Version Vérifier les mises à jour Aider à traduire &appName; + Contribuez à rendre l\'application accessible au plus grand nombre. Avancé Votre version est à jour Une erreur est survenue @@ -165,6 +168,7 @@ Une nouvelle version %s est disponible. Voulez-vous mettre à jour ? Quitter l\'application Dépannage + Transmettez vos journaux de diagnostic pour faciliter la résolution des bugs. Imprimer les journaux dans logcat Nettoyer les journaux Partager les journaux diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c07db9256..42be308f7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -32,8 +32,9 @@ https://linphone.org/contact https://linphone.org/linphone-softphone + https://linphone.org/en/docs/ https://linphone.org/en/privacy-policy - https://www.linphone.org/en/terms-of-use + https://linphone.org/en/terms-of-use https://subscribe.linphone.org/register/email https://subscribe.linphone.org/ https://weblate.linphone.org/ @@ -193,11 +194,14 @@ Help About &appName; + &appName; user guide + Learn how to master all app features, step by step. Privacy policy What information &appName; collects and uses Version Check update Contribute on &appName; translation + Help make the app accessible to as many people as possible. Advanced Your version is up-to-date An error occurred while checking for update @@ -205,6 +209,7 @@ A new version %s is available. Do you want to update? Quit app Troubleshooting + Transmit your diagnostic logs to facilitate bug resolution. Print logs in logcat Clean logs Share logs