forked from upstream-mirrors/quik
use class instead of hard coded string in speak unseen msgs widget. small code cleanups in the same file
This commit is contained in:
+5
-10
@@ -24,10 +24,9 @@ import android.appwidget.AppWidgetManager
|
|||||||
import android.appwidget.AppWidgetProvider
|
import android.appwidget.AppWidgetProvider
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import dev.octoshrimpy.quik.R
|
import dev.octoshrimpy.quik.R
|
||||||
import dev.octoshrimpy.quik.common.util.extensions.getColorCompat
|
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver
|
||||||
|
|
||||||
class WidgetSpeakUnseenProvider : AppWidgetProvider() {
|
class WidgetSpeakUnseenProvider : AppWidgetProvider() {
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ class WidgetSpeakUnseenProvider : AppWidgetProvider() {
|
|||||||
updateWidget(context, appWidgetId)
|
updateWidget(context, appWidgetId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateWidget(context: Context?, appWidgetId: Int) {
|
private fun updateWidget(context: Context?, appWidgetId: Int) {
|
||||||
super.onEnabled(context)
|
super.onEnabled(context)
|
||||||
|
|
||||||
if (context == null)
|
if (context == null)
|
||||||
@@ -53,14 +52,10 @@ class WidgetSpeakUnseenProvider : AppWidgetProvider() {
|
|||||||
remoteViews.setImageViewResource(R.id.speakUnseenImage, R.drawable.ic_speak_unseen_widget)
|
remoteViews.setImageViewResource(R.id.speakUnseenImage, R.drawable.ic_speak_unseen_widget)
|
||||||
|
|
||||||
// speak unseen intent
|
// speak unseen intent
|
||||||
val speakUnseenIntent = Intent("dev.octoshrimpy.quik.intent.action.ACTION_SPEAK_MESSAGES")
|
val speakUnseenIntent = Intent(context, SpeakThreadsReceiver::class.java)
|
||||||
.setPackage(context.packageName)
|
|
||||||
.putExtra("threadId", -1L)
|
.putExtra("threadId", -1L)
|
||||||
val speakUnseenPendingIntent = PendingIntent.getBroadcast(
|
val speakUnseenPendingIntent = PendingIntent.getBroadcast(context,0,
|
||||||
context,
|
speakUnseenIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||||
0,
|
|
||||||
speakUnseenIntent,
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
|
||||||
remoteViews.setOnClickPendingIntent(R.id.speakUnseenImage, speakUnseenPendingIntent)
|
remoteViews.setOnClickPendingIntent(R.id.speakUnseenImage, speakUnseenPendingIntent)
|
||||||
|
|
||||||
AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews)
|
AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews)
|
||||||
|
|||||||
Reference in New Issue
Block a user