Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4083 fixed external link warning when user wants to make a donation #4133

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class TopLevelDestinationTest : BaseActivityTest() {
clickSettingsOnSideNav(SettingsRobot::assertMenuSettingsDisplayed)
clickHelpOnSideNav(HelpRobot::assertToolbarDisplayed)
clickSupportKiwixOnSideNav()
assertExternalLinkDialogDisplayed()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same we are using in the GetContentShortcutTest so please make the changes there as well.

pressBack()
}
LeakAssertions.assertNoLeaks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
}

fun openSupportKiwixExternalLink() {
externalLinkOpener.openExternalUrl(KIWIX_SUPPORT_URL.toUri().browserIntent())
externalLinkOpener.openExternalUrl(KIWIX_SUPPORT_URL.toUri().browserIntent(), false)
MohitMaliFtechiz marked this conversation as resolved.
Show resolved Hide resolved
}

private fun handleBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,10 @@ abstract class CoreReaderFragment :
externalLinkOpener?.openExternalUrl(intent)
}

fun openExternalUrl(intent: Intent, showExternalLinkPopup: Boolean) {
externalLinkOpener?.openExternalUrl(intent, showExternalLinkPopup)
}

override fun showSaveOrOpenUnsupportedFilesDialog(url: String, documentType: String?) {
unsupportedMimeTypeHandler?.showSaveOrOpenUnsupportedFilesDialog(
url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ class ExternalLinkOpener @Inject constructor(
) {

fun openExternalUrl(intent: Intent) {
// Show popup with warning that this url is external and could lead to additional costs
// or may event not work when the user is offline.
openExternalUrl(intent, sharedPreferenceUtil.prefExternalLinkPopup)
}

// Overload for ignoring sharedPreferenceUtil.prefExternalLinkPopup
fun openExternalUrl(intent: Intent, showExternalLinkPopup: Boolean) {
if (intent.resolveActivity(activity.packageManager) != null) {
// Show popup with warning that this url is external and could lead to additional costs
// or may event not work when the user is offline.
if (sharedPreferenceUtil.prefExternalLinkPopup) {
if (showExternalLinkPopup) {
requestOpenLink(intent)
} else {
openLink(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class CustomMainActivity : CoreMainActivity() {
private fun openExternalUrl(url: String) {
// check if the provided url is not empty.
if (url.isNotEmpty()) {
externalLinkOpener.openExternalUrl(url.toUri().browserIntent())
externalLinkOpener.openExternalUrl(url.toUri().browserIntent(), false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viditpawar0 This code is used from two places, so your code works fine when someone wants to make a donation, but it does not show the external link popup if there is about_app URL is configured. It should show the external link popup for the about_app URL.

screen-20241212-112625.mp4

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class CustomReaderFragment : CoreReaderFragment() {

override fun openKiwixSupportUrl() {
if (BuildConfig.SUPPORT_URL.isNotEmpty()) {
openExternalUrl(BuildConfig.SUPPORT_URL.toUri().browserIntent())
openExternalUrl(BuildConfig.SUPPORT_URL.toUri().browserIntent(), false)
}
}

Expand Down