Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
feature(#99): complete interface that users can read or send mails
Browse files Browse the repository at this point in the history
  • Loading branch information
peterluo3131 committed Jul 12, 2023
1 parent c92f185 commit d44e91d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class ChatMainAdapter(
}

TYPE_WIDGET_MAIL_WRITE -> {
val composeMailWIdget = ComposeMailWidget(context).apply {
val composeMailWidget = ComposeMailWidget(context).apply {
this.callback = callbacks
this.hideListener = object : OnHideListener {
override fun hide() {
Expand All @@ -287,7 +287,7 @@ class ChatMainAdapter(
}
}
}
holder.itemLayout.addView(composeMailWIdget)
holder.itemLayout.addView(composeMailWidget)
}

else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.ChatMessageInterfa
import com.matthaigh27.chatgptwrapper.ui.chat.view.interfaces.OnHideListener
import com.matthaigh27.chatgptwrapper.utils.helpers.chat.MailHelper.isGmail

/**
* This ComposeMaiWidget, which is embed to the chat list, is used to send mail
*/
class ComposeMailWidget(
context: Context, attrs: AttributeSet? = null
) : ConstraintLayout(context, attrs), View.OnClickListener {
Expand Down Expand Up @@ -52,7 +55,6 @@ class ComposeMailWidget(
this.setOnClickListener(this)
findViewById<ImageView>(R.id.btn_send).setOnClickListener(this)
findViewById<ImageView>(R.id.btn_send_cancel).setOnClickListener(this)
findViewById<ImageView>(R.id.btn_attachment).setOnClickListener(this)

mailChipGroup = findViewById(R.id.mail_chip_group)
attachmentChipGroup = findViewById(R.id.attachment_chip_group)
Expand Down Expand Up @@ -102,52 +104,12 @@ class ComposeMailWidget(
filename = "",
fileContent = "",
)
}

R.id.btn_cancel -> {
hideListener?.hide()
}

R.id.btn_attachment -> {
// val choice = arrayOf("Local Storage", "Google Drive")
// val builder = AlertDialog.Builder(context)
// builder.setItems(choice) { dialog, which ->
// when (which) {
// 0 -> selectFileFromLocalStorage()
// 1 -> selectFileFromGoogleDrive()
// }
// }
// builder.show()
R.id.btn_send_cancel -> {
hideListener?.hide()
}
}
}

// fun selectFileFromLocalStorage() {
// val intent = Intent(Intent.ACTION_GET_CONTENT)
// intent.type = "*/*"
// startActivityForResult(intent, REQUEST_CODE_LOCAL_STORAGE)
// }
//
// fun selectFileFromGoogleDrive() {
// val intent = driveClient.newOpenFileActivityIntentBuilder()
// .setMimeType(new String[] {"text/plain"})
// .build();
// startActivityForResult(intent, REQUEST_CODE_GOOGLE_DRIVE);
// }
//
// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// super.onActivityResult(requestCode, resultCode, data)
// if (requestCode == REQUEST_CODE_LOCAL_STORAGE && resultCode == Activity.RESULT_OK && data != null) {
// fileName = data.data
// }
// }
//
// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// super.onActivityResult(requestCode, resultCode, data)
// // handle onActivityResult for local storage
// if (requestCode == REQUEST_CODE_GOOGLE_DRIVE && resultCode == Activity.RESULT_OK && data != null) {
// val driveId = data.getParcelableExtra<DriveId>(OpenFileActivityOptions.EXTRA_RESPONSE_DRIVE_ID);
// // use this driveId to handle file
// }
// }
}
1 change: 1 addition & 0 deletions Android/app/src/main/res/layout/widget_mail_compose.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
android:layout_width="@dimen/size_button_normal"
android:layout_height="@dimen/size_button_normal"
android:padding="@dimen/spacing_tiny"
android:visibility="gone"
android:src="@drawable/ic_attachment"
app:layout_constraintBottom_toBottomOf="@+id/txt_title"
app:layout_constraintEnd_toStartOf="@+id/btn_send"
Expand Down

0 comments on commit d44e91d

Please sign in to comment.