Make smartspace custom calendar experimental
Co-authored-by: Daria Hamrah Paytakht <info@dariarnd.ir>
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
<bool name="config_default_show_top_shadow">true</bool>
|
||||
<bool name="config_default_hide_app_drawer_search_bar">false</bool>
|
||||
<bool name="config_default_enable_font_selection">true</bool>
|
||||
<bool name="config_default_enable_smartspace_calendar_selection">true</bool>
|
||||
<bool name="config_default_dts2">true</bool>
|
||||
<bool name="config_default_auto_show_keyboard_in_drawer">false</bool>
|
||||
<bool name="config_default_show_icon_labels_on_home_screen">true</bool>
|
||||
|
||||
@@ -216,6 +216,8 @@
|
||||
<string name="icon_picker_description">May cause Lawnchair to freeze.</string>
|
||||
<string name="font_picker_label">Font Customization</string>
|
||||
<string name="font_picker_description">Some text remains unchanged.</string>
|
||||
<string name="smartspace_calendar_label">At a Glance Calendar Customization</string>
|
||||
<string name="smartspace_calendar_description">Allow showing date in non-Gregorian calendar systems.</string>
|
||||
<string name="search_provider_app_search">App Search</string>
|
||||
<string name="search_provider_google" translatable="false">Google</string>
|
||||
<string name="search_provider_google_go" translatable="false">Google Go</string>
|
||||
|
||||
@@ -155,6 +155,11 @@ class PreferenceManager2(private val context: Context) : PreferenceManager {
|
||||
},
|
||||
)
|
||||
|
||||
val enableSmartspaceCalendarSelection = preference(
|
||||
key = booleanPreferencesKey(name = "enable_smartspace_calendar_selection"),
|
||||
defaultValue = context.resources.getBoolean(R.bool.config_default_enable_smartspace_calendar_selection),
|
||||
)
|
||||
|
||||
val dt2s = preference(
|
||||
key = booleanPreferencesKey(name = "dt2s"),
|
||||
defaultValue = context.resources.getBoolean(R.bool.config_default_dts2),
|
||||
|
||||
@@ -8,11 +8,14 @@ import android.icu.text.DateFormat
|
||||
import android.icu.text.DisplayContext
|
||||
import android.os.SystemClock
|
||||
import android.util.AttributeSet
|
||||
import app.lawnchair.preferences.getAdapter
|
||||
import app.lawnchair.preferences2.PreferenceManager2
|
||||
import app.lawnchair.preferences2.subscribeBlocking
|
||||
import app.lawnchair.smartspace.model.SmartspaceCalendar
|
||||
import app.lawnchair.util.viewAttachedScope
|
||||
import com.android.launcher3.R
|
||||
import com.patrykmichalik.preferencemanager.first
|
||||
import com.patrykmichalik.preferencemanager.firstBlocking
|
||||
import saman.zamani.persiandate.PersianDate
|
||||
import saman.zamani.persiandate.PersianDateFormat
|
||||
import java.util.*
|
||||
@@ -87,8 +90,14 @@ class IcuDateTextView @JvmOverloads constructor(
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
preferenceManager2 = PreferenceManager2.getInstance(context)
|
||||
preferenceManager2.smartspaceCalendar.subscribeBlocking(scope = viewAttachedScope) {
|
||||
calendar = it
|
||||
val calendarSelectionEnabled =
|
||||
preferenceManager2.enableSmartspaceCalendarSelection.firstBlocking()
|
||||
if (calendarSelectionEnabled) {
|
||||
preferenceManager2.smartspaceCalendar.subscribeBlocking(scope = viewAttachedScope) {
|
||||
calendar = it
|
||||
}
|
||||
} else {
|
||||
calendar = preferenceManager2.smartspaceCalendar.defaultValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@ fun ExperimentalFeaturesPreferences() {
|
||||
label = stringResource(id = R.string.font_picker_label),
|
||||
description = stringResource(id = R.string.font_picker_description),
|
||||
)
|
||||
SwitchPreference(
|
||||
adapter = prefs.enableSmartspaceCalendarSelection.getAdapter(),
|
||||
label = stringResource(id = R.string.smartspace_calendar_label),
|
||||
description = stringResource(id = R.string.smartspace_calendar_description),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,11 @@ fun SmartspacePreferences(fromWidget: Boolean) {
|
||||
heading = stringResource(id = R.string.what_to_show),
|
||||
modifier = Modifier.padding(top = 8.dp),
|
||||
) {
|
||||
SmartspaceCalendarPreference()
|
||||
val calendarSelectionEnabled =
|
||||
preferenceManager2.enableSmartspaceCalendarSelection.getAdapter()
|
||||
if (calendarSelectionEnabled.state.value) {
|
||||
SmartspaceCalendarPreference()
|
||||
}
|
||||
smartspaceProvider.dataSources
|
||||
.filter { it.isAvailable }
|
||||
.forEach {
|
||||
|
||||
Reference in New Issue
Block a user