Skip to content
Snippets Groups Projects
Commit 7b67eaa3 authored by yansans's avatar yansans
Browse files

feat: integrate gmail to setting

parent cdf74561
Branches
Tags
1 merge request!13Release
......@@ -111,7 +111,7 @@ class SettingsFragment : Fragment() {
Log.d("BroadcastDebug", "Sending broadcast from SettingsFragment")
}
val exporter = TransactionsExporter(transactionsViewModel, requireContext())
exporter = TransactionsExporter(transactionsViewModel, requireContext())
// exporter = context?.let { TransactionsExporter(database, it) }!!
......@@ -184,6 +184,46 @@ class SettingsFragment : Fragment() {
context?.let { EmailHelper(it) }
?.sendGmail(recipientEmail, subject, message, attachment)
}
val formats = arrayOf("XLS", "XLSX")
val builder = AlertDialog.Builder(requireContext())
builder.setTitle("Pilih Format File")
builder.setItems(formats) { dialog: DialogInterface, which: Int ->
when (which) {
0 -> {
Toast.makeText(
appContext,
"Mengirim file xls...",
Toast.LENGTH_SHORT
).show()
settingsViewModel.getUser()?.let { user ->
recipientEmail = user.email
val attachment = getAttachmentUri("transactions.xls")
Log.d("Attachment", "Attachment URI: $attachment")
context?.let { EmailHelper(it) }
?.sendGmail(recipientEmail, subject, message, attachment)
}
}
1 -> {
Toast.makeText(
appContext,
"Menyimpan transaksi ke xlsx...",
Toast.LENGTH_SHORT
).show()
settingsViewModel.getUser()?.let { user ->
recipientEmail = user.email
val attachment = getAttachmentUri("transactions.xls")
Log.d("Attachment", "Attachment URI: $attachment")
context?.let { EmailHelper(it) }
?.sendGmail(recipientEmail, subject, message, attachment)
}
}
}
dialog.dismiss()
}
builder.create().show()
}
}
......
......@@ -4,8 +4,6 @@ import android.content.Context
import android.location.Address
import android.location.Geocoder
import android.os.Environment
import android.os.Handler
import android.os.Looper
import android.util.Log
import androidx.lifecycle.viewModelScope
import com.example.bondoyap.ui.transactions.TransactionsViewModel
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment