forked from upstream-mirrors/quik
Merge pull request #523 from Inhishonor/widget-dark
Various improvements to the widget
This commit is contained in:
@@ -201,6 +201,7 @@
|
|||||||
</receiver>
|
</receiver>
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".feature.widget.WidgetProvider"
|
android:name=".feature.widget.WidgetProvider"
|
||||||
|
android:label="@string/all_conversations_widget_title"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
|||||||
* we'll return the max count + 1, where the last row just shows "View more conversations"
|
* we'll return the max count + 1, where the last row just shows "View more conversations"
|
||||||
*/
|
*/
|
||||||
override fun getCount(): Int {
|
override fun getCount(): Int {
|
||||||
val count = Math.min(conversations.size, MAX_CONVERSATIONS_COUNT)
|
val count = conversations.size.coerceAtMost(MAX_CONVERSATIONS_COUNT)
|
||||||
val shouldShowViewMore = count < conversations.size
|
val shouldShowViewMore = count < conversations.size
|
||||||
return count + if (shouldShowViewMore) 1 else 0
|
return count + if (shouldShowViewMore) 1 else 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import android.appwidget.AppWidgetProvider
|
|||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.content.res.Configuration
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
@@ -39,6 +39,7 @@ import dev.octoshrimpy.quik.receiver.StartActivityFromWidgetReceiver
|
|||||||
import dev.octoshrimpy.quik.util.Preferences
|
import dev.octoshrimpy.quik.util.Preferences
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
|
||||||
class WidgetProvider : AppWidgetProvider() {
|
class WidgetProvider : AppWidgetProvider() {
|
||||||
|
|
||||||
@@ -109,8 +110,11 @@ class WidgetProvider : AppWidgetProvider() {
|
|||||||
Timber.v("updateWidget appWidgetId: $appWidgetId")
|
Timber.v("updateWidget appWidgetId: $appWidgetId")
|
||||||
val remoteViews = RemoteViews(context.packageName, R.layout.widget)
|
val remoteViews = RemoteViews(context.packageName, R.layout.widget)
|
||||||
|
|
||||||
|
val nightModeFlags = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
|
val isNightMode = nightModeFlags == Configuration.UI_MODE_NIGHT_YES
|
||||||
|
|
||||||
// Apply colors from theme
|
// Apply colors from theme
|
||||||
val night = prefs.night.get()
|
val night = prefs.night.get() || isNightMode
|
||||||
val black = prefs.black.get()
|
val black = prefs.black.get()
|
||||||
|
|
||||||
remoteViews.setInt(R.id.background, "setColorFilter", context.getColorCompat(when {
|
remoteViews.setInt(R.id.background, "setColorFilter", context.getColorCompat(when {
|
||||||
@@ -134,7 +138,7 @@ class WidgetProvider : AppWidgetProvider() {
|
|||||||
val intent = Intent(context, WidgetService::class.java)
|
val intent = Intent(context, WidgetService::class.java)
|
||||||
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
|
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
|
||||||
.putExtra("small_widget", smallWidget)
|
.putExtra("small_widget", smallWidget)
|
||||||
intent.data = Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))
|
intent.data = intent.toUri(Intent.URI_INTENT_SCHEME).toUri()
|
||||||
remoteViews.setRemoteAdapter(R.id.conversations, intent)
|
remoteViews.setRemoteAdapter(R.id.conversations, intent)
|
||||||
|
|
||||||
// compose new message image color and on click intent
|
// compose new message image color and on click intent
|
||||||
|
|||||||
@@ -433,6 +433,7 @@
|
|||||||
|
|
||||||
<string name="widget_loading">Loading…</string>
|
<string name="widget_loading">Loading…</string>
|
||||||
<string name="widget_more">View more conversations</string>
|
<string name="widget_more">View more conversations</string>
|
||||||
|
<string name="all_conversations_widget_title">All Conversations</string>
|
||||||
|
|
||||||
<string name="qkreply_menu_read">Mark read</string>
|
<string name="qkreply_menu_read">Mark read</string>
|
||||||
<string name="qkreply_menu_call">Call</string>
|
<string name="qkreply_menu_call">Call</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user