crop
This commit is contained in:
@@ -96,5 +96,6 @@ dependencies {
|
||||
// Barcode scanner
|
||||
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
||||
|
||||
|
||||
// cropping
|
||||
implementation 'com.github.yalantis:ucrop:2.2.6'
|
||||
}
|
||||
7
app/proguard-rules.pro
vendored
7
app/proguard-rules.pro
vendored
@@ -18,4 +18,9 @@
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
# ucrop
|
||||
-dontwarn com.yalantis.ucrop**
|
||||
-keep class com.yalantis.ucrop** { *; }
|
||||
-keep interface com.yalantis.ucrop** { *; }
|
||||
@@ -42,6 +42,11 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.yalantis.ucrop.UCropActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -2,9 +2,11 @@ package com.example.hposregistration.ui.fragments.registration
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.app.Activity.RESULT_OK
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
@@ -22,6 +24,7 @@ import androidx.navigation.fragment.navArgs
|
||||
import com.bumptech.glide.Glide
|
||||
import com.example.hposregistration.data.user.UserData
|
||||
import com.example.hposregistration.ui.viewmodels.RegistrationViewModel
|
||||
import com.yalantis.ucrop.UCrop
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hposregistration.databinding.FragmentCaptureUserImageBinding
|
||||
import java.io.File
|
||||
@@ -122,10 +125,37 @@ class CaptureUserImageFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun submitImage(uri: Uri) {
|
||||
userData.userImage = uri.toString()
|
||||
viewModel.insert(userData)
|
||||
navigate()
|
||||
// userData.userImage = uri.toString()
|
||||
// viewModel.insert(userData)
|
||||
// navigate()
|
||||
var sourceUri = uri
|
||||
var destinationUri = uri
|
||||
val maxWidth = 160
|
||||
val maxHeight = 90
|
||||
|
||||
// val context = getContext().getA
|
||||
UCrop.of(sourceUri, destinationUri)
|
||||
.withAspectRatio(9F, 16F)
|
||||
.withMaxResultSize(maxWidth, maxHeight)
|
||||
.start(requireActivity())
|
||||
}
|
||||
//
|
||||
// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
// super.onActivityResult(requestCode, resultCode, data)
|
||||
// if (resultCode == RESULT_OK) when (requestCode) {
|
||||
// UCrop.REQUEST_CROP -> {
|
||||
// val fi = headPic.inputStream()
|
||||
// navhbg.setImageBitmap(BitmapFactory.decodeStream(fi))
|
||||
// fi.close()
|
||||
// }
|
||||
// 1 -> {
|
||||
// data?.data?.let {
|
||||
// saveFile(it)
|
||||
// cropImageUri()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private fun navigate() {
|
||||
val action = CaptureUserImageFragmentDirections
|
||||
|
||||
@@ -10,6 +10,7 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven {url "https://jitpack.io"}
|
||||
}
|
||||
}
|
||||
rootProject.name = "HPOS Registration"
|
||||
|
||||
Reference in New Issue
Block a user