Update ui

This commit is contained in:
Tommaso Berlose 2021-01-07 22:51:45 +01:00
parent 5bb81772f4
commit 20c5ce61b4
25 changed files with 135 additions and 234 deletions

Binary file not shown.

View File

@ -94,7 +94,7 @@ dependencies {
// Other
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'joda-time:joda-time:2.10.6'
implementation 'net.danlew:android.joda:2.10.9'
implementation 'me.everything:providers-android:1.0.1'
implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.2'

View File

@ -8,6 +8,7 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tommasoberlose.anotherwidget.global.Preferences
import io.realm.Realm
import io.realm.RealmConfiguration
import net.danlew.android.joda.JodaTimeAndroid
class AWApplication : Application() {
override fun onCreate() {

View File

@ -10,6 +10,7 @@ import android.os.Build
import android.view.LayoutInflater
import android.view.View
import androidx.core.view.isVisible
import androidx.navigation.Navigation
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.auth.api.signin.GoogleSignInOptions

View File

@ -119,33 +119,43 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
binding.actionSettings.animate().alpha(if (!show) 1f else 0f).setDuration(200).translationX((if (!show) 0f else -4f).convertDpToPixel(requireContext())).start()
binding.fragmentTitle.text = if (show) destination.label.toString() else getString(R.string.app_name)
}
binding.actionSettings.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_appMainFragment_to_appSettingsFragment, null, null, FragmentNavigatorExtras(
binding.actionBack to "action_back"
))
}
}
private var uiJob: Job? = null
private fun updateUI() {
Log.d("ciao", "UPDATE UI")
uiJob?.cancel()
binding.preview.clearAnimation()
binding.widgetDetail.timeContainer.clearAnimation()
binding.bottomPadding.isVisible = Preferences.showPreview
if (Preferences.showPreview) {
binding.preview.setCardBackgroundColor(
ContextCompat.getColor(
lifecycleScope.launch(Dispatchers.IO) {
val bgColor: Int = ContextCompat.getColor(
requireContext(),
if (ColorHelper.getFontColor(requireActivity().isDarkTheme())
.isColorDark()
) android.R.color.white else R.color.colorAccent
)
)
binding.widgetDetail.widgetShapeBackground.setImageDrawable(
BitmapHelper.getTintedDrawable(
val wallpaperDrawable = BitmapHelper.getTintedDrawable(
requireContext(),
R.drawable.card_background,
ColorHelper.getBackgroundColor(requireActivity().isDarkTheme())
)
)
withContext(Dispatchers.Main) {
binding.preview.setCardBackgroundColor(bgColor)
binding.widgetDetail.widgetShapeBackground.setImageDrawable(wallpaperDrawable)
}
}
WidgetHelper.runWithCustomTypeface(requireContext()) { typeface ->
uiJob = lifecycleScope.launch(Dispatchers.IO) {
val generatedView = MainWidget.generateWidgetView(requireContext(), typeface).root
@ -269,18 +279,9 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
}
}
} else {
ValueAnimator.ofInt(
binding.preview.height,
0
).apply {
duration = 300L
addUpdateListener {
val animatedValue = animatedValue as Int
val layoutParams = binding.preview.layoutParams
layoutParams.height = animatedValue
binding.preview.layoutParams = layoutParams
}
}.start()
binding.preview.layoutParams = binding.preview.layoutParams.apply {
height = 0
}
}
}
@ -312,10 +313,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
metrics.widthPixels to (wallpaper.intrinsicHeight) * metrics.widthPixels / (wallpaper.intrinsicWidth)
}
setMargins(
if (dimensions.first >= dimensions.second) (-80).toPixel(
requireContext()) else 0,
(-80).toPixel(requireContext()), 0, 0
setMargins(0, (-80).toPixel(requireContext()), 0, 0
)
width = dimensions.first
@ -327,8 +325,8 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
}
}
binding.actionSettings.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_appMainFragment_to_appSettingsFragment)
viewModel.fragmentScrollY.observe(viewLifecycleOwner) {
binding.toolbar.cardElevation = if (it > 0) 24f else 0f
}
}
@ -362,7 +360,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
class ChangeTabEvent(val page: Int)
@Subscribe(threadMode = ThreadMode.MAIN)
fun onMessageEvent(ignore: UpdateUiMessageEvent?) {
fun onMessageEvent(ignore: UpdateUiMessageEvent) {
delayJob?.cancel()
delayJob = lifecycleScope.launch(Dispatchers.IO) {
delay(300)
@ -371,4 +369,10 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onChangeTabEvent(ignore: ChangeTabEvent) {
val navHost = childFragmentManager.findFragmentById(R.id.settings_fragment) as? NavHostFragment?
navHost?.navController?.navigateUp()
}
}

View File

@ -86,6 +86,10 @@ class SettingsFragment : Fragment() {
setupListener()
binding.appVersion.text = "v%s (%s)".format(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
binding.scrollView.viewTreeObserver.addOnScrollChangedListener {
binding.toolbar.cardElevation = if (binding.scrollView.scrollY > 0) 32f else 0f
}
}
private fun subscribeUi(

View File

@ -175,7 +175,7 @@ class CalendarFragment : Fragment() {
updateCalendar()
}.show()
} else {
activity?.toast(getString(R.string.calendar_settings_list_error))
requireActivity().toast(getString(R.string.calendar_settings_list_error))
}
}
@ -275,7 +275,7 @@ class CalendarFragment : Fragment() {
}
private fun updateCalendar() {
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
if (requireActivity().checkGrantedPermission(Manifest.permission.READ_CALENDAR)) {
CalendarHelper.updateEventList(requireContext())
}
}

View File

@ -127,28 +127,6 @@ class ClockFragment : Fragment() {
}
}
}
viewModel.clockTextAlpha.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.clockTextAlpha == "00") {
binding.clockTextColorLabel.text = getString(R.string.transparent)
} else {
binding.clockTextColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
viewModel.clockTextAlphaDark.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.clockTextAlphaDark == "00") {
binding.clockTextColorLabel.text = getString(R.string.transparent)
} else {
binding.clockTextColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
}
private fun setupListener() {

View File

@ -312,13 +312,11 @@ class GlanceTabFragment : Fragment() {
if (isCurrentlyActive) {
ViewCompat.setElevation(view, 8f.convertDpToPixel(requireContext()))
view.setCardBackgroundColor(ContextCompat.getColor(requireContext(),
R.color.colorPrimary))
view.strokeWidth = 0
R.color.cardBorder))
} else {
ViewCompat.setElevation(view, 0f)
view.setCardBackgroundColor(ContextCompat.getColor(requireContext(),
R.color.colorPrimaryDark))
view.strokeWidth = 1
R.color.colorPrimary))
}
val topEdge = if ((view.top == 0 && dY < 0) || ((view.top + view.height >= recyclerView.height - 32f.convertDpToPixel(requireContext())) && dY > 0)) 0f else dY

View File

@ -62,7 +62,7 @@ class LayoutFragment : Fragment() {
binding.lifecycleOwner = this
binding.viewModel = viewModel
binding.isDarkModeEnabled = activity?.isDarkTheme() == true
binding.isDarkModeEnabled = requireActivity().isDarkTheme()
return binding.root
}
@ -119,7 +119,7 @@ class LayoutFragment : Fragment() {
binding.backgroundColorLabel.text = getString(R.string.transparent)
} else {
binding.backgroundColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(requireActivity().isDarkTheme()))).toUpperCase()
}
}
}
@ -130,29 +130,7 @@ class LayoutFragment : Fragment() {
binding.backgroundColorLabel.text = getString(R.string.transparent)
} else {
binding.backgroundColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
viewModel.backgroundCardAlpha.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.backgroundCardAlpha == "00") {
binding.backgroundColorLabel.text = getString(R.string.transparent)
} else {
binding.backgroundColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
viewModel.backgroundCardAlphaDark.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.backgroundCardAlphaDark == "00") {
binding.backgroundColorLabel.text = getString(R.string.transparent)
} else {
binding.backgroundColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(requireActivity().isDarkTheme()))).toUpperCase()
}
}
}
@ -223,10 +201,10 @@ class LayoutFragment : Fragment() {
BottomSheetColorPicker(requireContext(),
colors = colors,
header = getString(R.string.settings_background_color_title),
getSelected = { ColorHelper.getBackgroundColorRgb(activity?.isDarkTheme() == true) },
getSelected = { ColorHelper.getBackgroundColorRgb(requireActivity().isDarkTheme()) },
onColorSelected = { color: Int ->
val colorString = Integer.toHexString(color)
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
Preferences.backgroundCardColorDark =
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
} else {
@ -235,9 +213,9 @@ class LayoutFragment : Fragment() {
}
},
showAlphaSelector = true,
alpha = if (activity?.isDarkTheme() == true) Preferences.backgroundCardAlphaDark.toIntValue() else Preferences.backgroundCardAlpha.toIntValue(),
alpha = if (requireActivity().isDarkTheme()) Preferences.backgroundCardAlphaDark.toIntValue() else Preferences.backgroundCardAlpha.toIntValue(),
onAlphaChangeListener = { alpha ->
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
Preferences.backgroundCardAlphaDark = alpha.toHexValue()
} else {
Preferences.backgroundCardAlpha = alpha.toHexValue()

View File

@ -66,6 +66,10 @@ class PreferencesFragment : Fragment() {
setupListener()
binding.showEventsSwitch.setCheckedImmediatelyNoEvent(Preferences.showEvents)
binding.showWeatherSwitch.setCheckedImmediatelyNoEvent(Preferences.showWeather)
binding.showClockSwitch.setCheckedImmediatelyNoEvent(Preferences.showClock)
binding.scrollView.viewTreeObserver.addOnScrollChangedListener {
viewModel.fragmentScrollY.value = binding.scrollView.scrollY
}
@ -74,9 +78,6 @@ class PreferencesFragment : Fragment() {
private fun subscribeUi(
viewModel: MainViewModel
) {
binding.isCalendarEnabled = Preferences.showEvents
binding.isWeatherVisible = Preferences.showWeather
binding.isClockVisible = Preferences.showClock
viewModel.showEvents.observe(viewLifecycleOwner) {
maintainScrollPosition {

View File

@ -111,7 +111,7 @@ class TypographyFragment : Fragment() {
binding.fontColorLabel.text = getString(R.string.transparent)
} else {
binding.fontColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(requireActivity().isDarkTheme()))).toUpperCase()
}
}
}
@ -122,29 +122,7 @@ class TypographyFragment : Fragment() {
binding.fontColorLabelDark.text = getString(R.string.transparent)
} else {
binding.fontColorLabelDark.text =
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
viewModel.textGlobalAlpha.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.textGlobalAlpha == "00") {
binding.fontColorLabel.text = getString(R.string.transparent)
} else {
binding.fontColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
viewModel.textGlobalAlphaDark.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.textGlobalAlphaDark == "00") {
binding.fontColorLabelDark.text = getString(R.string.transparent)
} else {
binding.fontColorLabelDark.text =
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(requireActivity().isDarkTheme()))).toUpperCase()
}
}
}
@ -155,7 +133,7 @@ class TypographyFragment : Fragment() {
binding.secondaryFontColorLabel.text = getString(R.string.transparent)
} else {
binding.secondaryFontColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(requireActivity().isDarkTheme()))).toUpperCase()
}
}
}
@ -166,29 +144,7 @@ class TypographyFragment : Fragment() {
binding.secondaryFontColorLabelDark.text = getString(R.string.transparent)
} else {
binding.secondaryFontColorLabelDark.text =
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
viewModel.textSecondaryAlpha.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.textSecondaryAlpha == "00") {
binding.secondaryFontColorLabel.text = getString(R.string.transparent)
} else {
binding.secondaryFontColorLabel.text =
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
}
}
}
viewModel.textSecondaryAlphaDark.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.textSecondaryAlphaDark == "00") {
binding.secondaryFontColorLabelDark.text = getString(R.string.transparent)
} else {
binding.secondaryFontColorLabelDark.text =
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(requireActivity().isDarkTheme()))).toUpperCase()
}
}
}
@ -204,38 +160,16 @@ class TypographyFragment : Fragment() {
viewModel.textShadowDark.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
binding.textShadowLabelDark.text =
getString(SettingsStringHelper.getTextShadowString(it))
}
}
}
viewModel.customFont.observe(viewLifecycleOwner) {
maintainScrollPosition {
binding.customFontLabel.text = SettingsStringHelper.getCustomFontLabel(requireContext(), it)
MainWidget.updateWidget(requireContext())
}
}
viewModel.customFontFile.observe(viewLifecycleOwner) {
viewModel.font.observe(viewLifecycleOwner) {
maintainScrollPosition {
binding.customFontLabel.text = SettingsStringHelper.getCustomFontLabel(requireContext(), Preferences.customFont)
MainWidget.updateWidget(requireContext())
}
}
viewModel.customFontName.observe(viewLifecycleOwner) {
maintainScrollPosition {
binding.customFontLabel.text = SettingsStringHelper.getCustomFontLabel(requireContext(), Preferences.customFont)
MainWidget.updateWidget(requireContext())
}
}
viewModel.customFontVariant.observe(viewLifecycleOwner) {
maintainScrollPosition {
binding.customFontLabel.text = SettingsStringHelper.getCustomFontLabel(requireContext(), Preferences.customFont)
MainWidget.updateWidget(requireContext())
}
}
@ -273,19 +207,19 @@ class TypographyFragment : Fragment() {
BottomSheetColorPicker(requireContext(),
colors = colors,
header = getString(R.string.settings_font_color_title),
getSelected = { ColorHelper.getFontColorRgb(activity?.isDarkTheme() == true) },
getSelected = { ColorHelper.getFontColorRgb(requireActivity().isDarkTheme()) },
onColorSelected = { color: Int ->
val colorString = Integer.toHexString(color)
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
Preferences.textGlobalColorDark = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
} else {
Preferences.textGlobalColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
}
},
showAlphaSelector = true,
alpha = if (activity?.isDarkTheme() == true) Preferences.textGlobalAlphaDark.toIntValue() else Preferences.textGlobalAlpha.toIntValue(),
alpha = if (requireActivity().isDarkTheme()) Preferences.textGlobalAlphaDark.toIntValue() else Preferences.textGlobalAlpha.toIntValue(),
onAlphaChangeListener = { alpha ->
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
Preferences.textGlobalAlphaDark = alpha.toHexValue()
} else {
Preferences.textGlobalAlpha = alpha.toHexValue()
@ -298,10 +232,10 @@ class TypographyFragment : Fragment() {
BottomSheetColorPicker(requireContext(),
colors = colors,
header = getString(R.string.settings_secondary_font_color_title),
getSelected = { ColorHelper.getSecondaryFontColorRgb(activity?.isDarkTheme() == true) },
getSelected = { ColorHelper.getSecondaryFontColorRgb(requireActivity().isDarkTheme()) },
onColorSelected = { color: Int ->
val colorString = Integer.toHexString(color)
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
Preferences.textSecondaryColorDark =
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
} else {
@ -310,9 +244,9 @@ class TypographyFragment : Fragment() {
}
},
showAlphaSelector = true,
alpha = if (activity?.isDarkTheme() == true) Preferences.textSecondaryAlphaDark.toIntValue() else Preferences.textSecondaryAlpha.toIntValue(),
alpha = if (requireActivity().isDarkTheme()) Preferences.textSecondaryAlphaDark.toIntValue() else Preferences.textSecondaryAlpha.toIntValue(),
onAlphaChangeListener = { alpha ->
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
Preferences.textSecondaryAlphaDark = alpha.toHexValue()
} else {
Preferences.textSecondaryAlpha = alpha.toHexValue()
@ -322,12 +256,12 @@ class TypographyFragment : Fragment() {
}
binding.actionTextShadow.setOnClickListener {
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.title_text_shadow)).setSelectedValue(if (activity?.isDarkTheme() == true) Preferences.textShadowDark else Preferences.textShadow)
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.title_text_shadow)).setSelectedValue(if (requireActivity().isDarkTheme()) Preferences.textShadowDark else Preferences.textShadow)
(2 downTo 0).forEach {
dialog.addItem(getString(SettingsStringHelper.getTextShadowString(it)), it)
}
dialog.addOnSelectItemListener { value ->
if (activity?.isDarkTheme() == true) {
if (requireActivity().isDarkTheme()) {
Preferences.textShadowDark = value
} else {
Preferences.textShadow = value

View File

@ -7,26 +7,41 @@ import com.tommasoberlose.anotherwidget.global.Preferences
class MainViewModel : ViewModel() {
// General Settings
val textGlobalColor = Preferences.asLiveData(Preferences::textGlobalColor)
val textGlobalAlpha = Preferences.asLiveData(Preferences::textGlobalAlpha)
val textSecondaryColor = Preferences.asLiveData(Preferences::textSecondaryColor)
val textSecondaryAlpha = Preferences.asLiveData(Preferences::textSecondaryAlpha)
val backgroundCardColor = Preferences.asLiveData(Preferences::backgroundCardColor)
val backgroundCardAlpha = Preferences.asLiveData(Preferences::backgroundCardAlpha)
val textGlobalColorDark = Preferences.asLiveData(Preferences::textGlobalColorDark)
val textGlobalAlphaDark = Preferences.asLiveData(Preferences::textGlobalAlphaDark)
val textSecondaryColorDark = Preferences.asLiveData(Preferences::textSecondaryColorDark)
val textSecondaryAlphaDark = Preferences.asLiveData(Preferences::textSecondaryAlphaDark)
val backgroundCardColorDark = Preferences.asLiveData(Preferences::backgroundCardColorDark)
val backgroundCardAlphaDark = Preferences.asLiveData(Preferences::backgroundCardAlphaDark)
val textGlobalColor = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textGlobalColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::textGlobalAlpha)) { value = true }
}
val textSecondaryColor = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textSecondaryColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::textSecondaryAlpha)) { value = true }
}
val backgroundCardColor = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::backgroundCardColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::backgroundCardAlpha)) { value = true }
}
val textGlobalColorDark = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textGlobalColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::textGlobalAlphaDark)) { value = true }
}
val textSecondaryColorDark = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textSecondaryColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::textSecondaryAlphaDark)) { value = true }
}
val backgroundCardColorDark = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::backgroundCardColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::backgroundCardAlphaDark)) { value = true }
}
val textMainSize = Preferences.asLiveData(Preferences::textMainSize)
val textSecondSize = Preferences.asLiveData(Preferences::textSecondSize)
val textShadow = Preferences.asLiveData(Preferences::textShadow)
val textShadowDark = Preferences.asLiveData(Preferences::textShadowDark)
val customFont = Preferences.asLiveData(Preferences::customFont)
val customFontFile = Preferences.asLiveData(Preferences::customFontFile)
val customFontName = Preferences.asLiveData(Preferences::customFontName)
val customFontVariant = Preferences.asLiveData(Preferences::customFontVariant)
val font = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::customFont)) { value = true }
addSource(Preferences.asLiveData(Preferences::customFontFile)) { value = true }
addSource(Preferences.asLiveData(Preferences::customFontName)) { value = true }
addSource(Preferences.asLiveData(Preferences::customFontVariant)) { value = true }
}
val secondRowInformation = Preferences.asLiveData(Preferences::secondRowInformation)
val showDividers = Preferences.asLiveData(Preferences::showDividers)
val secondRowTopMargin = Preferences.asLiveData(Preferences::secondRowTopMargin)
@ -36,52 +51,42 @@ class MainViewModel : ViewModel() {
val calendarAllDay = Preferences.asLiveData(Preferences::calendarAllDay)
val showUntil = Preferences.asLiveData(Preferences::showUntil)
val showDiffTime = Preferences.asLiveData(Preferences::showDiffTime)
val showDeclinedEvents = Preferences.asLiveData(Preferences::showDeclinedEvents)
val showNextEvent = Preferences.asLiveData(Preferences::showNextEvent)
val openEventDetails = Preferences.asLiveData(Preferences::openEventDetails)
val calendarAppName = Preferences.asLiveData(Preferences::calendarAppName)
val widgetUpdateFrequency = Preferences.asLiveData(Preferences::widgetUpdateFrequency)
val showOnlyBusyEvents = Preferences.asLiveData(Preferences::showOnlyBusyEvents)
// Clock Settings
val showClock = Preferences.asLiveData(Preferences::showClock)
val clockTextSize = Preferences.asLiveData(Preferences::clockTextSize)
val clockTextColor = Preferences.asLiveData(Preferences::clockTextColor)
val clockTextAlpha = Preferences.asLiveData(Preferences::clockTextAlpha)
val clockTextColorDark = Preferences.asLiveData(Preferences::clockTextColorDark)
val clockTextAlphaDark = Preferences.asLiveData(Preferences::clockTextAlphaDark)
val clockTextColor = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::clockTextColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextAlpha)) { value = true }
}
val clockTextColorDark = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::clockTextColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextAlphaDark)) { value = true }
}
val showAMPMIndicator = Preferences.asLiveData(Preferences::showAMPMIndicator)
val clockAppName = Preferences.asLiveData(Preferences::clockAppName)
val dateFormat = Preferences.asLiveData(Preferences::dateFormat)
val clockBottomMargin = Preferences.asLiveData(Preferences::clockBottomMargin)
val showBigClockWarning = Preferences.asLiveData(Preferences::showBigClockWarning)
// Weather Settings
val showWeather = Preferences.asLiveData(Preferences::showWeather)
val weatherTempUnit = Preferences.asLiveData(Preferences::weatherTempUnit)
val weatherRefreshPeriod = Preferences.asLiveData(Preferences::weatherRefreshPeriod)
val weatherAppName = Preferences.asLiveData(Preferences::weatherAppName)
val weatherProviderApi = Preferences.asLiveData(Preferences::weatherProviderApiOpen)
val customLocationAdd = Preferences.asLiveData(Preferences::customLocationAdd)
val showWeatherWarning = Preferences.asLiveData(Preferences::showWeatherWarning)
val weatherIconPack = Preferences.asLiveData(Preferences::weatherIconPack)
val weatherProvider = Preferences.asLiveData(Preferences::weatherProvider)
val weatherProviderError = Preferences.asLiveData(Preferences::weatherProviderError)
val weatherProviderLocationError = Preferences.asLiveData(Preferences::weatherProviderLocationError)
// Glance
val showMusic = Preferences.asLiveData(Preferences::showMusic)
val showNextAlarm = Preferences.asLiveData(Preferences::showNextAlarm)
val showBatteryCharging = Preferences.asLiveData(Preferences::showBatteryCharging)
val showDailySteps = Preferences.asLiveData(Preferences::showDailySteps)
val customInfo = Preferences.asLiveData(Preferences::customNotes)
val musicPlayersFilter = Preferences.asLiveData(Preferences::musicPlayersFilter)
// Advanced Settings
val darkThemePreference = Preferences.asLiveData(Preferences::darkThemePreference)
val showWallpaper = Preferences.asLiveData(Preferences::showWallpaper)

View File

@ -4,13 +4,13 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorPrimaryDark"
android:background="?android:attr/colorPrimary"
tools:context=".ui.activities.MainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/content_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
app:defaultNavHost="true"
android:background="@color/colorPrimaryDark"
android:background="@color/colorPrimary"
app:navGraph="@navigation/nav_graph"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View File

@ -11,7 +11,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:cardElevation="4dp"
app:cardElevation="0dp"
app:cardCornerRadius="0dp"
android:id="@+id/toolbar"
android:transitionName="toolbar"
@ -32,6 +32,7 @@
android:src="@drawable/round_arrow_back_24"
android:clickable="true"
android:focusable="true"
android:transitionName="action_back"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/colorPrimaryText"
android:layout_centerVertical="true"
@ -51,9 +52,9 @@
android:text="@string/app_name"
android:gravity="center"
android:textStyle="bold"
android:transitionName="title"
android:id="@+id/fragment_title"
android:layout_marginBottom="1dp"
android:transitionName="fragment_title"
android:layout_marginBottom="6dp"
style="@style/AnotherWidget.Main.Title"/>
</LinearLayout>
<ImageView
@ -76,10 +77,8 @@
android:id="@+id/preview"
android:animateLayoutChanges="true"
app:cardBackgroundColor="@color/colorPrimary"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="9dp"
app:cardCornerRadius="0dp"
app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
@ -110,11 +109,6 @@
android:id="@+id/widget_loader" />
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="16dp"
android:orientation="vertical"
android:id="@+id/bottom_padding" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
@ -125,7 +119,7 @@
app:cardElevation="0dp"
app:cardPreventCornerOverlap="true"
app:cardCornerRadius="0dp"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardBackgroundColor="@color/colorPrimary"
android:orientation="vertical">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/settings_fragment"

View File

@ -16,24 +16,26 @@
android:layout_width="match_parent"
android:layout_height="56dp"
app:cardBackgroundColor="@color/colorPrimary"
app:cardElevation="2dp"
app:cardElevation="0dp"
app:cardCornerRadius="0dp"
android:background="@color/colorPrimary"
android:transitionName="toolbar"
android:id="@+id/toolbar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp">
android:layout_height="56dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:layout_marginTop="2dp"
android:layout_marginTop="4dp"
android:src="@drawable/round_arrow_back_24"
app:tint="@color/colorPrimaryText"
android:layout_centerVertical="true"
android:clickable="true"
android:focusable="true"
android:transitionName="action_back"
android:layout_marginEnd="8dp"
android:layout_alignParentLeft="true"
android:layout_marginStart="8dp"
@ -46,7 +48,8 @@
android:text="@string/settings_title"
android:textColor="@color/colorPrimaryText"
android:gravity="center"
android:transitionName="settings_title"
android:paddingBottom="6dp"
android:transitionName="fragment_title"
android:textAppearance="@style/AnotherWidget.Main.Title"
tools:ignore="RelativeOverlap" />
</RelativeLayout>
@ -56,13 +59,13 @@
android:layout_height="match_parent"
android:id="@+id/scrollView"
android:scrollbarThumbVertical="@color/colorPrimary"
android:background="@color/colorPrimaryDark">
android:background="@color/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
android:paddingBottom="48dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="48dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"

View File

@ -25,7 +25,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="48dp"
android:focusable="true"
android:orientation="vertical">
<LinearLayout

View File

@ -16,7 +16,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="48dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"

View File

@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="48dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"

View File

@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="48dp"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"

View File

@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="48dp"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"

View File

@ -18,7 +18,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingBottom="48dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"

View File

@ -14,7 +14,7 @@
android:layout_marginRight="16dp"
app:strokeColor="@color/cardBorder"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardBackgroundColor="@color/colorPrimary"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"

View File

@ -18,7 +18,7 @@
<fragment
android:id="@+id/generalTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.tabs.LayoutFragment"
android:label="GeneralTabFragment" />
android:label="@string/layout_settings_title" />
<fragment
android:id="@+id/weatherTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.tabs.WeatherFragment"
@ -52,9 +52,9 @@
<fragment
android:id="@+id/typographyTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.tabs.TypographyFragment"
android:label="TypographyTabFragment" />
android:label="@string/typography_settings_title" />
<fragment
android:id="@+id/gesturesFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.tabs.GesturesFragment"
android:label="GesturesFragment" />
android:label="@string/gestures_settings_title" />
</navigation>