-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new logic to fix crashes on devices without Custom Tabs
- Loading branch information
1 parent
7e43687
commit 449a73e
Showing
7 changed files
with
71 additions
and
37 deletions.
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
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
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
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/BrowserUtils.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,30 @@ | ||
package org.eu.exodus_privacy.exodusprivacy.utils | ||
|
||
import android.content.ActivityNotFoundException | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import androidx.browser.customtabs.CustomTabsClient | ||
import androidx.browser.customtabs.CustomTabsIntent | ||
import java.util.Collections | ||
|
||
fun startActivity(context: Context, url: String) { | ||
try { | ||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | ||
context.startActivity(intent) | ||
} catch (e: ActivityNotFoundException) { | ||
false | ||
} | ||
} | ||
|
||
fun openURL(customTabsIntent: CustomTabsIntent, context: Context, url: String) { | ||
val packageName = CustomTabsClient.getPackageName( | ||
context, | ||
Collections.emptyList(), | ||
) | ||
if (packageName != null) { | ||
customTabsIntent.launchUrl(context, Uri.parse(url)) | ||
} else { | ||
startActivity(context, url) | ||
} | ||
} |