Skip to content

Commit

Permalink
Replace hardcoded license file with OSS licenses plugin
Browse files Browse the repository at this point in the history
Change-Id: I4427fd5d7b7abd8a2912a41f61ffedfac4af9d6a
  • Loading branch information
mmoczkowski committed May 17, 2023
1 parent bbdc62c commit fc3d0ce
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 983 deletions.
931 changes: 0 additions & 931 deletions app/LICENSES.md

This file was deleted.

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {
id("nowinandroid.android.hilt")
id("jacoco")
id("nowinandroid.android.application.firebase")
id("com.google.android.gms.oss-licenses-plugin")
}

android {
Expand Down Expand Up @@ -118,7 +119,6 @@ dependencies {
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.window.manager)
implementation(libs.androidx.profileinstaller)

implementation(libs.coil.kt)
}

Expand Down
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ buildscript {
// Android Build Server
maven { url = uri("../nowinandroid-prebuilts/m2repository") }
}
dependencies {
classpath(libs.google.oss.licenses.plugin) {
exclude(group = "com.google.protobuf")
}
}
}

// Lists all plugins used throughout the project without applying them.
Expand Down
4 changes: 4 additions & 0 deletions feature/settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ plugins {
android {
namespace = "com.google.samples.apps.nowinandroid.feature.settings"
}

dependencies {
implementation(libs.google.oss.licenses)
}
10 changes: 9 additions & 1 deletion feature/settings/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@
limitations under the License.
-->
<manifest xmlns:android="http:https://schemas.android.com/apk/res/android">
<application>
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat" />

</manifest>
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.AppCompat" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

package com.google.samples.apps.nowinandroid.feature.settings

import android.content.Intent
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
Expand All @@ -40,6 +43,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
Expand All @@ -48,6 +52,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTextButton
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.designsystem.theme.supportsDynamicTheming
import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig
Expand Down Expand Up @@ -236,56 +242,43 @@ fun SettingsDialogThemeChooserRow(
}
}

@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun LinksPanel() {
Row(
modifier = Modifier.padding(top = 16.dp),
FlowRow(
horizontalArrangement = Arrangement.spacedBy(
space = 16.dp,
alignment = Alignment.CenterHorizontally,
),
modifier = Modifier.fillMaxWidth()
) {
Column(
Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
val uriHandler = LocalUriHandler.current
NiaTextButton(
onClick = { uriHandler.openUri(PRIVACY_POLICY_URL) }
) {
Row {
TextLink(
text = stringResource(string.privacy_policy),
url = PRIVACY_POLICY_URL,
)
Spacer(Modifier.width(16.dp))
TextLink(
text = stringResource(string.licenses),
url = LICENSES_URL,
)
}
Spacer(Modifier.height(16.dp))
Row {
TextLink(
text = stringResource(string.brand_guidelines),
url = BRAND_GUIDELINES_URL,
)
Spacer(Modifier.width(16.dp))
TextLink(
text = stringResource(string.feedback),
url = FEEDBACK_URL,
)
Text(text = stringResource(string.privacy_policy))
}
val context = LocalContext.current
NiaTextButton(
onClick = {
context.startActivity(Intent(context, OssLicensesMenuActivity::class.java))
}
) {
Text(text = stringResource(string.licenses))
}
NiaTextButton(
onClick = { uriHandler.openUri(BRAND_GUIDELINES_URL) }
) {
Text(text = stringResource(string.brand_guidelines))
}
NiaTextButton(
onClick = { uriHandler.openUri(FEEDBACK_URL) }
) {
Text(text = stringResource(string.feedback))
}
}
}

@Composable
private fun TextLink(text: String, url: String) {
val uriHandler = LocalUriHandler.current

Text(
text = text,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier
.padding(vertical = 8.dp)
.clickable { uriHandler.openUri(url) },
)
}

@Preview
@Composable
private fun PreviewSettingsDialog() {
Expand Down Expand Up @@ -322,8 +315,5 @@ private fun PreviewSettingsDialogLoading() {

/* ktlint-disable max-line-length */
private const val PRIVACY_POLICY_URL = "https://policies.google.com/privacy"
private const val LICENSES_URL =
"https://github.com/android/nowinandroid/blob/main/app/LICENSES.md#open-source-licenses-and-copyright-notices"
private const val BRAND_GUIDELINES_URL =
"https://developer.android.com/distribute/marketing-tools/brand-guidelines"
private const val BRAND_GUIDELINES_URL = "https://developer.android.com/distribute/marketing-tools/brand-guidelines"
private const val FEEDBACK_URL = "https://goo.gle/nia-app-feedback"
13 changes: 9 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ firebaseBom = "31.2.0"
firebaseCrashlyticsPlugin = "2.9.2"
firebasePerfPlugin = "1.4.2"
gmsPlugin = "4.3.14"
googleOss = "17.0.1"
googleOssPlugin = "0.10.6"
hilt = "2.44.2"
hiltExt = "1.0.0"
jacoco = "0.8.7"
Expand All @@ -44,18 +46,18 @@ kotlinxSerializationJson = "1.5.0"
ksp = "1.8.20-1.0.11"
lint = "30.3.1"
okhttp = "4.10.0"
protobuf = "3.21.12"
protobufPlugin = "0.9.1"
protobuf = "3.23.0"
protobufPlugin = "0.9.3"
retrofit = "2.9.0"
retrofitKotlinxSerializationJson = "1.0.0"
room = "2.5.0"
secrets = "2.0.1"
turbine = "0.12.1"

[libraries]
accompanist-permissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist" }
accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanist" }
accompanist-testharness = { group = "com.google.accompanist", name = "accompanist-testharness", version.ref = "accompanist" }
accompanist-permissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist" }
android-desugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
Expand Down Expand Up @@ -99,11 +101,14 @@ androidx-work-testing = { group = "androidx.work", name = "work-testing", versio
coil-kt = { group = "io.coil-kt", name = "coil", version.ref = "coil" }
coil-kt-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
coil-kt-svg = { group = "io.coil-kt", name = "coil-svg", version.ref = "coil" }
firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics-ktx" }
firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
firebase-cloud-messaging = { group = "com.google.firebase", name = "firebase-messaging-ktx" }
firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics-ktx" }
firebase-performance = { group = "com.google.firebase", name = "firebase-perf-ktx" }
firebase-performance-gradle = { group = "com.google.firebase", name = "perf-plugin", version.ref = "firebasePerfPlugin" }
google-oss-licenses = { group = "com.google.android.gms", name = "play-services-oss-licenses", version.ref = "googleOss" }
google-oss-licenses-plugin = { group = "com.google.android.gms", name = "oss-licenses-plugin", version.ref = "googleOssPlugin" }
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
Expand Down

0 comments on commit fc3d0ce

Please sign in to comment.