Skip to content

Commit 2261860

Browse files
committed
Add OSS dialog to app
1 parent 8efb434 commit 2261860

File tree

8 files changed

+59
-9
lines changed

8 files changed

+59
-9
lines changed

app/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ plugins {
2525
alias(libs.plugins.google.services)
2626
alias(libs.plugins.crashlytics)
2727
alias(libs.plugins.baselineprofile)
28+
id("com.google.android.gms.oss-licenses-plugin")
2829
}
2930

3031
android {
@@ -111,6 +112,10 @@ dependencies {
111112
implementation(libs.firebase.appcheck.debug)
112113

113114
implementation(libs.androidx.window)
115+
implementation(libs.androidx.appcompat)
116+
implementation(libs.google.oss.licenses) {
117+
exclude(group = "androidx.appcompat")
118+
}
114119

115120
implementation(projects.feature.camera)
116121
implementation(projects.feature.creation)

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@
7878
<category android:name="android.intent.category.LAUNCHER" />
7979
</intent-filter>
8080
</activity>
81+
<activity
82+
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
83+
android:theme="@style/Theme.Androidify" />
84+
85+
<activity
86+
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
87+
android:theme="@style/Theme.Androidify" />
8188
</application>
8289

8390
</manifest>

app/src/main/java/com/android/developers/androidify/navigation/MainNavigation.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.android.developers.androidify.navigation
1919

20+
import android.content.Intent
2021
import androidx.compose.animation.ContentTransform
2122
import androidx.compose.animation.ExperimentalSharedTransitionApi
2223
import androidx.compose.animation.fadeIn
@@ -29,6 +30,7 @@ import androidx.compose.runtime.getValue
2930
import androidx.compose.runtime.mutableStateOf
3031
import androidx.compose.runtime.remember
3132
import androidx.compose.runtime.setValue
33+
import androidx.compose.ui.platform.LocalContext
3234
import androidx.compose.ui.unit.IntOffset
3335
import androidx.lifecycle.viewmodel.navigation3.rememberViewModelStoreNavEntryDecorator
3436
import androidx.navigation3.runtime.entry
@@ -40,6 +42,8 @@ import com.android.developers.androidify.creation.CreationScreen
4042
import com.android.developers.androidify.home.AboutScreen
4143
import com.android.developers.androidify.home.HomeScreen
4244
import com.android.developers.androidify.theme.transitions.ColorSplashTransitionScreen
45+
import com.google.android.gms.oss.licenses.OssLicensesActivity
46+
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
4347

4448
@ExperimentalMaterial3ExpressiveApi
4549
@Composable
@@ -110,10 +114,14 @@ fun MainNavigation() {
110114
)
111115
}
112116
entry<About> {
117+
val context = LocalContext.current
113118
AboutScreen(
114119
onBackPressed = {
115120
backStack.removeLastOrNull()
116121
},
122+
onLicensesClicked = {
123+
context.startActivity(Intent(context, OssLicensesMenuActivity::class.java))
124+
}
117125
)
118126
}
119127
},

build.gradle.kts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.exclude
2+
13
// Top-level build file where you can add configuration options common to all sub-projects/modules.
24
plugins {
35
alias(libs.plugins.android.application) apply false
@@ -13,7 +15,15 @@ plugins {
1315
alias(libs.plugins.baselineprofile) apply false
1416
alias(libs.plugins.spotless) apply false
1517
}
16-
18+
buildscript {
19+
repositories {
20+
google()
21+
mavenCentral()
22+
}
23+
dependencies {
24+
classpath(libs.google.oss.licenses.plugin)
25+
}
26+
}
1727

1828
subprojects {
1929
apply(plugin = "com.diffplug.spotless")

feature/home/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ dependencies {
5959
implementation(libs.androidx.hilt.navigation.compose)
6060
implementation(libs.androidx.media3.exoplayer)
6161
implementation(libs.androidx.media3.ui.compose)
62+
implementation(libs.google.oss.licenses) {
63+
exclude(group = "androidx.appcompat")
64+
}
6265
ksp(libs.hilt.compiler)
6366

6467
implementation(libs.ai.edge) {

feature/home/src/main/java/com/android/developers/androidify/home/AboutScreen.kt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
package com.android.developers.androidify.home
1919

20+
import android.content.Intent
2021
import androidx.compose.animation.ExperimentalSharedTransitionApi
2122
import androidx.compose.foundation.background
2223
import androidx.compose.foundation.layout.Arrangement
2324
import androidx.compose.foundation.layout.Box
2425
import androidx.compose.foundation.layout.Column
26+
import androidx.compose.foundation.layout.FlowRow
2527
import androidx.compose.foundation.layout.IntrinsicSize
2628
import androidx.compose.foundation.layout.Row
2729
import androidx.compose.foundation.layout.Spacer
@@ -47,6 +49,7 @@ import androidx.compose.ui.Alignment
4749
import androidx.compose.ui.Modifier
4850
import androidx.compose.ui.graphics.vector.ImageVector
4951
import androidx.compose.ui.graphics.vector.rememberVectorPainter
52+
import androidx.compose.ui.platform.LocalContext
5053
import androidx.compose.ui.platform.LocalUriHandler
5154
import androidx.compose.ui.res.stringResource
5255
import androidx.compose.ui.res.vectorResource
@@ -64,27 +67,30 @@ import com.android.developers.androidify.theme.sharedBoundsReveal
6467
import com.android.developers.androidify.util.LargeScreensPreview
6568
import com.android.developers.androidify.util.PhonePreview
6669
import com.android.developers.androidify.util.isAtLeastMedium
70+
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
71+
import kotlin.jvm.java
6772

6873
@PhonePreview
6974
@Composable
7075
private fun AboutPreviewCompact() {
7176
SharedElementContextPreview {
72-
AboutScreen(isMediumWindowSize = false) {}
77+
AboutScreen(isMediumWindowSize = false, {}, {})
7378
}
7479
}
7580

7681
@LargeScreensPreview
7782
@Composable
7883
private fun AboutPreviewLargeScreens() {
7984
SharedElementContextPreview {
80-
AboutScreen(isMediumWindowSize = true) {}
85+
AboutScreen(isMediumWindowSize = true, {}, {})
8186
}
8287
}
8388

8489
@Composable
8590
fun AboutScreen(
8691
isMediumWindowSize: Boolean = isAtLeastMedium(),
8792
onBackPressed: () -> Unit,
93+
onLicensesClicked: () -> Unit
8894
) {
8995
val sharedElementScope = LocalSharedTransitionScope.current
9096
val navScope = LocalNavAnimatedContentScope.current
@@ -163,7 +169,8 @@ fun AboutScreen(
163169
)
164170
}
165171
Spacer(Modifier.size(48.dp))
166-
FooterButtons(modifier = Modifier.padding(bottom = 8.dp))
172+
FooterButtons(modifier = Modifier.padding(bottom = 8.dp),
173+
onLicensesClicked)
167174
}
168175
}
169176
} else {
@@ -197,30 +204,36 @@ fun AboutScreen(
197204
stringResource(R.string.about_step3_label),
198205
)
199206
Spacer(modifier = Modifier.size(24.dp))
200-
FooterButtons(modifier = Modifier.padding(bottom = 8.dp))
207+
FooterButtons(modifier = Modifier.padding(bottom = 8.dp), onLicensesClicked)
201208
}
202209
}
203210
}
204211
}
205212
}
206213

207214
@Composable
208-
private fun FooterButtons(modifier: Modifier = Modifier) {
215+
private fun FooterButtons(modifier: Modifier = Modifier,
216+
onLicensesClicked: () -> Unit) {
209217
val uriHandler = LocalUriHandler.current
210-
Row(modifier) {
218+
FlowRow(modifier, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
211219
SecondaryOutlinedButton(
212220
onClick = {
213221
uriHandler.openUri("https://policies.google.com/terms")
214222
},
215223
buttonText = stringResource(R.string.terms),
216224
)
217-
Spacer(modifier = Modifier.size(16.dp))
218225
SecondaryOutlinedButton(
219226
onClick = {
220227
uriHandler.openUri("https://policies.google.com/privacy")
221228
},
222229
buttonText = stringResource(R.string.privacy),
223230
)
231+
SecondaryOutlinedButton(
232+
onClick = {
233+
onLicensesClicked()
234+
},
235+
buttonText = stringResource(R.string.oss_license),
236+
)
224237
}
225238
}
226239

feature/home/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@
3636
<string name="pause">Pause</string>
3737
<string name="terms">Terms</string>
3838
<string name="privacy">Privacy</string>
39+
<string name="oss_license">Licenses</string>
3940
</resources>

gradle/libs.versions.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ espressoCore = "3.6.1"
2828
firebaseBom = "33.14.0"
2929
firebaseConfigKtx = "22.1.1"
3030
googleServices = "4.4.2"
31+
googleOss = "17.1.0"
32+
googleOssPlugin = "0.10.6"
3133
hiltAndroid = "2.56.2"
3234
hiltLifecycleViewmodel = "1.0.0-alpha03"
3335
hiltNavigationCompose = "1.2.0"
@@ -130,7 +132,8 @@ androidx-uiautomator = { group = "androidx.test.uiautomator", name = "uiautomato
130132
androidx-benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmarkMacroJunit4" }
131133
androidx-profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "profileinstaller" }
132134
ai-edge = { group = "com.google.ai.edge.aicore", name = "aicore", version.ref = "aiEdge" }
133-
135+
google-oss-licenses = { group = "com.google.android.gms", name = "play-services-oss-licenses", version.ref = "googleOss" }
136+
google-oss-licenses-plugin = { group = "com.google.android.gms", name = "oss-licenses-plugin", version.ref = "googleOssPlugin" }
134137
[plugins]
135138
android-application = { id = "com.android.application", version.ref = "agp" }
136139
android-library = { id = "com.android.library", version.ref = "agp" }

0 commit comments

Comments
 (0)