Cherish: Monet settings
This reverts commit f547af0ea1.
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2022 FlamingoOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cherish.settings.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.os.UserHandle
|
||||
import android.provider.Settings
|
||||
|
||||
import androidx.preference.Preference
|
||||
|
||||
import com.android.settings.core.BasePreferenceController
|
||||
import com.cherish.settings.preferences.CustomSeekBarPreference
|
||||
|
||||
class MonetChromaFactorPreferenceController(
|
||||
context: Context,
|
||||
key: String,
|
||||
) : BasePreferenceController(context, key),
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
override fun getAvailabilityStatus(): Int = AVAILABLE
|
||||
|
||||
override fun updateState(preference: Preference) {
|
||||
super.updateState(preference)
|
||||
val chromaFactor = Settings.Secure.getFloatForUser(
|
||||
mContext.contentResolver,
|
||||
Settings.Secure.MONET_ENGINE_CHROMA_FACTOR,
|
||||
CHROMA_DEFAULT,
|
||||
UserHandle.USER_CURRENT
|
||||
) * 100
|
||||
(preference as CustomSeekBarPreference).apply {
|
||||
setValue(chromaFactor.toInt())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
|
||||
return Settings.Secure.putFloatForUser(
|
||||
mContext.contentResolver,
|
||||
Settings.Secure.MONET_ENGINE_CHROMA_FACTOR,
|
||||
(newValue as Int) / 100f,
|
||||
UserHandle.USER_CURRENT
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val CHROMA_DEFAULT = 1f
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 FlamingoOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cherish.settings.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.os.UserHandle
|
||||
import android.provider.Settings
|
||||
|
||||
import com.android.settings.R
|
||||
import com.android.settings.core.BasePreferenceController
|
||||
|
||||
class MonetCustomColorPreferenceController(
|
||||
context: Context,
|
||||
key: String,
|
||||
) : BasePreferenceController(context, key) {
|
||||
|
||||
override fun getAvailabilityStatus(): Int = AVAILABLE
|
||||
|
||||
override fun getSummary(): CharSequence? {
|
||||
val customColor = Settings.Secure.getStringForUser(
|
||||
mContext.contentResolver,
|
||||
Settings.Secure.MONET_ENGINE_COLOR_OVERRIDE,
|
||||
UserHandle.USER_CURRENT,
|
||||
)
|
||||
return if (customColor == null || customColor.isBlank()) {
|
||||
mContext.getString(R.string.color_override_default_summary)
|
||||
} else {
|
||||
mContext.getString(
|
||||
R.string.custom_color_override_summary_placeholder,
|
||||
customColor
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/com/cherish/settings/fragments/MonetEngineSettings.kt
Normal file
37
src/com/cherish/settings/fragments/MonetEngineSettings.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2022 FlamingoOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cherish.settings.fragments
|
||||
|
||||
import com.android.settings.R
|
||||
import com.android.settings.search.BaseSearchIndexProvider
|
||||
import com.android.settingslib.search.SearchIndexable
|
||||
import com.cherish.settings.fragments.CherishDashboardFragment
|
||||
|
||||
@SearchIndexable
|
||||
class MonetEngineSettings : CherishDashboardFragment() {
|
||||
|
||||
override protected fun getPreferenceScreenResId() = R.xml.monet_engine_settings
|
||||
|
||||
override protected fun getLogTag() = TAG
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MonetEngineSettings"
|
||||
|
||||
@JvmField
|
||||
val SEARCH_INDEX_DATA_PROVIDER = BaseSearchIndexProvider(R.xml.monet_engine_settings)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user