update ui

This commit is contained in:
Tommaso Berlose 2021-01-09 18:33:22 +01:00
parent d32f680519
commit 889783bb4e
66 changed files with 553 additions and 466 deletions

View File

@ -17,7 +17,6 @@
<package name="" alias="true" withSubpackages="true" /> <package name="" alias="true" withSubpackages="true" />
</value> </value>
</option> </option>
<option name="ALLOW_TRAILING_COMMA" value="true" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings> </JetCodeStyleSettings>
<codeStyleSettings language="XML"> <codeStyleSettings language="XML">

View File

@ -56,8 +56,6 @@ class BottomSheetColorPicker(
private var listBinding: BottomSheetMenuListBinding = BottomSheetMenuListBinding.inflate(LayoutInflater.from(context)) private var listBinding: BottomSheetMenuListBinding = BottomSheetMenuListBinding.inflate(LayoutInflater.from(context))
override fun show() { override fun show() {
window?.setDimAmount(0f)
// Header // Header
binding.header.isVisible = header != null binding.header.isVisible = header != null
binding.headerText.text = header ?: "" binding.headerText.text = header ?: ""

View File

@ -111,8 +111,6 @@ object Preferences : KotprefModel() {
// Settings // Settings
var showWallpaper by booleanPref(default = true) 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 showPreview by booleanPref(default = true)
var showXiaomiWarning by booleanPref(default = true) var showXiaomiWarning by booleanPref(default = true)

View File

@ -2,14 +2,16 @@ package com.tommasoberlose.anotherwidget.helpers
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.graphics.Color import android.graphics.Color
import android.util.Log
import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.global.Preferences
import kotlin.math.roundToInt import kotlin.math.roundToInt
object ColorHelper { object ColorHelper {
fun getFontColor(isDark: Boolean): Int { fun getFontColor(isDark: Boolean): Int {
return try { 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) { } catch (e: Exception) {
Color.parseColor("#FFFFFFFF") Color.parseColor("#FFFFFFFF")
} }
@ -33,7 +35,10 @@ object ColorHelper {
fun getSecondaryFontColor(isDark: Boolean): Int { fun getSecondaryFontColor(isDark: Boolean): Int {
return try { 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) { } catch (e: Exception) {
Color.parseColor("#FFFFFFFF") Color.parseColor("#FFFFFFFF")
} }
@ -57,7 +62,10 @@ object ColorHelper {
fun getClockFontColor(isDark: Boolean): Int { fun getClockFontColor(isDark: Boolean): Int {
return try { 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) { } catch (e: Exception) {
Color.parseColor("#FFFFFFFF") Color.parseColor("#FFFFFFFF")
} }
@ -81,7 +89,10 @@ object ColorHelper {
fun getBackgroundColor(isDark: Boolean): Int { fun getBackgroundColor(isDark: Boolean): Int {
return try { 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) { } catch (e: Exception) {
Color.parseColor("#00000000") Color.parseColor("#00000000")
} }
@ -123,4 +134,14 @@ object ColorHelper {
val hexValue = this.toInt(16).toDouble() val hexValue = this.toInt(16).toDouble()
return (hexValue * 100 / 255).roundToInt() return (hexValue * 100 / 255).roundToInt()
} }
fun String.isColor(): Boolean {
return try {
Color.parseColor(this)
true
} catch (iae: IllegalArgumentException) {
iae.printStackTrace()
false
}
}
} }

View File

@ -30,7 +30,7 @@ object ImageHelper {
canvas.drawColor(Color.TRANSPARENT) canvas.drawColor(Color.TRANSPARENT)
canvas.save() canvas.save()
val rect = Rect() val rect = Rect()
val bounds = originalView.drawable.copyBounds() // val bounds = originalView.drawable.copyBounds()
canvas.getClipBounds(rect) canvas.getClipBounds(rect)
rect.inset(-2 * getBlurRadius(context, cElevation).toInt(), -2 * getBlurRadius(context, cElevation).toInt()) rect.inset(-2 * getBlurRadius(context, cElevation).toInt(), -2 * getBlurRadius(context, cElevation).toInt())
canvas.save() canvas.save()

View File

@ -25,9 +25,8 @@ object WidgetHelper {
) { ) {
fun getWidgetsSize(widgetId: Int): Pair<Int, Int> { fun getWidgetsSize(widgetId: Int): Pair<Int, Int> {
val isPortrait = context.resources.configuration.orientation == ORIENTATION_PORTRAIT val width = getWidgetWidth(widgetId)
val width = getWidgetWidth(isPortrait, widgetId) val height = getWidgetHeight(widgetId)
val height = getWidgetHeight(isPortrait, widgetId)
val widthInPx = context.dip(width) val widthInPx = context.dip(width)
val heightInPx = context.dip(height) val heightInPx = context.dip(height)
FirebaseCrashlytics.getInstance().setCustomKey("widthInPx", widthInPx) FirebaseCrashlytics.getInstance().setCustomKey("widthInPx", widthInPx)
@ -35,9 +34,9 @@ object WidgetHelper {
return widthInPx to heightInPx 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 = private fun getWidgetSizeInDp(widgetId: Int, key: String): Int =
appWidgetManager.getAppWidgetOptions(widgetId).getInt(key, 0) appWidgetManager.getAppWidgetOptions(widgetId).getInt(key, 0)

View File

@ -344,7 +344,7 @@ class WeatherNetworkApi(val context: Context) {
private suspend fun useAccuweatherProvider(context: Context) { private suspend fun useAccuweatherProvider(context: Context) {
if (Preferences.weatherProviderApiAccuweather != "") { if (Preferences.weatherProviderApiAccuweather != "") {
val repository = AccuweatherRepository() // val repository = AccuweatherRepository()
// when (val response = repository.getWeather()) { // when (val response = repository.getWeather()) {
// is NetworkResponse.Success -> { // is NetworkResponse.Success -> {

View File

@ -138,10 +138,8 @@ class ActivityDetectionReceiver : BroadcastReceiver() {
val endTime: Long = cal.timeInMillis val endTime: Long = cal.timeInMillis
val readRequest = DataReadRequest.Builder() val readRequest = DataReadRequest.Builder()
.aggregate( .aggregate(DataType.TYPE_STEP_COUNT_DELTA)
DataType.TYPE_STEP_COUNT_DELTA, .aggregate(DataType.AGGREGATE_STEP_COUNT_DELTA)
DataType.AGGREGATE_STEP_COUNT_DELTA
)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS) .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.bucketByTime(1, TimeUnit.DAYS) .bucketByTime(1, TimeUnit.DAYS)
.build() .build()

View File

@ -41,6 +41,7 @@ class NotificationListener : NotificationListenerService() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Preferences.lastNotificationIcon = sbn.notification.smallIcon.resId Preferences.lastNotificationIcon = sbn.notification.smallIcon.resId
} else { } else {
@Suppress("DEPRECATION")
Preferences.lastNotificationIcon = sbn.notification.icon Preferences.lastNotificationIcon = sbn.notification.icon
} }
} catch (ex: Exception) { } catch (ex: Exception) {

View File

@ -2,12 +2,11 @@ package com.tommasoberlose.anotherwidget.ui.activities.settings
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivityIntegrationsBinding 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 import net.idik.lib.slimadapter.SlimAdapter
class IntegrationsActivity : AppCompatActivity() { class IntegrationsActivity : AppCompatActivity() {

View File

@ -4,7 +4,6 @@ import android.os.Bundle
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager 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.android.billingclient.api.BillingClient.BillingResponseCode.USER_CANCELED
import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivitySupportDevBinding 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 com.tommasoberlose.anotherwidget.utils.toast
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter

View File

@ -6,7 +6,6 @@ import android.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -16,7 +15,7 @@ import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivityAppNotificationsFilterBinding import com.tommasoberlose.anotherwidget.databinding.ActivityAppNotificationsFilterBinding
import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.ActiveNotificationsHelper 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 kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter

View File

@ -10,7 +10,6 @@ import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -18,7 +17,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.tommasoberlose.anotherwidget.databinding.ActivityChooseApplicationBinding import com.tommasoberlose.anotherwidget.databinding.ActivityChooseApplicationBinding
import com.tommasoberlose.anotherwidget.global.Constants 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 kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter
import net.idik.lib.slimadapter.SlimAdapterEx import net.idik.lib.slimadapter.SlimAdapterEx
@ -90,15 +89,15 @@ class ChooseApplicationActivity : AppCompatActivity() {
binding.viewModel = viewModel binding.viewModel = viewModel
binding.lifecycleOwner = this binding.lifecycleOwner = this
viewModel.appList.observe(this, Observer { viewModel.appList.observe(this) {
updateList(list = it) updateList(list = it)
binding.loader.visibility = View.INVISIBLE binding.loader.visibility = View.INVISIBLE
}) }
viewModel.searchInput.observe(this, Observer { search -> viewModel.searchInput.observe(this) { search ->
updateList(search = search) updateList(search = search)
binding.clearSearch.isVisible = search.isNotBlank() binding.clearSearch.isVisible = search.isNotBlank()
}) }
} }
private fun updateList(list: List<ResolveInfo>? = viewModel.appList.value, search: String? = viewModel.searchInput.value) { private fun updateList(list: List<ResolveInfo>? = viewModel.appList.value, search: String? = viewModel.searchInput.value) {

View File

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -13,7 +12,7 @@ import com.chibatching.kotpref.blockingBulk
import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.databinding.ActivityCustomDateBinding import com.tommasoberlose.anotherwidget.databinding.ActivityCustomDateBinding
import com.tommasoberlose.anotherwidget.global.Preferences 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.getCapWordString
import com.tommasoberlose.anotherwidget.utils.openURI import com.tommasoberlose.anotherwidget.utils.openURI
import com.tommasoberlose.anotherwidget.utils.toast import com.tommasoberlose.anotherwidget.utils.toast

View File

@ -13,7 +13,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.provider.FontRequest import androidx.core.provider.FontRequest
import androidx.core.provider.FontsContractCompat import androidx.core.provider.FontsContractCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope 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.Constants
import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper 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 kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter
import net.idik.lib.slimadapter.diff.DefaultDiffCallback import net.idik.lib.slimadapter.diff.DefaultDiffCallback

View File

@ -9,7 +9,6 @@ import com.tommasoberlose.anotherwidget.R
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -22,7 +21,7 @@ import com.karumi.dexter.listener.PermissionRequest
import com.karumi.dexter.listener.multi.MultiplePermissionsListener import com.karumi.dexter.listener.multi.MultiplePermissionsListener
import com.tommasoberlose.anotherwidget.databinding.ActivityCustomLocationBinding import com.tommasoberlose.anotherwidget.databinding.ActivityCustomLocationBinding
import com.tommasoberlose.anotherwidget.global.Preferences 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 kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter

View File

@ -7,7 +7,6 @@ import android.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -16,7 +15,7 @@ import com.bumptech.glide.Glide
import com.tommasoberlose.anotherwidget.databinding.ActivityMusicPlayersFilterBinding import com.tommasoberlose.anotherwidget.databinding.ActivityMusicPlayersFilterBinding
import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper 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 kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter
@ -76,20 +75,20 @@ class MusicPlayersFilterActivity : AppCompatActivity() {
binding.viewModel = viewModel binding.viewModel = viewModel
binding.lifecycleOwner = this binding.lifecycleOwner = this
viewModel.appList.observe(this, Observer { viewModel.appList.observe(this) {
updateList(list = it) updateList(list = it)
binding.loader.visibility = View.INVISIBLE binding.loader.visibility = View.INVISIBLE
}) }
viewModel.searchInput.observe(this, Observer { search -> viewModel.searchInput.observe(this) { search ->
updateList(search = search) updateList(search = search)
binding.clearSearch.isVisible = search.isNotBlank() binding.clearSearch.isVisible = search.isNotBlank()
}) }
viewModel.musicPlayersFilter.observe(this, { viewModel.musicPlayersFilter.observe(this) {
updateList() updateList()
binding.clearSelection.isVisible = Preferences.musicPlayersFilter != "" binding.clearSelection.isVisible = Preferences.musicPlayersFilter != ""
}) }
} }
private fun updateList(list: List<ResolveInfo>? = viewModel.appList.value, search: String? = viewModel.searchInput.value) { private fun updateList(list: List<ResolveInfo>? = viewModel.appList.value, search: String? = viewModel.searchInput.value) {

View File

@ -18,7 +18,7 @@ import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment 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 kotlinx.coroutines.launch
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus

View File

@ -119,100 +119,6 @@ class MainFragment : Fragment() {
binding.actionBack to "action_back" 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 { binding.preview.layoutParams = binding.preview.layoutParams.apply {
height = PREVIEW_BASE_HEIGHT.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel( height = PREVIEW_BASE_HEIGHT.toPixel(requireContext()) + if (Preferences.showClock) 100.toPixel(
@ -272,6 +178,120 @@ class MainFragment : Fragment() {
viewModel.widgetPreferencesUpdate.observe(viewLifecycleOwner) { viewModel.widgetPreferencesUpdate.observe(viewLifecycleOwner) {
onUpdateUiEvent(null) 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() { override fun onResume() {

View File

@ -85,7 +85,7 @@ class CalendarFragment : Fragment() {
viewModel: MainViewModel viewModel: MainViewModel
) { ) {
binding.isCalendarEnabled = Preferences.showEvents binding.isCalendarEnabled = Preferences.showEvents
binding.isDiffEnabled = Preferences.showDiffTime || !Preferences.showEvents binding.isDiffEnabled = Preferences.showDiffTime
viewModel.calendarAllDay.observe(viewLifecycleOwner) { viewModel.calendarAllDay.observe(viewLifecycleOwner) {
maintainScrollPosition { maintainScrollPosition {
@ -122,7 +122,6 @@ class CalendarFragment : Fragment() {
maintainScrollPosition { maintainScrollPosition {
binding.showUntilLabel.text = getString(SettingsStringHelper.getShowUntilString(it)) binding.showUntilLabel.text = getString(SettingsStringHelper.getShowUntilString(it))
} }
updateCalendar()
} }
} }
@ -136,7 +135,7 @@ class CalendarFragment : Fragment() {
it.displayName, it.displayName,
it.accountName it.accountName
) )
}.sortedWith(Comparator { cal1, cal2 -> }.sortedWith { cal1, cal2 ->
when { when {
cal1.accountName != cal2.accountName -> { cal1.accountName != cal2.accountName -> {
cal1.accountName.compareTo(cal2.accountName) cal1.accountName.compareTo(cal2.accountName)
@ -151,7 +150,7 @@ class CalendarFragment : Fragment() {
cal1.name.compareTo(cal2.name) cal1.name.compareTo(cal2.name)
} }
} }
}) }
if (calendarSelectorList.isNotEmpty()) { if (calendarSelectorList.isNotEmpty()) {
val filteredCalendarIds = CalendarHelper.getFilteredCalendarIdList() val filteredCalendarIds = CalendarHelper.getFilteredCalendarIdList()
@ -271,6 +270,7 @@ class CalendarFragment : Fragment() {
} }
dialog.addOnSelectItemListener { value -> dialog.addOnSelectItemListener { value ->
Preferences.showUntil = value Preferences.showUntil = value
updateCalendar()
}.show() }.show()
} }
} }

View File

@ -13,10 +13,11 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.view.animation.LayoutAnimationController
import android.widget.ImageView import android.widget.ImageView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope 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.ui.viewmodels.MainViewModel
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
import com.tommasoberlose.anotherwidget.utils.convertDpToPixel 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.delay
import kotlinx.coroutines.launch
import net.idik.lib.slimadapter.SlimAdapter import net.idik.lib.slimadapter.SlimAdapter
@ -78,8 +80,6 @@ class GlanceTabFragment : Fragment() {
viewModel = ViewModelProvider(activity as MainActivity).get(MainViewModel::class.java) viewModel = ViewModelProvider(activity as MainActivity).get(MainViewModel::class.java)
binding = FragmentTabGlanceBinding.inflate(inflater) binding = FragmentTabGlanceBinding.inflate(inflater)
subscribeUi(viewModel)
binding.lifecycleOwner = this binding.lifecycleOwner = this
binding.viewModel = viewModel binding.viewModel = viewModel
@ -90,16 +90,12 @@ class GlanceTabFragment : Fragment() {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
// List // List
binding.providersList.setHasFixedSize(true) binding.providersList.hasFixedSize()
val mLayoutManager = LinearLayoutManager(context) val mLayoutManager = LinearLayoutManager(context)
binding.providersList.layoutManager = mLayoutManager binding.providersList.layoutManager = mLayoutManager
adapter = SlimAdapter.create() adapter = SlimAdapter.create()
adapter adapter
.register<String>(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<GlanceProvider>(R.layout.glance_provider_item) { item, injector -> .register<GlanceProvider>(R.layout.glance_provider_item) { item, injector ->
val provider = Constants.GlanceProviderId.from(item.id)!! val provider = Constants.GlanceProviderId.from(item.id)!!
injector injector
@ -130,9 +126,12 @@ class GlanceTabFragment : Fragment() {
MediaPlayerHelper.updatePlayingMediaInfo(requireContext()) MediaPlayerHelper.updatePlayingMediaInfo(requireContext())
injector.visibility(R.id.error_icon, View.GONE) injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE) 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( if (Preferences.showMusic) getString(R.string.settings_visible) else getString(
R.string.settings_not_visible)) R.string.settings_not_visible
)
)
isVisible = Preferences.showMusic isVisible = Preferences.showMusic
} }
Preferences.showMusic -> { Preferences.showMusic -> {
@ -150,26 +149,40 @@ class GlanceTabFragment : Fragment() {
} }
} }
Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> { Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> {
injector.text(R.id.label, injector.text(
R.id.label,
if (Preferences.showNextAlarm && !AlarmHelper.isAlarmProbablyWrong( if (Preferences.showNextAlarm && !AlarmHelper.isAlarmProbablyWrong(
requireContext()) requireContext()
)
) getString(R.string.settings_visible) else getString( ) getString(R.string.settings_visible) else getString(
R.string.settings_not_visible)) R.string.settings_not_visible
injector.visibility(R.id.error_icon, )
)
injector.visibility(
R.id.error_icon,
if (Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong( if (Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong(
requireContext()) requireContext()
) View.VISIBLE else View.GONE) )
injector.visibility(R.id.info_icon, ) View.VISIBLE else View.GONE
)
injector.visibility(
R.id.info_icon,
if (!(Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong( if (!(Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong(
requireContext())) requireContext()
) View.VISIBLE else View.GONE) ))
) View.VISIBLE else View.GONE
)
isVisible = !(Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong( isVisible = !(Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong(
requireContext())) requireContext()
))
} }
Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> { 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( 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.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE) injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.showBatteryCharging isVisible = Preferences.showBatteryCharging
@ -179,9 +192,12 @@ class GlanceTabFragment : Fragment() {
ActiveNotificationsHelper.checkNotificationAccess(requireContext()) -> { ActiveNotificationsHelper.checkNotificationAccess(requireContext()) -> {
injector.visibility(R.id.error_icon, View.GONE) injector.visibility(R.id.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE) injector.visibility(R.id.info_icon, View.VISIBLE)
injector.text(R.id.label, injector.text(
R.id.label,
if (Preferences.showNotifications) getString( 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 isVisible = Preferences.showNotifications
} }
Preferences.showNotifications -> { Preferences.showNotifications -> {
@ -199,29 +215,44 @@ class GlanceTabFragment : Fragment() {
} }
} }
Constants.GlanceProviderId.GREETINGS -> { Constants.GlanceProviderId.GREETINGS -> {
injector.text(R.id.label, injector.text(
R.id.label,
if (Preferences.showGreetings) getString(R.string.settings_visible) else getString( 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.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE) injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.showGreetings isVisible = Preferences.showGreetings
} }
Constants.GlanceProviderId.CUSTOM_INFO -> { Constants.GlanceProviderId.CUSTOM_INFO -> {
injector.text(R.id.label, injector.text(
R.id.label,
if (Preferences.customNotes != "") getString(R.string.settings_visible) else getString( 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.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE) injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.customNotes != "" isVisible = Preferences.customNotes != ""
} }
Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> { Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
val account: GoogleSignInAccount? = GoogleSignIn.getLastSignedInAccount(context) val account: GoogleSignInAccount? = GoogleSignIn.getLastSignedInAccount(
if (GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || requireActivity().checkGrantedPermission( context
Manifest.permission.ACTIVITY_RECOGNITION)) )
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( 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.error_icon, View.GONE)
injector.visibility(R.id.info_icon, View.VISIBLE) injector.visibility(R.id.info_icon, View.VISIBLE)
isVisible = Preferences.showDailySteps isVisible = Preferences.showDailySteps
@ -240,12 +271,24 @@ class GlanceTabFragment : Fragment() {
} }
} }
Constants.GlanceProviderId.EVENTS -> { Constants.GlanceProviderId.EVENTS -> {
isVisible = Preferences.showEventsAsGlanceProvider && Preferences.showEvents && requireContext().checkGrantedPermission(Manifest.permission.READ_CALENDAR) isVisible =
injector.text(R.id.label, Preferences.showEventsAsGlanceProvider && Preferences.showEvents && requireContext().checkGrantedPermission(
Manifest.permission.READ_CALENDAR
)
injector.text(
R.id.label,
if (isVisible) getString(R.string.settings_visible) else getString( if (isVisible) getString(R.string.settings_visible) else getString(
R.string.settings_not_visible)) 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) )
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( GlanceProviderHelper.saveGlanceProviderOrder(
list 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( override fun onChildDraw(
@ -315,23 +363,37 @@ class GlanceTabFragment : Fragment() {
val view = viewHolder.itemView as MaterialCardView val view = viewHolder.itemView as MaterialCardView
if (isCurrentlyActive) { if (isCurrentlyActive) {
ViewCompat.setElevation(view, 8f.convertDpToPixel(requireContext())) ViewCompat.setElevation(view, 8f.convertDpToPixel(requireContext()))
view.setCardBackgroundColor(ContextCompat.getColor(requireContext(), view.setCardBackgroundColor(
R.color.cardBorder)) ContextCompat.getColor(
requireContext(),
R.color.cardBorder
)
)
} else { } else {
ViewCompat.setElevation(view, 0f) ViewCompat.setElevation(view, 0f)
view.setCardBackgroundColor(ContextCompat.getColor(requireContext(), view.setCardBackgroundColor(
R.color.colorPrimary)) 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, recyclerView,
viewHolder, viewHolder,
dX, dX,
topEdge, topEdge,
actionState, actionState,
isCurrentlyActive) isCurrentlyActive
)
} }
override fun onSwiped( override fun onSwiped(
@ -343,7 +405,6 @@ class GlanceTabFragment : Fragment() {
}) })
mIth.attachToRecyclerView(binding.providersList) mIth.attachToRecyclerView(binding.providersList)
binding.providersList.isNestedScrollingEnabled = false
setupListener() setupListener()
@ -351,13 +412,16 @@ class GlanceTabFragment : Fragment() {
viewModel.fragmentScrollY.value = binding.scrollView.scrollY viewModel.fragmentScrollY.value = binding.scrollView.scrollY
} }
adapter.updateData(emptyList<Constants.GlanceProviderId>())
adapter.updateData(listOf("header") + list.mapNotNull { GlanceProviderHelper.getGlanceProviderById(requireContext(), it) } + listOf("footer")) lifecycleScope.launchWhenResumed {
} delay(800)
val l = list.mapNotNull { GlanceProviderHelper.getGlanceProviderById(
private fun subscribeUi( requireContext(),
viewModel: MainViewModel, it
) { ) }
adapter.updateData(l)
binding.listContainer.expand()
}
} }
private fun setupListener() { private fun setupListener() {
@ -371,8 +435,10 @@ class GlanceTabFragment : Fragment() {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
requireActivity().registerReceiver(nextAlarmChangeBroadcastReceiver, requireActivity().registerReceiver(
IntentFilter(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) nextAlarmChangeBroadcastReceiver,
IntentFilter(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)
)
if (dialog != null) { if (dialog != null) {
dialog?.show() dialog?.show()
} }
@ -403,13 +469,15 @@ class GlanceTabFragment : Fragment() {
2 -> { 2 -> {
try { try {
val account: GoogleSignInAccount? = GoogleSignIn.getSignedInAccountFromIntent( val account: GoogleSignInAccount? = GoogleSignIn.getSignedInAccountFromIntent(
data).getResult(ApiException::class.java) data
).getResult(ApiException::class.java)
if (!GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS)) { if (!GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS)) {
GoogleSignIn.requestPermissions( GoogleSignIn.requestPermissions(
requireActivity(), requireActivity(),
1, 1,
account, account,
FITNESS_OPTIONS) FITNESS_OPTIONS
)
} else { } else {
adapter.notifyItemRangeChanged(0, adapter.data.size) 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() { override fun onResume() {
super.onResume() super.onResume()
adapter.notifyItemRangeChanged(0, adapter.data?.size ?: 0) adapter.notifyItemRangeChanged(1, adapter.data?.size ?: 0)
if (dialog != null) { if (dialog != null) {
dialog?.show() dialog?.show()
} }

View File

@ -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) { viewModel.showDividers.observe(viewLifecycleOwner) {
maintainScrollPosition { maintainScrollPosition {
binding.showDividersLabel.text = binding.showDividersLabel.text =

View File

@ -94,9 +94,6 @@ class PreferencesFragment : Fragment() {
viewModel.showWeather.observe(viewLifecycleOwner) { viewModel.showWeather.observe(viewLifecycleOwner) {
checkWeatherProviderConfig() checkWeatherProviderConfig()
} }
viewModel.showClock.observe(viewLifecycleOwner) {
}
} }
private fun setupListener() { private fun setupListener() {
@ -115,9 +112,6 @@ class PreferencesFragment : Fragment() {
binding.showEventsSwitch.setOnCheckedChangeListener { _, enabled: Boolean -> binding.showEventsSwitch.setOnCheckedChangeListener { _, enabled: Boolean ->
if (enabled) { if (enabled) {
if (!requireActivity().checkGrantedPermission(Manifest.permission.READ_CALENDAR)) {
binding.showEventsSwitch.setCheckedImmediatelyNoEvent(false)
}
requireCalendarPermission() requireCalendarPermission()
} else { } else {
Preferences.showEvents = enabled Preferences.showEvents = enabled
@ -196,6 +190,11 @@ class PreferencesFragment : Fragment() {
binding.weatherProviderLocationError.text = Preferences.weatherProviderLocationError 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) { private fun maintainScrollPosition(callback: () -> Unit) {
binding.scrollView.isScrollable = false binding.scrollView.isScrollable = false
callback.invoke() callback.invoke()

View File

@ -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) { viewModel.textSecondaryColor.observe(viewLifecycleOwner) {
maintainScrollPosition { maintainScrollPosition {
if (Preferences.textSecondaryAlpha == "00") { if (Preferences.textSecondaryAlpha == "00") {
@ -138,20 +127,18 @@ class TypographyFragment : Fragment() {
} }
} }
viewModel.textSecondaryColorDark.observe(viewLifecycleOwner) { viewModel.textShadow.observe(viewLifecycleOwner) {
maintainScrollPosition { maintainScrollPosition {
if (Preferences.textSecondaryAlphaDark == "00") { if (requireActivity().isDarkTheme()) {
binding.secondaryFontColorLabelDark.text = getString(R.string.transparent) binding.textShadowLabel.text =
} else { getString(SettingsStringHelper.getTextShadowString(it))
binding.secondaryFontColorLabelDark.text =
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(requireActivity().isDarkTheme()))).toUpperCase()
} }
} }
} }
viewModel.textShadow.observe(viewLifecycleOwner) { viewModel.textShadow.observe(viewLifecycleOwner) {
maintainScrollPosition { maintainScrollPosition {
if (activity?.isDarkTheme() != true) { if (!requireActivity().isDarkTheme()) {
binding.textShadowLabel.text = binding.textShadowLabel.text =
getString(SettingsStringHelper.getTextShadowString(it)) getString(SettingsStringHelper.getTextShadowString(it))
} }
@ -161,7 +148,7 @@ class TypographyFragment : Fragment() {
viewModel.textShadowDark.observe(viewLifecycleOwner) { viewModel.textShadowDark.observe(viewLifecycleOwner) {
maintainScrollPosition { maintainScrollPosition {
if (requireActivity().isDarkTheme()) { if (requireActivity().isDarkTheme()) {
binding.textShadowLabelDark.text = binding.textShadowLabel.text =
getString(SettingsStringHelper.getTextShadowString(it)) getString(SettingsStringHelper.getTextShadowString(it))
} }
} }

View File

@ -1,36 +1,40 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels 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 androidx.lifecycle.*
import com.chibatching.kotpref.livedata.asLiveData 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.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 // General Settings
val textGlobalColor = MediatorLiveData<Boolean>().apply { val textGlobalColor = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textGlobalColor)) { value = true } addSource(Preferences.asLiveData(Preferences::textGlobalColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::textGlobalAlpha)) { 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<Boolean>().apply { val textSecondaryColor = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textSecondaryColor)) { value = true } addSource(Preferences.asLiveData(Preferences::textSecondaryColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::textSecondaryAlpha)) { 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<Boolean>().apply { val backgroundCardColor = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::backgroundCardColor)) { value = true } addSource(Preferences.asLiveData(Preferences::backgroundCardColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::backgroundCardAlpha)) { value = true } addSource(Preferences.asLiveData(Preferences::backgroundCardAlpha)) { value = true }
}
val textGlobalColorDark = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textGlobalColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::textGlobalAlphaDark)) { value = true }
}
val textSecondaryColorDark = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::textSecondaryColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::textSecondaryAlphaDark)) { value = true }
}
val backgroundCardColorDark = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::backgroundCardColorDark)) { value = true } addSource(Preferences.asLiveData(Preferences::backgroundCardColorDark)) { value = true }
addSource(Preferences.asLiveData(Preferences::backgroundCardAlphaDark)) { value = true } addSource(Preferences.asLiveData(Preferences::backgroundCardAlphaDark)) { value = true }
} }
val textMainSize = Preferences.asLiveData(Preferences::textMainSize) val textMainSize = Preferences.asLiveData(Preferences::textMainSize)
val textSecondSize = Preferences.asLiveData(Preferences::textSecondSize) val textSecondSize = Preferences.asLiveData(Preferences::textSecondSize)
val textShadow = Preferences.asLiveData(Preferences::textShadow) val textShadow = Preferences.asLiveData(Preferences::textShadow)
@ -92,11 +96,11 @@ class MainViewModel : ViewModel() {
val showWallpaper = Preferences.asLiveData(Preferences::showWallpaper) val showWallpaper = Preferences.asLiveData(Preferences::showWallpaper)
val showPreview = Preferences.asLiveData(Preferences::showPreview) val showPreview = Preferences.asLiveData(Preferences::showPreview)
val installedIntegrations = Preferences.asLiveData(Preferences::installedIntegrations) val installedIntegrations = Preferences.asLiveData(Preferences::installedIntegrations)
var colorClipboard: ArrayList<String> = ArrayList()
// UI // UI
val fragmentScrollY = MutableLiveData<Int>() val fragmentScrollY = MutableLiveData<Int>()
val clockPreferencesUpdate = MediatorLiveData<Boolean>().apply { val clockPreferencesUpdate = MediatorLiveData<Boolean>().apply {
addSource(Preferences.asLiveData(Preferences::showClock)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextSize)) { value = true } addSource(Preferences.asLiveData(Preferences::clockTextSize)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextColor)) { value = true } addSource(Preferences.asLiveData(Preferences::clockTextColor)) { value = true }
addSource(Preferences.asLiveData(Preferences::clockTextAlpha)) { 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::secondRowInformation)) { value = true }
addSource(Preferences.asLiveData(Preferences::showDividers)) { value = true } addSource(Preferences.asLiveData(Preferences::showDividers)) { value = true }
addSource(Preferences.asLiveData(Preferences::secondRowTopMargin)) { 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::showEvents)) { value = true }
addSource(Preferences.asLiveData(Preferences::calendarAllDay)) { value = true } addSource(Preferences.asLiveData(Preferences::calendarAllDay)) { value = true }
addSource(Preferences.asLiveData(Preferences::showDiffTime)) { value = true } addSource(Preferences.asLiveData(Preferences::showDiffTime)) { value = true }
addSource(Preferences.asLiveData(Preferences::showNextEvent)) { 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::showWeather)) { value = true }
addSource(Preferences.asLiveData(Preferences::weatherTempUnit)) { value = true } addSource(Preferences.asLiveData(Preferences::weatherTempUnit)) { value = true }
addSource(Preferences.asLiveData(Preferences::weatherIconPack)) { 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::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) {}
}
}
}
} }
} }

View File

@ -1,4 +1,4 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.settings
import android.app.Application import android.app.Application
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel

View File

@ -1,4 +1,4 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.settings
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context

View File

@ -1,4 +1,4 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application import android.app.Application
import android.content.Intent import android.content.Intent

View File

@ -1,11 +1,9 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application import android.app.Application
import android.content.Intent import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.pm.ResolveInfo import android.content.pm.ResolveInfo
import android.util.Log
import androidx.lifecycle.* import androidx.lifecycle.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch

View File

@ -1,4 +1,4 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application import android.app.Application
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel

View File

@ -1,4 +1,4 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application import android.app.Application
import android.content.Intent import android.content.Intent

View File

@ -1,4 +1,4 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application import android.app.Application
import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo

View File

@ -1,11 +1,9 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application import android.app.Application
import android.content.Intent import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.pm.ResolveInfo import android.content.pm.ResolveInfo
import android.util.Log
import androidx.lifecycle.* import androidx.lifecycle.*
import com.chibatching.kotpref.livedata.asLiveData import com.chibatching.kotpref.livedata.asLiveData
import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.global.Preferences

View File

@ -1,4 +1,4 @@
package com.tommasoberlose.anotherwidget.ui.viewmodels package com.tommasoberlose.anotherwidget.ui.viewmodels.tabs
import android.app.Application import android.app.Application
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71s-0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M4,19h16c0.55,0 1,-0.45 1,-1v-4c0,-0.55 -0.45,-1 -1,-1L4,13c-0.55,0 -1,0.45 -1,1v4c0,0.55 0.45,1 1,1zM4,11h16c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,9c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM3,6c0,0.55 0.45,1 1,1h16c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,5c-0.55,0 -1,0.45 -1,1z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M8.5,8.62v6.76L5.12,12L8.5,8.62M3.71,11.29c-0.39,0.39 -0.39,1.02 0,1.41l4.59,4.59C8.92,17.92 10,17.48 10,16.59V7.41c0,-0.89 -1.08,-1.34 -1.71,-0.71L3.71,11.29zM14,7.41v9.17c0,0.89 1.08,1.34 1.71,0.71l4.59,-4.59c0.39,-0.39 0.39,-1.02 0,-1.41l-4.59,-4.59C15.08,6.08 14,6.52 14,7.41z"/>
</vector>

View File

@ -3,7 +3,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.AppNotificationsViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.AppNotificationsViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -3,7 +3,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.ChooseApplicationViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.ChooseApplicationViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -4,7 +4,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.CustomDateViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomDateViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -3,7 +3,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.CustomFontViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomFontViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -3,7 +3,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.CustomLocationViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomLocationViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -3,7 +3,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.IntegrationsViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.settings.IntegrationsViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -3,7 +3,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.MusicPlayersFilterViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.MusicPlayersFilterViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -4,7 +4,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.CustomLocationViewModel" /> type="com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.CustomLocationViewModel" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -119,10 +119,10 @@
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
android:visibility="@{isDarkModeEnabled ? View.VISIBLE : View.GONE}" android:visibility="@{isDarkModeEnabled ? View.VISIBLE : View.GONE}"
app:cardCornerRadius="16dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
app:cardBackgroundColor="@color/colorPrimary" app:cardBackgroundColor="@color/cardBorder"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
app:cardElevation="0dp"> app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
@ -132,8 +132,8 @@
android:textSize="12sp" android:textSize="12sp"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:paddingStart="8dp" android:paddingStart="16dp"
android:paddingEnd="8dp" android:paddingEnd="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Button" android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:text="@string/settings_subtitle_dark_theme_dark"/> android:text="@string/settings_subtitle_dark_theme_dark"/>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
@ -145,6 +145,7 @@
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingStart="20dp" android:paddingStart="20dp"
android:paddingEnd="20dp" android:paddingEnd="20dp"
android:visibility="@{is24Format ? View.GONE : View.VISIBLE, default=visible}"
android:textAppearance="@style/AnotherWidget.Settings.Header" /> android:textAppearance="@style/AnotherWidget.Settings.Header" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -47,8 +47,8 @@
<ImageView <ImageView
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:padding="12dp" android:padding="11dp"
android:src="@drawable/round_code_24" android:src="@drawable/round_switch_left_24"
app:tint="@color/colorPrimaryText"/> app:tint="@color/colorPrimaryText"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"

View File

@ -15,15 +15,77 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/scrollView" android:id="@+id/scrollView"
android:scrollbarThumbVertical="@color/colorPrimary"> android:scrollbarThumbVertical="@color/colorPrimary">
<androidx.recyclerview.widget.RecyclerView <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="wrap_content"
android:layout_weight="1"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="8dp" android:paddingTop="8dp"
android:paddingBottom="48dp" android:paddingBottom="48dp"
android:layoutAnimation="@anim/layout_animation_fall_down" android:orientation="vertical">
android:id="@+id/providers_list" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/header"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/providers"
android:paddingTop="16dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:textAppearance="@style/AnotherWidget.Settings.Header" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_marginBottom="16dp"
android:text="@string/settings_sort_glance_providers_subtitle"
android:textAppearance="@style/AnotherWidget.Settings.SubHeader"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:alpha="0"
android:id="@+id/list_container"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:id="@+id/providers_list" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/footer"
android:padding="8dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="24dp"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/outline_info_24"
app:tint="@color/colorSecondaryText"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:duplicateParentState="true"
android:layout_marginTop="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/glance_info"
android:textColor="@color/colorSecondaryText"
android:letterSpacing="0"
android:fontFamily="@font/google_sans"
android:textAppearance="@style/AnotherWidget.Settings.Subtitle"
app:textAllCaps="false" />
</LinearLayout>
</LinearLayout>
</com.tommasoberlose.anotherwidget.components.FixedFocusScrollView> </com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</layout> </layout>

View File

@ -46,7 +46,7 @@
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/round_format_line_spacing" android:src="@drawable/round_horizontal_split_24"
app:tint="@color/colorPrimaryText" /> app:tint="@color/colorPrimaryText" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -201,10 +201,10 @@
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
android:layout_gravity="center_vertical"
app:cardBackgroundColor="@color/colorPrimary"
android:visibility="@{isDarkModeEnabled ? View.VISIBLE : View.GONE}" android:visibility="@{isDarkModeEnabled ? View.VISIBLE : View.GONE}"
app:cardCornerRadius="16dp"
android:layout_gravity="center_vertical"
app:cardBackgroundColor="@color/cardBorder"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
app:cardElevation="0dp"> app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
@ -214,8 +214,8 @@
android:textSize="12sp" android:textSize="12sp"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:paddingStart="8dp" android:paddingStart="16dp"
android:paddingEnd="8dp" android:paddingEnd="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Button" android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:text="@string/settings_subtitle_dark_theme_dark"/> android:text="@string/settings_subtitle_dark_theme_dark"/>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View File

@ -149,44 +149,27 @@
android:id="@+id/font_color_label" android:id="@+id/font_color_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
</LinearLayout> <androidx.cardview.widget.CardView
<LinearLayout android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_font_color_dark"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_palette_24"
app:tint="@color/colorPrimaryText"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:visibility="@{isDarkModeEnabled ? View.VISIBLE : View.GONE}"
android:paddingRight="8dp" app:cardCornerRadius="16dp"
android:orientation="vertical"> android:layout_gravity="center_vertical"
<TextView app:cardBackgroundColor="@color/cardBorder"
android:layout_marginEnd="8dp"
app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title" android:textColor="@color/colorPrimaryText"
android:text="@string/settings_font_color_title"/> android:textSize="12sp"
<TextView android:paddingTop="4dp"
android:layout_width="wrap_content" android:paddingBottom="4dp"
android:layout_height="wrap_content" android:paddingStart="16dp"
android:id="@+id/font_color_label_dark" android:paddingEnd="16dp"
style="@style/AnotherWidget.Settings.Subtitle"/> android:textAppearance="@style/TextAppearance.AppCompat.Button"
</LinearLayout> android:text="@string/settings_subtitle_dark_theme_dark"/>
</androidx.cardview.widget.CardView>
</LinearLayout> </LinearLayout>
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -270,44 +253,27 @@
android:id="@+id/secondary_font_color_label" android:id="@+id/secondary_font_color_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
</LinearLayout> <androidx.cardview.widget.CardView
<LinearLayout android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_secondary_font_color_dark"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_palette_24"
app:tint="@color/colorPrimaryText"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:visibility="@{isDarkModeEnabled ? View.VISIBLE : View.GONE}"
android:paddingRight="8dp" app:cardCornerRadius="16dp"
android:orientation="vertical"> android:layout_gravity="center_vertical"
<TextView app:cardBackgroundColor="@color/cardBorder"
android:layout_marginEnd="8dp"
app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title" android:textColor="@color/colorPrimaryText"
android:text="@string/settings_secondary_font_color_title"/> android:textSize="12sp"
<TextView android:paddingTop="4dp"
android:layout_width="wrap_content" android:paddingBottom="4dp"
android:layout_height="wrap_content" android:paddingStart="16dp"
android:id="@+id/secondary_font_color_label_dark" android:paddingEnd="16dp"
style="@style/AnotherWidget.Settings.Subtitle"/> android:textAppearance="@style/TextAppearance.AppCompat.Button"
</LinearLayout> android:text="@string/settings_subtitle_dark_theme_dark"/>
</androidx.cardview.widget.CardView>
</LinearLayout> </LinearLayout>
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -354,45 +320,27 @@
android:id="@+id/text_shadow_label" android:id="@+id/text_shadow_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
</LinearLayout> <androidx.cardview.widget.CardView
<LinearLayout android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_text_shadow_dark"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:visibility="invisible"
android:src="@drawable/round_texture_24"
app:tint="@color/colorPrimaryText"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:visibility="@{isDarkModeEnabled ? View.VISIBLE : View.GONE}"
android:paddingRight="8dp" app:cardCornerRadius="16dp"
android:orientation="vertical"> android:layout_gravity="center_vertical"
<TextView app:cardBackgroundColor="@color/cardBorder"
android:layout_marginEnd="8dp"
app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title" android:textColor="@color/colorPrimaryText"
android:text="@string/title_text_shadow"/> android:textSize="12sp"
<TextView android:paddingTop="4dp"
android:layout_width="wrap_content" android:paddingBottom="4dp"
android:layout_height="wrap_content" android:paddingStart="16dp"
android:id="@+id/text_shadow_label_dark" android:paddingEnd="16dp"
style="@style/AnotherWidget.Settings.Subtitle"/> android:textAppearance="@style/TextAppearance.AppCompat.Button"
</LinearLayout> android:text="@string/settings_subtitle_dark_theme_dark"/>
</androidx.cardview.widget.CardView>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/header"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/providers"
android:paddingTop="16dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:textAppearance="@style/AnotherWidget.Settings.Header" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_marginBottom="16dp"
android:text="@string/settings_sort_glance_providers_subtitle"
android:textAppearance="@style/AnotherWidget.Settings.SubHeader"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/footer"
android:padding="8dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="24dp"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/outline_info_24"
app:tint="@color/colorSecondaryText"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:duplicateParentState="true"
android:layout_marginTop="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/glance_info"
android:textColor="@color/colorSecondaryText"
android:letterSpacing="0"
android:fontFamily="@font/google_sans"
android:textAppearance="@style/AnotherWidget.Settings.Subtitle"
app:textAllCaps="false" />
</LinearLayout>
</LinearLayout>