blob: 8c9cb1b240bfa09ab3e339df7697dbba316445fb [file] [log] [blame]
Selim Cinek5dbef2d2020-05-07 17:44:38 -07001/*
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
17package com.android.systemui.media
18
19import android.app.PendingIntent
20import android.graphics.drawable.Drawable
Selim Cinekc5436712020-04-27 15:15:44 -070021import android.graphics.drawable.Icon
Selim Cinek5dbef2d2020-05-07 17:44:38 -070022import android.media.session.MediaSession
23
24/** State of a media view. */
25data class MediaData(
26 val initialized: Boolean = false,
Selim Cinek5dbef2d2020-05-07 17:44:38 -070027 val backgroundColor: Int,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070028 /**
29 * App name that will be displayed on the player.
30 */
Selim Cinek5dbef2d2020-05-07 17:44:38 -070031 val app: String?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070032 /**
33 * Icon shown on player, close to app name.
34 */
Selim Cinek5dbef2d2020-05-07 17:44:38 -070035 val appIcon: Drawable?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070036 /**
37 * Artist name.
38 */
Selim Cinekc5436712020-04-27 15:15:44 -070039 val artist: CharSequence?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070040 /**
41 * Song name.
42 */
Selim Cinekc5436712020-04-27 15:15:44 -070043 val song: CharSequence?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070044 /**
45 * Album artwork.
46 */
Selim Cinekc5436712020-04-27 15:15:44 -070047 val artwork: Icon?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070048 /**
49 * List of actions that can be performed on the player: prev, next, play, pause, etc.
50 */
Selim Cinek5dbef2d2020-05-07 17:44:38 -070051 val actions: List<MediaAction>,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070052 /**
53 * Same as above, but shown on smaller versions of the player, like in QQS or keyguard.
54 */
Selim Cinek5dbef2d2020-05-07 17:44:38 -070055 val actionsToShowInCompact: List<Int>,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070056 /**
57 * Package name of the app that's posting the media.
58 */
Beth Thibodeauf55bc6a2020-05-20 02:01:31 -040059 val packageName: String,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070060 /**
61 * Unique media session identifier.
62 */
Selim Cinek5dbef2d2020-05-07 17:44:38 -070063 val token: MediaSession.Token?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070064 /**
65 * Action to perform when the player is tapped.
66 * This is unrelated to {@link #actions}.
67 */
Robert Snoeberger70d0d6b2020-05-14 16:47:02 -040068 val clickIntent: PendingIntent?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070069 /**
70 * Where the media is playing: phone, headphones, ear buds, remote session.
71 */
Lucas Dupin6f0bd312020-05-28 18:19:29 -070072 val device: MediaDeviceData?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070073 /**
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 Thibodeauf55bc6a2020-05-20 02:01:31 -040082 var resumeAction: Runnable?,
Lucas Dupin84f5a0e2020-06-08 19:55:33 -070083 /**
Robert Snoebergerf05aa68f2020-06-18 16:14:29 -040084 * 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 Dupin84f5a0e2020-06-08 19:55:33 -070089 * Notification key for cancelling a media player after a timeout (when not using resumption.)
90 */
91 val notificationKey: String? = null,
Beth Thibodeauf55bc6a2020-05-20 02:01:31 -040092 var hasCheckedForResume: Boolean = false
Selim Cinek5dbef2d2020-05-07 17:44:38 -070093)
94
95/** State of a media action. */
96data class MediaAction(
97 val drawable: Drawable?,
Beth Thibodeauf55bc6a2020-05-20 02:01:31 -040098 val action: Runnable?,
Selim Cinek5dbef2d2020-05-07 17:44:38 -070099 val contentDescription: CharSequence?
100)
Robert Snoeberger70d0d6b2020-05-14 16:47:02 -0400101
102/** State of the media device. */
103data class MediaDeviceData(
Robert Snoeberger23e36892020-05-21 00:33:24 -0400104 val enabled: Boolean,
Robert Snoeberger70d0d6b2020-05-14 16:47:02 -0400105 val icon: Drawable?,
106 val name: String?
107)