Merge crud-device
BIN
.idea/caches/build_file_checksums.ser
generated
@ -18,7 +18,7 @@ android {
|
|||||||
applicationId "com.tommasoberlose.anotherwidget"
|
applicationId "com.tommasoberlose.anotherwidget"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 80
|
versionCode 81
|
||||||
versionName "2.0.6"
|
versionName "2.0.6"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.tommasoberlose.anotherwidget.db
|
package com.tommasoberlose.anotherwidget.db
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
import com.chibatching.kotpref.bulk
|
import com.chibatching.kotpref.bulk
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.models.Event
|
import com.tommasoberlose.anotherwidget.models.Event
|
||||||
@ -43,23 +44,25 @@ class EventRepository(val context: Context) {
|
|||||||
|
|
||||||
fun getNextEvent(): Event? {
|
fun getNextEvent(): Event? {
|
||||||
val nextEvent = getEventByEventId(Preferences.nextEventId)
|
val nextEvent = getEventByEventId(Preferences.nextEventId)
|
||||||
return if (nextEvent != null && nextEvent.endDate > Calendar.getInstance().timeInMillis + 60 * 1000) {
|
return if (nextEvent != null && nextEvent.endDate > Calendar.getInstance().timeInMillis) {
|
||||||
nextEvent
|
nextEvent
|
||||||
} else {
|
} else {
|
||||||
val events = getEvents()
|
val events = getEvents()
|
||||||
if (events.isNotEmpty())
|
if (events.isNotEmpty()) {
|
||||||
events.first()
|
val newNextEvent = events.first()
|
||||||
else
|
Preferences.nextEventId = newNextEvent!!.eventID
|
||||||
|
newNextEvent
|
||||||
|
} else {
|
||||||
resetNextEventData()
|
resetNextEventData()
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getEventByEventId(id: Long): Event? = realm.where(Event::class.java).equalTo("eventID", id).findFirst()
|
fun getEventByEventId(id: Long): Event? = realm.where(Event::class.java).equalTo("eventID", id).findFirst()
|
||||||
|
|
||||||
fun goToNextEvent() {
|
fun goToNextEvent() {
|
||||||
val eventList = getEvents()
|
val eventList = getEvents()
|
||||||
|
|
||||||
if (eventList.isNotEmpty()) {
|
if (eventList.isNotEmpty()) {
|
||||||
val index = eventList.indexOfFirst { it.id == Preferences.nextEventId }
|
val index = eventList.indexOfFirst { it.id == Preferences.nextEventId }
|
||||||
if (index > -1 && index < eventList.size - 1) {
|
if (index > -1 && index < eventList.size - 1) {
|
||||||
@ -76,7 +79,6 @@ class EventRepository(val context: Context) {
|
|||||||
|
|
||||||
fun goToPreviousEvent() {
|
fun goToPreviousEvent() {
|
||||||
val eventList = getEvents()
|
val eventList = getEvents()
|
||||||
|
|
||||||
if (eventList.isNotEmpty()) {
|
if (eventList.isNotEmpty()) {
|
||||||
val index = eventList.indexOfFirst { it.id == Preferences.nextEventId }
|
val index = eventList.indexOfFirst { it.id == Preferences.nextEventId }
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
@ -91,7 +93,14 @@ class EventRepository(val context: Context) {
|
|||||||
MainWidget.updateWidget(context)
|
MainWidget.updateWidget(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEvents(): RealmResults<Event> = realm.where(Event::class.java).greaterThan("endDate", Calendar.getInstance().timeInMillis + 60 * 1000).findAll()
|
fun getEvents(): RealmResults<Event> {
|
||||||
|
val now = Calendar.getInstance().timeInMillis
|
||||||
|
val list = realm.where(Event::class.java).greaterThan("endDate", now).findAll()
|
||||||
|
realm.executeTransactionAsync {
|
||||||
|
it.where(Event::class.java).lessThanOrEqualTo("endDate", now).findAll().deleteAllFromRealm()
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
fun getEventsCount(): Int = getEvents().size
|
fun getEventsCount(): Int = getEvents().size
|
||||||
}
|
}
|
@ -14,4 +14,12 @@ object Constants {
|
|||||||
MEDIUM(2),
|
MEDIUM(2),
|
||||||
LARGE(3)
|
LARGE(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class GlanceProviderId(val id: String) {
|
||||||
|
PLAYING_SONG("PLAYING_SONG"),
|
||||||
|
NEXT_CLOCK_ALARM("NEXT_CLOCK_ALARM"),
|
||||||
|
// BATTERY_LEVEL_LOW("BATTERY_LEVEL_LOW"),
|
||||||
|
// CUSTOM_INFO("CUSTOM_INFO"),
|
||||||
|
// GOOGLE_FIT_STEPS("GOOGLE_FIT_STEPS")
|
||||||
|
}
|
||||||
}
|
}
|
@ -76,6 +76,7 @@ object Preferences : KotprefModel() {
|
|||||||
|
|
||||||
// Glance
|
// Glance
|
||||||
var showGlance by booleanPref(default = true)
|
var showGlance by booleanPref(default = true)
|
||||||
|
var enabledGlanceProviderOrder by stringPref(default = "")
|
||||||
var customInfo by stringPref(default = "")
|
var customInfo by stringPref(default = "")
|
||||||
var showNextAlarm by booleanPref(default = false)
|
var showNextAlarm by booleanPref(default = false)
|
||||||
var isBatteryLevelLow by booleanPref(default = false)
|
var isBatteryLevelLow by booleanPref(default = false)
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.tommasoberlose.anotherwidget.helpers
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.tommasoberlose.anotherwidget.R
|
||||||
|
import com.tommasoberlose.anotherwidget.global.Constants
|
||||||
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
|
import com.tommasoberlose.anotherwidget.models.GlanceProvider
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
object GlanceProviderHelper {
|
||||||
|
fun getGlanceProviders(): ArrayList<Constants.GlanceProviderId> {
|
||||||
|
val enabledProviders = Preferences.enabledGlanceProviderOrder.split(",").filter { it != "" }
|
||||||
|
val providers = Constants.GlanceProviderId.values()
|
||||||
|
|
||||||
|
providers.sortWith(Comparator { p1, p2 ->
|
||||||
|
when {
|
||||||
|
enabledProviders.contains(p1.id) && enabledProviders.contains(p2.id) -> {
|
||||||
|
enabledProviders.indexOf(p1.id).compareTo(enabledProviders.indexOf(p2.id))
|
||||||
|
}
|
||||||
|
enabledProviders.contains(p1.id) -> {
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
enabledProviders.contains(p2.id) -> {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
p1.id.compareTo(p2.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return ArrayList(providers.toList())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGlanceProviderById(context: Context, providerId: Constants.GlanceProviderId): GlanceProvider? {
|
||||||
|
return when(providerId) {
|
||||||
|
Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> {
|
||||||
|
GlanceProvider(providerId.id,
|
||||||
|
context.getString(R.string.settings_show_next_alarm_title),
|
||||||
|
R.drawable.round_alarm,
|
||||||
|
context.getString(R.string.settings_show_next_alarm_subtitle)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Constants.GlanceProviderId.PLAYING_SONG -> {
|
||||||
|
GlanceProvider(providerId.id,
|
||||||
|
context.getString(R.string.settings_show_music_title),
|
||||||
|
R.drawable.round_music_note,
|
||||||
|
context.getString(R.string.settings_show_music_enabled_subtitle)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// Constants.GlanceProviderId.CUSTOM_INFO -> {
|
||||||
|
// GlanceProvider(providerId.id,
|
||||||
|
// context.getString(R.string.settings_show_next_alarm_title),
|
||||||
|
// R.drawable.round_event_note
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> {
|
||||||
|
// GlanceProvider(providerId.id,
|
||||||
|
// context.getString(R.string.settings_show_next_alarm_title),
|
||||||
|
// R.drawable.round_battery_charging_full
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
|
||||||
|
// GlanceProvider(providerId.id,
|
||||||
|
// context.getString(R.string.settings_show_next_alarm_title),
|
||||||
|
// R.drawable.round_directions_walk
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveGlanceProviderOrder(list: ArrayList<Constants.GlanceProviderId>) {
|
||||||
|
Preferences.enabledGlanceProviderOrder = list.joinToString(separator = ",")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.tommasoberlose.anotherwidget.models
|
||||||
|
|
||||||
|
class GlanceProvider(
|
||||||
|
val id: String,
|
||||||
|
val title: String,
|
||||||
|
val icon: Int,
|
||||||
|
val label: String = "",
|
||||||
|
val enabled: Boolean = false,
|
||||||
|
val isPermissionRequired: Boolean = false,
|
||||||
|
val isPermissionGranted: (() -> Boolean)? = null,
|
||||||
|
val requestPermission: (() -> Unit)? = null
|
||||||
|
)
|
@ -32,7 +32,6 @@ class UpdatesReceiver : BroadcastReceiver() {
|
|||||||
Intent.ACTION_DATE_CHANGED,
|
Intent.ACTION_DATE_CHANGED,
|
||||||
AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED,
|
AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED,
|
||||||
Actions.ACTION_TIME_UPDATE -> {
|
Actions.ACTION_TIME_UPDATE -> {
|
||||||
Log.d("ciao", "arrivata notifica")
|
|
||||||
MainWidget.updateWidget(context)
|
MainWidget.updateWidget(context)
|
||||||
if (intent.hasExtra(EVENT_ID)) {
|
if (intent.hasExtra(EVENT_ID)) {
|
||||||
setUpdates(context, intent.getLongExtra(EVENT_ID, -1))
|
setUpdates(context, intent.getLongExtra(EVENT_ID, -1))
|
||||||
@ -69,7 +68,6 @@ class UpdatesReceiver : BroadcastReceiver() {
|
|||||||
val diff = Period(now.timeInMillis, event.startDate)
|
val diff = Period(now.timeInMillis, event.startDate)
|
||||||
if (event.startDate > now.timeInMillis) {
|
if (event.startDate > now.timeInMillis) {
|
||||||
// Update the widget every hour till the event
|
// Update the widget every hour till the event
|
||||||
Log.d("ciao", "${event.title} hours: ${diff.hours} - ${diff.minutes}")
|
|
||||||
setExactAndAllowWhileIdle(
|
setExactAndAllowWhileIdle(
|
||||||
AlarmManager.RTC,
|
AlarmManager.RTC,
|
||||||
if (event.startDate - diff.hours * 1000 * 60 * 60 > (now.timeInMillis + 120 * 1000)) event.startDate - diff.hours * 1000 * 60 * 60 else now.timeInMillis + 120000,
|
if (event.startDate - diff.hours * 1000 * 60 * 60 > (now.timeInMillis + 120 * 1000)) event.startDate - diff.hours * 1000 * 60 * 60 else now.timeInMillis + 120000,
|
||||||
@ -85,10 +83,6 @@ class UpdatesReceiver : BroadcastReceiver() {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// Update the widget one second after the event is finished
|
// Update the widget one second after the event is finished
|
||||||
Log.d(
|
|
||||||
"ciao",
|
|
||||||
"${event.title} end: ${Date(if (event.endDate > now.timeInMillis + 120 * 1000) event.endDate else now.timeInMillis + 120000)}"
|
|
||||||
)
|
|
||||||
val fireTime =
|
val fireTime =
|
||||||
if (event.endDate > now.timeInMillis + 120 * 1000) event.endDate else now.timeInMillis + 120000
|
if (event.endDate > now.timeInMillis + 120 * 1000) event.endDate else now.timeInMillis + 120000
|
||||||
setExactAndAllowWhileIdle(
|
setExactAndAllowWhileIdle(
|
||||||
|
@ -10,26 +10,36 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||||
import com.tommasoberlose.anotherwidget.R
|
import com.tommasoberlose.anotherwidget.R
|
||||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||||
import com.tommasoberlose.anotherwidget.databinding.FragmentGlanceSettingsBinding
|
import com.tommasoberlose.anotherwidget.databinding.FragmentGlanceSettingsBinding
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.helpers.AlarmHelper
|
import com.tommasoberlose.anotherwidget.helpers.AlarmHelper
|
||||||
|
import com.tommasoberlose.anotherwidget.helpers.GlanceProviderHelper
|
||||||
import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper
|
import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper
|
||||||
|
import com.tommasoberlose.anotherwidget.models.GlanceProvider
|
||||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_glance_settings.*
|
import kotlinx.android.synthetic.main.fragment_glance_settings.*
|
||||||
import kotlinx.android.synthetic.main.fragment_glance_settings.scrollView
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.lang.Exception
|
import net.idik.lib.slimadapter.SlimAdapter
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class GlanceTabFragment : Fragment() {
|
class GlanceTabFragment : Fragment() {
|
||||||
|
|
||||||
@ -38,6 +48,7 @@ class GlanceTabFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var viewModel: MainViewModel
|
private lateinit var viewModel: MainViewModel
|
||||||
|
private lateinit var adapter: SlimAdapter
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -62,6 +73,65 @@ class GlanceTabFragment : Fragment() {
|
|||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
list.setHasFixedSize(true)
|
||||||
|
val mLayoutManager = LinearLayoutManager(requireContext())
|
||||||
|
list.layoutManager = mLayoutManager
|
||||||
|
|
||||||
|
adapter = SlimAdapter.create()
|
||||||
|
adapter
|
||||||
|
.register<String>(R.layout.glance_provider_item) { item, injector ->
|
||||||
|
injector
|
||||||
|
.text(R.id.title, item)
|
||||||
|
}
|
||||||
|
.register<GlanceProvider>(R.layout.glance_provider_item) { item, injector ->
|
||||||
|
injector
|
||||||
|
.text(R.id.title, item.title)
|
||||||
|
.with<ImageView>(R.id.icon) {
|
||||||
|
it.setImageDrawable(ContextCompat.getDrawable(requireContext(), item.icon))
|
||||||
|
}
|
||||||
|
.with<TextView>(R.id.label) {
|
||||||
|
it.isVisible = item.label != ""
|
||||||
|
it.text = item.label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.attachTo(list)
|
||||||
|
|
||||||
|
adapter.updateData(
|
||||||
|
GlanceProviderHelper.getGlanceProviders()
|
||||||
|
.mapNotNull { GlanceProviderHelper.getGlanceProviderById(requireContext(), it) }
|
||||||
|
)
|
||||||
|
|
||||||
|
val mIth = ItemTouchHelper(
|
||||||
|
object : ItemTouchHelper.SimpleCallback(
|
||||||
|
ItemTouchHelper.UP or ItemTouchHelper.DOWN,
|
||||||
|
ItemTouchHelper.LEFT
|
||||||
|
) {
|
||||||
|
override fun onMove(
|
||||||
|
recyclerView: RecyclerView,
|
||||||
|
viewHolder: ViewHolder, target: ViewHolder
|
||||||
|
): Boolean {
|
||||||
|
val fromPos = viewHolder.adapterPosition
|
||||||
|
val toPos = target.adapterPosition
|
||||||
|
// move item in `fromPos` to `toPos` in adapter.
|
||||||
|
adapter.notifyItemMoved(fromPos, toPos)
|
||||||
|
|
||||||
|
val list = GlanceProviderHelper.getGlanceProviders()
|
||||||
|
Collections.swap(list, fromPos, toPos)
|
||||||
|
GlanceProviderHelper.saveGlanceProviderOrder(list)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSwiped(
|
||||||
|
viewHolder: ViewHolder,
|
||||||
|
direction: Int
|
||||||
|
) {
|
||||||
|
// remove from adapter
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
mIth.attachToRecyclerView(list)
|
||||||
|
|
||||||
|
|
||||||
setupListener()
|
setupListener()
|
||||||
updateNextAlarmWarningUi()
|
updateNextAlarmWarningUi()
|
||||||
}
|
}
|
||||||
@ -71,29 +141,57 @@ class GlanceTabFragment : Fragment() {
|
|||||||
viewModel: MainViewModel
|
viewModel: MainViewModel
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// viewModel.showMusic.observe(viewLifecycleOwner, Observer {
|
viewModel.showGlance.observe(viewLifecycleOwner, Observer {
|
||||||
// checkNotificationPermission()
|
binding.isGlanceVisible = it
|
||||||
// })
|
})
|
||||||
//
|
|
||||||
// viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
|
viewModel.showMusic.observe(viewLifecycleOwner, Observer {
|
||||||
// updateNextAlarmWarningUi()
|
checkNotificationPermission()
|
||||||
// })
|
})
|
||||||
|
|
||||||
|
viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
|
||||||
|
updateNextAlarmWarningUi()
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListener() {
|
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_glance.setOnClickListener {
|
||||||
|
Preferences.showGlance = !Preferences.showGlance
|
||||||
|
}
|
||||||
|
|
||||||
|
show_glance_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
|
||||||
|
Preferences.showGlance = enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
action_show_music.setOnClickListener {
|
||||||
|
if (Preferences.showGlance) {
|
||||||
|
BottomSheetMenu<Boolean>(
|
||||||
|
requireContext(),
|
||||||
|
header = getString(R.string.settings_show_music_title)
|
||||||
|
).setSelectedValue(Preferences.showMusic)
|
||||||
|
.addItem(getString(R.string.settings_visible), true)
|
||||||
|
.addItem(getString(R.string.settings_not_visible), false)
|
||||||
|
.addOnSelectItemListener { value ->
|
||||||
|
Preferences.showMusic = value
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
action_show_next_alarm.setOnClickListener {
|
||||||
|
if (Preferences.showGlance) {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateNextAlarmWarningUi() {
|
private fun updateNextAlarmWarningUi() {
|
||||||
@ -106,7 +204,10 @@ class GlanceTabFragment : Fragment() {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
alarm.showIntent?.creatorPackage ?: ""
|
alarm.showIntent?.creatorPackage ?: ""
|
||||||
}
|
}
|
||||||
show_next_alarm_warning.text = getString(R.string.next_alarm_warning).format(appNameOrPackage)
|
maintainScrollPosition {
|
||||||
|
show_next_alarm_warning.text =
|
||||||
|
getString(R.string.next_alarm_warning).format(appNameOrPackage)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
maintainScrollPosition {
|
maintainScrollPosition {
|
||||||
show_next_alarm_label?.text = if (Preferences.showNextAlarm) getString(R.string.settings_visible) else getString(
|
show_next_alarm_label?.text = if (Preferences.showNextAlarm) getString(R.string.settings_visible) else getString(
|
||||||
|
@ -242,8 +242,8 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget_loader.animate().scaleX(0f).scaleY(0f).alpha(0f).setDuration(200L).start()
|
||||||
bitmap_container.setImageBitmap(bitmap)
|
bitmap_container.setImageBitmap(bitmap)
|
||||||
widget_loader.animate().scaleX(0f).scaleY(0f).start()
|
|
||||||
widget.animate().alpha(1f).start()
|
widget.animate().alpha(1f).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,8 @@ class MainViewModel : ViewModel() {
|
|||||||
|
|
||||||
// Glance
|
// Glance
|
||||||
val showGlance = Preferences.asLiveData(Preferences::showGlance)
|
val showGlance = Preferences.asLiveData(Preferences::showGlance)
|
||||||
|
val showMusic = Preferences.asLiveData(Preferences::showMusic)
|
||||||
|
val showNextAlarm = Preferences.asLiveData(Preferences::showNextAlarm)
|
||||||
|
|
||||||
// Advanced Settings
|
// Advanced Settings
|
||||||
val darkThemePreference = Preferences.asLiveData(Preferences::darkThemePreference)
|
val darkThemePreference = Preferences.asLiveData(Preferences::darkThemePreference)
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/round_battery_charging_full.png
Normal file
After Width: | Height: | Size: 426 B |
After Width: | Height: | Size: 238 B |
After Width: | Height: | Size: 263 B |
After Width: | Height: | Size: 355 B |
BIN
app/src/main/res/drawable-hdpi/round_collections_bookmark.png
Normal file
After Width: | Height: | Size: 231 B |
After Width: | Height: | Size: 241 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 409 B |
BIN
app/src/main/res/drawable-hdpi/round_directions_walk.png
Normal file
After Width: | Height: | Size: 705 B |
After Width: | Height: | Size: 318 B |
After Width: | Height: | Size: 407 B |
After Width: | Height: | Size: 561 B |
BIN
app/src/main/res/drawable-hdpi/round_dynamic_feed.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
app/src/main/res/drawable-hdpi/round_dynamic_feed_black_18.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
app/src/main/res/drawable-hdpi/round_dynamic_feed_black_36.png
Normal file
After Width: | Height: | Size: 325 B |
BIN
app/src/main/res/drawable-hdpi/round_dynamic_feed_black_48.png
Normal file
After Width: | Height: | Size: 363 B |
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 140 B |
After Width: | Height: | Size: 196 B |
After Width: | Height: | Size: 215 B |
BIN
app/src/main/res/drawable-hdpi/round_hourglass_empty.png
Normal file
After Width: | Height: | Size: 282 B |
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 389 B |
After Width: | Height: | Size: 485 B |
BIN
app/src/main/res/drawable-hdpi/round_landscape.png
Normal file
After Width: | Height: | Size: 220 B |
BIN
app/src/main/res/drawable-hdpi/round_landscape_black_24.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
app/src/main/res/drawable-hdpi/round_landscape_black_36.png
Normal file
After Width: | Height: | Size: 341 B |
BIN
app/src/main/res/drawable-hdpi/round_landscape_black_48.png
Normal file
After Width: | Height: | Size: 398 B |
BIN
app/src/main/res/drawable-hdpi/round_leak_add.png
Normal file
After Width: | Height: | Size: 540 B |
BIN
app/src/main/res/drawable-hdpi/round_leak_add_black_18.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
app/src/main/res/drawable-hdpi/round_leak_add_black_36.png
Normal file
After Width: | Height: | Size: 806 B |
BIN
app/src/main/res/drawable-hdpi/round_leak_add_black_48.png
Normal file
After Width: | Height: | Size: 982 B |
BIN
app/src/main/res/drawable-mdpi/round_battery_charging_full.png
Normal file
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 177 B |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 263 B |
BIN
app/src/main/res/drawable-mdpi/round_collections_bookmark.png
Normal file
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 172 B |
After Width: | Height: | Size: 241 B |
After Width: | Height: | Size: 288 B |
BIN
app/src/main/res/drawable-mdpi/round_directions_walk.png
Normal file
After Width: | Height: | Size: 485 B |
After Width: | Height: | Size: 251 B |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 407 B |
BIN
app/src/main/res/drawable-mdpi/round_dynamic_feed.png
Normal file
After Width: | Height: | Size: 166 B |
BIN
app/src/main/res/drawable-mdpi/round_dynamic_feed_black_18.png
Normal file
After Width: | Height: | Size: 193 B |
BIN
app/src/main/res/drawable-mdpi/round_dynamic_feed_black_36.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
app/src/main/res/drawable-mdpi/round_dynamic_feed_black_48.png
Normal file
After Width: | Height: | Size: 261 B |
After Width: | Height: | Size: 120 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 140 B |
After Width: | Height: | Size: 153 B |
BIN
app/src/main/res/drawable-mdpi/round_hourglass_empty.png
Normal file
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 337 B |
BIN
app/src/main/res/drawable-mdpi/round_landscape.png
Normal file
After Width: | Height: | Size: 177 B |
BIN
app/src/main/res/drawable-mdpi/round_landscape_black_24.png
Normal file
After Width: | Height: | Size: 195 B |
BIN
app/src/main/res/drawable-mdpi/round_landscape_black_36.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
app/src/main/res/drawable-mdpi/round_landscape_black_48.png
Normal file
After Width: | Height: | Size: 309 B |
BIN
app/src/main/res/drawable-mdpi/round_leak_add.png
Normal file
After Width: | Height: | Size: 364 B |
BIN
app/src/main/res/drawable-mdpi/round_leak_add_black_18.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
app/src/main/res/drawable-mdpi/round_leak_add_black_36.png
Normal file
After Width: | Height: | Size: 540 B |
BIN
app/src/main/res/drawable-mdpi/round_leak_add_black_48.png
Normal file
After Width: | Height: | Size: 675 B |
BIN
app/src/main/res/drawable-xhdpi/round_battery_charging_full.png
Normal file
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 263 B |
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 426 B |
BIN
app/src/main/res/drawable-xhdpi/round_collections_bookmark.png
Normal file
After Width: | Height: | Size: 241 B |
After Width: | Height: | Size: 288 B |
After Width: | Height: | Size: 409 B |
After Width: | Height: | Size: 537 B |
BIN
app/src/main/res/drawable-xhdpi/round_directions_walk.png
Normal file
After Width: | Height: | Size: 908 B |
After Width: | Height: | Size: 407 B |
After Width: | Height: | Size: 485 B |
After Width: | Height: | Size: 705 B |
BIN
app/src/main/res/drawable-xhdpi/round_dynamic_feed.png
Normal file
After Width: | Height: | Size: 261 B |
BIN
app/src/main/res/drawable-xhdpi/round_dynamic_feed_black_18.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
app/src/main/res/drawable-xhdpi/round_dynamic_feed_black_36.png
Normal file
After Width: | Height: | Size: 363 B |
BIN
app/src/main/res/drawable-xhdpi/round_dynamic_feed_black_48.png
Normal file
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 140 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 215 B |
After Width: | Height: | Size: 257 B |
BIN
app/src/main/res/drawable-xhdpi/round_hourglass_empty.png
Normal file
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 485 B |
After Width: | Height: | Size: 584 B |