Skip to content

Commit

Permalink
Fix samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Canato committed Nov 28, 2021
1 parent 5ee2f30 commit 38df145
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 494 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ Path: `.idea/codeStyles/` Please never change anything inside this folders
- After changes you can run `./gradlew ktlintFormat` or the shortcuts in your touched files.

### General code library rules
- We do not use reflection without need, so avoid any `::` kotlint reflection without need.
- Documentation should alwways reflect the latest and best way of using the library, if is not let's fix.
- We do not use reflection without need, so avoid any `::` kotlin reflection without need.
- Documentation should always reflect the latest and best way of using the library, if is not let's fix.
- For tests we use GIVEN/WHEN/THEN pattern
10 changes: 4 additions & 6 deletions cropper/src/main/java/com/canhub/cropper/CropImageActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import com.canhub.cropper.databinding.CropImageActivityBinding
import com.canhub.cropper.utils.getUriForFile
import java.io.File

/**
* Built-in activity for image cropping.<br></br>
* Use [CropImage.activity] to create a builder to start this activity.
*/
open class CropImageActivity :
AppCompatActivity(),
OnSetImageUriCompleteListener,
Expand Down Expand Up @@ -69,10 +65,10 @@ open class CropImageActivity :
cropImageOptions.imageSourceIncludeCamera ->
showImageSourceDialog(
openCamera = { openCamera() },
openGallery = { pickImageGallery.launch("/image/*") },
openGallery = { pickImageGallery.launch("image/*") },
)
cropImageOptions.imageSourceIncludeGallery ->
pickImageGallery.launch("/image/*")
pickImageGallery.launch("image/*")
cropImageOptions.imageSourceIncludeCamera ->
openCamera()
else -> finish()
Expand Down Expand Up @@ -111,10 +107,12 @@ open class CropImageActivity :
* and customised with the app layout if need.
*/
open fun showImageSourceDialog(openCamera: () -> Unit, openGallery: () -> Unit) {
// TODO improve layout
AlertDialog.Builder(this)
.setTitle(R.string.pick_image_chooser_title)
.setNegativeButton(R.string.pick_image_camera) { _, _ -> openCamera() }
.setPositiveButton(R.string.pick_image_gallery) { _, _ -> openGallery() }
.show()
}

public override fun onStart() {
Expand Down
14 changes: 12 additions & 2 deletions cropper/src/main/res/xml/library_file_paths.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<paths>
<files-path name="cropper" path="cropper-internal/" />
<external-files-path name="my_images" path="/" />
<files-path
name="cropper"
path="cropper-internal/" />
<external-files-path
name="my_images"
path="/" />
<cache-path
name="cached_files"
path="." />
<files-path
name="images"
path="." />
</paths>
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@ class ContractTestFragment(
this.cropResult = result
}

val pickImage = registerForActivityResult(PickImageContract(), registry) { result ->
this.pickResult = result
}

fun cropImage(input: CropImageContractOptions) {
cropImage.launch(input)
}

fun cropImageIntent(input: CropImageContractOptions): Intent {
return cropImage.contract.createIntent(requireContext(), input)
}

fun pickImageIntent(input: PickImageContractOptions): Intent {
return pickImage.contract.createIntent(requireContext(), input)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ package com.canhub.cropper
// // THEN
// assertEquals(expectedClassName, cropImageIntent?.component?.className)
// assertEquals(expectedSource, bundle?.getParcelable(CropImage.CROP_IMAGE_EXTRA_SOURCE))
// assertEquals(options.options, bundle?.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS))
// }
//
// @Test
Expand Down
85 changes: 0 additions & 85 deletions cropper/src/test/java/com/canhub/cropper/PickImageContractTest.kt

This file was deleted.

9 changes: 0 additions & 9 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,5 @@
android:name="com.canhub.cropper.sample.extend_activity.app.SExtendActivity"
android:theme="@style/Theme.SampleNoActionBar" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_file_paths" />
</provider>
</application>
</manifest>
Loading

0 comments on commit 38df145

Please sign in to comment.