#4083 fixed external link popup not showing for external links not for donation

This commit is contained in:
ArctikCircle 2024-12-12 15:09:43 +05:30 committed by MohitMaliFtechiz
parent b9d662f3da
commit 393d645918
5 changed files with 11 additions and 23 deletions

View File

@ -128,7 +128,6 @@ class GetContentShortcutTest {
clickSettingsOnSideNav(SettingsRobot::assertMenuSettingsDisplayed) clickSettingsOnSideNav(SettingsRobot::assertMenuSettingsDisplayed)
clickHelpOnSideNav(HelpRobot::assertToolbarDisplayed) clickHelpOnSideNav(HelpRobot::assertToolbarDisplayed)
clickSupportKiwixOnSideNav() clickSupportKiwixOnSideNav()
assertExternalLinkDialogDisplayed()
pressBack() pressBack()
} }
} }

View File

@ -1677,10 +1677,6 @@ abstract class CoreReaderFragment :
externalLinkOpener?.openExternalUrl(intent) externalLinkOpener?.openExternalUrl(intent)
} }
fun openExternalUrl(intent: Intent, showExternalLinkPopup: Boolean) {
externalLinkOpener?.openExternalUrl(intent, showExternalLinkPopup)
}
override fun showSaveOrOpenUnsupportedFilesDialog(url: String, documentType: String?) { override fun showSaveOrOpenUnsupportedFilesDialog(url: String, documentType: String?) {
unsupportedMimeTypeHandler?.showSaveOrOpenUnsupportedFilesDialog( unsupportedMimeTypeHandler?.showSaveOrOpenUnsupportedFilesDialog(
url, url,

View File

@ -33,14 +33,10 @@ class ExternalLinkOpener @Inject constructor(
private val alertDialogShower: AlertDialogShower private val alertDialogShower: AlertDialogShower
) { ) {
fun openExternalUrl(intent: Intent) { fun openExternalUrl(
// Show popup with warning that this url is external and could lead to additional costs intent: Intent,
// or may event not work when the user is offline. showExternalLinkPopup: Boolean = sharedPreferenceUtil.prefExternalLinkPopup
openExternalUrl(intent, sharedPreferenceUtil.prefExternalLinkPopup) ) {
}
// Overload for ignoring sharedPreferenceUtil.prefExternalLinkPopup
fun openExternalUrl(intent: Intent, showExternalLinkPopup: Boolean) {
if (intent.resolveActivity(activity.packageManager) != null) { if (intent.resolveActivity(activity.packageManager) != null) {
if (showExternalLinkPopup) { if (showExternalLinkPopup) {
requestOpenLink(intent) requestOpenLink(intent)

View File

@ -170,12 +170,16 @@ class CustomMainActivity : CoreMainActivity() {
override fun onNavigationItemSelected(item: MenuItem): Boolean { override fun onNavigationItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
org.kiwix.kiwixmobile.core.R.id.menu_about_app -> { org.kiwix.kiwixmobile.core.R.id.menu_about_app -> {
openExternalUrl(BuildConfig.ABOUT_APP_URL) if (BuildConfig.ABOUT_APP_URL.isNotEmpty()) {
externalLinkOpener.openExternalUrl(BuildConfig.ABOUT_APP_URL.toUri().browserIntent())
}
true true
} }
org.kiwix.kiwixmobile.core.R.id.menu_support_kiwix -> { org.kiwix.kiwixmobile.core.R.id.menu_support_kiwix -> {
openExternalUrl(BuildConfig.SUPPORT_URL) if (BuildConfig.SUPPORT_URL.isNotEmpty()) {
externalLinkOpener.openExternalUrl(BuildConfig.SUPPORT_URL.toUri().browserIntent(), false)
}
true true
} }
@ -183,13 +187,6 @@ class CustomMainActivity : CoreMainActivity() {
} }
} }
private fun openExternalUrl(url: String) {
// check if the provided url is not empty.
if (url.isNotEmpty()) {
externalLinkOpener.openExternalUrl(url.toUri().browserIntent(), false)
}
}
override fun getIconResId() = R.mipmap.ic_launcher override fun getIconResId() = R.mipmap.ic_launcher
override fun createApplicationShortcuts() { override fun createApplicationShortcuts() {

View File

@ -348,7 +348,7 @@ class CustomReaderFragment : CoreReaderFragment() {
override fun openKiwixSupportUrl() { override fun openKiwixSupportUrl() {
if (BuildConfig.SUPPORT_URL.isNotEmpty()) { if (BuildConfig.SUPPORT_URL.isNotEmpty()) {
openExternalUrl(BuildConfig.SUPPORT_URL.toUri().browserIntent(), false) externalLinkOpener?.openExternalUrl(BuildConfig.SUPPORT_URL.toUri().browserIntent(), false)
} }
} }