Skip to content
Snippets Groups Projects
Commit 035ebdfd authored by Ghazi Akmal Fauzan's avatar Ghazi Akmal Fauzan
Browse files

update: change minor UI

This improvement committed after Deadline
parent f57f88ed
Branches
No related merge requests found
...@@ -170,13 +170,17 @@ class TwibbonFragment : Fragment() { ...@@ -170,13 +170,17 @@ class TwibbonFragment : Fragment() {
val top = (cameraBitmap.height - sideLength) / 2 val top = (cameraBitmap.height - sideLength) / 2
// Crop or resize the camera image to make it square // Crop or resize the camera image to make it square
val croppedCameraBitmap = Bitmap.createBitmap(cameraBitmap, 0, 0, sideLength, sideLength) val croppedCameraBitmap = if (cameraBitmap.width > cameraBitmap.height) {
Bitmap.createBitmap(cameraBitmap, (cameraBitmap.width - sideLength) / 2, 0, sideLength, sideLength)
} else {
Bitmap.createBitmap(cameraBitmap, 0, (cameraBitmap.height - sideLength) / 2, sideLength, sideLength)
}
// Resize the twibbon image to match the dimensions of the cropped camera image // Resize the twibbon image to match the dimensions of the cropped camera image
val resizedTwibbonBitmap = Bitmap.createScaledBitmap(twibbonBitmap, sideLength, sideLength, true) val resizedTwibbonBitmap = Bitmap.createScaledBitmap(twibbonBitmap, sideLength, sideLength, true)
// Create a new bitmap with the combined images // Create a new bitmap with the combined images
val combinedBitmap = Bitmap.createBitmap(cameraBitmap.width, cameraBitmap.height, Bitmap.Config.ARGB_8888) val combinedBitmap = Bitmap.createBitmap(sideLength, sideLength, Bitmap.Config.ARGB_8888)
val canvas = Canvas(combinedBitmap) val canvas = Canvas(combinedBitmap)
val paint = Paint(Paint.FILTER_BITMAP_FLAG) val paint = Paint(Paint.FILTER_BITMAP_FLAG)
...@@ -184,7 +188,7 @@ class TwibbonFragment : Fragment() { ...@@ -184,7 +188,7 @@ class TwibbonFragment : Fragment() {
canvas.drawBitmap(croppedCameraBitmap, Matrix(), paint) canvas.drawBitmap(croppedCameraBitmap, Matrix(), paint)
// Draw the resized twibbon image onto the canvas at the calculated position // Draw the resized twibbon image onto the canvas at the calculated position
canvas.drawBitmap(resizedTwibbonBitmap, left.toFloat(), top.toFloat(), paint) canvas.drawBitmap(resizedTwibbonBitmap, 0f, 0f, paint)
return combinedBitmap return combinedBitmap
} }
...@@ -209,7 +213,7 @@ class TwibbonFragment : Fragment() { ...@@ -209,7 +213,7 @@ class TwibbonFragment : Fragment() {
private fun showImagePopup(imageBitmap: Bitmap?) { private fun showImagePopup(imageBitmap: Bitmap?) {
if (imageBitmap != null) { if (imageBitmap != null) {
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext(), R.style.AlertDialogTheme)
.setTitle("Save this picture?") .setTitle("Save this picture?")
.setPositiveButton("Yes") { dialog, _ -> .setPositiveButton("Yes") { dialog, _ ->
showFilenameInputDialog(imageBitmap) showFilenameInputDialog(imageBitmap)
...@@ -246,7 +250,7 @@ class TwibbonFragment : Fragment() { ...@@ -246,7 +250,7 @@ class TwibbonFragment : Fragment() {
val inputView = LayoutInflater.from(requireContext()).inflate(R.layout.twibbon_filename, null) val inputView = LayoutInflater.from(requireContext()).inflate(R.layout.twibbon_filename, null)
val filenameEditText = inputView.findViewById<EditText>(R.id.filenameInput) val filenameEditText = inputView.findViewById<EditText>(R.id.filenameInput)
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext(), R.style.AlertDialogTheme)
.setTitle("Save Image") .setTitle("Save Image")
.setView(inputView) .setView(inputView)
.setPositiveButton("Save") { dialog, _ -> .setPositiveButton("Save") { dialog, _ ->
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp" android:padding="16dp">
android:background="@drawable/round_corner_input_transaction_form">
<EditText <EditText
android:id="@+id/filenameInput" android:id="@+id/filenameInput"
......
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