Skip to content

Commit 9ccdf88

Browse files
authored
Merge pull request #68 from android/feature/oss
Add OSS dialog to app
2 parents 8efb434 + 7b6e904 commit 9ccdf88

File tree

10 files changed

+91
-9
lines changed

10 files changed

+91
-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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@
7878
<category android:name="android.intent.category.LAUNCHER" />
7979
</intent-filter>
8080
</activity>
81+
<!-- need to use Theme.AppCompat -->
82+
<activity
83+
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
84+
android:theme="@style/AppCompatAndroidify" />
85+
86+
<!-- needs to use Theme.AppCompat -->
87+
<activity
88+
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
89+
android:theme="@style/AppCompatAndroidify" />
8190
</application>
8291

8392
</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
},
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<resources>
18+
19+
<style name="AppCompatAndroidify" parent="Theme.AppCompat.DayNight">
20+
<item name="android:windowTranslucentStatus">false</item>
21+
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
22+
<item name="android:statusBarColor">@android:color/white</item>
23+
<item name="android:fitsSystemWindows">true</item>
24+
<!-- https://github.com/google/play-services-plugins/issues/296 -->
25+
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
26+
<item name="android:windowLightStatusBar">true</item>
27+
</style>
28+
</resources>

app/src/main/res/values/themes.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@
1717
<resources>
1818

1919
<style name="Theme.Androidify" parent="android:Theme.Material.Light.NoActionBar" />
20+
21+
<style name="AppCompatAndroidify" parent="Theme.AppCompat.DayNight">
22+
<item name="android:windowTranslucentStatus">false</item>
23+
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
24+
<item name="android:statusBarColor">@android:color/white</item>
25+
<item name="android:fitsSystemWindows">true</item>
26+
<item name="android:windowLightStatusBar">true</item>
27+
</style>
2028
</resources>

build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ plugins {
1313
alias(libs.plugins.baselineprofile) apply false
1414
alias(libs.plugins.spotless) apply false
1515
}
16-
16+
buildscript {
17+
repositories {
18+
google()
19+
mavenCentral()
20+
}
21+
dependencies {
22+
classpath(libs.google.oss.licenses.plugin)
23+
}
24+
}
1725

1826
subprojects {
1927
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: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.compose.foundation.background
2222
import androidx.compose.foundation.layout.Arrangement
2323
import androidx.compose.foundation.layout.Box
2424
import androidx.compose.foundation.layout.Column
25+
import androidx.compose.foundation.layout.FlowRow
2526
import androidx.compose.foundation.layout.IntrinsicSize
2627
import androidx.compose.foundation.layout.Row
2728
import androidx.compose.foundation.layout.Spacer
@@ -69,22 +70,23 @@ import com.android.developers.androidify.util.isAtLeastMedium
6970
@Composable
7071
private fun AboutPreviewCompact() {
7172
SharedElementContextPreview {
72-
AboutScreen(isMediumWindowSize = false) {}
73+
AboutScreen(isMediumWindowSize = false, {}, {})
7374
}
7475
}
7576

7677
@LargeScreensPreview
7778
@Composable
7879
private fun AboutPreviewLargeScreens() {
7980
SharedElementContextPreview {
80-
AboutScreen(isMediumWindowSize = true) {}
81+
AboutScreen(isMediumWindowSize = true, {}, {})
8182
}
8283
}
8384

8485
@Composable
8586
fun AboutScreen(
8687
isMediumWindowSize: Boolean = isAtLeastMedium(),
8788
onBackPressed: () -> Unit,
89+
onLicensesClicked: () -> Unit
8890
) {
8991
val sharedElementScope = LocalSharedTransitionScope.current
9092
val navScope = LocalNavAnimatedContentScope.current
@@ -163,7 +165,8 @@ fun AboutScreen(
163165
)
164166
}
165167
Spacer(Modifier.size(48.dp))
166-
FooterButtons(modifier = Modifier.padding(bottom = 8.dp))
168+
FooterButtons(modifier = Modifier.padding(bottom = 8.dp),
169+
onLicensesClicked)
167170
}
168171
}
169172
} else {
@@ -197,30 +200,36 @@ fun AboutScreen(
197200
stringResource(R.string.about_step3_label),
198201
)
199202
Spacer(modifier = Modifier.size(24.dp))
200-
FooterButtons(modifier = Modifier.padding(bottom = 8.dp))
203+
FooterButtons(modifier = Modifier.padding(bottom = 8.dp), onLicensesClicked)
201204
}
202205
}
203206
}
204207
}
205208
}
206209

207210
@Composable
208-
private fun FooterButtons(modifier: Modifier = Modifier) {
211+
private fun FooterButtons(modifier: Modifier = Modifier,
212+
onLicensesClicked: () -> Unit) {
209213
val uriHandler = LocalUriHandler.current
210-
Row(modifier) {
214+
FlowRow(modifier, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
211215
SecondaryOutlinedButton(
212216
onClick = {
213217
uriHandler.openUri("https://policies.google.com/terms")
214218
},
215219
buttonText = stringResource(R.string.terms),
216220
)
217-
Spacer(modifier = Modifier.size(16.dp))
218221
SecondaryOutlinedButton(
219222
onClick = {
220223
uriHandler.openUri("https://policies.google.com/privacy")
221224
},
222225
buttonText = stringResource(R.string.privacy),
223226
)
227+
SecondaryOutlinedButton(
228+
onClick = {
229+
onLicensesClicked()
230+
},
231+
buttonText = stringResource(R.string.oss_license),
232+
)
224233
}
225234
}
226235

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)