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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
agp = "8.9.1"
fragmentCompose = "1.8.6"
kotlin = "2.1.10"
coreKtx = "1.15.0"
coreKtx = "1.17.0-alpha01"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
Expand Down
2 changes: 1 addition & 1 deletion samples/accessibility/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

android {
namespace = "com.example.platform.accessibility"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/camera/camera2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {

android {
namespace = "com.example.platform.camera"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/camera/camerax/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {

android {
namespace = "com.example.platform.camerax"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/connectivity/audio/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.connectivity.audio"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/connectivity/bluetooth/ble/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.connectivity.bluetooth.ble"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.connectivity.bluetooth.companion"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/connectivity/callnotification/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

android {
namespace = "com.example.platform.connectivity.callnotification"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/connectivity/telecom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {

android {
namespace = "com.example.platform.connectivity.telecom"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/graphics/pdf/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

android {
namespace = "com.example.platform.graphics.pdf"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/graphics/ultrahdr/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.graphics.ultrahdr"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/location/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {

android {
namespace = "com.example.platform.location"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/media/ultrahdr/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.media.ultrahdr"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/media/video/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.media.video"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/privacy/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.privacy.data"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/privacy/permissions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {

android {
namespace = "com.example.platform.privacy.permissions"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/privacy/transparency/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {

android {
namespace = "com.example.platform.privacy.transparency"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/storage/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

android {
namespace = "com.example.platform.storage"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/user-interface/appwidgets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {

android {
namespace = "com.example.platform.ui.appwidgets"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/user-interface/constraintlayout/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {

android {
namespace = "com.example.platform.ui.constraintlayout"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/user-interface/draganddrop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {

android {
namespace = "com.example.platform.ui.draganddrop"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion samples/user-interface/haptics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {

android {
namespace = "com.example.platform.ui.haptics"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!--Permission for posting notifications-->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<!--Permission for live update eligibility-->
<uses-permission android:name="android.permission.POST_PROMOTED_NOTIFICATIONS" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import com.google.accompanist.permissions.rememberPermissionState
import com.google.accompanist.permissions.shouldShowRationale
import kotlinx.coroutines.launch

@RequiresApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.BAKLAVA)
@Composable
fun LiveUpdateSample() {
val notificationManager =
Expand Down Expand Up @@ -81,6 +81,7 @@ fun LiveUpdateSample() {
}
}

@RequiresApi(Build.VERSION_CODES.BAKLAVA)
fun onCheckout() {
SnackbarNotificationManager.start()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@

package com.example.platform.ui.live_updates

import android.app.Notification
import android.app.Notification.ProgressStyle
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.NotificationManager.IMPORTANCE_DEFAULT
import android.content.Context
import androidx.core.app.NotificationCompat.ProgressStyle
import android.graphics.Color
import android.os.Build
import android.os.Handler
import android.os.Looper
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.IconCompat
import java.util.logging.Level
import java.util.logging.Logger

object SnackbarNotificationManager {
private lateinit var notificationManager: NotificationManager
Expand All @@ -48,7 +50,7 @@ object SnackbarNotificationManager {
private enum class OrderState(val delay: Long) {
INITIALIZING(5000) {
@RequiresApi(Build.VERSION_CODES.BAKLAVA)
override fun buildNotification(): Notification.Builder {
override fun buildNotification(): NotificationCompat.Builder {
return buildBaseNotification(appContext, INITIALIZING)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle("You order is being placed")
Expand All @@ -58,7 +60,7 @@ object SnackbarNotificationManager {
},
FOOD_PREPARATION(9000) {
@RequiresApi(Build.VERSION_CODES.BAKLAVA)
override fun buildNotification(): Notification.Builder {
override fun buildNotification(): NotificationCompat.Builder {
return buildBaseNotification(appContext, FOOD_PREPARATION)
.setContentTitle("Your order is being prepared")
.setContentText("Next step will be delivery")
Expand All @@ -72,7 +74,7 @@ object SnackbarNotificationManager {
},
FOOD_ENROUTE(13000) {
@RequiresApi(Build.VERSION_CODES.BAKLAVA)
override fun buildNotification(): Notification.Builder {
override fun buildNotification(): NotificationCompat.Builder {
return buildBaseNotification(appContext, FOOD_ENROUTE)
.setContentTitle("Your order is on its way")
.setContentText("Enroute to destination")
Expand All @@ -81,7 +83,7 @@ object SnackbarNotificationManager {
.setProgressTrackerIcon(
IconCompat.createWithResource(
appContext, R.drawable.shopping_bag
).toIcon(appContext)
)
)
.setProgress(50)
)
Expand All @@ -94,7 +96,7 @@ object SnackbarNotificationManager {
},
FOOD_ARRIVING(18000) {
@RequiresApi(Build.VERSION_CODES.BAKLAVA)
override fun buildNotification(): Notification.Builder {
override fun buildNotification(): NotificationCompat.Builder {
return buildBaseNotification(appContext, FOOD_ARRIVING)
.setContentTitle("Your order is arriving and has been dropped off")
.setContentText("Enjoy & don't forget to refrigerate any perishable items.")
Expand All @@ -103,7 +105,7 @@ object SnackbarNotificationManager {
.setProgressTrackerIcon(
IconCompat.createWithResource(
appContext, R.drawable.delivery_truck
).toIcon(appContext)
)
)
.setProgress(75)
)
Expand All @@ -116,7 +118,7 @@ object SnackbarNotificationManager {
},
ORDER_COMPLETE(21000) {
@RequiresApi(Build.VERSION_CODES.BAKLAVA)
override fun buildNotification(): Notification.Builder {
override fun buildNotification(): NotificationCompat.Builder {
return buildBaseNotification(appContext, ORDER_COMPLETE)
.setContentTitle("Your order is complete.")
.setContentText("Thank you for using JetSnack for your snacking needs.")
Expand All @@ -125,7 +127,7 @@ object SnackbarNotificationManager {
.setProgressTrackerIcon(
IconCompat.createWithResource(
appContext, R.drawable.check_circle
).toIcon(appContext)
)
)
.setProgress(100)
)
Expand All @@ -142,7 +144,7 @@ object SnackbarNotificationManager {
fun buildBaseProgressStyle(orderState: OrderState): ProgressStyle {
val pointColor = Color.valueOf(236f, 183f, 255f, 1f).toArgb()
val segmentColor = Color.valueOf(134f, 247f, 250f, 1f).toArgb()
var progressStyle = ProgressStyle()
var progressStyle = NotificationCompat.ProgressStyle()
.setProgressPoints(
listOf(
ProgressStyle.Point(25).setColor(pointColor),
Expand Down Expand Up @@ -187,11 +189,11 @@ object SnackbarNotificationManager {
}

@RequiresApi(Build.VERSION_CODES.O)
fun buildBaseNotification(appContext: Context, orderState: OrderState): Notification.Builder {
var notificationBuilder = Notification.Builder(appContext, CHANNEL_ID)
fun buildBaseNotification(appContext: Context, orderState: OrderState): NotificationCompat.Builder {
val notificationBuilder = NotificationCompat.Builder(appContext, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setOngoing(true)
.setColorized(true)
.setRequestPromotedOngoing(true)

when (orderState) {
INITIALIZING -> {}
Expand All @@ -200,27 +202,38 @@ object SnackbarNotificationManager {
FOOD_ARRIVING ->
notificationBuilder
.addAction(
Notification.Action.Builder(null, "Got it", null).build()
NotificationCompat.Action.Builder(null, "Got it", null).build()
)
.addAction(
Notification.Action.Builder(null, "Tip", null).build()
NotificationCompat.Action.Builder(null, "Tip", null).build()
)
ORDER_COMPLETE ->
notificationBuilder
.addAction(
Notification.Action.Builder(
NotificationCompat.Action.Builder(
null, "Rate delivery", null).build()
)
}
return notificationBuilder
}

abstract fun buildNotification(): Notification.Builder
abstract fun buildNotification(): NotificationCompat.Builder
}

@RequiresApi(Build.VERSION_CODES.BAKLAVA)
fun start() {
for (state in OrderState.entries) {
val notification = state.buildNotification().build()

Logger.getLogger("canPostPromotedNotifications")
.log(
Level.INFO,
notificationManager.canPostPromotedNotifications().toString())
Logger.getLogger("hasPromotableCharacteristics")
.log(
Level.INFO,
notification.hasPromotableCharacteristics().toString())

Handler(Looper.getMainLooper()).postDelayed({
notificationManager.notify(NOTIFICATION_ID, notification)
}, state.delay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

android {
namespace = "com.example.android.pip"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 21
Expand Down
Loading
Loading