|
@ -4,6 +4,7 @@ import android.Manifest |
|
|
import android.annotation.SuppressLint |
|
|
import android.annotation.SuppressLint |
|
|
import android.app.ActionBar.LayoutParams |
|
|
import android.app.ActionBar.LayoutParams |
|
|
import android.app.Dialog |
|
|
import android.app.Dialog |
|
|
|
|
|
import android.content.DialogInterface |
|
|
import android.content.pm.PackageManager |
|
|
import android.content.pm.PackageManager |
|
|
import android.database.Cursor |
|
|
import android.database.Cursor |
|
|
import android.graphics.Bitmap |
|
|
import android.graphics.Bitmap |
|
@ -19,6 +20,7 @@ import android.view.ViewGroup |
|
|
import android.widget.* |
|
|
import android.widget.* |
|
|
import androidx.activity.result.ActivityResultLauncher |
|
|
import androidx.activity.result.ActivityResultLauncher |
|
|
import androidx.activity.result.contract.ActivityResultContracts |
|
|
import androidx.activity.result.contract.ActivityResultContracts |
|
|
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
import androidx.core.content.ContextCompat |
|
|
import androidx.core.content.ContextCompat |
|
|
import androidx.core.content.FileProvider |
|
|
import androidx.core.content.FileProvider |
|
|
import androidx.lifecycle.ViewModelProvider |
|
|
import androidx.lifecycle.ViewModelProvider |
|
@ -72,6 +74,8 @@ class StepThreeBajajFDFragment : BaseFragment() { |
|
|
private val mapImage: HashMap<String, String> = HashMap() |
|
|
private val mapImage: HashMap<String, String> = HashMap() |
|
|
private lateinit var listOfDocType: List<GetCodes> |
|
|
private lateinit var listOfDocType: List<GetCodes> |
|
|
|
|
|
|
|
|
|
|
|
private val check = arrayOf<CharSequence>("Take Photo", "Choose from Gallery", "Cancel") |
|
|
|
|
|
|
|
|
private val requestPermission = registerForActivityResult( |
|
|
private val requestPermission = registerForActivityResult( |
|
|
ActivityResultContracts.RequestPermission() |
|
|
ActivityResultContracts.RequestPermission() |
|
|
) { isGranted: Boolean -> |
|
|
) { isGranted: Boolean -> |
|
@ -205,48 +209,42 @@ class StepThreeBajajFDFragment : BaseFragment() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun selectImage() { |
|
|
private fun selectImage() { |
|
|
dialog = Dialog(activity as BajajFdMainActivity) |
|
|
|
|
|
dialog.setContentView(R.layout.camera_gallery_layout) |
|
|
|
|
|
val ivCut: ImageView = dialog.findViewById(R.id.ivCut) |
|
|
|
|
|
val tvGallery: TextView = dialog.findViewById(R.id.tvGallery) |
|
|
|
|
|
val tvCamera: TextView = dialog.findViewById(R.id.tvCamera) |
|
|
|
|
|
|
|
|
|
|
|
ivCut.setOnClickListener { |
|
|
|
|
|
dialog.cancel() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tvGallery.setOnClickListener { |
|
|
|
|
|
dialog.cancel() |
|
|
|
|
|
val permission = ContextCompat.checkSelfPermission( |
|
|
|
|
|
activity as BajajFdMainActivity, |
|
|
|
|
|
Manifest.permission.READ_EXTERNAL_STORAGE |
|
|
|
|
|
) |
|
|
|
|
|
if (permission == PackageManager.PERMISSION_GRANTED) { |
|
|
|
|
|
selectImageIntent?.launch("image/*") |
|
|
|
|
|
} else { |
|
|
|
|
|
requestPermission.launch( |
|
|
|
|
|
Manifest.permission.READ_EXTERNAL_STORAGE |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tvCamera.setOnClickListener { |
|
|
|
|
|
dialog.cancel() |
|
|
|
|
|
val permission = ContextCompat.checkSelfPermission( |
|
|
|
|
|
activity as BajajFdMainActivity, |
|
|
|
|
|
Manifest.permission.CAMERA |
|
|
|
|
|
) |
|
|
|
|
|
if (permission == PackageManager.PERMISSION_GRANTED) { |
|
|
|
|
|
takeImage() |
|
|
|
|
|
} else { |
|
|
|
|
|
requestPermission.launch( |
|
|
|
|
|
|
|
|
val builder = AlertDialog.Builder( |
|
|
|
|
|
mActivity!! |
|
|
|
|
|
) |
|
|
|
|
|
builder.setTitle("Add Photo!") |
|
|
|
|
|
builder.setItems(check |
|
|
|
|
|
) { dialog: DialogInterface, item: Int -> |
|
|
|
|
|
if (check[item] == "Take Photo") { |
|
|
|
|
|
val permission = ContextCompat.checkSelfPermission( |
|
|
|
|
|
activity as BajajFdMainActivity, |
|
|
Manifest.permission.CAMERA |
|
|
Manifest.permission.CAMERA |
|
|
) |
|
|
) |
|
|
|
|
|
if (permission == PackageManager.PERMISSION_GRANTED) { |
|
|
|
|
|
takeImage() |
|
|
|
|
|
} else { |
|
|
|
|
|
requestPermission.launch( |
|
|
|
|
|
Manifest.permission.CAMERA |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
dialog.dismiss() |
|
|
|
|
|
} else if (check[item] == "Choose from Gallery") { |
|
|
|
|
|
val permission = ContextCompat.checkSelfPermission( |
|
|
|
|
|
activity as BajajFdMainActivity, |
|
|
|
|
|
Manifest.permission.READ_EXTERNAL_STORAGE |
|
|
|
|
|
) |
|
|
|
|
|
if (permission == PackageManager.PERMISSION_GRANTED) { |
|
|
|
|
|
selectImageIntent?.launch("image/*") |
|
|
|
|
|
} else { |
|
|
|
|
|
requestPermission.launch( |
|
|
|
|
|
Manifest.permission.READ_EXTERNAL_STORAGE |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
} else if (check[item] == "Cancel") { |
|
|
|
|
|
dialog.dismiss() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dialog.show() |
|
|
|
|
|
dialog.window?.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) |
|
|
|
|
|
|
|
|
builder.show() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun setOtherUploadLayout(itemName: String?) { |
|
|
private fun setOtherUploadLayout(itemName: String?) { |
|
|