adding a shadowed version of the Next alarm image on the widget
This commit is contained in:
parent
73fceb9504
commit
e38bd8e660
|
@ -6,6 +6,7 @@ import android.appwidget.AppWidgetProvider
|
|||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.*
|
||||
import android.widget.RemoteViews
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SplashActivity
|
||||
|
@ -74,9 +75,15 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
|||
setTextColor(R.id.widget_time_am_pm, widgetTextColor)
|
||||
setTextColor(R.id.widget_date, widgetTextColor)
|
||||
setTextColor(R.id.widget_next_alarm, widgetTextColor)
|
||||
|
||||
if (context.config.useTextShadow) {
|
||||
val bitmap = getMultiplyColoredBitmap(R.drawable.ic_clock_shadowed, widgetTextColor, context)
|
||||
setImageViewBitmap(R.id.widget_next_alarm_image, bitmap)
|
||||
} else {
|
||||
setImageViewBitmap(R.id.widget_next_alarm_image, context.resources.getColoredBitmap(R.drawable.ic_clock, widgetTextColor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getComponentName(context: Context) = ComponentName(context, this::class.java)
|
||||
|
||||
|
@ -121,4 +128,16 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
|||
else -> nextAlarm
|
||||
}
|
||||
}
|
||||
|
||||
fun getMultiplyColoredBitmap(resourceId: Int, newColor: Int, context: Context): Bitmap {
|
||||
val options = BitmapFactory.Options()
|
||||
options.inMutable = true
|
||||
val bmp = BitmapFactory.decodeResource(context.resources, resourceId, options)
|
||||
val paint = Paint()
|
||||
val filter = PorterDuffColorFilter(newColor, PorterDuff.Mode.MULTIPLY)
|
||||
paint.colorFilter = filter
|
||||
val canvas = Canvas(bmp)
|
||||
canvas.drawBitmap(bmp, 0f, 0f, paint)
|
||||
return bmp
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Loading…
Reference in New Issue