peterluo3131 commited on
Commit
d44e91d
·
1 Parent(s): c92f185

feature(#99): complete interface that users can read or send mails

Browse files
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/adapters/ChatMainAdapter.kt CHANGED
@@ -277,7 +277,7 @@ class ChatMainAdapter(
277
  }
278
 
279
  TYPE_WIDGET_MAIL_WRITE -> {
280
- val composeMailWIdget = ComposeMailWidget(context).apply {
281
  this.callback = callbacks
282
  this.hideListener = object : OnHideListener {
283
  override fun hide() {
@@ -287,7 +287,7 @@ class ChatMainAdapter(
287
  }
288
  }
289
  }
290
- holder.itemLayout.addView(composeMailWIdget)
291
  }
292
 
293
  else -> {
 
277
  }
278
 
279
  TYPE_WIDGET_MAIL_WRITE -> {
280
+ val composeMailWidget = ComposeMailWidget(context).apply {
281
  this.callback = callbacks
282
  this.hideListener = object : OnHideListener {
283
  override fun hide() {
 
287
  }
288
  }
289
  }
290
+ holder.itemLayout.addView(composeMailWidget)
291
  }
292
 
293
  else -> {
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/widgets/chatwidget/mail/ComposeMailWidget.kt CHANGED
@@ -20,6 +20,9 @@ import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.ChatMessageInterfa
20
  import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.OnHideListener
21
  import com.matthaigh27.chatgptwrapper.utils.helpers.chat.MailHelper.isGmail
22
 
 
 
 
23
  class ComposeMailWidget(
24
  context: Context, attrs: AttributeSet? = null
25
  ) : ConstraintLayout(context, attrs), View.OnClickListener {
@@ -52,7 +55,6 @@ class ComposeMailWidget(
52
  this.setOnClickListener(this)
53
  findViewById<ImageView>(R.id.btn_send).setOnClickListener(this)
54
  findViewById<ImageView>(R.id.btn_send_cancel).setOnClickListener(this)
55
- findViewById<ImageView>(R.id.btn_attachment).setOnClickListener(this)
56
 
57
  mailChipGroup = findViewById(R.id.mail_chip_group)
58
  attachmentChipGroup = findViewById(R.id.attachment_chip_group)
@@ -102,52 +104,12 @@ class ComposeMailWidget(
102
  filename = "",
103
  fileContent = "",
104
  )
105
- }
106
-
107
- R.id.btn_cancel -> {
108
  hideListener?.hide()
109
  }
110
 
111
- R.id.btn_attachment -> {
112
- // val choice = arrayOf("Local Storage", "Google Drive")
113
- // val builder = AlertDialog.Builder(context)
114
- // builder.setItems(choice) { dialog, which ->
115
- // when (which) {
116
- // 0 -> selectFileFromLocalStorage()
117
- // 1 -> selectFileFromGoogleDrive()
118
- // }
119
- // }
120
- // builder.show()
121
  }
122
  }
123
  }
124
-
125
- // fun selectFileFromLocalStorage() {
126
- // val intent = Intent(Intent.ACTION_GET_CONTENT)
127
- // intent.type = "*/*"
128
- // startActivityForResult(intent, REQUEST_CODE_LOCAL_STORAGE)
129
- // }
130
- //
131
- // fun selectFileFromGoogleDrive() {
132
- // val intent = driveClient.newOpenFileActivityIntentBuilder()
133
- // .setMimeType(new String[] {"text/plain"})
134
- // .build();
135
- // startActivityForResult(intent, REQUEST_CODE_GOOGLE_DRIVE);
136
- // }
137
- //
138
- // override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
139
- // super.onActivityResult(requestCode, resultCode, data)
140
- // if (requestCode == REQUEST_CODE_LOCAL_STORAGE && resultCode == Activity.RESULT_OK && data != null) {
141
- // fileName = data.data
142
- // }
143
- // }
144
- //
145
- // override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
146
- // super.onActivityResult(requestCode, resultCode, data)
147
- // // handle onActivityResult for local storage
148
- // if (requestCode == REQUEST_CODE_GOOGLE_DRIVE && resultCode == Activity.RESULT_OK && data != null) {
149
- // val driveId = data.getParcelableExtra<DriveId>(OpenFileActivityOptions.EXTRA_RESPONSE_DRIVE_ID);
150
- // // use this driveId to handle file
151
- // }
152
- // }
153
  }
 
20
  import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.OnHideListener
21
  import com.matthaigh27.chatgptwrapper.utils.helpers.chat.MailHelper.isGmail
22
 
23
+ /**
24
+ * This ComposeMaiWidget, which is embed to the chat list, is used to send mail
25
+ */
26
  class ComposeMailWidget(
27
  context: Context, attrs: AttributeSet? = null
28
  ) : ConstraintLayout(context, attrs), View.OnClickListener {
 
55
  this.setOnClickListener(this)
56
  findViewById<ImageView>(R.id.btn_send).setOnClickListener(this)
57
  findViewById<ImageView>(R.id.btn_send_cancel).setOnClickListener(this)
 
58
 
59
  mailChipGroup = findViewById(R.id.mail_chip_group)
60
  attachmentChipGroup = findViewById(R.id.attachment_chip_group)
 
104
  filename = "",
105
  fileContent = "",
106
  )
 
 
 
107
  hideListener?.hide()
108
  }
109
 
110
+ R.id.btn_send_cancel -> {
111
+ hideListener?.hide()
 
 
 
 
 
 
 
 
112
  }
113
  }
114
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
Android/app/src/main/res/layout/widget_mail_compose.xml CHANGED
@@ -52,6 +52,7 @@
52
  android:layout_width="@dimen/size_button_normal"
53
  android:layout_height="@dimen/size_button_normal"
54
  android:padding="@dimen/spacing_tiny"
 
55
  android:src="@drawable/ic_attachment"
56
  app:layout_constraintBottom_toBottomOf="@+id/txt_title"
57
  app:layout_constraintEnd_toStartOf="@+id/btn_send"
 
52
  android:layout_width="@dimen/size_button_normal"
53
  android:layout_height="@dimen/size_button_normal"
54
  android:padding="@dimen/spacing_tiny"
55
+ android:visibility="gone"
56
  android:src="@drawable/ic_attachment"
57
  app:layout_constraintBottom_toBottomOf="@+id/txt_title"
58
  app:layout_constraintEnd_toStartOf="@+id/btn_send"