Skip to content

Commit 720741d

Browse files
committed
External links: display them again if device is in US region
1 parent 6b25af8 commit 720741d

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ Releases marked with 🧪 (or previously with the "beta" suffix) were released o
2222

2323
### 2025.2.13 - 2025-10-30
2424

25+
* 🔧 Thanks to a United States court ordered injunction in the Google Play Antitrust case coming
26+
into effect, again display links to TMDB, Trakt and other external websites if your device region
27+
is set to "United States". Note that links remain displayed for devices set to a region in the
28+
European Economic Area. For all other regions, Google Play Payments policy continues to disallow
29+
this.
2530
* 🔧 On Android 16 on Samsung devices, increase the limit of widget items back to 100.
2631

2732
### 2025.2.12 - 2025-09-19

app/src/main/java/com/battlelancer/seriesguide/SgAppContainer.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package com.battlelancer.seriesguide
66
import android.content.Context
77
import com.battlelancer.seriesguide.diagnostics.DebugLogBuffer
88
import com.battlelancer.seriesguide.util.PackageTools
9+
import com.battlelancer.seriesguide.util.PackageTools.isEuropeanEconomicArea
10+
import com.battlelancer.seriesguide.util.PackageTools.isUnitedStates
911
import timber.log.Timber
1012

1113
class SgAppContainer(context: Context) {
@@ -18,9 +20,20 @@ class SgAppContainer(context: Context) {
1820
*/
1921
val preventExternalLinks by lazy {
2022
val installedByPlay = PackageTools.wasInstalledByPlayStore(context)
21-
val isDeviceInEEA = PackageTools.isDeviceInEEA(context)
22-
(installedByPlay && !isDeviceInEEA)
23-
.also { Timber.d("preventExternalLinks = %s", it) }
23+
val region = PackageTools.getDeviceRegion(context)
24+
val isEEA = region.isEuropeanEconomicArea(context)
25+
val isUS = region.isUnitedStates()
26+
(installedByPlay && !isEEA && !isUS)
27+
.also {
28+
Timber.i(
29+
"preventExternalLinks=%s installedByPlay=%s region=%s isEEA=%s isUS=%s",
30+
installedByPlay,
31+
it,
32+
region.code,
33+
isEEA,
34+
isUS
35+
)
36+
}
2437
// .let { if (BuildConfig.DEBUG) true else it }
2538
}
2639

app/src/main/java/com/battlelancer/seriesguide/util/PackageTools.kt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.battlelancer.seriesguide.R
1212
import com.battlelancer.seriesguide.provider.SgRoomDatabase
1313
import com.uwetrottmann.androidutils.AndroidUtils
1414
import timber.log.Timber
15+
import java.util.Locale
1516

1617
/**
1718
* Helpers that work with [PackageManager].
@@ -119,15 +120,30 @@ object PackageTools {
119120
}.also { Timber.d("installingPackageName = '%s'", it) }
120121
}
121122

122-
fun isDeviceInEEA(context: Context): Boolean {
123-
@Suppress("DEPRECATION")
124-
val region = context.resources.configuration.locale.country
125-
return if (region.isEmpty()) {
123+
@JvmInline
124+
value class DeviceRegion(val code: String)
125+
126+
fun getDeviceRegion(context: Context): DeviceRegion {
127+
val region = if (AndroidUtils.isNougatOrHigher) {
128+
context.resources.configuration.locales[0].country
129+
} else {
130+
@Suppress("DEPRECATION")
131+
context.resources.configuration.locale.country
132+
}
133+
return DeviceRegion(region)
134+
}
135+
136+
fun DeviceRegion.isEuropeanEconomicArea(context: Context): Boolean {
137+
return if (code.isEmpty()) {
126138
false
127139
} else {
128140
val eeaRegions = context.resources.getStringArray(R.array.eea_regions)
129-
eeaRegions.contains(region)
130-
}.also { Timber.d("region = '%s', isEEA = %s", region, it) }
141+
eeaRegions.contains(code)
142+
}
143+
}
144+
145+
fun DeviceRegion.isUnitedStates() : Boolean {
146+
return code == Locale.US.country
131147
}
132148

133149
}

0 commit comments

Comments
 (0)