Skip to content

Commit

Permalink
Update build configurations and dependencies
Browse files Browse the repository at this point in the history
Upgraded bytecode target level, Gradle version, and Kotlin version.
Improved comments and cleaned up unnecessary source set configuration.
Enhanced error handling and documentation in CustomTabs helper classes.
  • Loading branch information
saschpe committed Sep 12, 2024
1 parent 5593c7a commit 0fc7324
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {
google()
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.2")
classpath("com.android.tools.build:gradle:8.5.2")
}
}

Expand Down
2 changes: 0 additions & 2 deletions customtabs-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ android {
}

kotlinOptions.jvmTarget = "1.8"

sourceSets.forEach { it.java.srcDir("src/${it.name}/kotlin") }
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import androidx.appcompat.app.AppCompatDelegate
import saschpe.android.customtabs.CustomTabsActivityLifecycleCallbacks

/**
* Optional pre-loading for improved performance
* Optional preloading for improved performance
*/
class Application : android.app.Application() {
override fun onCreate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import saschpe.android.customtabs.WebViewFallback

class MainActivity : AppCompatActivity() {
/**
* Apply some sane defaults across a single app.
* Apply some sensible defaults across a single app.
* Not strictly necessary but simplifies code when having many different
* custom tab intents in one app.
*
Expand All @@ -62,7 +62,7 @@ class MainActivity : AppCompatActivity() {
}

/**
* Start GitHub project custom tab
* Start a GitHub project custom tab
*
* See https://developer.chrome.com/multidevice/android/customtabs
*/
Expand Down
2 changes: 1 addition & 1 deletion customtabs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {

testImplementation("androidx.test:core:1.3.0")
testImplementation("androidx.test.ext:junit:1.1.2")
testImplementation("org.robolectric:robolectric:4.5.1")
testImplementation("org.robolectric:robolectric:4.7.1")
testImplementation("org.mockito:mockito-core:3.9.0")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CustomTabsHelper {
connection?.let {
try {
activity.unbindService(it)
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
}
client = null
customTabsSession = null
Expand Down Expand Up @@ -145,10 +145,10 @@ class CustomTabsHelper {
"android.support.customtabs.extra.KEEP_ALIVE"

/**
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView
* Opens the URL on a Custom Tab if possible. Otherwise, falls back to opening it on a WebView
*
* @param context The host activity
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available
* @param customTabsIntent customTabsIntent to be used if Custom Tabs is available
* @param uri the Uri to be opened
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available
*/
Expand All @@ -159,8 +159,8 @@ class CustomTabsHelper {
fallback: CustomTabFallback?
) {
val packageName = getPackageNameToUse(context)
// If we cant find a package name, it means there's no browser that supports
// Chrome Custom Tabs installed. So, we fallback to the web-view
// If we can't find a package name, it means there's no browser that supports Chrome Custom Tabs installed.
// So, we fall back to the web-view
if (packageName == null) {
fallback?.openUri(context, uri)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ internal object CustomTabsPackageHelper {

/**
* Goes through all apps that handle VIEW intents and have a warmup service. Picks
* the one chosen by the user if there is one, otherwise makes a best effort to return a
* the one chosen by the user if there is one, otherwise makes the best effort to return a
* valid package name.
*
* This is **not** threadsafe.
*
* @param context [Context] to use for accessing [PackageManager].
* @return The package name recommended to use for connecting to custom tabs related components.
* @return The package name recommended for connecting to custom tabs related components.
*/
@JvmStatic
fun getPackageNameToUse(context: Context): String? {
Expand All @@ -52,7 +52,7 @@ internal object CustomTabsPackageHelper {
val pm = context.packageManager

// Get default VIEW intent handler.
val activityIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"))
val activityIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.example.com"))
val defaultHandlerInfo = pm.resolveActivity(activityIntent, 0)
val defaultHandlerPackageName: String? = defaultHandlerInfo?.activityInfo?.packageName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class WebViewActivity : AppCompatActivity(R.layout.activity_webview) {
url?.let { webView.loadUrl(it) }
webView.settings.javaScriptEnabled = true

// No title provided. Use the website's once it's loaded...
// No title provided. Use the website once it's loaded...
if (title == null) {
webView.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
Expand Down
15 changes: 7 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Project-wide Gradle settings.
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
# Gradle
file.encoding=utf-8
org.gradle.caching=true
org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true

# Kotlin
kotlin.code.style=official
# https://blog.jetbrains.com/kotlin/2019/01/kotlin-1-3-20-released
kotlin.parallel.tasks.in.project=true

# AndroidX
# Android
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 0fc7324

Please sign in to comment.