Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ buildscript {
plugins {
alias(libs.plugins.com.diffplug.spotless) apply(false)
alias(libs.plugins.com.android.application) apply(false)
alias(libs.plugins.org.jetbrains.kotlin.plugin.compose) apply(false)
}

subprojects {
Expand Down
19 changes: 8 additions & 11 deletions finished/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
*/
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'org.jetbrains.kotlin.android'
alias(libs.plugins.org.jetbrains.kotlin.plugin.compose)
}

android {
compileSdk 34
compileSdk 36

namespace "com.android.example.wear.ongoingactivity"

defaultConfig {
applicationId "com.android.example.wear.ongoingactivity"
minSdk 30
targetSdk 34
targetSdk 36
versionCode 1
versionName "1.0"

Expand All @@ -43,15 +44,11 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.majorVersion
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()

kotlin {
jvmToolchain(17)
}

packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.example.wear.ongoingactivity.data

import android.content.Context
Expand Down Expand Up @@ -43,5 +58,5 @@ class PermissionStateDataStore(private val context: Context) {
enum class ShownRationaleStatus {
HAS_SHOWN,
HAS_NOT_SHOWN,
UNKNOWN
}
UNKNOWN,
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ class WalkingWorkoutsDataStore(private val context: Context) {
private val ACTIVE_WALKING_WORKOUT_KEY =
booleanPreferencesKey("active_walking_workout")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun OngoingActivityExampleApp(
// Below T, POST_NOTIFICATIONS does not need to be requested at runtime but must still be
// specified in the Manifest. Therefore, permissionState is created such that it is already
// in the granted state.
object: PermissionState {
object : PermissionState {
override val permission = "no_runtime_permission_required"
override val status = PermissionStatus.Granted
override fun launchPermissionRequest() { }
Expand Down Expand Up @@ -97,14 +97,14 @@ fun OngoingActivityExampleApp(
// now, as opposed to the false seen from shouldShowRationale on first ever launch
PermissionRequiredScreen(
onPermissionClick = { permissionState.launchPermissionRequest() },
buttonLabelResId = R.string.show_permissions
buttonLabelResId = R.string.show_permissions,
)
} else if (hasPreviouslyShown == ShownRationaleStatus.HAS_SHOWN) {
// Rationale has been shown previously, but the user has decided not to grant permission
// Offer the user the option to go to permission settings.
PermissionRequiredScreen(
onPermissionClick = { launchPermissionsSettings(context) },
buttonLabelResId = R.string.show_settings
buttonLabelResId = R.string.show_settings,
)
} else if (hasPreviouslyShown == ShownRationaleStatus.HAS_NOT_SHOWN) {
// First launch of permissions, show the permission request without any rationale.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import com.android.example.wear.ongoingactivity.R
@Composable
fun PermissionRequiredScreen(
onPermissionClick: () -> Unit,
@StringRes buttonLabelResId: Int
@StringRes buttonLabelResId: Int,
) {
Box(
modifier = Modifier.fillMaxSize(),
Expand Down
37 changes: 19 additions & 18 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
[versions]
android-gradle-plugin = "8.1.2"
accompanist-permissions = "0.30.1"
androidx-activity = "1.8.0"
androidx-wear-compose = "1.2.1"
compose = "1.5.4"
compose-compiler = "1.5.3"
core-ktx = "1.12.0"
datastore-preferences = "1.0.0"
gradle = "8.1.2"
kotlin-gradle-plugin = "1.9.10"
kotlinx-coroutines-android = "1.7.3"
kotlinx-coroutines-core = "1.7.1"
android-gradle-plugin = "8.12.3"
accompanist-permissions = "0.37.3"
androidx-activity = "1.11.0"
androidx-wear-compose = "1.5.1"
compose = "1.9.1"
core-ktx = "1.17.0"
datastore-preferences = "1.1.7"
gradle = "8.12.3"
kotlin-gradle-plugin = "2.1.0"
kotlinx-coroutines-android = "1.10.2"
kotlinx-coroutines-core = "1.10.2"
ktlint = "0.50.0"
lifecycle = "2.6.2"
org-jetbrains-kotlin = "1.9.10"
lifecycle = "2.9.3"
org-jetbrains-kotlin = "2.2.20"
wear = "1.3.0"
wear-ongoing = "1.0.0"
wear-ongoing = "1.1.0"

[libraries]
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist-permissions" }
Expand All @@ -32,7 +31,8 @@ androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-

androidx-wear = { module = "androidx.wear:wear", version.ref = "wear" }
androidx-wear-ongoing = { module = "androidx.wear:wear-ongoing", version.ref = "wear-ongoing" }
compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compose-compiler" }


compose-material-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
Expand All @@ -46,5 +46,6 @@ wear-compose-material = { module = "androidx.wear.compose:compose-material", ver

[plugins]
com-android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
com-diffplug-spotless = "com.diffplug.spotless:6.22.0"
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "org-jetbrains-kotlin" }
com-diffplug-spotless = "com.diffplug.spotless:7.2.1"
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "org-jetbrains-kotlin" }
org-jetbrains-kotlin-plugin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "org-jetbrains-kotlin" }
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Sep 15 13:07:51 BST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 7 additions & 11 deletions start/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
*/
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'org.jetbrains.kotlin.android'
alias(libs.plugins.org.jetbrains.kotlin.plugin.compose)
}

android {
compileSdk 34
compileSdk 36

namespace "com.android.example.wear.ongoingactivity"

defaultConfig {
applicationId "com.android.example.wear.ongoingactivity"
minSdk 30
targetSdk 34
targetSdk 36
versionCode 1
versionName "1.0"

Expand All @@ -43,15 +44,10 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.majorVersion
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()
kotlin {
jvmToolchain(17)
}

packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.example.wear.ongoingactivity.data

import android.content.Context
Expand Down Expand Up @@ -43,5 +58,5 @@ class PermissionStateDataStore(private val context: Context) {
enum class ShownRationaleStatus {
HAS_SHOWN,
HAS_NOT_SHOWN,
UNKNOWN
}
UNKNOWN,
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ class WalkingWorkoutsDataStore(private val context: Context) {
private val ACTIVE_WALKING_WORKOUT_KEY =
booleanPreferencesKey("active_walking_workout")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun OngoingActivityExampleApp(
// Below T, POST_NOTIFICATIONS does not need to be requested at runtime but must still be
// specified in the Manifest. Therefore, permissionState is created such that it is already
// in the granted state.
object: PermissionState {
object : PermissionState {
override val permission = "no_runtime_permission_required"
override val status = PermissionStatus.Granted
override fun launchPermissionRequest() { }
Expand Down Expand Up @@ -97,14 +97,14 @@ fun OngoingActivityExampleApp(
// now, as opposed to the false seen from shouldShowRationale on first ever launch
PermissionRequiredScreen(
onPermissionClick = { permissionState.launchPermissionRequest() },
buttonLabelResId = R.string.show_permissions
buttonLabelResId = R.string.show_permissions,
)
} else if (hasPreviouslyShown == ShownRationaleStatus.HAS_SHOWN) {
// Rationale has been shown previously, but the user has decided not to grant permission
// Offer the user the option to go to permission settings.
PermissionRequiredScreen(
onPermissionClick = { launchPermissionsSettings(context) },
buttonLabelResId = R.string.show_settings
buttonLabelResId = R.string.show_settings,
)
} else if (hasPreviouslyShown == ShownRationaleStatus.HAS_NOT_SHOWN) {
// First launch of permissions, show the permission request without any rationale.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import com.android.example.wear.ongoingactivity.R
@Composable
fun PermissionRequiredScreen(
onPermissionClick: () -> Unit,
@StringRes buttonLabelResId: Int
@StringRes buttonLabelResId: Int,
) {
Box(
modifier = Modifier.fillMaxSize(),
Expand Down