Skip to content

Commit 9abec19

Browse files
Merge pull request #2 from AlfredoHdez1709/develop
rename UI
2 parents a4aeb54 + 746a8f8 commit 9abec19

File tree

6 files changed

+25
-52
lines changed

6 files changed

+25
-52
lines changed

EasyCameraAndGallery/src/main/java/dev/ahrsoft/easycameraandgallery/CameraActivity.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ class CameraActivity : AppCompatActivity() {
8989
flashModeOptions(optionsCamera.flash)
9090

9191
with(binding) {
92-
galleryCaptureButton.setOnClickListener {
92+
galleryCaptureButtonCamera.setOnClickListener {
9393
getPickImageIntent()
9494
}
95-
cameraCaptureButton.setOnClickListener {
95+
cameraCaptureButtonCamera.setOnClickListener {
9696
takePhoto()
9797
}
9898
ibFrontCamera.setOnClickListener {
@@ -241,12 +241,12 @@ class CameraActivity : AppCompatActivity() {
241241
private fun hideUI(isCompleteSelect : Boolean){
242242
if (isCompleteSelect){
243243
binding.fabSendData.visibility = View.VISIBLE
244-
binding.cameraCaptureButton.visibility = View.GONE
245-
binding.galleryCaptureButton.visibility = View.GONE
244+
binding.cameraCaptureButtonCamera.visibility = View.GONE
245+
binding.galleryCaptureButtonCamera.visibility = View.GONE
246246
}else{
247247
binding.fabSendData.visibility = View.GONE
248-
binding.cameraCaptureButton.visibility = View.VISIBLE
249-
binding.galleryCaptureButton.visibility = View.VISIBLE
248+
binding.cameraCaptureButtonCamera.visibility = View.VISIBLE
249+
binding.galleryCaptureButtonCamera.visibility = View.VISIBLE
250250
}
251251
}
252252

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

273273
private fun setImageList(){
274274
adapter = GalleryAdapter(this,imageList)
275-
binding.rvGallery.layoutManager = LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false)
276-
binding.rvGallery.adapter = adapter
275+
binding.rvGalleryCamera.layoutManager = LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false)
276+
binding.rvGalleryCamera.adapter = adapter
277277
adapter.setOnItemClickListener(object : GalleryAdapter.OnItemClickListener{
278278
override fun onItemClick(position: Int) {
279279
val imageModel = imageList[position]
@@ -530,7 +530,7 @@ class CameraActivity : AppCompatActivity() {
530530

531531
try {
532532
cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture)
533-
preview?.setSurfaceProvider(binding.viewFinder.surfaceProvider)
533+
preview?.setSurfaceProvider(binding.viewFinderCamera.surfaceProvider)
534534
} catch (exc: Exception) {
535535
throw Exception("Use case fallo", exc)
536536
}

EasyCameraAndGallery/src/main/java/dev/ahrsoft/easycameraandgallery/gallery/GalleryAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class GalleryAdapter(private val context : Context, private val imageList : List
1414
with(binding){
1515
Glide.with(context)
1616
.load(imageModel.image)
17-
.into(image)
18-
checkBox.isChecked = imageModel.isSelected
17+
.into(imagePickerCamera)
18+
checkBoxPickerCamera.isChecked = imageModel.isSelected
1919
}
2020
}
2121
}

EasyCameraAndGallery/src/main/res/layout/activity_camera.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,36 @@
3939
android:layout_marginEnd="16dp"
4040
android:layout_marginBottom="16dp"
4141
android:clickable="true"
42-
app:layout_constraintBottom_toTopOf="@+id/rv.gallery"
42+
app:layout_constraintBottom_toTopOf="@+id/rv.gallery.camera"
4343
app:layout_constraintEnd_toEndOf="parent"
4444
app:srcCompat="@drawable/ic_baseline_check_24"
4545
android:focusable="true"
4646
android:visibility="gone"/>
4747

4848

4949
<androidx.camera.view.PreviewView
50-
android:id="@+id/view.finder"
50+
android:id="@+id/view.finder.camera"
5151
android:layout_width="match_parent"
5252
android:layout_height="match_parent"
5353
android:layout_weight="1"
5454
tools:layout_editor_absoluteX="0dp"
5555
tools:layout_editor_absoluteY="0dp" />
5656

5757
<androidx.recyclerview.widget.RecyclerView
58-
android:id="@+id/rv.gallery"
58+
android:id="@+id/rv.gallery.camera"
5959
android:layout_width="match_parent"
6060
android:layout_height="80dp"
6161
android:layout_marginBottom="16dp"
6262
android:elevation="9dp"
63-
app:layout_constraintBottom_toTopOf="@+id/camera.capture.button"
63+
app:layout_constraintBottom_toTopOf="@+id/camera.capture.button.camera"
6464
app:layout_constraintEnd_toEndOf="parent"
6565
app:layout_constraintStart_toStartOf="parent"
6666
tools:itemCount="8"
6767
tools:listitem="@layout/image_picker_list"
6868
tools:orientation="horizontal" />
6969

7070
<ImageButton
71-
android:id="@+id/camera.capture.button"
71+
android:id="@+id/camera.capture.button.camera"
7272
android:layout_width="@dimen/round_button_large"
7373
android:layout_height="@dimen/round_button_large"
7474
android:layout_marginBottom="24dp"
@@ -82,17 +82,17 @@
8282

8383

8484
<ImageButton
85-
android:id="@+id/gallery.capture.button"
85+
android:id="@+id/gallery.capture.button.camera"
8686
android:layout_width="@dimen/round_button_medium"
8787
android:layout_height="@dimen/round_button_medium"
8888
android:layout_marginRight="24dp"
8989
android:background="@drawable/ic_baseline_image_24"
9090
android:contentDescription="@string/tomar_foto"
9191
android:elevation="9dp"
9292
android:scaleType="fitCenter"
93-
app:layout_constraintBottom_toBottomOf="@+id/camera.capture.button"
93+
app:layout_constraintBottom_toBottomOf="@+id/camera.capture.button.camera"
9494
app:layout_constraintRight_toRightOf="parent"
95-
app:layout_constraintTop_toTopOf="@+id/camera.capture.button" />
95+
app:layout_constraintTop_toTopOf="@+id/camera.capture.button.camera" />
9696

9797
<View
9898
android:layout_width="match_parent"
@@ -101,7 +101,7 @@
101101
app:layout_constraintBottom_toBottomOf="parent"
102102
app:layout_constraintEnd_toEndOf="parent"
103103
app:layout_constraintStart_toStartOf="parent"
104-
app:layout_constraintTop_toTopOf="@+id/rv.gallery"
104+
app:layout_constraintTop_toTopOf="@+id/rv.gallery.camera"
105105
android:elevation="8dp"/>
106106

107107
<View

EasyCameraAndGallery/src/main/res/layout/image_picker_list.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
android:layout_margin="4dp">
88

99
<ImageView
10-
android:id="@+id/image"
10+
android:id="@+id/imagePickerCamera"
1111
android:layout_width="0dp"
1212
android:layout_height="0dp"
1313
android:scaleType="centerCrop"
@@ -19,12 +19,12 @@
1919
tools:srcCompat="@tools:sample/avatars" />
2020

2121
<CheckBox
22-
android:id="@+id/checkBox"
22+
android:id="@+id/checkBoxPickerCamera"
2323
android:layout_width="20dp"
2424
android:layout_height="20dp"
2525
android:button="@drawable/custom_checkbox"
2626
android:clickable="false"
27-
app:layout_constraintTop_toTopOf="@+id/image"
28-
app:layout_constraintEnd_toEndOf="@id/image"/>
27+
app:layout_constraintTop_toTopOf="@+id/imagePickerCamera"
28+
app:layout_constraintEnd_toEndOf="@id/imagePickerCamera"/>
2929

3030
</androidx.constraintlayout.widget.ConstraintLayout>

app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ dependencies {
4040
implementation 'androidx.appcompat:appcompat:1.3.0'
4141
implementation 'com.google.android.material:material:1.4.0'
4242
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
43-
implementation project(path: ':EasyCameraAndGallery')
4443
testImplementation 'junit:junit:4.13.2'
4544
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
4645
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,17 @@
11
package dev.ahrsoft.cameralibrary
22

3-
import android.app.Activity
4-
import android.content.Intent
3+
54
import androidx.appcompat.app.AppCompatActivity
65
import android.os.Bundle
7-
import androidx.activity.result.ActivityResultLauncher
86
import dev.ahrsoft.cameralibrary.databinding.ActivityMainBinding
9-
import dev.ahrsoft.easycameraandgallery.*
107

118
class MainActivity : AppCompatActivity() {
129

1310
lateinit var binding: ActivityMainBinding
14-
private lateinit var resultScan: ActivityResultLauncher<Intent>
1511

1612
override fun onCreate(savedInstanceState: Bundle?) {
1713
super.onCreate(savedInstanceState)
1814
binding = ActivityMainBinding.inflate(layoutInflater)
1915
setContentView(binding.root)
20-
initCall()
21-
22-
val optionsCamera = OptionsCamera(
23-
ratio = Ratio.RATIO_16_9,
24-
path = "Evidences",
25-
flash = Flash.Off,
26-
count = 2
27-
)
28-
29-
binding.textInput.setOnClickListener {
30-
EasyCamera.start(this, optionsCamera = optionsCamera, resultScan = resultScan)
31-
}
32-
}
33-
34-
private fun initCall() {
35-
resultScan = registerForActivityResult(androidx.activity.result.contract.
36-
ActivityResultContracts.StartActivityForResult()) { result ->
37-
if (result.resultCode == Activity.RESULT_OK) {
38-
val list = result.data?.getStringArrayListExtra(EasyCamera.IMAGE_RESULTS)
39-
print(list)
40-
}
41-
}
4216
}
4317
}

0 commit comments

Comments
 (0)