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
17 
18 import android.content.Context
19 import com.android.wallpaper.module.DefaultWallpaperPreferences
20 import dagger.hilt.android.qualifiers.ApplicationContext
21 import javax.inject.Inject
22 import javax.inject.Singleton
23 
24 @Singleton
25 open class DefaultCustomizationPreferences
26 @Inject
27 constructor(@ApplicationContext context: Context) :
28     DefaultWallpaperPreferences(context), CustomizationPreferences {
29 
getSerializedCustomThemesnull30     override fun getSerializedCustomThemes(): String? {
31         return sharedPrefs.getString(CustomizationPreferences.KEY_CUSTOM_THEME, null)
32     }
33 
storeCustomThemesnull34     override fun storeCustomThemes(serializedCustomThemes: String) {
35         sharedPrefs
36             .edit()
37             .putString(CustomizationPreferences.KEY_CUSTOM_THEME, serializedCustomThemes)
38             .apply()
39     }
40 
getTabVisitednull41     override fun getTabVisited(id: String): Boolean {
42         return sharedPrefs.getBoolean(CustomizationPreferences.KEY_VISITED_PREFIX + id, false)
43     }
44 
setTabVisitednull45     override fun setTabVisited(id: String) {
46         sharedPrefs
47             .edit()
48             .putBoolean(CustomizationPreferences.KEY_VISITED_PREFIX + id, true)
49             .apply()
50     }
51 
getThemedIconEnablednull52     override fun getThemedIconEnabled(): Boolean {
53         return sharedPrefs.getBoolean(CustomizationPreferences.KEY_THEMED_ICON_ENABLED, false)
54     }
55 
setThemedIconEnablednull56     override fun setThemedIconEnabled(enabled: Boolean) {
57         sharedPrefs
58             .edit()
59             .putBoolean(CustomizationPreferences.KEY_THEMED_ICON_ENABLED, enabled)
60             .apply()
61     }
62 }
63