Gix switcher, update glance, add glance order, add ampm toggle
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 81
|
versionCode 83
|
||||||
versionName "2.0.6"
|
versionName "2.0.6"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
@ -146,6 +146,17 @@
|
|||||||
<action android:name="android.service.notification.NotificationListenerService" />
|
<action android:name="android.service.notification.NotificationListenerService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<receiver android:name=".receivers.BatteryLevelReceiver"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
|
||||||
|
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
|
||||||
|
<action android:name="android.intent.action.BATTERY_LOW"/>
|
||||||
|
<action android:name="android.intent.action.BATTERY_OKAY"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.tommasoberlose.anotherwidget.components
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.tommasoberlose.anotherwidget.R
|
||||||
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
|
import kotlinx.android.synthetic.main.custom_notes_dialog_layout.view.*
|
||||||
|
|
||||||
|
class CustomNotesDialog(context: Context) : BottomSheetDialog(context, R.style.BottomSheetDialogTheme) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
val view = View.inflate(context, R.layout.custom_notes_dialog_layout, null)
|
||||||
|
view.notes.setText(Preferences.customNotes)
|
||||||
|
|
||||||
|
view.action_positive.setOnClickListener {
|
||||||
|
Preferences.customNotes = view.notes.text.toString()
|
||||||
|
this.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
view.notes.requestFocus()
|
||||||
|
|
||||||
|
setContentView(view)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package com.tommasoberlose.anotherwidget.components
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
|
import com.google.android.material.card.MaterialCardView
|
||||||
|
import com.tommasoberlose.anotherwidget.R
|
||||||
|
import com.tommasoberlose.anotherwidget.helpers.ColorHelper.isColorDark
|
||||||
|
import com.tommasoberlose.anotherwidget.helpers.GlanceProviderHelper
|
||||||
|
import com.tommasoberlose.anotherwidget.models.GlanceProvider
|
||||||
|
import kotlinx.android.synthetic.main.glance_provider_sort_bottom_menu.view.*
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import net.idik.lib.slimadapter.SlimAdapter
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
class GlanceProviderSortMenu(
|
||||||
|
context: Context
|
||||||
|
) : BottomSheetDialog(context, R.style.BottomSheetDialogTheme) {
|
||||||
|
|
||||||
|
private lateinit var adapter: SlimAdapter
|
||||||
|
|
||||||
|
override fun show() {
|
||||||
|
val view = View.inflate(context, R.layout.glance_provider_sort_bottom_menu, null)
|
||||||
|
|
||||||
|
// Header
|
||||||
|
view.header_text.text = context.getString(R.string.settings_sort_glance_providers_title)
|
||||||
|
|
||||||
|
// List
|
||||||
|
adapter = SlimAdapter.create()
|
||||||
|
|
||||||
|
view.menu.setHasFixedSize(true)
|
||||||
|
val mLayoutManager = LinearLayoutManager(context)
|
||||||
|
view.menu.layoutManager = mLayoutManager
|
||||||
|
|
||||||
|
adapter = SlimAdapter.create()
|
||||||
|
adapter
|
||||||
|
.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(context, item.icon))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.attachTo(view.menu)
|
||||||
|
|
||||||
|
val mIth = ItemTouchHelper(
|
||||||
|
object : ItemTouchHelper.SimpleCallback(
|
||||||
|
ItemTouchHelper.UP or ItemTouchHelper.DOWN,
|
||||||
|
ItemTouchHelper.LEFT
|
||||||
|
) {
|
||||||
|
override fun onMove(
|
||||||
|
recyclerView: RecyclerView,
|
||||||
|
viewHolder: RecyclerView.ViewHolder, target: RecyclerView.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: RecyclerView.ViewHolder,
|
||||||
|
direction: Int
|
||||||
|
) {
|
||||||
|
// remove from adapter
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
mIth.attachToRecyclerView(view.menu)
|
||||||
|
|
||||||
|
adapter.updateData(
|
||||||
|
GlanceProviderHelper.getGlanceProviders()
|
||||||
|
.mapNotNull { GlanceProviderHelper.getGlanceProviderById(context, it) }
|
||||||
|
)
|
||||||
|
|
||||||
|
setContentView(view)
|
||||||
|
super.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,7 +39,7 @@ class EventRepository(val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveNextEventData(event: Event) {
|
fun saveNextEventData(event: Event) {
|
||||||
Preferences.nextEventId = event.id
|
Preferences.nextEventId = event.eventID
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNextEvent(): Event? {
|
fun getNextEvent(): Event? {
|
||||||
@ -64,11 +64,11 @@ class EventRepository(val context: Context) {
|
|||||||
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.eventID == Preferences.nextEventId }
|
||||||
if (index > -1 && index < eventList.size - 1) {
|
if (index > -1 && index < eventList.size - 1) {
|
||||||
Preferences.nextEventId = eventList[index + 1]!!.id
|
Preferences.nextEventId = eventList[index + 1]!!.eventID
|
||||||
} else {
|
} else {
|
||||||
Preferences.nextEventId = eventList.first()!!.id
|
Preferences.nextEventId = eventList.first()!!.eventID
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resetNextEventData()
|
resetNextEventData()
|
||||||
@ -80,11 +80,11 @@ 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.eventID == Preferences.nextEventId }
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
Preferences.nextEventId = eventList[index - 1]!!.id
|
Preferences.nextEventId = eventList[index - 1]!!.eventID
|
||||||
} else {
|
} else {
|
||||||
Preferences.nextEventId = eventList.last()!!.id
|
Preferences.nextEventId = eventList.last()!!.eventID
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resetNextEventData()
|
resetNextEventData()
|
||||||
@ -95,11 +95,7 @@ class EventRepository(val context: Context) {
|
|||||||
|
|
||||||
fun getEvents(): RealmResults<Event> {
|
fun getEvents(): RealmResults<Event> {
|
||||||
val now = Calendar.getInstance().timeInMillis
|
val now = Calendar.getInstance().timeInMillis
|
||||||
val list = realm.where(Event::class.java).greaterThan("endDate", now).findAll()
|
return 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
|
||||||
|
@ -19,7 +19,7 @@ object Constants {
|
|||||||
PLAYING_SONG("PLAYING_SONG"),
|
PLAYING_SONG("PLAYING_SONG"),
|
||||||
NEXT_CLOCK_ALARM("NEXT_CLOCK_ALARM"),
|
NEXT_CLOCK_ALARM("NEXT_CLOCK_ALARM"),
|
||||||
// BATTERY_LEVEL_LOW("BATTERY_LEVEL_LOW"),
|
// BATTERY_LEVEL_LOW("BATTERY_LEVEL_LOW"),
|
||||||
// CUSTOM_INFO("CUSTOM_INFO"),
|
CUSTOM_INFO("CUSTOM_INFO"),
|
||||||
// GOOGLE_FIT_STEPS("GOOGLE_FIT_STEPS")
|
// GOOGLE_FIT_STEPS("GOOGLE_FIT_STEPS")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,6 +48,7 @@ object Preferences : KotprefModel() {
|
|||||||
|
|
||||||
var clockTextColor by stringPref(default = "#FFFFFF")
|
var clockTextColor by stringPref(default = "#FFFFFF")
|
||||||
var clockTextAlpha by stringPref(default = "FF")
|
var clockTextAlpha by stringPref(default = "FF")
|
||||||
|
var showAMPMIndicator by booleanPref(default = true)
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
var textMainSize by floatPref(key = "PREF_TEXT_MAIN_SIZE", default = 26f)
|
var textMainSize by floatPref(key = "PREF_TEXT_MAIN_SIZE", default = 26f)
|
||||||
@ -77,8 +78,9 @@ object Preferences : KotprefModel() {
|
|||||||
// Glance
|
// Glance
|
||||||
var showGlance by booleanPref(default = true)
|
var showGlance by booleanPref(default = true)
|
||||||
var enabledGlanceProviderOrder by stringPref(default = "")
|
var enabledGlanceProviderOrder by stringPref(default = "")
|
||||||
var customInfo by stringPref(default = "")
|
var customNotes by stringPref(default = "")
|
||||||
var showNextAlarm by booleanPref(default = false)
|
var showNextAlarm by booleanPref(default = true)
|
||||||
|
var showBatteryCharging by booleanPref(default = false)
|
||||||
var isBatteryLevelLow by booleanPref(default = false)
|
var isBatteryLevelLow by booleanPref(default = false)
|
||||||
var googleFitSteps by longPref(default = -1)
|
var googleFitSteps by longPref(default = -1)
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.tommasoberlose.anotherwidget.helpers
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.tommasoberlose.anotherwidget.R
|
import com.tommasoberlose.anotherwidget.R
|
||||||
|
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||||
import com.tommasoberlose.anotherwidget.global.Constants
|
import com.tommasoberlose.anotherwidget.global.Constants
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.models.GlanceProvider
|
import com.tommasoberlose.anotherwidget.models.GlanceProvider
|
||||||
@ -37,40 +38,47 @@ object GlanceProviderHelper {
|
|||||||
Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> {
|
Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> {
|
||||||
GlanceProvider(providerId.id,
|
GlanceProvider(providerId.id,
|
||||||
context.getString(R.string.settings_show_next_alarm_title),
|
context.getString(R.string.settings_show_next_alarm_title),
|
||||||
R.drawable.round_alarm,
|
R.drawable.round_alarm
|
||||||
context.getString(R.string.settings_show_next_alarm_subtitle)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Constants.GlanceProviderId.PLAYING_SONG -> {
|
Constants.GlanceProviderId.PLAYING_SONG -> {
|
||||||
GlanceProvider(providerId.id,
|
GlanceProvider(providerId.id,
|
||||||
context.getString(R.string.settings_show_music_title),
|
context.getString(R.string.settings_show_music_title),
|
||||||
R.drawable.round_music_note,
|
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_custom_notes_title),
|
||||||
|
R.drawable.round_notes
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// 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 -> {
|
// Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> {
|
||||||
// GlanceProvider(providerId.id,
|
// GlanceProvider(providerId.id,
|
||||||
// context.getString(R.string.settings_show_next_alarm_title),
|
// context.getString(R.string.settings_low_battery_level_title),
|
||||||
// R.drawable.round_battery_charging_full
|
// R.drawable.round_battery_charging_full
|
||||||
// )
|
// )
|
||||||
// }
|
// }
|
||||||
// Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
|
// Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
|
||||||
// GlanceProvider(providerId.id,
|
// GlanceProvider(providerId.id,
|
||||||
// context.getString(R.string.settings_show_next_alarm_title),
|
// context.getString(R.string.settings_daily_steps_title),
|
||||||
// R.drawable.round_directions_walk
|
// R.drawable.round_directions_walk
|
||||||
// )
|
// )
|
||||||
// }
|
// }
|
||||||
else -> null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveGlanceProviderOrder(list: ArrayList<Constants.GlanceProviderId>) {
|
fun saveGlanceProviderOrder(list: ArrayList<Constants.GlanceProviderId>) {
|
||||||
Preferences.enabledGlanceProviderOrder = list.joinToString(separator = ",")
|
Preferences.enabledGlanceProviderOrder = list.joinToString(separator = ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showSpecialWeather(context: Context): Boolean {
|
||||||
|
return EventRepository(context).getEventsCount() == 0 && (
|
||||||
|
(Preferences.showNextAlarm && AlarmHelper.getNextAlarm(context) != "") ||
|
||||||
|
(MediaPlayerHelper.isSomeonePlaying(context)) ||
|
||||||
|
(Preferences.isBatteryLevelLow) ||
|
||||||
|
(Preferences.customNotes.isNotEmpty()) ||
|
||||||
|
(Preferences.googleFitSteps > 0)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
@ -53,11 +53,4 @@ object WidgetHelper {
|
|||||||
width to second * factor
|
width to second * factor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showSpecialWeather(context: Context): Boolean {
|
|
||||||
return EventRepository(context).getEventsCount() == 0 && (
|
|
||||||
(Preferences.showNextAlarm && AlarmHelper.getNextAlarm(context) != "") ||
|
|
||||||
(MediaPlayerHelper.isSomeonePlaying(context))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,10 +3,5 @@ package com.tommasoberlose.anotherwidget.models
|
|||||||
class GlanceProvider(
|
class GlanceProvider(
|
||||||
val id: String,
|
val id: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val icon: Int,
|
val icon: Int
|
||||||
val label: String = "",
|
|
||||||
val enabled: Boolean = false,
|
|
||||||
val isPermissionRequired: Boolean = false,
|
|
||||||
val isPermissionGranted: (() -> Boolean)? = null,
|
|
||||||
val requestPermission: (() -> Unit)? = null
|
|
||||||
)
|
)
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.tommasoberlose.anotherwidget.receivers
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.BatteryManager
|
||||||
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
|
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||||
|
|
||||||
|
class BatteryLevelReceiver : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
when(intent.action) {
|
||||||
|
Intent.ACTION_BATTERY_LOW -> Preferences.isBatteryLevelLow = true
|
||||||
|
Intent.ACTION_BATTERY_OKAY -> Preferences.isBatteryLevelLow = false
|
||||||
|
}
|
||||||
|
MainWidget.updateWidget(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -129,7 +129,10 @@ class CalendarTabFragment : Fragment() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
viewModel.showNextEvent.observe(viewLifecycleOwner, Observer {
|
viewModel.showNextEvent.observe(viewLifecycleOwner, Observer {
|
||||||
show_multiple_events_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
maintainScrollPosition {
|
||||||
|
show_multiple_events_label?.text =
|
||||||
|
if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
viewModel.dateFormat.observe(viewLifecycleOwner, Observer {
|
viewModel.dateFormat.observe(viewLifecycleOwner, Observer {
|
||||||
@ -278,7 +281,7 @@ class CalendarTabFragment : Fragment() {
|
|||||||
action_show_until.setOnClickListener {
|
action_show_until.setOnClickListener {
|
||||||
if (Preferences.showEvents) {
|
if (Preferences.showEvents) {
|
||||||
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_show_until_title)).setSelectedValue(Preferences.showUntil)
|
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_show_until_title)).setSelectedValue(Preferences.showUntil)
|
||||||
intArrayOf(6,7,0,1,2).forEach {
|
intArrayOf(6,7,0,1,2,3).forEach {
|
||||||
dialog.addItem(getString(SettingsStringHelper.getShowUntilString(it)), it)
|
dialog.addItem(getString(SettingsStringHelper.getShowUntilString(it)), it)
|
||||||
}
|
}
|
||||||
dialog.addOnSelectItemListener { value ->
|
dialog.addOnSelectItemListener { value ->
|
||||||
|
@ -104,6 +104,12 @@ class ClockTabFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
viewModel.showAMPMIndicator.observe(viewLifecycleOwner, Observer {
|
||||||
|
maintainScrollPosition {
|
||||||
|
ampm_indicator_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
viewModel.clockTextColor.observe(viewLifecycleOwner, Observer {
|
viewModel.clockTextColor.observe(viewLifecycleOwner, Observer {
|
||||||
maintainScrollPosition {
|
maintainScrollPosition {
|
||||||
if (Preferences.clockTextAlpha == "00") {
|
if (Preferences.clockTextAlpha == "00") {
|
||||||
@ -168,6 +174,15 @@ class ClockTabFragment : Fragment() {
|
|||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action_ampm_indicator_size.setOnClickListener {
|
||||||
|
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_ampm_indicator_title)).setSelectedValue(Preferences.showAMPMIndicator)
|
||||||
|
.addItem(getString(R.string.settings_visible), true)
|
||||||
|
.addItem(getString(R.string.settings_not_visible), false)
|
||||||
|
.addOnSelectItemListener { value ->
|
||||||
|
Preferences.showAMPMIndicator = value
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
action_clock_text_color.setOnClickListener {
|
action_clock_text_color.setOnClickListener {
|
||||||
BottomSheetColorPicker(requireContext(),
|
BottomSheetColorPicker(requireContext(),
|
||||||
colors = colors,
|
colors = colors,
|
||||||
|
@ -148,7 +148,10 @@ class GeneralTabFragment : Fragment() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
viewModel.showDividers.observe(viewLifecycleOwner, Observer {
|
viewModel.showDividers.observe(viewLifecycleOwner, Observer {
|
||||||
show_dividers_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
maintainScrollPosition {
|
||||||
|
show_dividers_label?.text =
|
||||||
|
if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,11 +7,13 @@ import android.content.Intent
|
|||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
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.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
@ -26,6 +28,8 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
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.components.CustomNotesDialog
|
||||||
|
import com.tommasoberlose.anotherwidget.components.GlanceProviderSortMenu
|
||||||
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
|
||||||
@ -48,7 +52,6 @@ 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)
|
||||||
@ -73,65 +76,6 @@ 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()
|
||||||
}
|
}
|
||||||
@ -142,15 +86,33 @@ class GlanceTabFragment : Fragment() {
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
viewModel.showGlance.observe(viewLifecycleOwner, Observer {
|
viewModel.showGlance.observe(viewLifecycleOwner, Observer {
|
||||||
binding.isGlanceVisible = it
|
maintainScrollPosition {
|
||||||
|
binding.isGlanceVisible = it
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
viewModel.showMusic.observe(viewLifecycleOwner, Observer {
|
viewModel.showMusic.observe(viewLifecycleOwner, Observer {
|
||||||
checkNotificationPermission()
|
maintainScrollPosition {
|
||||||
|
checkNotificationPermission()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
|
viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
|
||||||
updateNextAlarmWarningUi()
|
maintainScrollPosition {
|
||||||
|
updateNextAlarmWarningUi()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
viewModel.showBatteryCharging.observe(viewLifecycleOwner, Observer {
|
||||||
|
maintainScrollPosition {
|
||||||
|
show_low_battery_level_warning_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
viewModel.customInfo.observe(viewLifecycleOwner, Observer {
|
||||||
|
maintainScrollPosition {
|
||||||
|
show_custom_notes_label?.text = if (it == "") getString(R.string.settings_not_visible) else it
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -165,6 +127,11 @@ class GlanceTabFragment : Fragment() {
|
|||||||
Preferences.showGlance = enabled
|
Preferences.showGlance = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action_sort_glance_providers.setOnClickListener {
|
||||||
|
GlanceProviderSortMenu(requireContext())
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
action_show_music.setOnClickListener {
|
action_show_music.setOnClickListener {
|
||||||
if (Preferences.showGlance) {
|
if (Preferences.showGlance) {
|
||||||
BottomSheetMenu<Boolean>(
|
BottomSheetMenu<Boolean>(
|
||||||
@ -192,6 +159,26 @@ class GlanceTabFragment : Fragment() {
|
|||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action_show_low_battery_level_warning.setOnClickListener {
|
||||||
|
if (Preferences.showGlance) {
|
||||||
|
BottomSheetMenu<Boolean>(
|
||||||
|
requireContext(),
|
||||||
|
header = getString(R.string.settings_low_battery_level_title)
|
||||||
|
).setSelectedValue(Preferences.showBatteryCharging)
|
||||||
|
.addItem(getString(R.string.settings_visible), true)
|
||||||
|
.addItem(getString(R.string.settings_not_visible), false)
|
||||||
|
.addOnSelectItemListener { value ->
|
||||||
|
Preferences.showBatteryCharging = value
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
action_show_custom_notes.setOnClickListener {
|
||||||
|
if (Preferences.showGlance) {
|
||||||
|
CustomNotesDialog(requireContext()).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateNextAlarmWarningUi() {
|
private fun updateNextAlarmWarningUi() {
|
||||||
@ -204,15 +191,11 @@ class GlanceTabFragment : Fragment() {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
alarm.showIntent?.creatorPackage ?: ""
|
alarm.showIntent?.creatorPackage ?: ""
|
||||||
}
|
}
|
||||||
maintainScrollPosition {
|
show_next_alarm_warning.text =
|
||||||
show_next_alarm_warning.text =
|
getString(R.string.next_alarm_warning).format(appNameOrPackage)
|
||||||
getString(R.string.next_alarm_warning).format(appNameOrPackage)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
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(
|
|
||||||
R.string.settings_not_visible)
|
R.string.settings_not_visible)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +220,7 @@ class GlanceTabFragment : Fragment() {
|
|||||||
if (NotificationManagerCompat.getEnabledListenerPackages(requireContext()).contains(requireContext().packageName)) {
|
if (NotificationManagerCompat.getEnabledListenerPackages(requireContext()).contains(requireContext().packageName)) {
|
||||||
notification_permission_alert?.isVisible = false
|
notification_permission_alert?.isVisible = false
|
||||||
MediaPlayerHelper.updatePlayingMediaInfo(requireContext())
|
MediaPlayerHelper.updatePlayingMediaInfo(requireContext())
|
||||||
show_music_label?.text = if (Preferences.showMusic) getString(R.string.settings_show_music_enabled_subtitle) else getString(R.string.settings_show_music_disabled_subtitle)
|
show_music_label?.text = if (Preferences.showMusic) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||||
} else if (Preferences.showMusic) {
|
} else if (Preferences.showMusic) {
|
||||||
notification_permission_alert?.isVisible = true
|
notification_permission_alert?.isVisible = true
|
||||||
show_music_label?.text = getString(R.string.settings_request_notification_access)
|
show_music_label?.text = getString(R.string.settings_request_notification_access)
|
||||||
|
@ -160,6 +160,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
TypedValue.COMPLEX_UNIT_SP,
|
TypedValue.COMPLEX_UNIT_SP,
|
||||||
Preferences.clockTextSize.toPixel(requireContext()) / 5 * 2
|
Preferences.clockTextSize.toPixel(requireContext()) / 5 * 2
|
||||||
)
|
)
|
||||||
|
time_am_pm.isVisible = Preferences.showAMPMIndicator
|
||||||
|
|
||||||
// Clock bottom margin
|
// Clock bottom margin
|
||||||
clock_bottom_margin_none.isVisible =
|
clock_bottom_margin_none.isVisible =
|
||||||
|
@ -33,6 +33,7 @@ class MainViewModel : ViewModel() {
|
|||||||
val clockTextSize = Preferences.asLiveData(Preferences::clockTextSize)
|
val clockTextSize = Preferences.asLiveData(Preferences::clockTextSize)
|
||||||
val clockTextColor = Preferences.asLiveData(Preferences::clockTextColor)
|
val clockTextColor = Preferences.asLiveData(Preferences::clockTextColor)
|
||||||
val clockTextAlpha = Preferences.asLiveData(Preferences::clockTextAlpha)
|
val clockTextAlpha = Preferences.asLiveData(Preferences::clockTextAlpha)
|
||||||
|
val showAMPMIndicator = Preferences.asLiveData(Preferences::showAMPMIndicator)
|
||||||
|
|
||||||
val clockAppName = Preferences.asLiveData(Preferences::clockAppName)
|
val clockAppName = Preferences.asLiveData(Preferences::clockAppName)
|
||||||
val dateFormat = Preferences.asLiveData(Preferences::dateFormat)
|
val dateFormat = Preferences.asLiveData(Preferences::dateFormat)
|
||||||
@ -56,6 +57,8 @@ class MainViewModel : ViewModel() {
|
|||||||
val showGlance = Preferences.asLiveData(Preferences::showGlance)
|
val showGlance = Preferences.asLiveData(Preferences::showGlance)
|
||||||
val showMusic = Preferences.asLiveData(Preferences::showMusic)
|
val showMusic = Preferences.asLiveData(Preferences::showMusic)
|
||||||
val showNextAlarm = Preferences.asLiveData(Preferences::showNextAlarm)
|
val showNextAlarm = Preferences.asLiveData(Preferences::showNextAlarm)
|
||||||
|
val showBatteryCharging = Preferences.asLiveData(Preferences::showBatteryCharging)
|
||||||
|
val customInfo = Preferences.asLiveData(Preferences::customNotes)
|
||||||
|
|
||||||
// Advanced Settings
|
// Advanced Settings
|
||||||
val darkThemePreference = Preferences.asLiveData(Preferences::darkThemePreference)
|
val darkThemePreference = Preferences.asLiveData(Preferences::darkThemePreference)
|
||||||
|
@ -261,14 +261,62 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
|
|
||||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||||
} else if (MediaPlayerHelper.isSomeonePlaying(context)) {
|
} else if (Preferences.showGlance) {
|
||||||
val musicIntent = PendingIntent.getActivity(
|
|
||||||
context,
|
|
||||||
widgetID,
|
|
||||||
IntentHelper.getMusicIntent(context),
|
|
||||||
0
|
|
||||||
)
|
loop@ for (provider:Constants.GlanceProviderId in GlanceProviderHelper.getGlanceProviders()) {
|
||||||
views.setOnClickPendingIntent(R.id.second_row_rect, musicIntent)
|
when (provider) {
|
||||||
|
Constants.GlanceProviderId.PLAYING_SONG -> {
|
||||||
|
if (MediaPlayerHelper.isSomeonePlaying(context)) {
|
||||||
|
val musicIntent = PendingIntent.getActivity(
|
||||||
|
context,
|
||||||
|
widgetID,
|
||||||
|
IntentHelper.getMusicIntent(context),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
views.setOnClickPendingIntent(R.id.second_row_rect, musicIntent)
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> {
|
||||||
|
if (Preferences.showNextAlarm && nextAlarm != "") {
|
||||||
|
val alarmIntent = PendingIntent.getActivity(
|
||||||
|
context,
|
||||||
|
widgetID,
|
||||||
|
IntentHelper.getClockIntent(context),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
views.setOnClickPendingIntent(R.id.second_row_rect, alarmIntent)
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> {
|
||||||
|
// if (Preferences.isBatteryLevelLow) {
|
||||||
|
// val alarmIntent = PendingIntent.getActivity(
|
||||||
|
// context,
|
||||||
|
// widgetID,
|
||||||
|
// IntentHelper.getClockIntent(context),
|
||||||
|
// 0
|
||||||
|
// )
|
||||||
|
// views.setOnClickPendingIntent(R.id.second_row_rect, alarmIntent)
|
||||||
|
// break@loop
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
Constants.GlanceProviderId.CUSTOM_INFO -> {
|
||||||
|
if (Preferences.customNotes.isNotEmpty()) {
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
|
||||||
|
// if (Preferences.googleFitSteps > 0) {
|
||||||
|
// break@loop
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
views.setImageViewBitmap(
|
views.setImageViewBitmap(
|
||||||
R.id.next_event_rect,
|
R.id.next_event_rect,
|
||||||
@ -279,31 +327,8 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
R.id.second_row_rect,
|
R.id.second_row_rect,
|
||||||
BitmapHelper.getBitmapFromView(v.second_row, draw = false)
|
BitmapHelper.getBitmapFromView(v.second_row, draw = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
views.setViewVisibility(R.id.second_row_rect, View.VISIBLE)
|
views.setViewVisibility(R.id.second_row_rect, View.VISIBLE)
|
||||||
|
|
||||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
|
||||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
|
||||||
views.setOnClickPendingIntent(R.id.next_event_rect, calPIntent)
|
|
||||||
} else if (Preferences.showNextAlarm && nextAlarm != "") {
|
|
||||||
val alarmIntent = PendingIntent.getActivity(
|
|
||||||
context,
|
|
||||||
widgetID,
|
|
||||||
IntentHelper.getClockIntent(context),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
views.setOnClickPendingIntent(R.id.second_row_rect, alarmIntent)
|
|
||||||
|
|
||||||
views.setImageViewBitmap(
|
|
||||||
R.id.next_event_rect,
|
|
||||||
BitmapHelper.getBitmapFromView(v.next_event, draw = false)
|
|
||||||
)
|
|
||||||
|
|
||||||
views.setImageViewBitmap(
|
|
||||||
R.id.second_row_rect,
|
|
||||||
BitmapHelper.getBitmapFromView(v.second_row, draw = false)
|
|
||||||
)
|
|
||||||
views.setViewVisibility(R.id.second_row_rect, View.VISIBLE)
|
|
||||||
|
|
||||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||||
views.setOnClickPendingIntent(R.id.next_event_rect, calPIntent)
|
views.setOnClickPendingIntent(R.id.next_event_rect, calPIntent)
|
||||||
@ -346,7 +371,7 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
BitmapHelper.getBitmapFromView(v.calendar_weather, draw = false)
|
BitmapHelper.getBitmapFromView(v.calendar_weather, draw = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WidgetHelper.showSpecialWeather(context)) {
|
if (GlanceProviderHelper.showSpecialWeather(context)) {
|
||||||
views.setViewVisibility(R.id.calendar_weather_rect, View.GONE)
|
views.setViewVisibility(R.id.calendar_weather_rect, View.GONE)
|
||||||
} else {
|
} else {
|
||||||
views.setViewVisibility(R.id.special_weather_rect, View.GONE)
|
views.setViewVisibility(R.id.special_weather_rect, View.GONE)
|
||||||
@ -394,7 +419,7 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
views.setOnClickPendingIntent(R.id.time, clockPIntent)
|
views.setOnClickPendingIntent(R.id.time, clockPIntent)
|
||||||
views.setOnClickPendingIntent(R.id.time_am_pm, clockPIntent)
|
views.setOnClickPendingIntent(R.id.time_am_pm, clockPIntent)
|
||||||
views.setViewVisibility(R.id.time, View.VISIBLE)
|
views.setViewVisibility(R.id.time, View.VISIBLE)
|
||||||
views.setViewVisibility(R.id.time_am_pm, View.VISIBLE)
|
views.setViewVisibility(R.id.time_am_pm, if (Preferences.showAMPMIndicator) View.VISIBLE else View.GONE)
|
||||||
|
|
||||||
views.setViewVisibility(
|
views.setViewVisibility(
|
||||||
R.id.clock_bottom_margin_none,
|
R.id.clock_bottom_margin_none,
|
||||||
@ -499,26 +524,69 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
|
|
||||||
v.empty_layout.visibility = View.GONE
|
v.empty_layout.visibility = View.GONE
|
||||||
v.calendar_layout.visibility = View.VISIBLE
|
v.calendar_layout.visibility = View.VISIBLE
|
||||||
} else if (MediaPlayerHelper.isSomeonePlaying(context)) {
|
} else if (Preferences.showGlance) {
|
||||||
v.second_row_icon.setImageDrawable(
|
v.second_row_icon.isVisible = true
|
||||||
ContextCompat.getDrawable(
|
loop@ for (provider:Constants.GlanceProviderId in GlanceProviderHelper.getGlanceProviders()) {
|
||||||
context,
|
when (provider) {
|
||||||
R.drawable.round_music_note
|
Constants.GlanceProviderId.PLAYING_SONG -> {
|
||||||
)
|
if (MediaPlayerHelper.isSomeonePlaying(context)) {
|
||||||
)
|
v.second_row_icon.setImageDrawable(
|
||||||
|
ContextCompat.getDrawable(
|
||||||
|
context,
|
||||||
|
R.drawable.round_music_note
|
||||||
|
)
|
||||||
|
)
|
||||||
|
v.next_event_date.text = MediaPlayerHelper.getMediaInfo()
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> {
|
||||||
|
if (Preferences.showNextAlarm && nextAlarm != "") {
|
||||||
|
v.second_row_icon.setImageDrawable(
|
||||||
|
ContextCompat.getDrawable(
|
||||||
|
context,
|
||||||
|
R.drawable.round_alarm
|
||||||
|
)
|
||||||
|
)
|
||||||
|
v.next_event_date.text = AlarmHelper.getNextAlarm(context)
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> {
|
||||||
|
// if (Preferences.isBatteryLevelLow) {
|
||||||
|
// v.second_row_icon.setImageDrawable(
|
||||||
|
// ContextCompat.getDrawable(
|
||||||
|
// context,
|
||||||
|
// R.drawable.round_battery_charging_full
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// v.next_event_date.text = context.getString(R.string.battery_low_warning)
|
||||||
|
// break@loop
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
Constants.GlanceProviderId.CUSTOM_INFO -> {
|
||||||
|
if (Preferences.customNotes.isNotEmpty()) {
|
||||||
|
v.second_row_icon.isVisible = false
|
||||||
|
v.next_event_date.text = Preferences.customNotes
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
|
||||||
|
// if (Preferences.googleFitSteps > 0) {
|
||||||
|
// v.second_row_icon.setImageDrawable(
|
||||||
|
// ContextCompat.getDrawable(
|
||||||
|
// context,
|
||||||
|
// R.drawable.round_directions_walk
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// v.next_event_date.text = ""
|
||||||
|
// break@loop
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
v.next_event.text = DateHelper.getDateText(context, now)
|
v.next_event.text = DateHelper.getDateText(context, now)
|
||||||
v.next_event_date.text = MediaPlayerHelper.getMediaInfo()
|
|
||||||
v.empty_layout.visibility = View.GONE
|
|
||||||
v.calendar_layout.visibility = View.VISIBLE
|
|
||||||
} else if (Preferences.showNextAlarm && nextAlarm != "") {
|
|
||||||
v.second_row_icon.setImageDrawable(
|
|
||||||
ContextCompat.getDrawable(
|
|
||||||
context,
|
|
||||||
R.drawable.round_alarm
|
|
||||||
)
|
|
||||||
)
|
|
||||||
v.next_event.text = DateHelper.getDateText(context, now)
|
|
||||||
v.next_event_date.text = AlarmHelper.getNextAlarm(context)
|
|
||||||
v.empty_layout.visibility = View.GONE
|
v.empty_layout.visibility = View.GONE
|
||||||
v.calendar_layout.visibility = View.VISIBLE
|
v.calendar_layout.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
@ -626,7 +694,7 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
v.calendar_temp.text = currentTemp
|
v.calendar_temp.text = currentTemp
|
||||||
v.special_temp.text = currentTemp
|
v.special_temp.text = currentTemp
|
||||||
|
|
||||||
if (WidgetHelper.showSpecialWeather(context)) {
|
if (GlanceProviderHelper.showSpecialWeather(context)) {
|
||||||
v.calendar_weather.visibility = View.GONE
|
v.calendar_weather.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
v.special_weather.visibility = View.GONE
|
v.special_weather.visibility = View.GONE
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/round_flip_to_front_black_18.png
Normal file
After Width: | Height: | Size: 244 B |
BIN
app/src/main/res/drawable-hdpi/round_flip_to_front_black_24.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
app/src/main/res/drawable-hdpi/round_flip_to_front_black_36.png
Normal file
After Width: | Height: | Size: 315 B |
BIN
app/src/main/res/drawable-hdpi/round_flip_to_front_black_48.png
Normal file
After Width: | Height: | Size: 356 B |
BIN
app/src/main/res/drawable-hdpi/round_notes.png
Normal file
After Width: | Height: | Size: 241 B |
BIN
app/src/main/res/drawable-hdpi/round_notes_black_18.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
app/src/main/res/drawable-hdpi/round_notes_black_24.png
Normal file
After Width: | Height: | Size: 181 B |
BIN
app/src/main/res/drawable-hdpi/round_notes_black_36.png
Normal file
After Width: | Height: | Size: 242 B |
BIN
app/src/main/res/drawable-hdpi/round_sort.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
app/src/main/res/drawable-hdpi/round_sort_black_18.png
Normal file
After Width: | Height: | Size: 170 B |
BIN
app/src/main/res/drawable-hdpi/round_sort_black_24.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
app/src/main/res/drawable-hdpi/round_sort_black_36.png
Normal file
After Width: | Height: | Size: 241 B |
BIN
app/src/main/res/drawable-hdpi/round_sort_by_alpha.png
Normal file
After Width: | Height: | Size: 617 B |
BIN
app/src/main/res/drawable-hdpi/round_sort_by_alpha_black_18.png
Normal file
After Width: | Height: | Size: 352 B |
BIN
app/src/main/res/drawable-hdpi/round_sort_by_alpha_black_24.png
Normal file
After Width: | Height: | Size: 454 B |
BIN
app/src/main/res/drawable-hdpi/round_sort_by_alpha_black_48.png
Normal file
After Width: | Height: | Size: 774 B |
BIN
app/src/main/res/drawable-hdpi/round_swap_vert.png
Normal file
After Width: | Height: | Size: 292 B |
BIN
app/src/main/res/drawable-hdpi/round_swap_vert_black_18.png
Normal file
After Width: | Height: | Size: 197 B |
BIN
app/src/main/res/drawable-hdpi/round_swap_vert_black_24.png
Normal file
After Width: | Height: | Size: 207 B |
BIN
app/src/main/res/drawable-hdpi/round_swap_vert_black_48.png
Normal file
After Width: | Height: | Size: 331 B |
BIN
app/src/main/res/drawable-hdpi/round_text_rotate_vertical.png
Normal file
After Width: | Height: | Size: 577 B |
After Width: | Height: | Size: 279 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 464 B |
BIN
app/src/main/res/drawable-hdpi/round_wrap_text.png
Normal file
After Width: | Height: | Size: 422 B |
BIN
app/src/main/res/drawable-hdpi/round_wrap_text_black_18.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
app/src/main/res/drawable-hdpi/round_wrap_text_black_24.png
Normal file
After Width: | Height: | Size: 278 B |
BIN
app/src/main/res/drawable-hdpi/round_wrap_text_black_36.png
Normal file
After Width: | Height: | Size: 387 B |
BIN
app/src/main/res/drawable-mdpi/round_flip_to_front_black_18.png
Normal file
After Width: | Height: | Size: 176 B |
BIN
app/src/main/res/drawable-mdpi/round_flip_to_front_black_24.png
Normal file
After Width: | Height: | Size: 157 B |
BIN
app/src/main/res/drawable-mdpi/round_flip_to_front_black_36.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
app/src/main/res/drawable-mdpi/round_flip_to_front_black_48.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
app/src/main/res/drawable-mdpi/round_notes.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
app/src/main/res/drawable-mdpi/round_notes_black_18.png
Normal file
After Width: | Height: | Size: 130 B |
BIN
app/src/main/res/drawable-mdpi/round_notes_black_24.png
Normal file
After Width: | Height: | Size: 116 B |
BIN
app/src/main/res/drawable-mdpi/round_notes_black_36.png
Normal file
After Width: | Height: | Size: 181 B |
BIN
app/src/main/res/drawable-mdpi/round_sort.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
app/src/main/res/drawable-mdpi/round_sort_black_18.png
Normal file
After Width: | Height: | Size: 125 B |
BIN
app/src/main/res/drawable-mdpi/round_sort_black_24.png
Normal file
After Width: | Height: | Size: 111 B |
BIN
app/src/main/res/drawable-mdpi/round_sort_black_36.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
app/src/main/res/drawable-mdpi/round_sort_by_alpha.png
Normal file
After Width: | Height: | Size: 454 B |
BIN
app/src/main/res/drawable-mdpi/round_sort_by_alpha_black_18.png
Normal file
After Width: | Height: | Size: 267 B |
BIN
app/src/main/res/drawable-mdpi/round_sort_by_alpha_black_24.png
Normal file
After Width: | Height: | Size: 320 B |
BIN
app/src/main/res/drawable-mdpi/round_sort_by_alpha_black_48.png
Normal file
After Width: | Height: | Size: 574 B |
BIN
app/src/main/res/drawable-mdpi/round_swap_vert.png
Normal file
After Width: | Height: | Size: 207 B |
BIN
app/src/main/res/drawable-mdpi/round_swap_vert_black_18.png
Normal file
After Width: | Height: | Size: 174 B |
BIN
app/src/main/res/drawable-mdpi/round_swap_vert_black_24.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
app/src/main/res/drawable-mdpi/round_swap_vert_black_48.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
app/src/main/res/drawable-mdpi/round_text_rotate_vertical.png
Normal file
After Width: | Height: | Size: 408 B |
After Width: | Height: | Size: 198 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 335 B |
BIN
app/src/main/res/drawable-mdpi/round_wrap_text.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
app/src/main/res/drawable-mdpi/round_wrap_text_black_18.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
app/src/main/res/drawable-mdpi/round_wrap_text_black_24.png
Normal file
After Width: | Height: | Size: 178 B |
BIN
app/src/main/res/drawable-mdpi/round_wrap_text_black_36.png
Normal file
After Width: | Height: | Size: 278 B |
BIN
app/src/main/res/drawable-xhdpi/round_flip_to_front_black_18.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
app/src/main/res/drawable-xhdpi/round_flip_to_front_black_24.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
app/src/main/res/drawable-xhdpi/round_flip_to_front_black_36.png
Normal file
After Width: | Height: | Size: 356 B |
BIN
app/src/main/res/drawable-xhdpi/round_flip_to_front_black_48.png
Normal file
After Width: | Height: | Size: 450 B |
BIN
app/src/main/res/drawable-xhdpi/round_notes.png
Normal file
After Width: | Height: | Size: 288 B |
BIN
app/src/main/res/drawable-xhdpi/round_notes_black_18.png
Normal file
After Width: | Height: | Size: 181 B |
BIN
app/src/main/res/drawable-xhdpi/round_notes_black_24.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
app/src/main/res/drawable-xhdpi/round_notes_black_36.png
Normal file
After Width: | Height: | Size: 241 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort.png
Normal file
After Width: | Height: | Size: 267 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort_black_18.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort_black_24.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort_black_36.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort_by_alpha.png
Normal file
After Width: | Height: | Size: 774 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort_by_alpha_black_18.png
Normal file
After Width: | Height: | Size: 454 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort_by_alpha_black_24.png
Normal file
After Width: | Height: | Size: 574 B |
BIN
app/src/main/res/drawable-xhdpi/round_sort_by_alpha_black_48.png
Normal file
After Width: | Height: | Size: 1001 B |
BIN
app/src/main/res/drawable-xhdpi/round_swap_vert.png
Normal file
After Width: | Height: | Size: 331 B |
BIN
app/src/main/res/drawable-xhdpi/round_swap_vert_black_18.png
Normal file
After Width: | Height: | Size: 207 B |
BIN
app/src/main/res/drawable-xhdpi/round_swap_vert_black_24.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
app/src/main/res/drawable-xhdpi/round_swap_vert_black_48.png
Normal file
After Width: | Height: | Size: 425 B |
BIN
app/src/main/res/drawable-xhdpi/round_text_rotate_vertical.png
Normal file
After Width: | Height: | Size: 766 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 408 B |
After Width: | Height: | Size: 577 B |