Commit ·
eb47ef7
1
Parent(s): 120c455
feature(#99): complete UI/UX that shows mails that users receive
Browse files
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/adapters/ChatMainAdapter.kt
CHANGED
|
@@ -19,10 +19,12 @@ import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.ChatMessageInterfa
|
|
| 19 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.OnHideListener
|
| 20 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.SendSmsWidget
|
| 21 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.alarm.ScheduleAlarmWidget
|
| 22 |
-
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.contact.
|
| 23 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.helpprompt.HelpPromptWidget
|
|
|
|
| 24 |
import com.matthaigh27.chatgptwrapper.utils.Constants.PROPS_WIDGET_DESC
|
| 25 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_HELP_PROMPT
|
|
|
|
| 26 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_SCHEDULE_ALARM
|
| 27 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_SEARCH_CONTACT
|
| 28 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_SMS
|
|
@@ -121,8 +123,6 @@ class ChatMainAdapter(
|
|
| 121 |
|
| 122 |
data.content?.let { message ->
|
| 123 |
holder.txtMessage.text = message
|
| 124 |
-
if(message.isEmpty())
|
| 125 |
-
holder.txtMessage.visibility = View.GONE
|
| 126 |
} ?: run {
|
| 127 |
holder.txtMessage.visibility = View.GONE
|
| 128 |
}
|
|
@@ -140,6 +140,7 @@ class ChatMainAdapter(
|
|
| 140 |
|
| 141 |
private fun setMessageData(holder: ChatWidgetViewHolder, data: ChatMessageModel) {
|
| 142 |
holder.itemLayout.visibility = View.VISIBLE
|
|
|
|
| 143 |
holder.itemLayout.removeAllViews()
|
| 144 |
val index = holder.adapterPosition
|
| 145 |
|
|
@@ -183,7 +184,7 @@ class ChatMainAdapter(
|
|
| 183 |
}
|
| 184 |
|
| 185 |
TYPE_WIDGET_SEARCH_CONTACT -> {
|
| 186 |
-
holder.
|
| 187 |
|
| 188 |
val contacts = getContacts(context)
|
| 189 |
|
|
@@ -192,16 +193,19 @@ class ChatMainAdapter(
|
|
| 192 |
val contactId = contactIds[i].toString()
|
| 193 |
val contact = getContactModelById(contactId, contacts)
|
| 194 |
|
| 195 |
-
val
|
| 196 |
this.callback = callbacks
|
| 197 |
}
|
| 198 |
-
holder.
|
| 199 |
}
|
| 200 |
}
|
| 201 |
|
| 202 |
TYPE_WIDGET_SCHEDULE_ALARM -> {
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
| 205 |
val scheduleAlarmWidget =
|
| 206 |
ScheduleAlarmWidget(context, props.time, props.label, props.repeat).apply {
|
| 207 |
this.callback = callbacks
|
|
@@ -216,6 +220,17 @@ class ChatMainAdapter(
|
|
| 216 |
holder.itemLayout.addView(scheduleAlarmWidget)
|
| 217 |
}
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
else -> {
|
| 220 |
holder.itemLayout.visibility = View.GONE
|
| 221 |
}
|
|
@@ -238,11 +253,11 @@ class ChatMainAdapter(
|
|
| 238 |
inner class ChatWidgetViewHolder internal constructor(itemView: View) :
|
| 239 |
RecyclerView.ViewHolder(itemView) {
|
| 240 |
var itemLayout: FrameLayout
|
| 241 |
-
var
|
| 242 |
|
| 243 |
init {
|
| 244 |
itemLayout = itemView.findViewById<View>(R.id.fl_widget_message) as FrameLayout
|
| 245 |
-
|
| 246 |
}
|
| 247 |
}
|
| 248 |
}
|
|
|
|
| 19 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.OnHideListener
|
| 20 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.SendSmsWidget
|
| 21 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.alarm.ScheduleAlarmWidget
|
| 22 |
+
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.contact.ContactWidget
|
| 23 |
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.helpprompt.HelpPromptWidget
|
| 24 |
+
import com.matthaigh27.chatgptwrapper.ui.chat.view.widgets.chatwidget.mail.MailWidget
|
| 25 |
import com.matthaigh27.chatgptwrapper.utils.Constants.PROPS_WIDGET_DESC
|
| 26 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_HELP_PROMPT
|
| 27 |
+
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_MAIL_READ
|
| 28 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_SCHEDULE_ALARM
|
| 29 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_SEARCH_CONTACT
|
| 30 |
import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_WIDGET_SMS
|
|
|
|
| 123 |
|
| 124 |
data.content?.let { message ->
|
| 125 |
holder.txtMessage.text = message
|
|
|
|
|
|
|
| 126 |
} ?: run {
|
| 127 |
holder.txtMessage.visibility = View.GONE
|
| 128 |
}
|
|
|
|
| 140 |
|
| 141 |
private fun setMessageData(holder: ChatWidgetViewHolder, data: ChatMessageModel) {
|
| 142 |
holder.itemLayout.visibility = View.VISIBLE
|
| 143 |
+
holder.llHorizontalScroll.removeAllViews()
|
| 144 |
holder.itemLayout.removeAllViews()
|
| 145 |
val index = holder.adapterPosition
|
| 146 |
|
|
|
|
| 184 |
}
|
| 185 |
|
| 186 |
TYPE_WIDGET_SEARCH_CONTACT -> {
|
| 187 |
+
holder.llHorizontalScroll.visibility = View.VISIBLE
|
| 188 |
|
| 189 |
val contacts = getContacts(context)
|
| 190 |
|
|
|
|
| 193 |
val contactId = contactIds[i].toString()
|
| 194 |
val contact = getContactModelById(contactId, contacts)
|
| 195 |
|
| 196 |
+
val contactWidget = ContactWidget(context, contact).apply {
|
| 197 |
this.callback = callbacks
|
| 198 |
}
|
| 199 |
+
holder.llHorizontalScroll.addView(contactWidget)
|
| 200 |
}
|
| 201 |
}
|
| 202 |
|
| 203 |
TYPE_WIDGET_SCHEDULE_ALARM -> {
|
| 204 |
+
var props = ScheduleAlarmProps()
|
| 205 |
+
data.data?.run {
|
| 206 |
+
val widgetDesc = data.data.asJsonObject[PROPS_WIDGET_DESC].asString
|
| 207 |
+
props = ScheduleAlarmProps.init(widgetDesc)
|
| 208 |
+
}
|
| 209 |
val scheduleAlarmWidget =
|
| 210 |
ScheduleAlarmWidget(context, props.time, props.label, props.repeat).apply {
|
| 211 |
this.callback = callbacks
|
|
|
|
| 220 |
holder.itemLayout.addView(scheduleAlarmWidget)
|
| 221 |
}
|
| 222 |
|
| 223 |
+
TYPE_WIDGET_MAIL_READ -> {
|
| 224 |
+
holder.llHorizontalScroll.visibility = View.VISIBLE
|
| 225 |
+
|
| 226 |
+
for (i in 0 until 10) {
|
| 227 |
+
val mailWidget = MailWidget(context).apply {
|
| 228 |
+
this.callback = callbacks
|
| 229 |
+
}
|
| 230 |
+
holder.llHorizontalScroll.addView(mailWidget)
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
else -> {
|
| 235 |
holder.itemLayout.visibility = View.GONE
|
| 236 |
}
|
|
|
|
| 253 |
inner class ChatWidgetViewHolder internal constructor(itemView: View) :
|
| 254 |
RecyclerView.ViewHolder(itemView) {
|
| 255 |
var itemLayout: FrameLayout
|
| 256 |
+
var llHorizontalScroll: LinearLayout
|
| 257 |
|
| 258 |
init {
|
| 259 |
itemLayout = itemView.findViewById<View>(R.id.fl_widget_message) as FrameLayout
|
| 260 |
+
llHorizontalScroll = itemView.findViewById<View>(R.id.ll_horizontal_scroll) as LinearLayout
|
| 261 |
}
|
| 262 |
}
|
| 263 |
}
|