1 /*
2  * Copyright (C) 2019 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 package com.android.customization.module.logging
17 
18 import android.stats.style.StyleEnums
19 import com.android.customization.model.grid.GridOption
20 import com.android.customization.module.logging.ThemesUserEventLogger.ClockSize
21 import com.android.customization.module.logging.ThemesUserEventLogger.ColorSource
22 import com.android.wallpaper.module.logging.TestUserEventLogger
23 import javax.inject.Inject
24 import javax.inject.Singleton
25 
26 /** Test implementation of [ThemesUserEventLogger]. */
27 @Singleton
28 class TestThemesUserEventLogger @Inject constructor() :
29     TestUserEventLogger(), ThemesUserEventLogger {
30     @ClockSize private var clockSize: Int = StyleEnums.CLOCK_SIZE_UNSPECIFIED
31     @ColorSource
32     var themeColorSource: Int = StyleEnums.COLOR_SOURCE_UNSPECIFIED
33         private set
34 
35     var themeColorStyle: Int = -1
36         private set
37 
38     var themeSeedColor: Int = -1
39         private set
40 
41     var shortcutLogs: List<Pair<String, String>> = emptyList()
42 
43     var useDarkTheme: Boolean = false
44         private set
45 
logThemeColorAppliednull46     override fun logThemeColorApplied(@ColorSource source: Int, style: Int, seedColor: Int) {
47         this.themeColorSource = source
48         this.themeColorStyle = style
49         this.themeSeedColor = seedColor
50     }
51 
logGridAppliednull52     override fun logGridApplied(grid: GridOption) {}
53 
logClockAppliednull54     override fun logClockApplied(clockId: String) {}
55 
logClockColorAppliednull56     override fun logClockColorApplied(seedColor: Int) {}
57 
logClockSizeAppliednull58     override fun logClockSizeApplied(@ClockSize clockSize: Int) {
59         this.clockSize = clockSize
60     }
61 
logThemedIconAppliednull62     override fun logThemedIconApplied(useThemeIcon: Boolean) {}
63 
logLockScreenNotificationAppliednull64     override fun logLockScreenNotificationApplied(showLockScreenNotifications: Boolean) {}
65 
logShortcutAppliednull66     override fun logShortcutApplied(shortcut: String, shortcutSlotId: String) {
67         shortcutLogs = shortcutLogs.toMutableList().apply { add(shortcut to shortcutSlotId) }
68     }
69 
logDarkThemeAppliednull70     override fun logDarkThemeApplied(useDarkTheme: Boolean) {
71         this.useDarkTheme = useDarkTheme
72     }
73 
74     @ClockSize
getLoggedClockSizenull75     fun getLoggedClockSize(): Int {
76         return clockSize
77     }
78 }
79