Skip to content

Commit 28c11cc

Browse files
added general linking for uplift
1 parent d318e93 commit 28c11cc

3 files changed

Lines changed: 32 additions & 7 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<queries>
1010
<package android:name="com.cornellappdev.android.eatery" />
11+
<package android:name="com.cornellappdev.uplift" />
1112
</queries>
1213

1314
<application

app/src/main/java/com/cornellappdev/transit/ui/components/home/EateryDetailsContent.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ fun EateryDetailsContent(
103103
modifier = Modifier.clickable(
104104
onClick = {
105105
val eateryPackage = "com.cornellappdev.android.eatery"
106+
val eateryIntent = context.packageManager.getLaunchIntentForPackage(eateryPackage)
106107

107-
try {
108-
val intent = context.packageManager.getLaunchIntentForPackage(eateryPackage)
109-
if (intent != null) {
110-
context.startActivity(intent)
111-
}
112-
} catch (e: ActivityNotFoundException) {
108+
if (eateryIntent != null) {
109+
context.startActivity(eateryIntent)
110+
} else {
113111
try {
114112
val playStoreIntent = Intent(Intent.ACTION_VIEW, "market://details?id=$eateryPackage".toUri())
115113
playStoreIntent.setPackage("com.android.vending")

app/src/main/java/com/cornellappdev/transit/ui/components/home/GymDetailsContent.kt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.cornellappdev.transit.ui.components.home
22

3+
import android.content.ActivityNotFoundException
4+
import android.content.Intent
5+
import androidx.compose.foundation.clickable
36
import androidx.compose.foundation.layout.Column
47
import androidx.compose.foundation.layout.Row
58
import androidx.compose.foundation.layout.Spacer
@@ -13,9 +16,11 @@ import androidx.compose.material3.Text
1316
import androidx.compose.runtime.Composable
1417
import androidx.compose.ui.Alignment
1518
import androidx.compose.ui.Modifier
19+
import androidx.compose.ui.platform.LocalContext
1620
import androidx.compose.ui.res.painterResource
1721
import androidx.compose.ui.res.stringResource
1822
import androidx.compose.ui.unit.dp
23+
import androidx.core.net.toUri
1924
import com.cornellappdev.transit.R
2025
import com.cornellappdev.transit.models.ecosystem.UpliftGym
2126
import com.cornellappdev.transit.ui.theme.DividerGray
@@ -97,11 +102,32 @@ fun GymDetailsContent(
97102
val (annotatedString, inlineContent) =
98103
stringResource(R.string.view_gym).createDeepLink(R.drawable.upliftlink)
99104

105+
val context = LocalContext.current
106+
100107
Text(
101108
text = annotatedString,
102109
inlineContent = inlineContent,
103110
style = Style.heading2,
104-
color = TransitBlue
111+
color = TransitBlue,
112+
modifier = Modifier.clickable(
113+
onClick = {
114+
val upliftPackage = "com.cornellappdev.uplift"
115+
val upliftIntent = context.packageManager.getLaunchIntentForPackage(upliftPackage)
116+
117+
if (upliftIntent != null ) {
118+
context.startActivity(upliftIntent)
119+
} else {
120+
try {
121+
val playStoreIntent = Intent(Intent.ACTION_VIEW, "market://details?id=$upliftPackage".toUri())
122+
playStoreIntent.setPackage("com.android.vending")
123+
context.startActivity(playStoreIntent)
124+
} catch (e: ActivityNotFoundException) {
125+
context.startActivity(Intent(Intent.ACTION_VIEW, "https://play.google.com/store/apps/details?id=$upliftPackage}".toUri()))
126+
127+
}
128+
}
129+
}
130+
)
105131
)
106132

107133
Spacer(modifier = Modifier.height(24.dp))

0 commit comments

Comments
 (0)