Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.media |
| 18 | |
| 19 | import android.app.PendingIntent |
| 20 | import android.graphics.drawable.Drawable |
Selim Cinek | c543671 | 2020-04-27 15:15:44 -0700 | [diff] [blame] | 21 | import android.graphics.drawable.Icon |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 22 | import android.media.session.MediaSession |
| 23 | |
| 24 | /** State of a media view. */ |
| 25 | data class MediaData( |
| 26 | val initialized: Boolean = false, |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 27 | val backgroundColor: Int, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 28 | /** |
| 29 | * App name that will be displayed on the player. |
| 30 | */ |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 31 | val app: String?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 32 | /** |
| 33 | * Icon shown on player, close to app name. |
| 34 | */ |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 35 | val appIcon: Drawable?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 36 | /** |
| 37 | * Artist name. |
| 38 | */ |
Selim Cinek | c543671 | 2020-04-27 15:15:44 -0700 | [diff] [blame] | 39 | val artist: CharSequence?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 40 | /** |
| 41 | * Song name. |
| 42 | */ |
Selim Cinek | c543671 | 2020-04-27 15:15:44 -0700 | [diff] [blame] | 43 | val song: CharSequence?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 44 | /** |
| 45 | * Album artwork. |
| 46 | */ |
Selim Cinek | c543671 | 2020-04-27 15:15:44 -0700 | [diff] [blame] | 47 | val artwork: Icon?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 48 | /** |
| 49 | * List of actions that can be performed on the player: prev, next, play, pause, etc. |
| 50 | */ |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 51 | val actions: List<MediaAction>, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 52 | /** |
| 53 | * Same as above, but shown on smaller versions of the player, like in QQS or keyguard. |
| 54 | */ |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 55 | val actionsToShowInCompact: List<Int>, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 56 | /** |
| 57 | * Package name of the app that's posting the media. |
| 58 | */ |
Beth Thibodeau | f55bc6a | 2020-05-20 02:01:31 -0400 | [diff] [blame] | 59 | val packageName: String, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 60 | /** |
| 61 | * Unique media session identifier. |
| 62 | */ |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 63 | val token: MediaSession.Token?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Action to perform when the player is tapped. |
| 66 | * This is unrelated to {@link #actions}. |
| 67 | */ |
Robert Snoeberger | 70d0d6b | 2020-05-14 16:47:02 -0400 | [diff] [blame] | 68 | val clickIntent: PendingIntent?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Where the media is playing: phone, headphones, ear buds, remote session. |
| 71 | */ |
Lucas Dupin | 6f0bd31 | 2020-05-28 18:19:29 -0700 | [diff] [blame] | 72 | val device: MediaDeviceData?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 73 | /** |
| 74 | * When active, a player will be displayed on keyguard and quick-quick settings. |
| 75 | * This is unrelated to the stream being playing or not, a player will not be active if |
| 76 | * timed out, or in resumption mode. |
| 77 | */ |
| 78 | var active: Boolean, |
| 79 | /** |
| 80 | * Action that should be performed to restart a non active session. |
| 81 | */ |
Beth Thibodeau | f55bc6a | 2020-05-20 02:01:31 -0400 | [diff] [blame] | 82 | var resumeAction: Runnable?, |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 83 | /** |
Robert Snoeberger | f05aa68f | 2020-06-18 16:14:29 -0400 | [diff] [blame] | 84 | * Indicates that this player is a resumption player (ie. It only shows a play actions which |
| 85 | * will start the app and start playing). |
| 86 | */ |
| 87 | var resumption: Boolean = false, |
| 88 | /** |
Lucas Dupin | 84f5a0e | 2020-06-08 19:55:33 -0700 | [diff] [blame] | 89 | * Notification key for cancelling a media player after a timeout (when not using resumption.) |
| 90 | */ |
| 91 | val notificationKey: String? = null, |
Beth Thibodeau | f55bc6a | 2020-05-20 02:01:31 -0400 | [diff] [blame] | 92 | var hasCheckedForResume: Boolean = false |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 93 | ) |
| 94 | |
| 95 | /** State of a media action. */ |
| 96 | data class MediaAction( |
| 97 | val drawable: Drawable?, |
Beth Thibodeau | f55bc6a | 2020-05-20 02:01:31 -0400 | [diff] [blame] | 98 | val action: Runnable?, |
Selim Cinek | 5dbef2d | 2020-05-07 17:44:38 -0700 | [diff] [blame] | 99 | val contentDescription: CharSequence? |
| 100 | ) |
Robert Snoeberger | 70d0d6b | 2020-05-14 16:47:02 -0400 | [diff] [blame] | 101 | |
| 102 | /** State of the media device. */ |
| 103 | data class MediaDeviceData( |
Robert Snoeberger | 23e3689 | 2020-05-21 00:33:24 -0400 | [diff] [blame] | 104 | val enabled: Boolean, |
Robert Snoeberger | 70d0d6b | 2020-05-14 16:47:02 -0400 | [diff] [blame] | 105 | val icon: Drawable?, |
| 106 | val name: String? |
| 107 | ) |