Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ANDROIDX_LIBRARY_VERSION= 1.0.0
LIFECYCLE_VERSION = 2.2.0
ARC_TESTING_VERSION = 1.1.1
JAVAPOET_VERSION = 1.9.0
KOTLINPOET_VERSION = 1.3.0
KOTLINPOET_VERSION = 1.11.0
JUNIT_VERSION = 4.12
MOCKITO_VERSION = 2.28.2
MOCKITO_KOTLIN_VERSION = 2.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class KotlinBaseProcessorUnit : KtProcessorUnit {

override fun createFile(rpe: RuntimePermissionsElement, requestCodeProvider: RequestCodeProvider): FileSpec {
return FileSpec.builder(rpe.packageName, rpe.generatedClassName)
.addComment(FILE_COMMENT)
.addFileComment(FILE_COMMENT, arrayOf<Any>())
.addAnnotation(createJvmNameAnnotation(rpe.generatedClassName))
.addProperties(createProperties(rpe, requestCodeProvider))
.addFunctions(createWithPermissionCheckFuns(rpe))
Expand Down Expand Up @@ -449,7 +449,7 @@ abstract class KotlinBaseProcessorUnit : KtProcessorUnit {
val targetParam = "target"
val constructorSpec = FunSpec.constructorBuilder().addParameter(targetParam, rpe.ktTypeName)
needsMethod.parameters.forEach {
constructorSpec.addParameter(it.simpleString(), it.asPreparedType(), KModifier.PRIVATE)
constructorSpec.addParameter(it.simpleString(), it.asPreparedType())
}
builder.primaryConstructor(constructorSpec.build())

Expand Down
10 changes: 10 additions & 0 deletions sample/src/main/kotlin/permissions/dispatcher/sample/Callback.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package permissions.dispatcher.sample

/**
* @author chenglei01
* @date 2023/11/10
* @time 12:03
*/
interface Callback {
fun onSuccess()
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
val buttonCamera: Button = findViewById(R.id.button_camera)
buttonCamera.setOnClickListener {
showCameraWithPermissionCheck()
showCameraWithPermissionCheck(object : Callback {
override fun onSuccess() {}
})
}
val buttonContacts: Button = findViewById(R.id.button_contacts)
buttonContacts.setOnClickListener {
Expand All @@ -34,12 +36,13 @@ class MainActivity : AppCompatActivity() {
}

@NeedsPermission(Manifest.permission.CAMERA)
fun showCamera() {
fun showCamera(callback: Callback) {
// NOTE: Perform action that requires the permission. If this is run by PermissionsDispatcher, the permission will have been granted
supportFragmentManager.beginTransaction()
.replace(R.id.sample_content_fragment, CameraPreviewFragment.newInstance())
.addToBackStack("camera")
.commitAllowingStateLoss()
callback.onSuccess()
}

@OnPermissionDenied(Manifest.permission.CAMERA)
Expand All @@ -58,6 +61,7 @@ class MainActivity : AppCompatActivity() {

@OnNeverAskAgain(Manifest.permission.CAMERA)
fun onCameraNeverAskAgain() {
// callback.onFailure()
Toast.makeText(this, R.string.permission_camera_never_ask_again, Toast.LENGTH_SHORT).show()
}

Expand Down