1 /* 2 * Copyright (C) 2024 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.controls.shared 18 19 import android.content.Context 20 import android.graphics.drawable.Drawable 21 import com.android.systemui.Flags.mediaControlsDrawablesReuseBugfix 22 import com.android.systemui.res.R 23 24 object MediaControlDrawables { 25 26 // Prev button. 27 private var prevIcon: Drawable? = null 28 // Next button. 29 private var nextIcon: Drawable? = null 30 // Output switcher drawables. 31 private var leAudioSharing: Drawable? = null 32 private var antenna: Drawable? = null 33 private var groupDevice: Drawable? = null 34 private var homeDevices: Drawable? = null 35 getNextIconnull36 fun getNextIcon(context: Context): Drawable? { 37 if (!mediaControlsDrawablesReuseBugfix()) { 38 return context.getDrawable(R.drawable.ic_media_next) 39 } 40 return nextIcon ?: context.getDrawable(R.drawable.ic_media_next).also { nextIcon = it } 41 } 42 getPrevIconnull43 fun getPrevIcon(context: Context): Drawable? { 44 if (!mediaControlsDrawablesReuseBugfix()) { 45 return context.getDrawable(R.drawable.ic_media_prev) 46 } 47 return prevIcon ?: context.getDrawable(R.drawable.ic_media_prev).also { prevIcon = it } 48 } 49 getLeAudioSharingnull50 fun getLeAudioSharing(context: Context): Drawable? { 51 if (!mediaControlsDrawablesReuseBugfix()) { 52 return context.getDrawable(com.android.settingslib.R.drawable.ic_bt_le_audio_sharing) 53 } 54 return leAudioSharing 55 ?: context.getDrawable(com.android.settingslib.R.drawable.ic_bt_le_audio_sharing).also { 56 leAudioSharing = it 57 } 58 } 59 getAntennanull60 fun getAntenna(context: Context): Drawable? { 61 if (!mediaControlsDrawablesReuseBugfix()) { 62 return context.getDrawable(R.drawable.settings_input_antenna) 63 } 64 return antenna 65 ?: context.getDrawable(R.drawable.settings_input_antenna).also { antenna = it } 66 } 67 getGroupDevicenull68 fun getGroupDevice(context: Context): Drawable? { 69 if (!mediaControlsDrawablesReuseBugfix()) { 70 return context.getDrawable(com.android.settingslib.R.drawable.ic_media_group_device) 71 } 72 return groupDevice 73 ?: context.getDrawable(com.android.settingslib.R.drawable.ic_media_group_device).also { 74 groupDevice = it 75 } 76 } 77 getHomeDevicesnull78 fun getHomeDevices(context: Context): Drawable? { 79 if (!mediaControlsDrawablesReuseBugfix()) { 80 return context.getDrawable(R.drawable.ic_media_home_devices) 81 } 82 return homeDevices 83 ?: context.getDrawable(R.drawable.ic_media_home_devices).also { homeDevices = it } 84 } 85 } 86