Skip to content

Commit

Permalink
rename UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfredoHdez1709 committed Jul 25, 2022
1 parent a40fbae commit 746a8f8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ class CameraActivity : AppCompatActivity() {
flashModeOptions(optionsCamera.flash)

with(binding) {
galleryCaptureButton.setOnClickListener {
galleryCaptureButtonCamera.setOnClickListener {
getPickImageIntent()
}
cameraCaptureButton.setOnClickListener {
cameraCaptureButtonCamera.setOnClickListener {
takePhoto()
}
ibFrontCamera.setOnClickListener {
Expand Down Expand Up @@ -241,12 +241,12 @@ class CameraActivity : AppCompatActivity() {
private fun hideUI(isCompleteSelect : Boolean){
if (isCompleteSelect){
binding.fabSendData.visibility = View.VISIBLE
binding.cameraCaptureButton.visibility = View.GONE
binding.galleryCaptureButton.visibility = View.GONE
binding.cameraCaptureButtonCamera.visibility = View.GONE
binding.galleryCaptureButtonCamera.visibility = View.GONE
}else{
binding.fabSendData.visibility = View.GONE
binding.cameraCaptureButton.visibility = View.VISIBLE
binding.galleryCaptureButton.visibility = View.VISIBLE
binding.cameraCaptureButtonCamera.visibility = View.VISIBLE
binding.galleryCaptureButtonCamera.visibility = View.VISIBLE
}
}

Expand All @@ -272,8 +272,8 @@ class CameraActivity : AppCompatActivity() {

private fun setImageList(){
adapter = GalleryAdapter(this,imageList)
binding.rvGallery.layoutManager = LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false)
binding.rvGallery.adapter = adapter
binding.rvGalleryCamera.layoutManager = LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false)
binding.rvGalleryCamera.adapter = adapter
adapter.setOnItemClickListener(object : GalleryAdapter.OnItemClickListener{
override fun onItemClick(position: Int) {
val imageModel = imageList[position]
Expand Down Expand Up @@ -530,7 +530,7 @@ class CameraActivity : AppCompatActivity() {

try {
cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture)
preview?.setSurfaceProvider(binding.viewFinder.surfaceProvider)
preview?.setSurfaceProvider(binding.viewFinderCamera.surfaceProvider)
} catch (exc: Exception) {
throw Exception("Use case fallo", exc)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class GalleryAdapter(private val context : Context, private val imageList : List
with(binding){
Glide.with(context)
.load(imageModel.image)
.into(image)
checkBox.isChecked = imageModel.isSelected
.into(imagePickerCamera)
checkBoxPickerCamera.isChecked = imageModel.isSelected
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions EasyCameraAndGallery/src/main/res/layout/activity_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,36 @@
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:clickable="true"
app:layout_constraintBottom_toTopOf="@+id/rv.gallery"
app:layout_constraintBottom_toTopOf="@+id/rv.gallery.camera"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_baseline_check_24"
android:focusable="true"
android:visibility="gone"/>


<androidx.camera.view.PreviewView
android:id="@+id/view.finder"
android:id="@+id/view.finder.camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv.gallery"
android:id="@+id/rv.gallery.camera"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginBottom="16dp"
android:elevation="9dp"
app:layout_constraintBottom_toTopOf="@+id/camera.capture.button"
app:layout_constraintBottom_toTopOf="@+id/camera.capture.button.camera"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:itemCount="8"
tools:listitem="@layout/image_picker_list"
tools:orientation="horizontal" />

<ImageButton
android:id="@+id/camera.capture.button"
android:id="@+id/camera.capture.button.camera"
android:layout_width="@dimen/round_button_large"
android:layout_height="@dimen/round_button_large"
android:layout_marginBottom="24dp"
Expand All @@ -82,17 +82,17 @@


<ImageButton
android:id="@+id/gallery.capture.button"
android:id="@+id/gallery.capture.button.camera"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginRight="24dp"
android:background="@drawable/ic_baseline_image_24"
android:contentDescription="@string/tomar_foto"
android:elevation="9dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/camera.capture.button"
app:layout_constraintBottom_toBottomOf="@+id/camera.capture.button.camera"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/camera.capture.button" />
app:layout_constraintTop_toTopOf="@+id/camera.capture.button.camera" />

<View
android:layout_width="match_parent"
Expand All @@ -101,7 +101,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/rv.gallery"
app:layout_constraintTop_toTopOf="@+id/rv.gallery.camera"
android:elevation="8dp"/>

<View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_margin="4dp">

<ImageView
android:id="@+id/image"
android:id="@+id/imagePickerCamera"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
Expand All @@ -19,12 +19,12 @@
tools:srcCompat="@tools:sample/avatars" />

<CheckBox
android:id="@+id/checkBox"
android:id="@+id/checkBoxPickerCamera"
android:layout_width="20dp"
android:layout_height="20dp"
android:button="@drawable/custom_checkbox"
android:clickable="false"
app:layout_constraintTop_toTopOf="@+id/image"
app:layout_constraintEnd_toEndOf="@id/image"/>
app:layout_constraintTop_toTopOf="@+id/imagePickerCamera"
app:layout_constraintEnd_toEndOf="@id/imagePickerCamera"/>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(path: ':EasyCameraAndGallery')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
28 changes: 1 addition & 27 deletions app/src/main/java/dev/ahrsoft/cameralibrary/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,43 +1,17 @@
package dev.ahrsoft.cameralibrary

import android.app.Activity
import android.content.Intent

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher
import dev.ahrsoft.cameralibrary.databinding.ActivityMainBinding
import dev.ahrsoft.easycameraandgallery.*

class MainActivity : AppCompatActivity() {

lateinit var binding: ActivityMainBinding
private lateinit var resultScan: ActivityResultLauncher<Intent>

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
initCall()

val optionsCamera = OptionsCamera(
ratio = Ratio.RATIO_16_9,
path = "Evidences",
flash = Flash.Off,
count = 2
)

binding.textInput.setOnClickListener {
EasyCamera.start(this, optionsCamera = optionsCamera, resultScan = resultScan)
}
}

private fun initCall() {
resultScan = registerForActivityResult(androidx.activity.result.contract.
ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val list = result.data?.getStringArrayListExtra(EasyCamera.IMAGE_RESULTS)
print(list)
}
}
}
}

0 comments on commit 746a8f8

Please sign in to comment.