Skip to content

Commit

Permalink
check installation
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Mar 9, 2024
1 parent d4caf3a commit 12fb794
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
12 changes: 12 additions & 0 deletions app/android/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<queries>
<package android:name="dev.datlag.pulz" />
</queries>

<uses-feature
android:name="android.hardware.wifi"
android:required="false" />
Expand All @@ -12,6 +16,14 @@
android:name="android.hardware.ethernet"
android:required="false" />

<uses-feature
android:name="android.software.leanback"
android:required="false"/>

<uses-feature
android:name="android.hardware.touchscreen"
android:required="false"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ fun Context.isTv(): Boolean {
return packageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || packageManager.hasSystemFeature(
PackageManager.FEATURE_LEANBACK
) || packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY)
}

fun Context.isPackageInstalled(packageName: String): Boolean {
return try {
packageManager.getPackageInfo(packageName, 0)
true
} catch (e: PackageManager.NameNotFoundException) {
false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.unit.dp
import dev.datlag.burningseries.model.Release
import dev.datlag.burningseries.shared.SharedRes
import dev.datlag.burningseries.shared.common.header
import dev.datlag.burningseries.shared.common.isPackageInstalled
import dev.datlag.burningseries.shared.common.lifecycle.collectAsStateWithLifecycle
import dev.datlag.burningseries.shared.common.openInBrowser
import dev.datlag.burningseries.shared.other.Constants
Expand Down Expand Up @@ -63,33 +64,37 @@ actual fun LazyGridScope.DeviceContent(release: StateFlow<Release?>, onDeviceRea
} else {
val context = LocalContext.current

Card(
modifier = Modifier.fillMaxWidth(),
onClick = {
Constants.GOOGLE_PLAY_PULZ.openInBrowser(context)
},
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary,
)
) {
Row(
modifier = Modifier.fillMaxWidth().padding(16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
modifier = Modifier.weight(1F),
text = stringResource(SharedRes.strings.google_play_pulz)
if (!context.isPackageInstalled(Constants.PULZ_PACKAGE)) {
Card(
modifier = Modifier.fillMaxWidth(),
onClick = {
Constants.GOOGLE_PLAY_PULZ.openInBrowser(context)
},
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary,
)
FilledTonalButton(
onClick = {
Constants.GOOGLE_PLAY_PULZ.openInBrowser(context)
}
) {
Row(
modifier = Modifier.fillMaxWidth().padding(16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(text = stringResource(SharedRes.strings.yes))
Text(
modifier = Modifier.weight(1F),
text = stringResource(SharedRes.strings.google_play_pulz)
)
FilledTonalButton(
onClick = {
Constants.GOOGLE_PLAY_PULZ.openInBrowser(context)
}
) {
Text(text = stringResource(SharedRes.strings.yes))
}
}
}
} else if (!reachable) {
Text(text = stringResource(SharedRes.strings.enable_custom_dns))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.datlag.burningseries.shared.other

data object Constants {
const val PULZ_PACKAGE = "dev.datlag.pulz"
const val GOOGLE_PLAY_PULZ = "https://play.google.com/store/apps/details?id=dev.datlag.pulz"
}

0 comments on commit 12fb794

Please sign in to comment.