Add dividers toggle
This commit is contained in:
@ -15,7 +15,7 @@ class ViewPagerAdapter(fragmentActivity: FragmentActivity) :
|
||||
1 -> CalendarTabFragment.newInstance()
|
||||
2 -> WeatherTabFragment.newInstance()
|
||||
3 -> ClockTabFragment.newInstance()
|
||||
4 -> AtAGlanceTabFragment.newInstance()
|
||||
4 -> GlanceTabFragment.newInstance()
|
||||
else -> GeneralTabFragment.newInstance()
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -160,6 +161,13 @@ class CalendarTabFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
show_events_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
|
||||
Preferences.showEvents = enabled
|
||||
if (Preferences.showEvents) {
|
||||
requirePermission()
|
||||
}
|
||||
}
|
||||
|
||||
action_filter_calendar.setOnClickListener {
|
||||
val calendarSelectorList: List<CalendarSelector> = CalendarHelper.getCalendarList(requireContext()).map {
|
||||
CalendarSelector(
|
||||
@ -339,6 +347,8 @@ class CalendarTabFragment : Fragment() {
|
||||
report?.let {
|
||||
if (report.areAllPermissionsGranted()){
|
||||
checkReadEventsPermission()
|
||||
} else {
|
||||
Preferences.showEvents = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,10 @@ class ClockTabFragment : Fragment() {
|
||||
Preferences.showClock = !Preferences.showClock
|
||||
}
|
||||
|
||||
show_clock_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
|
||||
Preferences.showClock = enabled
|
||||
}
|
||||
|
||||
action_clock_text_size.setOnClickListener {
|
||||
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 {
|
||||
@ -182,7 +186,7 @@ class ClockTabFragment : Fragment() {
|
||||
}
|
||||
|
||||
action_clock_bottom_margin_size.setOnClickListener {
|
||||
BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_show_next_alarm_title)).setSelectedValue(Preferences.clockBottomMargin)
|
||||
BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_clock_bottom_margin_title)).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)
|
||||
|
@ -146,6 +146,10 @@ class GeneralTabFragment : Fragment() {
|
||||
custom_font_label?.text = getString(SettingsStringHelper.getCustomFontLabel(it))
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.showDividers.observe(viewLifecycleOwner, Observer {
|
||||
show_dividers_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
})
|
||||
}
|
||||
|
||||
private fun maintainScrollPosition(callback: () -> Unit) {
|
||||
@ -243,6 +247,15 @@ class GeneralTabFragment : Fragment() {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
action_show_dividers.setOnClickListener {
|
||||
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_multiple_events_title)).setSelectedValue(Preferences.showDividers)
|
||||
.addItem(getString(R.string.settings_visible), true)
|
||||
.addItem(getString(R.string.settings_not_visible), false)
|
||||
.addOnSelectItemListener { value ->
|
||||
Preferences.showDividers = value
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
@ -19,22 +19,22 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentAtAGlanceSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentGlanceSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.AlarmHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import kotlinx.android.synthetic.main.fragment_at_a_glance_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_at_a_glance_settings.scrollView
|
||||
import kotlinx.android.synthetic.main.fragment_glance_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_glance_settings.scrollView
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.lang.Exception
|
||||
|
||||
class AtAGlanceTabFragment : Fragment() {
|
||||
class GlanceTabFragment : Fragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance() = AtAGlanceTabFragment()
|
||||
fun newInstance() = GlanceTabFragment()
|
||||
}
|
||||
|
||||
private lateinit var viewModel: MainViewModel
|
||||
@ -49,7 +49,7 @@ class AtAGlanceTabFragment : Fragment() {
|
||||
): View {
|
||||
|
||||
viewModel = ViewModelProvider(activity as MainActivity).get(MainViewModel::class.java)
|
||||
val binding = DataBindingUtil.inflate<FragmentAtAGlanceSettingsBinding>(inflater, R.layout.fragment_at_a_glance_settings, container, false)
|
||||
val binding = DataBindingUtil.inflate<FragmentGlanceSettingsBinding>(inflater, R.layout.fragment_glance_settings, container, false)
|
||||
|
||||
subscribeUi(binding, viewModel)
|
||||
|
||||
@ -67,32 +67,32 @@ class AtAGlanceTabFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun subscribeUi(
|
||||
binding: FragmentAtAGlanceSettingsBinding,
|
||||
binding: FragmentGlanceSettingsBinding,
|
||||
viewModel: MainViewModel
|
||||
) {
|
||||
|
||||
viewModel.showMusic.observe(viewLifecycleOwner, Observer {
|
||||
checkNotificationPermission()
|
||||
})
|
||||
|
||||
viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
|
||||
updateNextAlarmWarningUi()
|
||||
})
|
||||
// viewModel.showMusic.observe(viewLifecycleOwner, Observer {
|
||||
// checkNotificationPermission()
|
||||
// })
|
||||
//
|
||||
// viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
|
||||
// updateNextAlarmWarningUi()
|
||||
// })
|
||||
}
|
||||
|
||||
private fun setupListener() {
|
||||
action_show_music.setOnClickListener {
|
||||
Preferences.showMusic = !Preferences.showMusic
|
||||
}
|
||||
|
||||
action_show_next_alarm.setOnClickListener {
|
||||
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_next_alarm_title)).setSelectedValue(Preferences.showNextAlarm)
|
||||
.addItem(getString(R.string.settings_visible), true)
|
||||
.addItem(getString(R.string.settings_not_visible), false)
|
||||
.addOnSelectItemListener { value ->
|
||||
Preferences.showNextAlarm = value
|
||||
}.show()
|
||||
}
|
||||
// action_show_music.setOnClickListener {
|
||||
// Preferences.showMusic = !Preferences.showMusic
|
||||
// }
|
||||
//
|
||||
// action_show_next_alarm.setOnClickListener {
|
||||
// BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_next_alarm_title)).setSelectedValue(Preferences.showNextAlarm)
|
||||
// .addItem(getString(R.string.settings_visible), true)
|
||||
// .addItem(getString(R.string.settings_not_visible), false)
|
||||
// .addOnSelectItemListener { value ->
|
||||
// Preferences.showNextAlarm = value
|
||||
// }.show()
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -28,8 +29,6 @@ import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.MaterialBottomSheetDialog
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentAdvancedSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentAppMainBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.BitmapHelper
|
||||
@ -53,6 +52,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
|
||||
companion object {
|
||||
fun newInstance() = MainFragment()
|
||||
private const val PREVIEW_BASE_HEIGHT = 120
|
||||
}
|
||||
|
||||
private lateinit var viewModel: MainViewModel
|
||||
@ -98,7 +98,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
time_container.isVisible = Preferences.showClock
|
||||
|
||||
preview.layoutParams = preview.layoutParams.apply {
|
||||
height = 160.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(requireContext()) else 0
|
||||
height = PREVIEW_BASE_HEIGHT.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(requireContext()) else 0
|
||||
}
|
||||
subscribeUi(viewModel)
|
||||
updateUI()
|
||||
@ -136,7 +136,6 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
)
|
||||
widget_shape_background.setImageDrawable(BitmapHelper.getTintedDrawable(requireContext(), R.drawable.card_background, ColorHelper.getBackgroundColor()))
|
||||
uiJob = viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
||||
delay(200)
|
||||
val generatedView = MainWidget.generateWidgetView(requireContext())
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
@ -207,7 +206,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
|
||||
ValueAnimator.ofInt(
|
||||
preview.height,
|
||||
160.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(
|
||||
PREVIEW_BASE_HEIGHT.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(
|
||||
requireContext()
|
||||
) else 0
|
||||
).apply {
|
||||
@ -229,7 +228,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
if (preview.height == 0) {
|
||||
ValueAnimator.ofInt(
|
||||
preview.height,
|
||||
160.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(
|
||||
PREVIEW_BASE_HEIGHT.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(
|
||||
requireContext()
|
||||
) else 0
|
||||
).apply {
|
||||
@ -323,6 +322,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
Preferences.preferences.registerOnSharedPreferenceChangeListener(this)
|
||||
EventBus.getDefault().register(this)
|
||||
showErrorBadge()
|
||||
updateUI()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@ -14,7 +14,6 @@ import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.Navigation
|
||||
import com.google.android.material.transition.MaterialContainerTransform
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import com.karumi.dexter.Dexter
|
||||
import com.karumi.dexter.MultiplePermissionsReport
|
||||
@ -24,7 +23,7 @@ import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
||||
import com.tommasoberlose.anotherwidget.BuildConfig
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentAdvancedSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.SupportDevActivity
|
||||
@ -35,7 +34,7 @@ import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.IntegrationsActivity
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.openURI
|
||||
import kotlinx.android.synthetic.main.fragment_advanced_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_settings.*
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@ -60,7 +59,7 @@ class SettingsFragment : Fragment() {
|
||||
): View {
|
||||
|
||||
viewModel = ViewModelProvider(activity as MainActivity).get(MainViewModel::class.java)
|
||||
val binding = DataBindingUtil.inflate<FragmentAdvancedSettingsBinding>(inflater, R.layout.fragment_advanced_settings, container, false)
|
||||
val binding = DataBindingUtil.inflate<FragmentSettingsBinding>(inflater, R.layout.fragment_settings, container, false)
|
||||
|
||||
binding.lifecycleOwner = this
|
||||
binding.viewModel = viewModel
|
||||
|
@ -168,6 +168,10 @@ class WeatherTabFragment : Fragment() {
|
||||
Preferences.showWeather = !Preferences.showWeather
|
||||
}
|
||||
|
||||
show_weather_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
|
||||
Preferences.showWeather = enabled
|
||||
}
|
||||
|
||||
action_weather_provider_api_key.setOnClickListener {
|
||||
if (Preferences.showWeather) {
|
||||
startActivityForResult(
|
||||
|
@ -16,6 +16,7 @@ class MainViewModel : ViewModel() {
|
||||
val textShadow = Preferences.asLiveData(Preferences::textShadow)
|
||||
val customFont = Preferences.asLiveData(Preferences::customFont)
|
||||
val secondRowInformation = Preferences.asLiveData(Preferences::secondRowInformation)
|
||||
val showDividers = Preferences.asLiveData(Preferences::showDividers)
|
||||
|
||||
// Calendar Settings
|
||||
val showEvents = Preferences.asLiveData(Preferences::showEvents)
|
||||
@ -34,7 +35,6 @@ class MainViewModel : ViewModel() {
|
||||
val clockTextAlpha = Preferences.asLiveData(Preferences::clockTextAlpha)
|
||||
|
||||
val clockAppName = Preferences.asLiveData(Preferences::clockAppName)
|
||||
val showNextAlarm = Preferences.asLiveData(Preferences::showNextAlarm)
|
||||
val dateFormat = Preferences.asLiveData(Preferences::dateFormat)
|
||||
val clockBottomMargin = Preferences.asLiveData(Preferences::clockBottomMargin)
|
||||
|
||||
@ -52,9 +52,8 @@ class MainViewModel : ViewModel() {
|
||||
|
||||
val showWeatherWarning = Preferences.asLiveData(Preferences::showWeatherWarning)
|
||||
|
||||
// Music
|
||||
val showMusic = Preferences.asLiveData(Preferences::showMusic)
|
||||
val mediaInfoFormat = Preferences.asLiveData(Preferences::mediaInfoFormat)
|
||||
// Glance
|
||||
val showGlance = Preferences.asLiveData(Preferences::showGlance)
|
||||
|
||||
// Advanced Settings
|
||||
val darkThemePreference = Preferences.asLiveData(Preferences::darkThemePreference)
|
||||
|
@ -637,6 +637,11 @@ class MainWidget : AppWidgetProvider() {
|
||||
v.special_weather.visibility = View.GONE
|
||||
}
|
||||
|
||||
// Dividers
|
||||
arrayOf(v.divider1, v.divider2, v.divider3).forEach {
|
||||
it.isVisible = Preferences.showDividers
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user