Merge "Send Weather SmartspaceAction Intent to Weather Clock" into udc-qpr-dev am: 054716145f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23765926

Change-Id: I8901d6fdfa5c1af7091d66cc4cae551699e12f65
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-06-22 21:55:44 +00:00
committed by Automerger Merge Worker
2 changed files with 17 additions and 3 deletions

View File

@@ -2,14 +2,18 @@ package com.android.systemui.plugins
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.View
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
typealias WeatherTouchAction = (View) -> Unit
class WeatherData class WeatherData
constructor( constructor(
val description: String, val description: String,
val state: WeatherStateIcon, val state: WeatherStateIcon,
val useCelsius: Boolean, val useCelsius: Boolean,
val temperature: Int, val temperature: Int,
val touchAction: WeatherTouchAction? = null,
) { ) {
companion object { companion object {
const val DEBUG = true const val DEBUG = true
@@ -20,7 +24,7 @@ constructor(
@VisibleForTesting const val TEMPERATURE_KEY = "temperature" @VisibleForTesting const val TEMPERATURE_KEY = "temperature"
private const val INVALID_WEATHER_ICON_STATE = -1 private const val INVALID_WEATHER_ICON_STATE = -1
fun fromBundle(extras: Bundle): WeatherData? { fun fromBundle(extras: Bundle, touchAction: WeatherTouchAction? = null): WeatherData? {
val description = extras.getString(DESCRIPTION_KEY) val description = extras.getString(DESCRIPTION_KEY)
val state = val state =
WeatherStateIcon.fromInt(extras.getInt(STATE_KEY, INVALID_WEATHER_ICON_STATE)) WeatherStateIcon.fromInt(extras.getInt(STATE_KEY, INVALID_WEATHER_ICON_STATE))
@@ -41,7 +45,8 @@ constructor(
description = description, description = description,
state = state, state = state,
useCelsius = extras.getBoolean(USE_CELSIUS_KEY), useCelsius = extras.getBoolean(USE_CELSIUS_KEY),
temperature = temperature temperature = temperature,
touchAction = touchAction
) )
if (DEBUG) { if (DEBUG) {
Log.i(TAG, "Weather data parsed $result from $extras") Log.i(TAG, "Weather data parsed $result from $extras")

View File

@@ -176,7 +176,16 @@ constructor(
now.isBefore(Instant.ofEpochMilli(t.expiryTimeMillis)) now.isBefore(Instant.ofEpochMilli(t.expiryTimeMillis))
} }
if (weatherTarget != null) { if (weatherTarget != null) {
val weatherData = WeatherData.fromBundle(weatherTarget.baseAction.extras) val clickIntent = weatherTarget.headerAction?.intent
val weatherData = WeatherData.fromBundle(weatherTarget.baseAction.extras, { v ->
if (!falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
activityStarter.startActivity(
clickIntent,
true, /* dismissShade */
null,
false)
}
})
if (weatherData != null) { if (weatherData != null) {
keyguardUpdateMonitor.sendWeatherData(weatherData) keyguardUpdateMonitor.sendWeatherData(weatherData)
} }