Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JetChat] Add glance widget for JetChat App #1424 #1425

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Glance Widget for JetChat
  • Loading branch information
shangeethsivan committed Jul 3, 2024
commit ed13f9a297224f5d083962ca312dcfcfed6c64fc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.compose.jetchat.widget

import android.content.Context
import androidx.glance.GlanceId
import androidx.glance.GlanceTheme
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.provideContent
import com.example.compose.jetchat.widget.composables.MessagesWidget

class JetChatWidget : GlanceAppWidget() {

override suspend fun provideGlance(context: Context, id: GlanceId) {
provideContent {
GlanceTheme {
MessagesWidget()
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import androidx.glance.appwidget.GlanceAppWidgetReceiver
class WidgetReceiver : GlanceAppWidgetReceiver() {

override val glanceAppWidget: GlanceAppWidget
get() = MyAppWidget()
get() = JetChatWidget()

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.ui.unit.dp
import androidx.glance.GlanceModifier
import androidx.glance.ImageProvider
import androidx.glance.LocalContext
import androidx.glance.LocalSize
import androidx.glance.action.actionStartActivity
import androidx.glance.action.clickable
import androidx.glance.appwidget.components.Scaffold
Expand All @@ -22,25 +21,9 @@ import com.example.compose.jetchat.NavActivity
import com.example.compose.jetchat.R
import com.example.compose.jetchat.conversation.Message
import com.example.compose.jetchat.data.unreadMessages
import com.example.compose.jetchat.widget.MyAppWidget.Companion.ICON_SQUARE

@Composable
fun MessagesWidget() {
val size = LocalSize.current
if (size.width <= ICON_SQUARE.width) {
SmallIcon()
} else {
LargeMessages()
}
}

@Composable
fun SmallIcon() {
// IconImageProvider(Icon(R.drawable.ic_jetchat))
}

@Composable
fun LargeMessages() {
Scaffold(titleBar = {
TitleBar(
startIcon = ImageProvider(R.drawable.ic_jetchat),
Expand Down
2 changes: 1 addition & 1 deletion Jetchat/app/src/main/res/xml/my_app_widget_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:minWidth="276dp"
android:minHeight="102dp"
android:previewImage="@drawable/widget_icon"
android:resizeMode="horizontal|vertical"
android:resizeMode="none"
android:targetCellWidth="4"
android:targetCellHeight="3" />