Skip to content

Commit

Permalink
use class instead of hard coded string in speak unseen msgs widget. s…
Browse files Browse the repository at this point in the history
…mall code cleanups in the same file
  • Loading branch information
gavine99 committed Jan 7, 2025
1 parent 20f2e7f commit 714cec2
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.widget.ImageView
import android.widget.RemoteViews
import dev.octoshrimpy.quik.R
import dev.octoshrimpy.quik.common.util.extensions.getColorCompat
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver

class WidgetSpeakUnseenProvider : AppWidgetProvider() {

Expand All @@ -42,7 +41,7 @@ class WidgetSpeakUnseenProvider : AppWidgetProvider() {
updateWidget(context, appWidgetId)
}

fun updateWidget(context: Context?, appWidgetId: Int) {
private fun updateWidget(context: Context?, appWidgetId: Int) {
super.onEnabled(context)

if (context == null)
Expand All @@ -53,14 +52,10 @@ class WidgetSpeakUnseenProvider : AppWidgetProvider() {
remoteViews.setImageViewResource(R.id.speakUnseenImage, R.drawable.ic_speak_unseen_widget)

// speak unseen intent
val speakUnseenIntent = Intent("dev.octoshrimpy.quik.intent.action.ACTION_SPEAK_MESSAGES")
.setPackage(context.packageName)
val speakUnseenIntent = Intent(context, SpeakThreadsReceiver::class.java)
.putExtra("threadId", -1L)
val speakUnseenPendingIntent = PendingIntent.getBroadcast(
context,
0,
speakUnseenIntent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
val speakUnseenPendingIntent = PendingIntent.getBroadcast(context,0,
speakUnseenIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
remoteViews.setOnClickPendingIntent(R.id.speakUnseenImage, speakUnseenPendingIntent)

AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews)
Expand Down

0 comments on commit 714cec2

Please sign in to comment.