Update the UI

This commit is contained in:
Tommaso Berlose 2020-05-20 20:46:21 +02:00
parent 863b8f79d8
commit e1d2f5a782
43 changed files with 384 additions and 157 deletions

View File

@ -0,0 +1,24 @@
package com.tommasoberlose.anotherwidget.components
import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.util.Log
import android.view.View
import android.widget.ScrollView
class FixedFocusScrollView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : ScrollView(context, attrs, defStyle) {
var isScrollable = true
override fun scrollTo(x: Int, y: Int) {
if (isScrollable) {
super.scrollTo(x, y)
}
}
}

View File

@ -0,0 +1,21 @@
package com.tommasoberlose.anotherwidget.components
import android.view.View
import android.widget.CompoundButton
class MenuItem (
val icon: Int,
val getIcon: (() -> Int)? = null,
val title: String,
val label: String = "",
val getLabel: (() -> String)? = null,
val isEnabled: (() -> Boolean) = fun (): Boolean { return true },
val onClick: View.OnClickListener? = null,
val onLongClick: View.OnLongClickListener? = null,
val showToggle: Boolean = false,
val toggleValue: (() -> Boolean) = fun (): Boolean { return false },
val onToggle: CompoundButton.OnCheckedChangeListener? = null,
val showPermission: (() -> Boolean) = fun (): Boolean { return false },
val onPermissionClickListener: View.OnClickListener? = null,
val render: ((view: View) -> Unit)? = null
)

View File

@ -24,7 +24,6 @@ import kotlin.collections.ArrayList
*/ */
object CalendarHelper { object CalendarHelper {
fun updateEventList(context: Context) { fun updateEventList(context: Context) {
val eventRepository = EventRepository(context) val eventRepository = EventRepository(context)
if (Preferences.showEvents) { if (Preferences.showEvents) {

View File

@ -74,6 +74,11 @@ class CalendarTabFragment : Fragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
show_all_day_toggle.isChecked = Preferences.calendarAllDay
show_declined_events_toggle.isChecked = Preferences.showDeclinedEvents
show_diff_time_toggle.isChecked = Preferences.showDiffTime
show_multiple_events_toggle.isChecked = Preferences.showNextEvent
setupListener() setupListener()
} }
@ -82,6 +87,7 @@ class CalendarTabFragment : Fragment() {
viewModel: MainViewModel viewModel: MainViewModel
) { ) {
binding.isCalendarEnabled = Preferences.showEvents binding.isCalendarEnabled = Preferences.showEvents
binding.isDiffEnabled = Preferences.showDiffTime || !Preferences.showEvents
viewModel.showEvents.observe(viewLifecycleOwner, Observer { viewModel.showEvents.observe(viewLifecycleOwner, Observer {
maintainScrollPosition { maintainScrollPosition {
@ -92,8 +98,10 @@ class CalendarTabFragment : Fragment() {
} else { } else {
CalendarHelper.removeEventUpdatesAndroidN(requireContext()) CalendarHelper.removeEventUpdatesAndroidN(requireContext())
} }
binding.isDiffEnabled = Preferences.showDiffTime || !it
} }
checkReadEventsPermission() checkReadEventsPermission()
updateCalendar()
}) })
viewModel.calendarAllDay.observe(viewLifecycleOwner, Observer { viewModel.calendarAllDay.observe(viewLifecycleOwner, Observer {
@ -101,14 +109,14 @@ class CalendarTabFragment : Fragment() {
all_day_label?.text = all_day_label?.text =
if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible) if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
} }
checkReadEventsPermission() updateCalendar()
}) })
viewModel.showDeclinedEvents.observe(viewLifecycleOwner, Observer { viewModel.showDeclinedEvents.observe(viewLifecycleOwner, Observer {
maintainScrollPosition { maintainScrollPosition {
show_declined_events_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible) show_declined_events_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
} }
checkReadEventsPermission() updateCalendar()
}) })
viewModel.secondRowInformation.observe(viewLifecycleOwner, Observer { viewModel.secondRowInformation.observe(viewLifecycleOwner, Observer {
@ -120,6 +128,7 @@ class CalendarTabFragment : Fragment() {
viewModel.showDiffTime.observe(viewLifecycleOwner, Observer { viewModel.showDiffTime.observe(viewLifecycleOwner, Observer {
maintainScrollPosition { maintainScrollPosition {
show_diff_time_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible) show_diff_time_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
binding.isDiffEnabled = it || !Preferences.showEvents
} }
}) })
@ -138,7 +147,7 @@ class CalendarTabFragment : Fragment() {
maintainScrollPosition { maintainScrollPosition {
show_until_label?.text = getString(SettingsStringHelper.getShowUntilString(it)) show_until_label?.text = getString(SettingsStringHelper.getShowUntilString(it))
} }
checkReadEventsPermission() updateCalendar()
}) })
viewModel.showNextEvent.observe(viewLifecycleOwner, Observer { viewModel.showNextEvent.observe(viewLifecycleOwner, Observer {
@ -222,7 +231,7 @@ class CalendarTabFragment : Fragment() {
dialog.addOnMultipleSelectItemListener { values -> dialog.addOnMultipleSelectItemListener { values ->
CalendarHelper.filterCalendar(calendarSelectorList.map { it.id }.filter { !values.contains(it) }) CalendarHelper.filterCalendar(calendarSelectorList.map { it.id }.filter { !values.contains(it) })
checkReadEventsPermission() updateCalendar()
}.show() }.show()
} else { } else {
activity?.toast(getString(R.string.calendar_settings_list_error)) activity?.toast(getString(R.string.calendar_settings_list_error))
@ -231,50 +240,54 @@ class CalendarTabFragment : Fragment() {
action_show_all_day.setOnClickListener { action_show_all_day.setOnClickListener {
if (Preferences.showEvents) { if (Preferences.showEvents) {
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_all_day_title)).setSelectedValue(Preferences.calendarAllDay) show_all_day_toggle.isChecked = !show_all_day_toggle.isChecked
.addItem(getString(R.string.settings_visible), true) }
.addItem(getString(R.string.settings_not_visible), false) }
.addOnSelectItemListener { value ->
Preferences.calendarAllDay = value show_all_day_toggle.setOnCheckedChangeListener { _, isChecked ->
}.show() if (Preferences.showEvents) {
Preferences.calendarAllDay = isChecked
} }
} }
action_show_declined_events.setOnClickListener { action_show_declined_events.setOnClickListener {
if (Preferences.showEvents) { if (Preferences.showEvents) {
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_declined_events_title)).setSelectedValue(Preferences.showDeclinedEvents) show_declined_events_toggle.isChecked = !show_declined_events_toggle.isChecked
.addItem(getString(R.string.settings_visible), true) }
.addItem(getString(R.string.settings_not_visible), false) }
.addOnSelectItemListener { value ->
Preferences.showDeclinedEvents = value show_declined_events_toggle.setOnCheckedChangeListener { _, isChecked ->
}.show() if (Preferences.showEvents) {
Preferences.showDeclinedEvents = isChecked
} }
} }
action_show_multiple_events.setOnClickListener { action_show_multiple_events.setOnClickListener {
if (Preferences.showEvents) { if (Preferences.showEvents) {
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_multiple_events_title)).setSelectedValue(Preferences.showNextEvent) show_multiple_events_toggle.isChecked = !show_multiple_events_toggle.isChecked
.addItem(getString(R.string.settings_visible), true) }
.addItem(getString(R.string.settings_not_visible), false) }
.addOnSelectItemListener { value ->
Preferences.showNextEvent = value show_multiple_events_toggle.setOnCheckedChangeListener { _, isChecked ->
}.show() if (Preferences.showEvents) {
Preferences.showNextEvent = isChecked
} }
} }
action_show_diff_time.setOnClickListener { action_show_diff_time.setOnClickListener {
if (Preferences.showEvents) { if (Preferences.showEvents) {
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_diff_time_title)).setSelectedValue(Preferences.showDiffTime) show_diff_time_toggle.isChecked = !show_diff_time_toggle.isChecked
.addItem(getString(R.string.settings_visible), true) }
.addItem(getString(R.string.settings_not_visible), false) }
.addOnSelectItemListener { value ->
Preferences.showDiffTime = value show_diff_time_toggle.setOnCheckedChangeListener { _, isChecked ->
}.show() if (Preferences.showEvents) {
Preferences.showDiffTime = isChecked
} }
} }
action_widget_update_frequency.setOnClickListener { action_widget_update_frequency.setOnClickListener {
if (Preferences.showEvents) { if (Preferences.showEvents && Preferences.showDiffTime) {
BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_widget_update_frequency_title), message = getString(R.string.settings_widget_update_frequency_subtitle)).setSelectedValue(Preferences.widgetUpdateFrequency) BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_widget_update_frequency_title), message = getString(R.string.settings_widget_update_frequency_subtitle)).setSelectedValue(Preferences.widgetUpdateFrequency)
.addItem(getString(R.string.settings_widget_update_frequency_high), Constants.WidgetUpdateFrequency.HIGH.value) .addItem(getString(R.string.settings_widget_update_frequency_high), Constants.WidgetUpdateFrequency.HIGH.value)
.addItem(getString(R.string.settings_widget_update_frequency_default), Constants.WidgetUpdateFrequency.DEFAULT.value) .addItem(getString(R.string.settings_widget_update_frequency_default), Constants.WidgetUpdateFrequency.DEFAULT.value)
@ -329,7 +342,6 @@ class CalendarTabFragment : Fragment() {
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) { if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
show_events_label?.text = if (showEvents) getString(R.string.show_events_visible) else getString(R.string.show_events_not_visible) show_events_label?.text = if (showEvents) getString(R.string.show_events_visible) else getString(R.string.show_events_not_visible)
read_calendar_permission_alert?.isVisible = false read_calendar_permission_alert?.isVisible = false
CalendarHelper.updateEventList(requireContext())
} else { } else {
show_events_label?.text = if (showEvents) getString(R.string.description_permission_calendar) else getString(R.string.show_events_not_visible) show_events_label?.text = if (showEvents) getString(R.string.description_permission_calendar) else getString(R.string.show_events_not_visible)
read_calendar_permission_alert?.isVisible = showEvents read_calendar_permission_alert?.isVisible = showEvents
@ -339,6 +351,12 @@ class CalendarTabFragment : Fragment() {
} }
} }
private fun updateCalendar() {
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
CalendarHelper.updateEventList(requireContext())
}
}
private fun requirePermission() { private fun requirePermission() {
Dexter.withContext(requireContext()) Dexter.withContext(requireContext())
.withPermissions( .withPermissions(
@ -386,11 +404,11 @@ class CalendarTabFragment : Fragment() {
} }
private fun maintainScrollPosition(callback: () -> Unit) { private fun maintainScrollPosition(callback: () -> Unit) {
val scrollPosition = scrollView.scrollY scrollView.isScrollable = false
callback.invoke() callback.invoke()
lifecycleScope.launch { lifecycleScope.launch {
delay(200) delay(200)
scrollView.smoothScrollTo(0, scrollPosition) scrollView.isScrollable = true
} }
} }
} }

View File

@ -21,6 +21,7 @@ import com.chibatching.kotpref.bulk
import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.components.BottomSheetColorPicker import com.tommasoberlose.anotherwidget.components.BottomSheetColorPicker
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
import com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
import com.tommasoberlose.anotherwidget.databinding.FragmentClockSettingsBinding import com.tommasoberlose.anotherwidget.databinding.FragmentClockSettingsBinding
import com.tommasoberlose.anotherwidget.global.Constants import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.global.Preferences
@ -72,6 +73,8 @@ class ClockTabFragment : Fragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
ampm_indicator_toggle.isChecked = Preferences.showAMPMIndicator
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
val lazyColors = requireContext().resources.getIntArray(R.array.material_colors) val lazyColors = requireContext().resources.getIntArray(R.array.material_colors)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
@ -167,7 +170,11 @@ class ClockTabFragment : Fragment() {
} }
action_clock_text_size.setOnClickListener { action_clock_text_size.setOnClickListener {
val dialog = BottomSheetMenu<Float>(requireContext(), header = getString(R.string.settings_clock_text_size_title)).setSelectedValue(Preferences.clockTextSize) if (Preferences.showClock) {
val dialog = BottomSheetMenu<Float>(
requireContext(),
header = getString(R.string.settings_clock_text_size_title)
).setSelectedValue(Preferences.clockTextSize)
(46 downTo 12).filter { it % 2 == 0 }.forEach { (46 downTo 12).filter { it % 2 == 0 }.forEach {
dialog.addItem("${it}sp", it.toFloat()) dialog.addItem("${it}sp", it.toFloat())
} }
@ -175,24 +182,30 @@ class ClockTabFragment : Fragment() {
Preferences.clockTextSize = value Preferences.clockTextSize = value
}.show() }.show()
} }
}
action_ampm_indicator_size.setOnClickListener { action_ampm_indicator_size.setOnClickListener {
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_ampm_indicator_title)).setSelectedValue(Preferences.showAMPMIndicator) if (Preferences.showClock) {
.addItem(getString(R.string.settings_visible), true) ampm_indicator_toggle.isChecked = !ampm_indicator_toggle.isChecked
.addItem(getString(R.string.settings_not_visible), false) }
.addOnSelectItemListener { value -> }
Preferences.showAMPMIndicator = value
}.show() ampm_indicator_toggle.setOnCheckedChangeListener { _, isChecked ->
if (Preferences.showClock) {
Preferences.showAMPMIndicator = isChecked
}
} }
action_clock_text_color.setOnClickListener { action_clock_text_color.setOnClickListener {
if (Preferences.showClock) {
BottomSheetColorPicker(requireContext(), BottomSheetColorPicker(requireContext(),
colors = colors, colors = colors,
header = getString(R.string.settings_font_color_title), header = getString(R.string.settings_font_color_title),
getSelected = ColorHelper::getClockFontColorRgb, getSelected = ColorHelper::getClockFontColorRgb,
onColorSelected = { color: Int -> onColorSelected = { color: Int ->
val colorString = Integer.toHexString(color) val colorString = Integer.toHexString(color)
Preferences.clockTextColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString Preferences.clockTextColor =
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
}, },
showAlphaSelector = true, showAlphaSelector = true,
alpha = Preferences.clockTextAlpha.toIntValue(), alpha = Preferences.clockTextAlpha.toIntValue(),
@ -201,26 +214,47 @@ class ClockTabFragment : Fragment() {
} }
).show() ).show()
} }
}
action_clock_bottom_margin_size.setOnClickListener { action_clock_bottom_margin_size.setOnClickListener {
BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_clock_bottom_margin_title)).setSelectedValue(Preferences.clockBottomMargin) if (Preferences.showClock) {
.addItem(getString(R.string.settings_clock_bottom_margin_subtitle_none), Constants.ClockBottomMargin.NONE.value) BottomSheetMenu<Int>(
.addItem(getString(R.string.settings_clock_bottom_margin_subtitle_small), Constants.ClockBottomMargin.SMALL.value) requireContext(),
.addItem(getString(R.string.settings_clock_bottom_margin_subtitle_medium), Constants.ClockBottomMargin.MEDIUM.value) header = getString(R.string.settings_clock_bottom_margin_title)
.addItem(getString(R.string.settings_clock_bottom_margin_subtitle_large), Constants.ClockBottomMargin.LARGE.value) ).setSelectedValue(Preferences.clockBottomMargin)
.addItem(
getString(R.string.settings_clock_bottom_margin_subtitle_none),
Constants.ClockBottomMargin.NONE.value
)
.addItem(
getString(R.string.settings_clock_bottom_margin_subtitle_small),
Constants.ClockBottomMargin.SMALL.value
)
.addItem(
getString(R.string.settings_clock_bottom_margin_subtitle_medium),
Constants.ClockBottomMargin.MEDIUM.value
)
.addItem(
getString(R.string.settings_clock_bottom_margin_subtitle_large),
Constants.ClockBottomMargin.LARGE.value
)
.addOnSelectItemListener { value -> .addOnSelectItemListener { value ->
Preferences.clockBottomMargin = value Preferences.clockBottomMargin = value
}.show() }.show()
} }
}
action_clock_app.setOnClickListener { action_clock_app.setOnClickListener {
if (Preferences.showClock) { if (Preferences.showClock) {
startActivityForResult(Intent(requireContext(), ChooseApplicationActivity::class.java), if (Preferences.showClock) {
startActivityForResult(
Intent(requireContext(), ChooseApplicationActivity::class.java),
RequestCode.CLOCK_APP_REQUEST_CODE.code RequestCode.CLOCK_APP_REQUEST_CODE.code
) )
} }
} }
} }
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK && requestCode == RequestCode.CLOCK_APP_REQUEST_CODE.code) { if (resultCode == Activity.RESULT_OK && requestCode == RequestCode.CLOCK_APP_REQUEST_CODE.code) {
@ -233,11 +267,11 @@ class ClockTabFragment : Fragment() {
} }
private fun maintainScrollPosition(callback: () -> Unit) { private fun maintainScrollPosition(callback: () -> Unit) {
val scrollPosition = scrollView.scrollY scrollView.isScrollable = false
callback.invoke() callback.invoke()
lifecycleScope.launch { lifecycleScope.launch {
delay(200) delay(200)
scrollView.smoothScrollTo(0, scrollPosition) scrollView.isScrollable = true
} }
} }
} }

View File

@ -67,6 +67,8 @@ class GeneralTabFragment : Fragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
show_dividers_toggle.isChecked = Preferences.showDividers
setupListener() setupListener()
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
val lazyColors = requireContext().resources.getIntArray(R.array.material_colors) val lazyColors = requireContext().resources.getIntArray(R.array.material_colors)
@ -186,15 +188,6 @@ class GeneralTabFragment : Fragment() {
}) })
} }
private fun maintainScrollPosition(callback: () -> Unit) {
val scrollPosition = scrollView.scrollY
callback.invoke()
lifecycleScope.launch {
delay(200)
scrollView.smoothScrollTo(0, scrollPosition)
}
}
private fun setupListener() { private fun setupListener() {
action_main_text_size.setOnClickListener { action_main_text_size.setOnClickListener {
val dialog = BottomSheetMenu<Float>(requireContext(), header = getString(R.string.title_main_text_size)).setSelectedValue(Preferences.textMainSize) val dialog = BottomSheetMenu<Float>(requireContext(), header = getString(R.string.title_main_text_size)).setSelectedValue(Preferences.textMainSize)
@ -319,12 +312,11 @@ class GeneralTabFragment : Fragment() {
} }
action_show_dividers.setOnClickListener { action_show_dividers.setOnClickListener {
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_dividers_title)).setSelectedValue(Preferences.showDividers) show_dividers_toggle.isChecked = !show_dividers_toggle.isChecked
.addItem(getString(R.string.settings_visible), true) }
.addItem(getString(R.string.settings_not_visible), false)
.addOnSelectItemListener { value -> show_dividers_toggle.setOnCheckedChangeListener { _, isChecked ->
Preferences.showDividers = value Preferences.showDividers = isChecked
}.show()
} }
} }
@ -346,4 +338,13 @@ class GeneralTabFragment : Fragment() {
} }
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
} }
private fun maintainScrollPosition(callback: () -> Unit) {
scrollView.isScrollable = false
callback.invoke()
lifecycleScope.launch {
delay(200)
scrollView.isScrollable = true
}
}
} }

View File

@ -373,11 +373,11 @@ class GlanceTabFragment : Fragment() {
} }
private fun maintainScrollPosition(callback: () -> Unit) { private fun maintainScrollPosition(callback: () -> Unit) {
val scrollPosition = scrollView.scrollY scrollView.isScrollable = false
callback.invoke() callback.invoke()
lifecycleScope.launch { lifecycleScope.launch {
delay(200) delay(200)
scrollView.smoothScrollTo(0, scrollPosition) scrollView.isScrollable = true
} }
} }

View File

@ -65,6 +65,8 @@ class SettingsFragment : Fragment() {
binding.lifecycleOwner = this binding.lifecycleOwner = this
binding.viewModel = viewModel binding.viewModel = viewModel
subscribeUi(viewModel)
return binding.root return binding.root
} }
@ -75,7 +77,8 @@ class SettingsFragment : Fragment() {
Navigation.findNavController(it).popBackStack() Navigation.findNavController(it).popBackStack()
} }
subscribeUi(viewModel) show_widget_preview_toggle.isChecked = Preferences.showPreview
show_wallpaper_toggle.isChecked = Preferences.showWallpaper
setupListener() setupListener()
@ -120,44 +123,26 @@ class SettingsFragment : Fragment() {
} }
private fun setupListener() { private fun setupListener() {
action_show_widget_preview.setOnClickListener { action_show_widget_preview.setOnClickListener {
maintainScrollPosition { show_widget_preview_toggle.isChecked = !show_widget_preview_toggle.isChecked
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.action_show_widget_preview))
.setSelectedValue(Preferences.showPreview)
.addItem(
getString(R.string.settings_visible),
true
)
.addItem(
getString(R.string.settings_not_visible),
false
)
.addOnSelectItemListener { value ->
Preferences.showPreview = value
}.show()
} }
show_widget_preview_toggle.setOnCheckedChangeListener { _, isChecked ->
Preferences.showPreview = isChecked
} }
action_show_wallpaper.setOnClickListener { action_show_wallpaper.setOnClickListener {
maintainScrollPosition { }
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_title_show_wallpaper))
.setSelectedValue(Preferences.showWallpaper && activity?.checkGrantedPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == true) action_show_wallpaper.setOnClickListener {
.addItem( show_wallpaper_toggle.isChecked = !show_wallpaper_toggle.isChecked
getString(R.string.settings_visible), }
true
) show_wallpaper_toggle.setOnCheckedChangeListener { _, isChecked ->
.addItem( if (isChecked) {
getString(R.string.settings_not_visible),
false
)
.addOnSelectItemListener { value ->
if (value) {
requirePermission() requirePermission()
} else { } else {
Preferences.showWallpaper = value Preferences.showWallpaper = isChecked
}
}.show()
} }
} }
@ -211,11 +196,11 @@ class SettingsFragment : Fragment() {
} }
private fun maintainScrollPosition(callback: () -> Unit) { private fun maintainScrollPosition(callback: () -> Unit) {
val scrollPosition = scrollView.scrollY scrollView.isScrollable = false
callback.invoke() callback.invoke()
lifecycleScope.launch { lifecycleScope.launch {
delay(200) delay(200)
scrollView.smoothScrollTo(0, scrollPosition) scrollView.isScrollable = true
} }
} }
@ -226,8 +211,8 @@ class SettingsFragment : Fragment() {
).withListener(object: MultiplePermissionsListener { ).withListener(object: MultiplePermissionsListener {
override fun onPermissionsChecked(report: MultiplePermissionsReport?) { override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
report?.let { report?.let {
Preferences.showWallpaper = false show_wallpaper_toggle?.isChecked = false
Preferences.showWallpaper = report.areAllPermissionsGranted() show_wallpaper_toggle?.isChecked = report.areAllPermissionsGranted()
} }
} }
override fun onPermissionRationaleShouldBeShown( override fun onPermissionRationaleShouldBeShown(

View File

@ -133,7 +133,7 @@ class WeatherTabFragment : Fragment() {
viewModel.weatherIconPack.observe(viewLifecycleOwner, Observer { viewModel.weatherIconPack.observe(viewLifecycleOwner, Observer {
maintainScrollPosition { maintainScrollPosition {
label_weather_icon_pack?.text = getString(R.string.settings_weather_icon_pack_default).format((it + 1)) label_weather_icon_pack?.text = getString(R.string.settings_weather_icon_pack_default).format((it + 1))
weather_icon_pack.setImageDrawable(ContextCompat.getDrawable(requireContext(), WeatherHelper.getWeatherIconResource("01d"))) weather_icon_pack.setImageDrawable(ContextCompat.getDrawable(requireContext(), WeatherHelper.getWeatherIconResource("02d")))
if (it == Constants.WeatherIconPack.MINIMAL.value) { if (it == Constants.WeatherIconPack.MINIMAL.value) {
weather_icon_pack.setColorFilter(ContextCompat.getColor(requireContext(), R.color.colorPrimaryText)) weather_icon_pack.setColorFilter(ContextCompat.getColor(requireContext(), R.color.colorPrimaryText))
} else { } else {
@ -303,11 +303,11 @@ class WeatherTabFragment : Fragment() {
} }
private fun maintainScrollPosition(callback: () -> Unit) { private fun maintainScrollPosition(callback: () -> Unit) {
val scrollPosition = scrollView.scrollY scrollView.isScrollable = false
callback.invoke() callback.invoke()
lifecycleScope.launch { lifecycleScope.launch {
delay(200) delay(200)
scrollView.smoothScrollTo(0, scrollPosition) scrollView.isScrollable = true
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM16.5,16L8,16c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3h0.14c0.44,-1.73 1.99,-3 3.86,-3 2.21,0 4,1.79 4,4h0.5c1.38,0 2.5,1.12 2.5,2.5S17.88,16 16.5,16z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -7,9 +7,12 @@
<variable <variable
name="isCalendarEnabled" name="isCalendarEnabled"
type="Boolean" /> type="Boolean" />
<variable
name="isDiffEnabled"
type="Boolean" />
</data> </data>
<ScrollView <com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -158,7 +161,8 @@
android:src="@drawable/round_date_range" android:src="@drawable/round_date_range"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
@ -174,6 +178,12 @@
android:id="@+id/all_day_label" android:id="@+id/all_day_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/show_all_day_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -195,7 +205,8 @@
android:src="@drawable/round_event_busy" android:src="@drawable/round_event_busy"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
@ -211,6 +222,12 @@
android:id="@+id/show_declined_events_label" android:id="@+id/show_declined_events_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/show_declined_events_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -281,7 +298,8 @@
android:src="@drawable/round_timelapse" android:src="@drawable/round_timelapse"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
@ -297,6 +315,12 @@
android:id="@+id/show_diff_time_label" android:id="@+id/show_diff_time_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/show_diff_time_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -307,6 +331,7 @@
android:paddingRight="8dp" android:paddingRight="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:alpha="@{isDiffEnabled ? 1f : 0.2f, default=1}"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" android:gravity="center_vertical"
android:id="@+id/action_widget_update_frequency" android:id="@+id/action_widget_update_frequency"
@ -404,7 +429,8 @@
android:src="@drawable/round_code" android:src="@drawable/round_code"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
@ -420,6 +446,12 @@
android:id="@+id/show_multiple_events_label" android:id="@+id/show_multiple_events_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/show_multiple_events_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -497,5 +529,5 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</layout> </layout>

View File

@ -8,7 +8,7 @@
name="isClockVisible" name="isClockVisible"
type="Boolean" /> type="Boolean" />
</data> </data>
<ScrollView <com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -20,6 +20,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="8dp" android:paddingTop="8dp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:focusable="true"
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -77,8 +78,7 @@
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/round_schedule" android:src="@drawable/alarm"/>
android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
@ -230,7 +230,8 @@
android:scaleX="-1" android:scaleX="-1"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
@ -246,6 +247,12 @@
android:id="@+id/ampm_indicator_label" android:id="@+id/ampm_indicator_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/ampm_indicator_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -356,5 +363,5 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</layout> </layout>

View File

@ -6,7 +6,7 @@
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel" />
</data> </data>
<ScrollView <com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/scrollView" android:id="@+id/scrollView"
@ -334,7 +334,8 @@
android:rotation="90" android:rotation="90"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="8dp" android:paddingLeft="8dp"
@ -350,6 +351,12 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/show_dividers_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -392,5 +399,5 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</layout> </layout>

View File

@ -10,7 +10,7 @@
name="isGlanceVisible" name="isGlanceVisible"
type="Boolean" /> type="Boolean" />
</data> </data>
<ScrollView <com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/scrollView" android:id="@+id/scrollView"
@ -39,8 +39,7 @@
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/round_hourglass_empty" android:src="@drawable/menu"/>
android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
@ -382,5 +381,5 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</layout> </layout>

View File

@ -49,7 +49,7 @@
tools:ignore="RelativeOverlap" /> tools:ignore="RelativeOverlap" />
</RelativeLayout> </RelativeLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<ScrollView <com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/scrollView" android:id="@+id/scrollView"
@ -126,7 +126,8 @@
android:src="@drawable/round_compare" android:src="@drawable/round_compare"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
@ -142,6 +143,12 @@
android:id="@+id/show_widget_preview_label" android:id="@+id/show_widget_preview_label"
style="@style/AnotherWidget.Settings.Subtitle" /> style="@style/AnotherWidget.Settings.Subtitle" />
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/show_widget_preview_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -163,7 +170,8 @@
android:src="@drawable/round_wallpaper" android:src="@drawable/round_wallpaper"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
@ -179,6 +187,12 @@
android:id="@+id/show_wallpaper_label" android:id="@+id/show_wallpaper_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/show_wallpaper_toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -440,6 +454,6 @@
app:textAllCaps="false" /> app:textAllCaps="false" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</LinearLayout> </LinearLayout>
</layout> </layout>

View File

@ -8,7 +8,7 @@
name="isWeatherVisible" name="isWeatherVisible"
type="Boolean" /> type="Boolean" />
</data> </data>
<ScrollView <com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -77,6 +77,7 @@
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:padding="12dp" android:padding="12dp"
android:id="@+id/weather_icon_pack"
android:src="@drawable/round_brightness_5" android:src="@drawable/round_brightness_5"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
@ -327,8 +328,7 @@
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:padding="12dp" android:padding="12dp"
android:id="@+id/weather_icon_pack" android:src="@drawable/round_cloud_circle"
android:src="@drawable/round_cloud_queue"
android:tint="@color/colorPrimaryText"/> android:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -399,5 +399,5 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</layout> </layout>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:text="@string/filters_header"
android:textAlignment="viewStart"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textSize="16sp"
android:id="@+id/header"
android:textColor="@color/colorAccent"
android:textAppearance="@style/AnotherWidget.Settings.Header"
android:textAllCaps="false" />

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/container"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:id="@+id/icon"
android:src="@drawable/calendar"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:id="@+id/title"
android:text="@string/title_permission_calendar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label"
android:text="@string/description_permission_calendar"
style="@style/AnotherWidget.Settings.Subtitle"/>
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="36dp"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:letterSpacing="0"
android:textAllCaps="false"
android:clickable="true"
android:layout_marginStart="-8dp"
android:layout_marginBottom="-8dp"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:focusable="true"
android:id="@+id/action_grant_permission"
android:textColor="@color/errorColorText"
android:text="@string/action_grant_permission"/>
</LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:id="@+id/toggle"
android:buttonTint="@color/colorAccent" />
</LinearLayout>