diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 6da653d..3cc336b 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -17,7 +17,6 @@
-
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/components/BottomSheetColorPicker.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/components/BottomSheetColorPicker.kt
index 4478aaa..740c1cb 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/components/BottomSheetColorPicker.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/components/BottomSheetColorPicker.kt
@@ -56,8 +56,6 @@ class BottomSheetColorPicker(
private var listBinding: BottomSheetMenuListBinding = BottomSheetMenuListBinding.inflate(LayoutInflater.from(context))
override fun show() {
- window?.setDimAmount(0f)
-
// Header
binding.header.isVisible = header != null
binding.headerText.text = header ?: ""
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt
index 8d7b898..a25edeb 100755
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt
@@ -111,8 +111,6 @@ object Preferences : KotprefModel() {
// Settings
var showWallpaper by booleanPref(default = true)
- var showBigClockWarning by booleanPref(default = true)
- var showWeatherWarning by booleanPref(default = true)
var showPreview by booleanPref(default = true)
var showXiaomiWarning by booleanPref(default = true)
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ColorHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ColorHelper.kt
index 439be80..36af820 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ColorHelper.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ColorHelper.kt
@@ -2,14 +2,16 @@ package com.tommasoberlose.anotherwidget.helpers
import android.annotation.SuppressLint
import android.graphics.Color
-import android.util.Log
import com.tommasoberlose.anotherwidget.global.Preferences
import kotlin.math.roundToInt
object ColorHelper {
fun getFontColor(isDark: Boolean): Int {
return try {
- Color.parseColor("#%s%s".format(if (!isDark) Preferences.textGlobalAlpha else Preferences.textGlobalAlphaDark, (if (!isDark) Preferences.textGlobalColor else Preferences.textGlobalColorDark).replace("#", "")))
+ Color.parseColor("#%s%s".format(if (!isDark) Preferences.textGlobalAlpha else Preferences.textGlobalAlphaDark,
+ (if (!isDark) Preferences.textGlobalColor else Preferences.textGlobalColorDark).replace(
+ "#",
+ "")))
} catch (e: Exception) {
Color.parseColor("#FFFFFFFF")
}
@@ -33,7 +35,10 @@ object ColorHelper {
fun getSecondaryFontColor(isDark: Boolean): Int {
return try {
- Color.parseColor("#%s%s".format((if (!isDark) Preferences.textSecondaryAlpha else Preferences.textSecondaryAlphaDark), (if (!isDark) Preferences.textSecondaryColor else Preferences.textSecondaryColorDark).replace("#", "")))
+ Color.parseColor("#%s%s".format((if (!isDark) Preferences.textSecondaryAlpha else Preferences.textSecondaryAlphaDark),
+ (if (!isDark) Preferences.textSecondaryColor else Preferences.textSecondaryColorDark).replace(
+ "#",
+ "")))
} catch (e: Exception) {
Color.parseColor("#FFFFFFFF")
}
@@ -57,7 +62,10 @@ object ColorHelper {
fun getClockFontColor(isDark: Boolean): Int {
return try {
- Color.parseColor("#%s%s".format((if (!isDark) Preferences.clockTextAlpha else Preferences.clockTextAlphaDark), (if (!isDark) Preferences.clockTextColor else Preferences.clockTextColorDark).replace("#", "")))
+ Color.parseColor("#%s%s".format((if (!isDark) Preferences.clockTextAlpha else Preferences.clockTextAlphaDark),
+ (if (!isDark) Preferences.clockTextColor else Preferences.clockTextColorDark).replace(
+ "#",
+ "")))
} catch (e: Exception) {
Color.parseColor("#FFFFFFFF")
}
@@ -81,7 +89,10 @@ object ColorHelper {
fun getBackgroundColor(isDark: Boolean): Int {
return try {
- Color.parseColor("#%s%s".format((if (!isDark) Preferences.backgroundCardAlpha else Preferences.backgroundCardAlphaDark), (if (!isDark) Preferences.backgroundCardColor else Preferences.backgroundCardColorDark).replace("#", "")))
+ Color.parseColor("#%s%s".format((if (!isDark) Preferences.backgroundCardAlpha else Preferences.backgroundCardAlphaDark),
+ (if (!isDark) Preferences.backgroundCardColor else Preferences.backgroundCardColorDark).replace(
+ "#",
+ "")))
} catch (e: Exception) {
Color.parseColor("#00000000")
}
@@ -123,4 +134,14 @@ object ColorHelper {
val hexValue = this.toInt(16).toDouble()
return (hexValue * 100 / 255).roundToInt()
}
+
+ fun String.isColor(): Boolean {
+ return try {
+ Color.parseColor(this)
+ true
+ } catch (iae: IllegalArgumentException) {
+ iae.printStackTrace()
+ false
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ImageHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ImageHelper.kt
index 0bf1b61..257115d 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ImageHelper.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ImageHelper.kt
@@ -30,7 +30,7 @@ object ImageHelper {
canvas.drawColor(Color.TRANSPARENT)
canvas.save()
val rect = Rect()
- val bounds = originalView.drawable.copyBounds()
+// val bounds = originalView.drawable.copyBounds()
canvas.getClipBounds(rect)
rect.inset(-2 * getBlurRadius(context, cElevation).toInt(), -2 * getBlurRadius(context, cElevation).toInt())
canvas.save()
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WidgetHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WidgetHelper.kt
index d87f7cc..1c12409 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WidgetHelper.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WidgetHelper.kt
@@ -25,9 +25,8 @@ object WidgetHelper {
) {
fun getWidgetsSize(widgetId: Int): Pair {
- val isPortrait = context.resources.configuration.orientation == ORIENTATION_PORTRAIT
- val width = getWidgetWidth(isPortrait, widgetId)
- val height = getWidgetHeight(isPortrait, widgetId)
+ val width = getWidgetWidth(widgetId)
+ val height = getWidgetHeight(widgetId)
val widthInPx = context.dip(width)
val heightInPx = context.dip(height)
FirebaseCrashlytics.getInstance().setCustomKey("widthInPx", widthInPx)
@@ -35,9 +34,9 @@ object WidgetHelper {
return widthInPx to heightInPx
}
- private fun getWidgetWidth(isPortrait: Boolean, widgetId: Int): Int = getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)
+ private fun getWidgetWidth(widgetId: Int): Int = getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)
- private fun getWidgetHeight(isPortrait: Boolean, widgetId: Int): Int = getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT)
+ private fun getWidgetHeight(widgetId: Int): Int = getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT)
private fun getWidgetSizeInDp(widgetId: Int, key: String): Int =
appWidgetManager.getAppWidgetOptions(widgetId).getInt(key, 0)
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt
index 59d30fc..69afc62 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt
@@ -344,7 +344,7 @@ class WeatherNetworkApi(val context: Context) {
private suspend fun useAccuweatherProvider(context: Context) {
if (Preferences.weatherProviderApiAccuweather != "") {
- val repository = AccuweatherRepository()
+// val repository = AccuweatherRepository()
// when (val response = repository.getWeather()) {
// is NetworkResponse.Success -> {
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/ActivityDetectionReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/ActivityDetectionReceiver.kt
index c3fc8a9..200deb4 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/ActivityDetectionReceiver.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/ActivityDetectionReceiver.kt
@@ -138,10 +138,8 @@ class ActivityDetectionReceiver : BroadcastReceiver() {
val endTime: Long = cal.timeInMillis
val readRequest = DataReadRequest.Builder()
- .aggregate(
- DataType.TYPE_STEP_COUNT_DELTA,
- DataType.AGGREGATE_STEP_COUNT_DELTA
- )
+ .aggregate(DataType.TYPE_STEP_COUNT_DELTA)
+ .aggregate(DataType.AGGREGATE_STEP_COUNT_DELTA)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.bucketByTime(1, TimeUnit.DAYS)
.build()
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt
index 644858b..e86d2ba 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt
@@ -41,6 +41,7 @@ class NotificationListener : NotificationListenerService() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Preferences.lastNotificationIcon = sbn.notification.smallIcon.resId
} else {
+ @Suppress("DEPRECATION")
Preferences.lastNotificationIcon = sbn.notification.icon
}
} catch (ex: Exception) {
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/IntegrationsActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/IntegrationsActivity.kt
index 0e2be6f..cdf3913 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/IntegrationsActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/IntegrationsActivity.kt
@@ -2,12 +2,11 @@ package com.tommasoberlose.anotherwidget.ui.activities.settings
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivityIntegrationsBinding
-import com.tommasoberlose.anotherwidget.ui.viewmodels.IntegrationsViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.settings.IntegrationsViewModel
import net.idik.lib.slimadapter.SlimAdapter
class IntegrationsActivity : AppCompatActivity() {
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/SupportDevActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/SupportDevActivity.kt
index 4d439ef..06d0319 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/SupportDevActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/settings/SupportDevActivity.kt
@@ -4,7 +4,6 @@ import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
@@ -13,7 +12,7 @@ import com.android.billingclient.api.BillingClient.BillingResponseCode.OK
import com.android.billingclient.api.BillingClient.BillingResponseCode.USER_CANCELED
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivitySupportDevBinding
-import com.tommasoberlose.anotherwidget.ui.viewmodels.SupportDevViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.settings.SupportDevViewModel
import com.tommasoberlose.anotherwidget.utils.toast
import net.idik.lib.slimadapter.SlimAdapter
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/AppNotificationsFilterActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/AppNotificationsFilterActivity.kt
index d993577..7b50635 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/AppNotificationsFilterActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/AppNotificationsFilterActivity.kt
@@ -6,7 +6,6 @@ import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -16,7 +15,7 @@ import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivityAppNotificationsFilterBinding
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.ActiveNotificationsHelper
-import com.tommasoberlose.anotherwidget.ui.viewmodels.AppNotificationsViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.AppNotificationsViewModel
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt
index 8c44742..cffa6e3 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt
@@ -10,7 +10,6 @@ import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -18,7 +17,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.bumptech.glide.Glide
import com.tommasoberlose.anotherwidget.databinding.ActivityChooseApplicationBinding
import com.tommasoberlose.anotherwidget.global.Constants
-import com.tommasoberlose.anotherwidget.ui.viewmodels.ChooseApplicationViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.ChooseApplicationViewModel
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
import net.idik.lib.slimadapter.SlimAdapterEx
@@ -90,15 +89,15 @@ class ChooseApplicationActivity : AppCompatActivity() {
binding.viewModel = viewModel
binding.lifecycleOwner = this
- viewModel.appList.observe(this, Observer {
+ viewModel.appList.observe(this) {
updateList(list = it)
binding.loader.visibility = View.INVISIBLE
- })
+ }
- viewModel.searchInput.observe(this, Observer { search ->
+ viewModel.searchInput.observe(this) { search ->
updateList(search = search)
binding.clearSearch.isVisible = search.isNotBlank()
- })
+ }
}
private fun updateList(list: List? = viewModel.appList.value, search: String? = viewModel.searchInput.value) {
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomDateActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomDateActivity.kt
index 783c866..f7df13f 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomDateActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomDateActivity.kt
@@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -13,7 +12,7 @@ import com.chibatching.kotpref.blockingBulk
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivityCustomDateBinding
import com.tommasoberlose.anotherwidget.global.Preferences
-import com.tommasoberlose.anotherwidget.ui.viewmodels.CustomDateViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomDateViewModel
import com.tommasoberlose.anotherwidget.utils.getCapWordString
import com.tommasoberlose.anotherwidget.utils.openURI
import com.tommasoberlose.anotherwidget.utils.toast
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomFontActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomFontActivity.kt
index 065ad75..6a8e25d 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomFontActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomFontActivity.kt
@@ -13,7 +13,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.provider.FontRequest
import androidx.core.provider.FontsContractCompat
import androidx.core.view.isVisible
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -26,7 +25,7 @@ import com.tommasoberlose.anotherwidget.databinding.ActivityCustomFontBinding
import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
-import com.tommasoberlose.anotherwidget.ui.viewmodels.CustomFontViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomFontViewModel
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
import net.idik.lib.slimadapter.diff.DefaultDiffCallback
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomLocationActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomLocationActivity.kt
index 88e5450..8be37f3 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomLocationActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/CustomLocationActivity.kt
@@ -9,7 +9,6 @@ import com.tommasoberlose.anotherwidget.R
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -22,7 +21,7 @@ import com.karumi.dexter.listener.PermissionRequest
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
import com.tommasoberlose.anotherwidget.databinding.ActivityCustomLocationBinding
import com.tommasoberlose.anotherwidget.global.Preferences
-import com.tommasoberlose.anotherwidget.ui.viewmodels.CustomLocationViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomLocationViewModel
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/MusicPlayersFilterActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/MusicPlayersFilterActivity.kt
index 46647ce..45589c1 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/MusicPlayersFilterActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/MusicPlayersFilterActivity.kt
@@ -7,7 +7,6 @@ import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
-import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -16,7 +15,7 @@ import com.bumptech.glide.Glide
import com.tommasoberlose.anotherwidget.databinding.ActivityMusicPlayersFilterBinding
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper
-import com.tommasoberlose.anotherwidget.ui.viewmodels.MusicPlayersFilterViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.MusicPlayersFilterViewModel
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
@@ -76,20 +75,20 @@ class MusicPlayersFilterActivity : AppCompatActivity() {
binding.viewModel = viewModel
binding.lifecycleOwner = this
- viewModel.appList.observe(this, Observer {
+ viewModel.appList.observe(this) {
updateList(list = it)
binding.loader.visibility = View.INVISIBLE
- })
+ }
- viewModel.searchInput.observe(this, Observer { search ->
+ viewModel.searchInput.observe(this) { search ->
updateList(search = search)
binding.clearSearch.isVisible = search.isNotBlank()
- })
+ }
- viewModel.musicPlayersFilter.observe(this, {
+ viewModel.musicPlayersFilter.observe(this) {
updateList()
binding.clearSelection.isVisible = Preferences.musicPlayersFilter != ""
- })
+ }
}
private fun updateList(list: List? = viewModel.appList.value, search: String? = viewModel.searchInput.value) {
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/WeatherProviderActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/WeatherProviderActivity.kt
index 911a993..544334f 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/WeatherProviderActivity.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/WeatherProviderActivity.kt
@@ -18,7 +18,7 @@ import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
-import com.tommasoberlose.anotherwidget.ui.viewmodels.WeatherProviderViewModel
+import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.WeatherProviderViewModel
import kotlinx.coroutines.launch
import net.idik.lib.slimadapter.SlimAdapter
import org.greenrobot.eventbus.EventBus
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt
index 41ba0b2..14b14a9 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt
@@ -119,100 +119,6 @@ class MainFragment : Fragment() {
binding.actionBack to "action_back"
))
}
- }
-
- private var uiJob: Job? = null
-
- private fun updateUI() {
- uiJob?.cancel()
-
- if (Preferences.showPreview) {
- lifecycleScope.launch(Dispatchers.IO) {
- val bgColor: Int = ContextCompat.getColor(
- requireContext(),
- if (ColorHelper.getFontColor(requireActivity().isDarkTheme())
- .isColorDark()
- ) android.R.color.white else R.color.colorAccent
- )
-
- val wallpaperDrawable = BitmapHelper.getTintedDrawable(
- requireContext(),
- R.drawable.card_background,
- ColorHelper.getBackgroundColor(requireActivity().isDarkTheme())
- )
-
- withContext(Dispatchers.Main) {
- binding.preview.setCardBackgroundColor(bgColor)
- binding.widgetDetail.widgetShapeBackground.setImageDrawable(wallpaperDrawable)
- }
- }
-
- WidgetHelper.runWithCustomTypeface(requireContext()) { typeface ->
- uiJob = lifecycleScope.launch(Dispatchers.IO) {
- val generatedView = MainWidget.generateWidgetView(requireContext(), typeface).root
-
- withContext(Dispatchers.Main) {
- generatedView.measure(0, 0)
- binding.preview.measure(0, 0)
- }
-
- val bitmap = BitmapHelper.getBitmapFromView(
- generatedView,
- if (binding.preview.width > 0) binding.preview.width else generatedView.measuredWidth,
- generatedView.measuredHeight
- )
-
- withContext(Dispatchers.Main) {
- binding.widget.animate().alpha(0f).start()
- binding.widgetLoader.animate().scaleX(1f).scaleY(1f).alpha(1f)
-
- .setDuration(200L).start()
- binding.widgetDetail.bitmapContainer.apply {
- setImageBitmap(bitmap)
- }
-
- binding.widgetLoader.animate().scaleX(0f).scaleY(0f).alpha(0f)
- .setDuration(200L).start()
- binding.widget.animate().alpha(1f).start()
- }
- }
- }
- } else {
- binding.preview.layoutParams = binding.preview.layoutParams.apply {
- height = 0
- }
- }
- }
-
- private fun updateClock() {
- // Clock
- binding.widgetDetail.time.setTextColor(ColorHelper.getClockFontColor(requireActivity().isDarkTheme()))
- binding.widgetDetail.timeAmPm.setTextColor(ColorHelper.getClockFontColor(requireActivity().isDarkTheme()))
- binding.widgetDetail.time.setTextSize(
- TypedValue.COMPLEX_UNIT_SP,
- Preferences.clockTextSize.toPixel(requireContext())
- )
- binding.widgetDetail.timeAmPm.setTextSize(
- TypedValue.COMPLEX_UNIT_SP,
- Preferences.clockTextSize.toPixel(requireContext()) / 5 * 2
- )
- binding.widgetDetail.timeAmPm.isVisible = Preferences.showAMPMIndicator
-
- // Clock bottom margin
- binding.widgetDetail.clockBottomMarginNone.isVisible =
- Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.NONE.value
- binding.widgetDetail.clockBottomMarginSmall.isVisible =
- Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.SMALL.value
- binding.widgetDetail.clockBottomMarginMedium.isVisible =
- Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.MEDIUM.value
- binding.widgetDetail.clockBottomMarginLarge.isVisible =
- Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.LARGE.value
-
- if (Preferences.showClock) {
- binding.widgetDetail.timeContainer.expand()
- } else {
- binding.widgetDetail.timeContainer.collapse()
- }
binding.preview.layoutParams = binding.preview.layoutParams.apply {
height = PREVIEW_BASE_HEIGHT.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(
@@ -272,6 +178,120 @@ class MainFragment : Fragment() {
viewModel.widgetPreferencesUpdate.observe(viewLifecycleOwner) {
onUpdateUiEvent(null)
}
+
+ viewModel.showClock.observe(viewLifecycleOwner) {
+ updateClockVisibility(it)
+ }
+ }
+
+ private var uiJob: Job? = null
+
+ private fun updateUI() {
+ uiJob?.cancel()
+
+ if (Preferences.showPreview) {
+ lifecycleScope.launch(Dispatchers.IO) {
+ val bgColor: Int = ContextCompat.getColor(
+ requireContext(),
+ if (ColorHelper.getFontColor(requireActivity().isDarkTheme())
+ .isColorDark()
+ ) android.R.color.white else R.color.colorAccent
+ )
+
+ val wallpaperDrawable = BitmapHelper.getTintedDrawable(
+ requireContext(),
+ R.drawable.card_background,
+ ColorHelper.getBackgroundColor(requireActivity().isDarkTheme())
+ )
+
+ withContext(Dispatchers.Main) {
+ binding.preview.setCardBackgroundColor(bgColor)
+ binding.widgetDetail.widgetShapeBackground.setImageDrawable(wallpaperDrawable)
+ }
+ }
+
+ WidgetHelper.runWithCustomTypeface(requireContext()) { typeface ->
+ uiJob = lifecycleScope.launch(Dispatchers.IO) {
+ val generatedView = MainWidget.generateWidgetView(requireContext(), typeface).root
+
+ withContext(Dispatchers.Main) {
+ generatedView.measure(0, 0)
+ binding.preview.measure(0, 0)
+ }
+
+ val bitmap = BitmapHelper.getBitmapFromView(
+ generatedView,
+ if (binding.preview.width > 0) binding.preview.width else generatedView.measuredWidth,
+ generatedView.measuredHeight
+ )
+
+ withContext(Dispatchers.Main) {
+ binding.widgetDetail.bitmapContainer.apply {
+ setImageBitmap(bitmap)
+ }
+
+ binding.widgetLoader.animate().scaleX(0f).scaleY(0f).alpha(0f)
+ .setDuration(200L).start()
+ binding.widget.animate().alpha(1f).start()
+ }
+ }
+ }
+ } else {
+ binding.preview.layoutParams = binding.preview.layoutParams.apply {
+ height = 0
+ }
+ }
+ }
+
+ private fun updateClock() {
+ // Clock
+ binding.widgetDetail.time.setTextColor(ColorHelper.getClockFontColor(requireActivity().isDarkTheme()))
+ binding.widgetDetail.timeAmPm.setTextColor(ColorHelper.getClockFontColor(requireActivity().isDarkTheme()))
+ binding.widgetDetail.time.setTextSize(
+ TypedValue.COMPLEX_UNIT_SP,
+ Preferences.clockTextSize.toPixel(requireContext())
+ )
+ binding.widgetDetail.timeAmPm.setTextSize(
+ TypedValue.COMPLEX_UNIT_SP,
+ Preferences.clockTextSize.toPixel(requireContext()) / 5 * 2
+ )
+ binding.widgetDetail.timeAmPm.isVisible = Preferences.showAMPMIndicator
+
+ // Clock bottom margin
+ binding.widgetDetail.clockBottomMarginNone.isVisible =
+ Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.NONE.value
+ binding.widgetDetail.clockBottomMarginSmall.isVisible =
+ Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.SMALL.value
+ binding.widgetDetail.clockBottomMarginMedium.isVisible =
+ Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.MEDIUM.value
+ binding.widgetDetail.clockBottomMarginLarge.isVisible =
+ Preferences.showClock && Preferences.clockBottomMargin == Constants.ClockBottomMargin.LARGE.value
+
+ }
+
+ private fun updateClockVisibility(showClock: Boolean) {
+ binding.preview.animation?.cancel()
+
+ val clockInitialHeight = binding.widgetDetail.timeContainer.measuredHeight.toFloat()
+ ValueAnimator.ofFloat(
+ if (Preferences.showClock) 0f else 1f,
+ if (Preferences.showClock) 1f else 0f
+ ).apply {
+ this.duration = 500L
+ addUpdateListener {
+ val animatedValue = animatedValue as Float
+
+ binding.preview.layoutParams = binding.preview.layoutParams.apply {
+ height = (PREVIEW_BASE_HEIGHT.toPixel(requireContext()) + 100.toPixel(requireContext()) * animatedValue).toInt()
+ }
+
+ binding.widgetDetail.timeContainer.layoutParams = binding.widgetDetail.timeContainer.layoutParams.apply {
+ height = (clockInitialHeight * animatedValue).toInt()
+ }
+ binding.widgetDetail.timeContainer.translationY = (clockInitialHeight * animatedValue - clockInitialHeight)
+ binding.widgetDetail.timeContainer.alpha = animatedValue
+ }
+ }.start()
}
override fun onResume() {
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/CalendarFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/CalendarFragment.kt
index b1a644a..900e15d 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/CalendarFragment.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/CalendarFragment.kt
@@ -85,7 +85,7 @@ class CalendarFragment : Fragment() {
viewModel: MainViewModel
) {
binding.isCalendarEnabled = Preferences.showEvents
- binding.isDiffEnabled = Preferences.showDiffTime || !Preferences.showEvents
+ binding.isDiffEnabled = Preferences.showDiffTime
viewModel.calendarAllDay.observe(viewLifecycleOwner) {
maintainScrollPosition {
@@ -122,7 +122,6 @@ class CalendarFragment : Fragment() {
maintainScrollPosition {
binding.showUntilLabel.text = getString(SettingsStringHelper.getShowUntilString(it))
}
- updateCalendar()
}
}
@@ -136,7 +135,7 @@ class CalendarFragment : Fragment() {
it.displayName,
it.accountName
)
- }.sortedWith(Comparator { cal1, cal2 ->
+ }.sortedWith { cal1, cal2 ->
when {
cal1.accountName != cal2.accountName -> {
cal1.accountName.compareTo(cal2.accountName)
@@ -151,7 +150,7 @@ class CalendarFragment : Fragment() {
cal1.name.compareTo(cal2.name)
}
}
- })
+ }
if (calendarSelectorList.isNotEmpty()) {
val filteredCalendarIds = CalendarHelper.getFilteredCalendarIdList()
@@ -271,6 +270,7 @@ class CalendarFragment : Fragment() {
}
dialog.addOnSelectItemListener { value ->
Preferences.showUntil = value
+ updateCalendar()
}.show()
}
}
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/GlanceTabFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/GlanceTabFragment.kt
index 0ee4733..02e5ecd 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/GlanceTabFragment.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/GlanceTabFragment.kt
@@ -13,10 +13,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.animation.AnimationUtils
+import android.view.animation.LayoutAnimationController
import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
-import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -45,8 +46,9 @@ import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
import com.tommasoberlose.anotherwidget.utils.convertDpToPixel
+import com.tommasoberlose.anotherwidget.utils.expand
+import com.tommasoberlose.anotherwidget.utils.reveal
import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
import net.idik.lib.slimadapter.SlimAdapter
@@ -78,8 +80,6 @@ class GlanceTabFragment : Fragment() {
viewModel = ViewModelProvider(activity as MainActivity).get(MainViewModel::class.java)
binding = FragmentTabGlanceBinding.inflate(inflater)
- subscribeUi(viewModel)
-
binding.lifecycleOwner = this
binding.viewModel = viewModel
@@ -90,16 +90,12 @@ class GlanceTabFragment : Fragment() {
super.onActivityCreated(savedInstanceState)
// List
- binding.providersList.setHasFixedSize(true)
+ binding.providersList.hasFixedSize()
val mLayoutManager = LinearLayoutManager(context)
binding.providersList.layoutManager = mLayoutManager
adapter = SlimAdapter.create()
adapter
- .register(R.layout.glance_providers_list_ornament) { item, injector ->
- injector.visibility(R.id.footer, if(item == "footer") View.VISIBLE else View.GONE)
- injector.visibility(R.id.header, if(item == "header") View.VISIBLE else View.GONE)
- }
.register(R.layout.glance_provider_item) { item, injector ->
val provider = Constants.GlanceProviderId.from(item.id)!!
injector
@@ -130,9 +126,12 @@ class GlanceTabFragment : Fragment() {
MediaPlayerHelper.updatePlayingMediaInfo(requireContext())
injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE)
- injector.text(R.id.label,
+ injector.text(
+ R.id.label,
if (Preferences.showMusic) getString(R.string.settings_visible) else getString(
- R.string.settings_not_visible))
+ R.string.settings_not_visible
+ )
+ )
isVisible = Preferences.showMusic
}
Preferences.showMusic -> {
@@ -150,26 +149,40 @@ class GlanceTabFragment : Fragment() {
}
}
Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> {
- injector.text(R.id.label,
+ injector.text(
+ R.id.label,
if (Preferences.showNextAlarm && !AlarmHelper.isAlarmProbablyWrong(
- requireContext())
+ requireContext()
+ )
) getString(R.string.settings_visible) else getString(
- R.string.settings_not_visible))
- injector.visibility(R.id.error_icon,
+ R.string.settings_not_visible
+ )
+ )
+ injector.visibility(
+ R.id.error_icon,
if (Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong(
- requireContext())
- ) View.VISIBLE else View.GONE)
- injector.visibility(R.id.info_icon,
+ requireContext()
+ )
+ ) View.VISIBLE else View.GONE
+ )
+ injector.visibility(
+ R.id.info_icon,
if (!(Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong(
- requireContext()))
- ) View.VISIBLE else View.GONE)
+ requireContext()
+ ))
+ ) View.VISIBLE else View.GONE
+ )
isVisible = !(Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong(
- requireContext()))
+ requireContext()
+ ))
}
Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> {
- injector.text(R.id.label,
+ injector.text(
+ R.id.label,
if (Preferences.showBatteryCharging) getString(R.string.settings_visible) else getString(
- R.string.settings_not_visible))
+ R.string.settings_not_visible
+ )
+ )
injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.showBatteryCharging
@@ -179,9 +192,12 @@ class GlanceTabFragment : Fragment() {
ActiveNotificationsHelper.checkNotificationAccess(requireContext()) -> {
injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE)
- injector.text(R.id.label,
+ injector.text(
+ R.id.label,
if (Preferences.showNotifications) getString(
- R.string.settings_visible) else getString(R.string.settings_not_visible))
+ R.string.settings_visible
+ ) else getString(R.string.settings_not_visible)
+ )
isVisible = Preferences.showNotifications
}
Preferences.showNotifications -> {
@@ -199,29 +215,44 @@ class GlanceTabFragment : Fragment() {
}
}
Constants.GlanceProviderId.GREETINGS -> {
- injector.text(R.id.label,
+ injector.text(
+ R.id.label,
if (Preferences.showGreetings) getString(R.string.settings_visible) else getString(
- R.string.settings_not_visible))
+ R.string.settings_not_visible
+ )
+ )
injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.showGreetings
}
Constants.GlanceProviderId.CUSTOM_INFO -> {
- injector.text(R.id.label,
+ injector.text(
+ R.id.label,
if (Preferences.customNotes != "") getString(R.string.settings_visible) else getString(
- R.string.settings_not_visible))
+ R.string.settings_not_visible
+ )
+ )
injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.customNotes != ""
}
Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
- val account: GoogleSignInAccount? = GoogleSignIn.getLastSignedInAccount(context)
- if (GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || requireActivity().checkGrantedPermission(
- Manifest.permission.ACTIVITY_RECOGNITION))
+ val account: GoogleSignInAccount? = GoogleSignIn.getLastSignedInAccount(
+ context
+ )
+ if (GoogleSignIn.hasPermissions(
+ account,
+ FITNESS_OPTIONS
+ ) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || requireActivity().checkGrantedPermission(
+ Manifest.permission.ACTIVITY_RECOGNITION
+ ))
) {
- injector.text(R.id.label,
+ injector.text(
+ R.id.label,
if (Preferences.showDailySteps) getString(R.string.settings_visible) else getString(
- R.string.settings_not_visible))
+ R.string.settings_not_visible
+ )
+ )
injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.showDailySteps
@@ -240,12 +271,24 @@ class GlanceTabFragment : Fragment() {
}
}
Constants.GlanceProviderId.EVENTS -> {
- isVisible = Preferences.showEventsAsGlanceProvider && Preferences.showEvents && requireContext().checkGrantedPermission(Manifest.permission.READ_CALENDAR)
- injector.text(R.id.label,
+ isVisible =
+ Preferences.showEventsAsGlanceProvider && Preferences.showEvents && requireContext().checkGrantedPermission(
+ Manifest.permission.READ_CALENDAR
+ )
+ injector.text(
+ R.id.label,
if (isVisible) getString(R.string.settings_visible) else getString(
- R.string.settings_not_visible))
- injector.visibility(R.id.error_icon, if (isVisible) View.GONE else View.VISIBLE)
- injector.visibility(R.id.info_icon, if (isVisible) View.VISIBLE else View.GONE)
+ R.string.settings_not_visible
+ )
+ )
+ injector.visibility(
+ R.id.error_icon,
+ if (isVisible) View.GONE else View.VISIBLE
+ )
+ injector.visibility(
+ R.id.info_icon,
+ if (isVisible) View.VISIBLE else View.GONE
+ )
}
}
@@ -300,7 +343,12 @@ class GlanceTabFragment : Fragment() {
GlanceProviderHelper.saveGlanceProviderOrder(
list
)
- adapter.updateData(listOf("header") + list.mapNotNull { GlanceProviderHelper.getGlanceProviderById(requireContext(), it) } + listOf("footer"))
+ adapter.updateData(listOf("header") + list.mapNotNull {
+ GlanceProviderHelper.getGlanceProviderById(
+ requireContext(),
+ it
+ )
+ } + listOf("footer"))
}
override fun onChildDraw(
@@ -315,23 +363,37 @@ class GlanceTabFragment : Fragment() {
val view = viewHolder.itemView as MaterialCardView
if (isCurrentlyActive) {
ViewCompat.setElevation(view, 8f.convertDpToPixel(requireContext()))
- view.setCardBackgroundColor(ContextCompat.getColor(requireContext(),
- R.color.cardBorder))
+ view.setCardBackgroundColor(
+ ContextCompat.getColor(
+ requireContext(),
+ R.color.cardBorder
+ )
+ )
} else {
ViewCompat.setElevation(view, 0f)
- view.setCardBackgroundColor(ContextCompat.getColor(requireContext(),
- R.color.colorPrimary))
+ view.setCardBackgroundColor(
+ ContextCompat.getColor(
+ requireContext(),
+ R.color.colorPrimary
+ )
+ )
}
- val topEdge = if ((view.top == 0 && dY < 0) || ((view.top + view.height >= recyclerView.height - 32f.convertDpToPixel(requireContext())) && dY > 0)) 0f else dY
+ val topEdge =
+ if ((view.top == 0 && dY < 0) || ((view.top + view.height >= recyclerView.height - 32f.convertDpToPixel(
+ requireContext()
+ )) && dY > 0)
+ ) 0f else dY
- super.onChildDraw(c,
+ super.onChildDraw(
+ c,
recyclerView,
viewHolder,
dX,
topEdge,
actionState,
- isCurrentlyActive)
+ isCurrentlyActive
+ )
}
override fun onSwiped(
@@ -343,7 +405,6 @@ class GlanceTabFragment : Fragment() {
})
mIth.attachToRecyclerView(binding.providersList)
- binding.providersList.isNestedScrollingEnabled = false
setupListener()
@@ -351,13 +412,16 @@ class GlanceTabFragment : Fragment() {
viewModel.fragmentScrollY.value = binding.scrollView.scrollY
}
-
- adapter.updateData(listOf("header") + list.mapNotNull { GlanceProviderHelper.getGlanceProviderById(requireContext(), it) } + listOf("footer"))
- }
-
- private fun subscribeUi(
- viewModel: MainViewModel,
- ) {
+ adapter.updateData(emptyList())
+ lifecycleScope.launchWhenResumed {
+ delay(800)
+ val l = list.mapNotNull { GlanceProviderHelper.getGlanceProviderById(
+ requireContext(),
+ it
+ ) }
+ adapter.updateData(l)
+ binding.listContainer.expand()
+ }
}
private fun setupListener() {
@@ -371,8 +435,10 @@ class GlanceTabFragment : Fragment() {
override fun onStart() {
super.onStart()
- requireActivity().registerReceiver(nextAlarmChangeBroadcastReceiver,
- IntentFilter(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED))
+ requireActivity().registerReceiver(
+ nextAlarmChangeBroadcastReceiver,
+ IntentFilter(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)
+ )
if (dialog != null) {
dialog?.show()
}
@@ -403,13 +469,15 @@ class GlanceTabFragment : Fragment() {
2 -> {
try {
val account: GoogleSignInAccount? = GoogleSignIn.getSignedInAccountFromIntent(
- data).getResult(ApiException::class.java)
+ data
+ ).getResult(ApiException::class.java)
if (!GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS)) {
GoogleSignIn.requestPermissions(
requireActivity(),
1,
account,
- FITNESS_OPTIONS)
+ FITNESS_OPTIONS
+ )
} else {
adapter.notifyItemRangeChanged(0, adapter.data.size)
}
@@ -425,18 +493,9 @@ class GlanceTabFragment : Fragment() {
}
}
- private fun maintainScrollPosition(callback: () -> Unit) {
- binding.scrollView.isScrollable = false
- callback.invoke()
- lifecycleScope.launch {
- delay(200)
- binding.scrollView.isScrollable = true
- }
- }
-
override fun onResume() {
super.onResume()
- adapter.notifyItemRangeChanged(0, adapter.data?.size ?: 0)
+ adapter.notifyItemRangeChanged(1, adapter.data?.size ?: 0)
if (dialog != null) {
dialog?.show()
}
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/LayoutFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/LayoutFragment.kt
index 110719c..c19a10d 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/LayoutFragment.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/LayoutFragment.kt
@@ -124,17 +124,6 @@ class LayoutFragment : Fragment() {
}
}
- viewModel.backgroundCardColorDark.observe(viewLifecycleOwner) {
- maintainScrollPosition {
- if (Preferences.backgroundCardAlphaDark == "00") {
- binding.backgroundColorLabel.text = getString(R.string.transparent)
- } else {
- binding.backgroundColorLabel.text =
- "#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(requireActivity().isDarkTheme()))).toUpperCase()
- }
- }
- }
-
viewModel.showDividers.observe(viewLifecycleOwner) {
maintainScrollPosition {
binding.showDividersLabel.text =
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/PreferencesFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/PreferencesFragment.kt
index b67cf93..1aac699 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/PreferencesFragment.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/PreferencesFragment.kt
@@ -94,9 +94,6 @@ class PreferencesFragment : Fragment() {
viewModel.showWeather.observe(viewLifecycleOwner) {
checkWeatherProviderConfig()
}
-
- viewModel.showClock.observe(viewLifecycleOwner) {
- }
}
private fun setupListener() {
@@ -115,9 +112,6 @@ class PreferencesFragment : Fragment() {
binding.showEventsSwitch.setOnCheckedChangeListener { _, enabled: Boolean ->
if (enabled) {
- if (!requireActivity().checkGrantedPermission(Manifest.permission.READ_CALENDAR)) {
- binding.showEventsSwitch.setCheckedImmediatelyNoEvent(false)
- }
requireCalendarPermission()
} else {
Preferences.showEvents = enabled
@@ -196,6 +190,11 @@ class PreferencesFragment : Fragment() {
binding.weatherProviderLocationError.text = Preferences.weatherProviderLocationError
}
+ override fun onResume() {
+ super.onResume()
+ binding.showEventsSwitch.setCheckedNoEvent(Preferences.showEvents && requireActivity().checkGrantedPermission(Manifest.permission.READ_CALENDAR))
+ }
+
private fun maintainScrollPosition(callback: () -> Unit) {
binding.scrollView.isScrollable = false
callback.invoke()
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/TypographyFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/TypographyFragment.kt
index b2c4e42..25c347b 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/TypographyFragment.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/TypographyFragment.kt
@@ -116,17 +116,6 @@ class TypographyFragment : Fragment() {
}
}
- viewModel.textGlobalColorDark.observe(viewLifecycleOwner) {
- maintainScrollPosition {
- if (Preferences.textGlobalAlphaDark == "00") {
- binding.fontColorLabelDark.text = getString(R.string.transparent)
- } else {
- binding.fontColorLabelDark.text =
- "#%s".format(Integer.toHexString(ColorHelper.getFontColor(requireActivity().isDarkTheme()))).toUpperCase()
- }
- }
- }
-
viewModel.textSecondaryColor.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (Preferences.textSecondaryAlpha == "00") {
@@ -138,20 +127,18 @@ class TypographyFragment : Fragment() {
}
}
- viewModel.textSecondaryColorDark.observe(viewLifecycleOwner) {
+ viewModel.textShadow.observe(viewLifecycleOwner) {
maintainScrollPosition {
- if (Preferences.textSecondaryAlphaDark == "00") {
- binding.secondaryFontColorLabelDark.text = getString(R.string.transparent)
- } else {
- binding.secondaryFontColorLabelDark.text =
- "#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(requireActivity().isDarkTheme()))).toUpperCase()
+ if (requireActivity().isDarkTheme()) {
+ binding.textShadowLabel.text =
+ getString(SettingsStringHelper.getTextShadowString(it))
}
}
}
viewModel.textShadow.observe(viewLifecycleOwner) {
maintainScrollPosition {
- if (activity?.isDarkTheme() != true) {
+ if (!requireActivity().isDarkTheme()) {
binding.textShadowLabel.text =
getString(SettingsStringHelper.getTextShadowString(it))
}
@@ -161,7 +148,7 @@ class TypographyFragment : Fragment() {
viewModel.textShadowDark.observe(viewLifecycleOwner) {
maintainScrollPosition {
if (requireActivity().isDarkTheme()) {
- binding.textShadowLabelDark.text =
+ binding.textShadowLabel.text =
getString(SettingsStringHelper.getTextShadowString(it))
}
}
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/MainViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/MainViewModel.kt
index c088649..3e18e71 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/MainViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/MainViewModel.kt
@@ -1,36 +1,40 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels
+import android.app.Application
+import android.content.ClipData
+import android.content.ClipboardManager
+import android.content.Context
+import androidx.core.os.ConfigurationCompat
import androidx.lifecycle.*
import com.chibatching.kotpref.livedata.asLiveData
+import com.tommasoberlose.anotherwidget.R
+import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences
+import com.tommasoberlose.anotherwidget.helpers.ColorHelper.isColor
+import com.tommasoberlose.anotherwidget.utils.isMetric
-class MainViewModel : ViewModel() {
+class MainViewModel(context: Application) : AndroidViewModel(context) {
// General Settings
val textGlobalColor = MediatorLiveData().apply {
addSource(Preferences.asLiveData(Preferences::textGlobalColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::textGlobalAlpha)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::textGlobalColorDark)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::textGlobalAlphaDark)) { value = true }
}
val textSecondaryColor = MediatorLiveData().apply {
addSource(Preferences.asLiveData(Preferences::textSecondaryColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::textSecondaryAlpha)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::textSecondaryColorDark)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::textSecondaryAlphaDark)) { value = true }
}
val backgroundCardColor = MediatorLiveData().apply {
addSource(Preferences.asLiveData(Preferences::backgroundCardColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::backgroundCardAlpha)) { value = true }
- }
- val textGlobalColorDark = MediatorLiveData().apply {
- addSource(Preferences.asLiveData(Preferences::textGlobalColorDark)) { value = true }
- addSource(Preferences.asLiveData(Preferences::textGlobalAlphaDark)) { value = true }
- }
- val textSecondaryColorDark = MediatorLiveData().apply {
- addSource(Preferences.asLiveData(Preferences::textSecondaryColorDark)) { value = true }
- addSource(Preferences.asLiveData(Preferences::textSecondaryAlphaDark)) { value = true }
- }
- val backgroundCardColorDark = MediatorLiveData().apply {
addSource(Preferences.asLiveData(Preferences::backgroundCardColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::backgroundCardAlphaDark)) { value = true }
}
+
val textMainSize = Preferences.asLiveData(Preferences::textMainSize)
val textSecondSize = Preferences.asLiveData(Preferences::textSecondSize)
val textShadow = Preferences.asLiveData(Preferences::textShadow)
@@ -92,11 +96,11 @@ class MainViewModel : ViewModel() {
val showWallpaper = Preferences.asLiveData(Preferences::showWallpaper)
val showPreview = Preferences.asLiveData(Preferences::showPreview)
val installedIntegrations = Preferences.asLiveData(Preferences::installedIntegrations)
+ var colorClipboard: ArrayList = ArrayList()
// UI
val fragmentScrollY = MutableLiveData()
val clockPreferencesUpdate = MediatorLiveData().apply {
- addSource(Preferences.asLiveData(Preferences::showClock)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextSize)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextAlpha)) { value = true }
@@ -130,14 +134,57 @@ class MainViewModel : ViewModel() {
addSource(Preferences.asLiveData(Preferences::secondRowInformation)) { value = true }
addSource(Preferences.asLiveData(Preferences::showDividers)) { value = true }
addSource(Preferences.asLiveData(Preferences::secondRowTopMargin)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::isDateCapitalize)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::isDateUppercase)) { value = true }
+
addSource(Preferences.asLiveData(Preferences::showEvents)) { value = true }
addSource(Preferences.asLiveData(Preferences::calendarAllDay)) { value = true }
addSource(Preferences.asLiveData(Preferences::showDiffTime)) { value = true }
addSource(Preferences.asLiveData(Preferences::showNextEvent)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showDeclinedEvents)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showInvitedEvents)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showAcceptedEvents)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showOnlyBusyEvents)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::secondRowInformation)) { value = true }
addSource(Preferences.asLiveData(Preferences::showWeather)) { value = true }
addSource(Preferences.asLiveData(Preferences::weatherTempUnit)) { value = true }
addSource(Preferences.asLiveData(Preferences::weatherIconPack)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::customLocationLat)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::customLocationLon)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::customLocationAdd)) { value = true }
+
addSource(Preferences.asLiveData(Preferences::showPreview)) { value = true }
+
+
+ addSource(Preferences.asLiveData(Preferences::enabledGlanceProviderOrder)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::customNotes)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showNextAlarm)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showBatteryCharging)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showDailySteps)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showGreetings)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showNotifications)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showMusic)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::mediaInfoFormat)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::musicPlayersFilter)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::appNotificationsFilter)) { value = true }
+ addSource(Preferences.asLiveData(Preferences::showEventsAsGlanceProvider)) { value = true }
+
+ addSource(Preferences.asLiveData(Preferences::installedIntegrations)) { value = true }
+ }
+
+ init {
+ with(context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager) {
+ if (hasPrimaryClip()) {
+ (0..primaryClip!!.itemCount).forEach {
+ try {
+ val color = primaryClip!!.getItemAt(it).text.toString()
+ if (color.isColor()) {
+ colorClipboard.add(color)
+ }
+ } catch (ex: Exception) {}
+ }
+ }
+ }
}
}
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/IntegrationsViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/settings/IntegrationsViewModel.kt
similarity index 72%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/IntegrationsViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/settings/IntegrationsViewModel.kt
index 73cfc0c..29c8d03 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/IntegrationsViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/settings/IntegrationsViewModel.kt
@@ -1,4 +1,4 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.settings
import android.app.Application
import androidx.lifecycle.AndroidViewModel
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/SupportDevViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/settings/SupportDevViewModel.kt
similarity index 97%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/SupportDevViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/settings/SupportDevViewModel.kt
index e6f310b..dc2b492 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/SupportDevViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/settings/SupportDevViewModel.kt
@@ -1,4 +1,4 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.settings
import android.app.Activity
import android.content.Context
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/AppNotificationsViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/AppNotificationsViewModel.kt
similarity index 96%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/AppNotificationsViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/AppNotificationsViewModel.kt
index c41312a..2d6260d 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/AppNotificationsViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/AppNotificationsViewModel.kt
@@ -1,4 +1,4 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application
import android.content.Intent
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/ChooseApplicationViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/ChooseApplicationViewModel.kt
similarity index 90%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/ChooseApplicationViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/ChooseApplicationViewModel.kt
index 572bcb5..3210761 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/ChooseApplicationViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/ChooseApplicationViewModel.kt
@@ -1,11 +1,9 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application
import android.content.Intent
-import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
-import android.util.Log
import androidx.lifecycle.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomDateViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomDateViewModel.kt
similarity index 91%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomDateViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomDateViewModel.kt
index 2caf3e8..991a1ec 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomDateViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomDateViewModel.kt
@@ -1,4 +1,4 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application
import androidx.lifecycle.AndroidViewModel
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomFontViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomFontViewModel.kt
similarity index 95%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomFontViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomFontViewModel.kt
index affae88..30a7449 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomFontViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomFontViewModel.kt
@@ -1,4 +1,4 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application
import android.content.Intent
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomLocationViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomLocationViewModel.kt
similarity index 91%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomLocationViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomLocationViewModel.kt
index c27bda8..9072718 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/CustomLocationViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/CustomLocationViewModel.kt
@@ -1,4 +1,4 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application
import android.content.pm.ApplicationInfo
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/MusicPlayersFilterViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/MusicPlayersFilterViewModel.kt
similarity index 91%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/MusicPlayersFilterViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/MusicPlayersFilterViewModel.kt
index 0719c39..22ad78f 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/MusicPlayersFilterViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/MusicPlayersFilterViewModel.kt
@@ -1,11 +1,9 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application
import android.content.Intent
-import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
-import android.util.Log
import androidx.lifecycle.*
import com.chibatching.kotpref.livedata.asLiveData
import com.tommasoberlose.anotherwidget.global.Preferences
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/WeatherProviderViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/WeatherProviderViewModel.kt
similarity index 92%
rename from app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/WeatherProviderViewModel.kt
rename to app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/WeatherProviderViewModel.kt
index fd6ecc3..6575b71 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/WeatherProviderViewModel.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/tabs/WeatherProviderViewModel.kt
@@ -1,4 +1,4 @@
-package com.tommasoberlose.anotherwidget.ui.viewmodels
+package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application
import androidx.lifecycle.AndroidViewModel
diff --git a/app/src/main/res/drawable-night-hdpi/round_horizontal_split_2.png b/app/src/main/res/drawable-night-hdpi/round_horizontal_split_2.png
new file mode 100644
index 0000000..575a17d
Binary files /dev/null and b/app/src/main/res/drawable-night-hdpi/round_horizontal_split_2.png differ
diff --git a/app/src/main/res/drawable-night-hdpi/round_horizontal_split_24.png b/app/src/main/res/drawable-night-hdpi/round_horizontal_split_24.png
new file mode 100644
index 0000000..575a17d
Binary files /dev/null and b/app/src/main/res/drawable-night-hdpi/round_horizontal_split_24.png differ
diff --git a/app/src/main/res/drawable-night-hdpi/round_switch_left_24.png b/app/src/main/res/drawable-night-hdpi/round_switch_left_24.png
new file mode 100644
index 0000000..35fd797
Binary files /dev/null and b/app/src/main/res/drawable-night-hdpi/round_switch_left_24.png differ
diff --git a/app/src/main/res/drawable-night-mdpi/round_horizontal_split_2.png b/app/src/main/res/drawable-night-mdpi/round_horizontal_split_2.png
new file mode 100644
index 0000000..319ad9e
Binary files /dev/null and b/app/src/main/res/drawable-night-mdpi/round_horizontal_split_2.png differ
diff --git a/app/src/main/res/drawable-night-mdpi/round_horizontal_split_24.png b/app/src/main/res/drawable-night-mdpi/round_horizontal_split_24.png
new file mode 100644
index 0000000..319ad9e
Binary files /dev/null and b/app/src/main/res/drawable-night-mdpi/round_horizontal_split_24.png differ
diff --git a/app/src/main/res/drawable-night-mdpi/round_switch_left_24.png b/app/src/main/res/drawable-night-mdpi/round_switch_left_24.png
new file mode 100644
index 0000000..b1dc9b4
Binary files /dev/null and b/app/src/main/res/drawable-night-mdpi/round_switch_left_24.png differ
diff --git a/app/src/main/res/drawable-night-xhdpi/round_horizontal_split_2.png b/app/src/main/res/drawable-night-xhdpi/round_horizontal_split_2.png
new file mode 100644
index 0000000..91c3b6a
Binary files /dev/null and b/app/src/main/res/drawable-night-xhdpi/round_horizontal_split_2.png differ
diff --git a/app/src/main/res/drawable-night-xhdpi/round_horizontal_split_24.png b/app/src/main/res/drawable-night-xhdpi/round_horizontal_split_24.png
new file mode 100644
index 0000000..91c3b6a
Binary files /dev/null and b/app/src/main/res/drawable-night-xhdpi/round_horizontal_split_24.png differ
diff --git a/app/src/main/res/drawable-night-xhdpi/round_switch_left_24.png b/app/src/main/res/drawable-night-xhdpi/round_switch_left_24.png
new file mode 100644
index 0000000..53b4e23
Binary files /dev/null and b/app/src/main/res/drawable-night-xhdpi/round_switch_left_24.png differ
diff --git a/app/src/main/res/drawable-night-xxhdpi/round_horizontal_split_2.png b/app/src/main/res/drawable-night-xxhdpi/round_horizontal_split_2.png
new file mode 100644
index 0000000..719d5b3
Binary files /dev/null and b/app/src/main/res/drawable-night-xxhdpi/round_horizontal_split_2.png differ
diff --git a/app/src/main/res/drawable-night-xxhdpi/round_horizontal_split_24.png b/app/src/main/res/drawable-night-xxhdpi/round_horizontal_split_24.png
new file mode 100644
index 0000000..719d5b3
Binary files /dev/null and b/app/src/main/res/drawable-night-xxhdpi/round_horizontal_split_24.png differ
diff --git a/app/src/main/res/drawable-night-xxhdpi/round_switch_left_24.png b/app/src/main/res/drawable-night-xxhdpi/round_switch_left_24.png
new file mode 100644
index 0000000..7fb3993
Binary files /dev/null and b/app/src/main/res/drawable-night-xxhdpi/round_switch_left_24.png differ
diff --git a/app/src/main/res/drawable-night-xxxhdpi/round_horizontal_split_2.png b/app/src/main/res/drawable-night-xxxhdpi/round_horizontal_split_2.png
new file mode 100644
index 0000000..c1ee954
Binary files /dev/null and b/app/src/main/res/drawable-night-xxxhdpi/round_horizontal_split_2.png differ
diff --git a/app/src/main/res/drawable-night-xxxhdpi/round_horizontal_split_24.png b/app/src/main/res/drawable-night-xxxhdpi/round_horizontal_split_24.png
new file mode 100644
index 0000000..c1ee954
Binary files /dev/null and b/app/src/main/res/drawable-night-xxxhdpi/round_horizontal_split_24.png differ
diff --git a/app/src/main/res/drawable-night-xxxhdpi/round_switch_left_24.png b/app/src/main/res/drawable-night-xxxhdpi/round_switch_left_24.png
new file mode 100644
index 0000000..8441f39
Binary files /dev/null and b/app/src/main/res/drawable-night-xxxhdpi/round_switch_left_24.png differ
diff --git a/app/src/main/res/drawable/round_android_24.xml b/app/src/main/res/drawable/round_android_24.xml
new file mode 100644
index 0000000..bf91766
--- /dev/null
+++ b/app/src/main/res/drawable/round_android_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/round_horizontal_split_24.xml b/app/src/main/res/drawable/round_horizontal_split_24.xml
new file mode 100644
index 0000000..5259e4b
--- /dev/null
+++ b/app/src/main/res/drawable/round_horizontal_split_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/round_switch_left_24.xml b/app/src/main/res/drawable/round_switch_left_24.xml
new file mode 100644
index 0000000..d442cea
--- /dev/null
+++ b/app/src/main/res/drawable/round_switch_left_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_app_notifications_filter.xml b/app/src/main/res/layout/activity_app_notifications_filter.xml
index 9259c79..11cab21 100644
--- a/app/src/main/res/layout/activity_app_notifications_filter.xml
+++ b/app/src/main/res/layout/activity_app_notifications_filter.xml
@@ -3,7 +3,7 @@
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.AppNotificationsViewModel" />
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.ChooseApplicationViewModel" />
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomDateViewModel" />
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomFontViewModel" />
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomLocationViewModel" />
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.settings.IntegrationsViewModel" />
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.MusicPlayersFilterViewModel" />
+ type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomLocationViewModel" />
@@ -145,6 +145,7 @@
android:paddingTop="16dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
+ android:visibility="@{is24Format ? View.GONE : View.VISIBLE, default=visible}"
android:textAppearance="@style/AnotherWidget.Settings.Header" />
-
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_tab_layout.xml b/app/src/main/res/layout/fragment_tab_layout.xml
index 372c148..f0e9dc1 100644
--- a/app/src/main/res/layout/fragment_tab_layout.xml
+++ b/app/src/main/res/layout/fragment_tab_layout.xml
@@ -46,7 +46,7 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
- android:src="@drawable/round_format_line_spacing"
+ android:src="@drawable/round_horizontal_split_24"
app:tint="@color/colorPrimaryText" />
diff --git a/app/src/main/res/layout/fragment_tab_typography.xml b/app/src/main/res/layout/fragment_tab_typography.xml
index 2d3d62c..bfcffa6 100644
--- a/app/src/main/res/layout/fragment_tab_typography.xml
+++ b/app/src/main/res/layout/fragment_tab_typography.xml
@@ -149,44 +149,27 @@
android:id="@+id/font_color_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
-
-
-
-
-
+
-
-
+ android:textColor="@color/colorPrimaryText"
+ android:textSize="12sp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textAppearance="@style/TextAppearance.AppCompat.Button"
+ android:text="@string/settings_subtitle_dark_theme_dark"/>
+
-
-
-
-
-
+
-
-
+ android:textColor="@color/colorPrimaryText"
+ android:textSize="12sp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textAppearance="@style/TextAppearance.AppCompat.Button"
+ android:text="@string/settings_subtitle_dark_theme_dark"/>
+
-
-
-
-
-
+
-
-
+ android:textColor="@color/colorPrimaryText"
+ android:textSize="12sp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textAppearance="@style/TextAppearance.AppCompat.Button"
+ android:text="@string/settings_subtitle_dark_theme_dark"/>
+
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file