mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-06-05 22:19:17 +02:00
add some special widget handling for devices before Oreo
This commit is contained in:
@ -13,6 +13,7 @@ import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SplashActivity
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||
import java.util.*
|
||||
|
||||
class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
||||
@ -31,8 +32,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
||||
private fun performUpdate(context: Context) {
|
||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
||||
val layout = if (context.config.useTextShadow) R.layout.widget_date_time_with_shadow else R.layout.widget_date_time
|
||||
RemoteViews(context.packageName, layout).apply {
|
||||
RemoteViews(context.packageName, getProperLayout(context)).apply {
|
||||
updateTexts(context, this)
|
||||
updateColors(context, this)
|
||||
setupAppOpenIntent(context, this)
|
||||
@ -41,6 +41,20 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getProperLayout(context: Context) = if (context.config.useTextShadow) {
|
||||
if (isOreoPlus()) {
|
||||
R.layout.widget_date_time_with_shadow
|
||||
} else {
|
||||
R.layout.widget_date_time_with_shadow_pre_oreo
|
||||
}
|
||||
} else {
|
||||
if (isOreoPlus()) {
|
||||
R.layout.widget_date_time
|
||||
} else {
|
||||
R.layout.widget_date_time_pre_oreo
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTexts(context: Context, views: RemoteViews) {
|
||||
val timeText = context.getFormattedTime(getPassedSeconds(), false, false).toString()
|
||||
val nextAlarm = getFormattedNextAlarm(context)
|
||||
|
Reference in New Issue
Block a user