view recipts full screen by pressing empty area, copy values by holding it
All checks were successful
Auto Tag on Version Change / check-version (push) Successful in 3s
All checks were successful
Auto Tag on Version Change / check-version (push) Successful in 3s
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package sh.sar.basedbank.ui.home
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
@@ -105,6 +109,8 @@ class TransferReceiptFragment : Fragment() {
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
receiptCard.setOnClickListener { showFullScreenReceipt() }
|
||||
|
||||
view.findViewById<MaterialButton>(R.id.btnDone).setOnClickListener {
|
||||
parentFragmentManager.popBackStack()
|
||||
}
|
||||
@@ -150,6 +156,12 @@ class TransferReceiptFragment : Fragment() {
|
||||
binding.tvTransactionDate.text = args.getString(ARG_MIB_DATE, "")
|
||||
binding.tvValueDate.text = args.getString(ARG_MIB_DATE, "")
|
||||
binding.tvPurpose.text = args.getString(ARG_REMARKS, "")
|
||||
|
||||
copyOnLongClick(
|
||||
binding.tvFromLabel, binding.tvToLabel, binding.tvAmount,
|
||||
binding.tvReferenceNo, binding.tvToAccount, binding.tvToBank,
|
||||
binding.tvTransactionDate, binding.tvValueDate, binding.tvPurpose
|
||||
)
|
||||
}
|
||||
|
||||
private fun loadProfileImage(hash: String, isProfile: Boolean, onLoaded: (Bitmap) -> Unit) {
|
||||
@@ -201,6 +213,13 @@ class TransferReceiptFragment : Fragment() {
|
||||
binding.remarksDivider.visibility = View.VISIBLE
|
||||
binding.remarksRow.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
copyOnLongClick(
|
||||
binding.tvMessage, binding.tvMessageRow, binding.tvReference,
|
||||
binding.tvTransactionDate, binding.tvFrom, binding.tvToName,
|
||||
binding.tvToAccount, binding.tvAmountRow, binding.tvAmountValue,
|
||||
binding.tvAmountCurrency, binding.tvRemarks
|
||||
)
|
||||
}
|
||||
|
||||
// ── Share / Save ──────────────────────────────────────────────────────────
|
||||
@@ -310,6 +329,54 @@ class TransferReceiptFragment : Fragment() {
|
||||
return bm
|
||||
}
|
||||
|
||||
private fun showFullScreenReceipt() {
|
||||
captureReceiptBitmap { bitmap ->
|
||||
if (bitmap == null) return@captureReceiptBitmap
|
||||
val ctx = requireContext()
|
||||
val dialog = Dialog(ctx, android.R.style.Theme_Black_NoTitleBar_Fullscreen)
|
||||
val iv = android.widget.ImageView(ctx).apply {
|
||||
setImageBitmap(bitmap)
|
||||
scaleType = android.widget.ImageView.ScaleType.FIT_CENTER
|
||||
setBackgroundColor(Color.BLACK)
|
||||
}
|
||||
iv.setOnClickListener { dialog.dismiss() }
|
||||
dialog.setContentView(iv)
|
||||
val actWin = requireActivity().window
|
||||
val prevColor = actWin.statusBarColor
|
||||
val insetsCtrl = androidx.core.view.WindowInsetsControllerCompat(actWin, actWin.decorView)
|
||||
actWin.statusBarColor = Color.BLACK
|
||||
insetsCtrl.isAppearanceLightStatusBars = false
|
||||
dialog.setOnDismissListener {
|
||||
actWin.statusBarColor = prevColor
|
||||
val isLight = (resources.configuration.uiMode and
|
||||
android.content.res.Configuration.UI_MODE_NIGHT_MASK) ==
|
||||
android.content.res.Configuration.UI_MODE_NIGHT_NO
|
||||
insetsCtrl.isAppearanceLightStatusBars = isLight
|
||||
}
|
||||
dialog.show()
|
||||
dialog.window?.let { win ->
|
||||
androidx.core.view.WindowCompat.setDecorFitsSystemWindows(win, false)
|
||||
androidx.core.view.WindowInsetsControllerCompat(win, iv).apply {
|
||||
hide(androidx.core.view.WindowInsetsCompat.Type.systemBars())
|
||||
systemBarsBehavior = androidx.core.view.WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyOnLongClick(vararg views: android.widget.TextView) {
|
||||
for (tv in views) {
|
||||
tv.setOnLongClickListener {
|
||||
val text = tv.text?.toString()?.trim() ?: return@setOnLongClickListener false
|
||||
if (text.isBlank()) return@setOnLongClickListener false
|
||||
val cm = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
cm.setPrimaryClip(ClipData.newPlainText("receipt", text))
|
||||
Toast.makeText(requireContext(), "Copied", Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
requireActivity().title = "Receipt"
|
||||
|
||||
Reference in New Issue
Block a user