├── aaper ├── .gitignore ├── consumer-rules.pro ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── likethesalad │ │ │ └── android │ │ │ └── aaper │ │ │ ├── testutils │ │ │ ├── RobolectricActivity.kt │ │ │ └── BaseRobolectricTest.kt │ │ │ ├── launcher │ │ │ └── RequestWithCodeLauncherTest.kt │ │ │ ├── base │ │ │ ├── activity │ │ │ │ ├── statusprovider │ │ │ │ │ └── ActivityPermissionStatusProviderTest.kt │ │ │ │ ├── launcher │ │ │ │ │ └── ActivityRequestLauncherTest.kt │ │ │ │ └── strategy │ │ │ │ │ └── ActivityRequestStrategyTest.kt │ │ │ ├── fragment │ │ │ │ └── strategy │ │ │ │ │ └── FragmentRequestStrategyTest.kt │ │ │ └── common │ │ │ │ └── strategy │ │ │ │ └── AllRequestStrategyTest.kt │ │ │ ├── data │ │ │ └── RequestCodeLaunchMetadataTest.kt │ │ │ ├── strategy │ │ │ ├── DefaultRequestStrategyTest.kt │ │ │ ├── DefaultRequestStrategyFactoryTest.kt │ │ │ └── RequestWithCodeMetadataStrategyTest.kt │ │ │ └── AaperTest.kt │ └── main │ │ ├── java │ │ └── com │ │ │ └── likethesalad │ │ │ └── android │ │ │ └── aaper │ │ │ ├── AaperInitializer.kt │ │ │ ├── errors │ │ │ ├── AaperNotInitializedException.kt │ │ │ └── AaperInitializedAlreadyException.kt │ │ │ ├── base │ │ │ ├── fragment │ │ │ │ ├── launcher │ │ │ │ │ └── FragmentRequestLauncher.kt │ │ │ │ ├── statusprovider │ │ │ │ │ └── FragmentPermissionStatusProvider.kt │ │ │ │ └── strategy │ │ │ │ │ └── FragmentRequestStrategy.kt │ │ │ ├── activity │ │ │ │ ├── launcher │ │ │ │ │ └── ActivityRequestLauncher.kt │ │ │ │ ├── statusprovider │ │ │ │ │ └── ActivityPermissionStatusProvider.kt │ │ │ │ └── strategy │ │ │ │ │ └── ActivityRequestStrategy.kt │ │ │ └── common │ │ │ │ └── strategy │ │ │ │ └── AllRequestStrategy.kt │ │ │ ├── data │ │ │ └── RequestCodeLaunchMetadata.kt │ │ │ ├── internal │ │ │ └── PermissionRequestHandler.kt │ │ │ ├── strategy │ │ │ ├── RequestWithCodeMetadataStrategy.kt │ │ │ ├── DefaultRequestStrategy.kt │ │ │ └── DefaultRequestStrategyFactory.kt │ │ │ ├── launcher │ │ │ └── RequestWithCodeLauncher.kt │ │ │ └── Aaper.kt │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── FUNDING.yml ├── tests.sh ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── libs.versions.toml ├── app ├── gradle │ ├── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ └── libs.versions.toml ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── my_fragment.xml │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── likethesalad │ │ │ │ └── android │ │ │ │ └── aaper │ │ │ │ └── sample │ │ │ │ ├── test │ │ │ │ ├── utils │ │ │ │ │ ├── CallMe.kt │ │ │ │ │ └── CallMeWithArg.kt │ │ │ │ ├── SimpleFragment.kt │ │ │ │ ├── JavaActivity.java │ │ │ │ ├── ActivityWithOverriddenResultMethod.kt │ │ │ │ └── SimpleActivity.kt │ │ │ │ ├── MyApp.kt │ │ │ │ ├── MyFragment.kt │ │ │ │ ├── custom │ │ │ │ ├── FinishActivityOnDeniedStrategy.kt │ │ │ │ └── AlertDialogStrategy.kt │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ └── test │ │ └── java │ │ └── com │ │ └── likethesalad │ │ └── android │ │ └── aaper │ │ └── sample │ │ └── test │ │ ├── testutils │ │ ├── TestApplication.kt │ │ ├── base │ │ │ ├── BaseRobolectricTest.kt │ │ │ └── BaseActivityTest.kt │ │ ├── strategies │ │ │ └── AlwaysSuccessfulStrategy.kt │ │ └── launcher │ │ │ └── TestRequestLauncher.kt │ │ ├── JavaActivityTest.kt │ │ ├── SimpleFragmentTest.kt │ │ ├── ActivityWithOverriddenResultMethodTest.kt │ │ └── SimpleActivityTest.kt ├── gradle.properties ├── proguard-rules.pro ├── build.gradle ├── settings.gradle ├── gradlew.bat └── gradlew ├── .gitignore ├── aaper-api ├── build.gradle └── src │ ├── test │ └── java │ │ └── com │ │ └── likethesalad │ │ └── android │ │ └── aaper │ │ ├── testutils │ │ └── StrategyTest.kt │ │ ├── api │ │ ├── strategy │ │ │ └── RequestStrategyFactoryTest.kt │ │ └── PermissionManagerTest.kt │ │ └── internal │ │ └── utils │ │ └── RequestRunnerTest.kt │ └── main │ └── java │ └── com │ └── likethesalad │ └── android │ └── aaper │ ├── api │ ├── errors │ │ ├── AaperException.kt │ │ └── RequestExecutedAlreadyException.kt │ ├── strategy │ │ ├── RequestStrategyFactory.kt │ │ ├── NoopRequestStrategy.kt │ │ └── RequestStrategy.kt │ ├── data │ │ ├── LaunchMetadata.kt │ │ ├── PermissionsResult.kt │ │ └── PermissionsRequest.kt │ ├── statusprovider │ │ └── PermissionStatusProvider.kt │ ├── launcher │ │ └── RequestLauncher.kt │ ├── EnsurePermissions.kt │ └── PermissionManager.kt │ └── internal │ ├── strategy │ └── RequestStrategyFactoryProvider.kt │ ├── data │ ├── CurrentRequest.kt │ └── PendingRequest.kt │ └── utils │ └── RequestRunner.kt ├── aaper-plugin ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── likethesalad │ │ │ └── android │ │ │ └── aaper │ │ │ └── plugin │ │ │ ├── appender │ │ │ ├── visitor │ │ │ │ ├── data │ │ │ │ │ ├── FieldInfo.kt │ │ │ │ │ └── ClassName.kt │ │ │ │ └── WraaperClassCreator.kt │ │ │ ├── data │ │ │ │ └── MethodInfo.kt │ │ │ └── CodeAppenderTask.kt │ │ │ ├── instrumentation │ │ │ └── target │ │ │ │ ├── visitor │ │ │ │ ├── utils │ │ │ │ │ └── AnnotatedMethodNotifier.kt │ │ │ │ ├── annotations │ │ │ │ │ ├── PermissionsAnnotationVisitor.kt │ │ │ │ │ └── TargetAnnotationVisitor.kt │ │ │ │ ├── ResultMethodWrapper.kt │ │ │ │ ├── TargetClassVisitor.kt │ │ │ │ └── TargetMethodVisitor.kt │ │ │ │ └── TargetAsmClassVisitorFactory.kt │ │ │ ├── utils │ │ │ ├── AsmUtils.kt │ │ │ └── NamingUtils.kt │ │ │ └── AaperPlugin.kt │ └── test │ │ ├── kotlin │ │ └── com │ │ │ └── likethesalad │ │ │ └── android │ │ │ └── aaper │ │ │ └── plugin │ │ │ ├── appender │ │ │ └── visitor │ │ │ │ ├── testutils │ │ │ │ └── GeneratedClassLoader.kt │ │ │ │ ├── data │ │ │ │ └── ClassNameTest.kt │ │ │ │ └── WraaperClassCreatorTest.kt │ │ │ └── AaperPluginTest.kt │ │ └── assets │ │ └── projects │ │ ├── nonVoidMethod │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── SomeActivity.java │ │ └── voidMethod │ │ └── main │ │ └── java │ │ └── com │ │ └── example │ │ └── SomeActivity.java └── build.gradle ├── CHANGELOG.md ├── settings.gradle ├── LICENSE.txt ├── gradle.properties ├── gradlew.bat └── gradlew /aaper/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /aaper/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: likethesalad 2 | -------------------------------------------------------------------------------- /tests.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | ./gradlew publishToMavenLocal 3 | ./gradlew test 4 | ./gradlew -p "app" testDebugUnitTest -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Annotated permission 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | local.properties 4 | .idea 5 | .DS_Store 6 | build 7 | captures 8 | .externalNativeBuild 9 | .cxx 10 | -------------------------------------------------------------------------------- /app/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536m 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | kotlin.code.style=official 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /aaper-api/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.java.library) 3 | } 4 | 5 | dependencies { 6 | testImplementation libs.unitTesting 7 | } -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LikeTheSalad/aaper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/java/com/likethesalad/android/aaper/sample/test/utils/CallMe.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.sample.test.utils 2 | 3 | interface CallMe { 4 | fun call() 5 | } -------------------------------------------------------------------------------- /aaper/src/test/java/com/likethesalad/android/aaper/testutils/RobolectricActivity.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.testutils 2 | 3 | import android.app.Activity 4 | 5 | class RobolectricActivity : Activity() -------------------------------------------------------------------------------- /app/src/main/java/com/likethesalad/android/aaper/sample/test/utils/CallMeWithArg.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.sample.test.utils 2 | 3 | interface CallMeWithArg { 4 | 5 | fun callMe(arg: T) 6 | } -------------------------------------------------------------------------------- /aaper-api/src/test/java/com/likethesalad/android/aaper/testutils/StrategyTest.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.testutils 2 | 3 | import com.likethesalad.android.aaper.api.strategy.NoopRequestStrategy 4 | 5 | class StrategyTest : NoopRequestStrategy() 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /aaper-plugin/src/main/java/com/likethesalad/android/aaper/plugin/appender/visitor/data/FieldInfo.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.plugin.appender.visitor.data 2 | 3 | import org.objectweb.asm.Type 4 | 5 | data class FieldInfo(val name: String, val type: Type) -------------------------------------------------------------------------------- /aaper-plugin/src/main/java/com/likethesalad/android/aaper/plugin/instrumentation/target/visitor/utils/AnnotatedMethodNotifier.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.plugin.instrumentation.target.visitor.utils 2 | 3 | interface AnnotatedMethodNotifier { 4 | fun foundAnnotatedMethod() 5 | } -------------------------------------------------------------------------------- /app/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 26 11:26:47 CET 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 26 11:26:47 CET 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /aaper-api/src/main/java/com/likethesalad/android/aaper/api/errors/AaperException.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.api.errors 2 | 3 | /** 4 | * Base exception for all Aaper operations' exceptions. 5 | */ 6 | open class AaperException(message: String?, cause: Throwable?) : Exception(message, cause) -------------------------------------------------------------------------------- /aaper/src/test/java/com/likethesalad/android/aaper/testutils/BaseRobolectricTest.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.testutils 2 | 3 | import org.junit.runner.RunWith 4 | import org.robolectric.RobolectricTestRunner 5 | 6 | @RunWith(RobolectricTestRunner::class) 7 | abstract class BaseRobolectricTest { 8 | } -------------------------------------------------------------------------------- /aaper-plugin/src/main/java/com/likethesalad/android/aaper/plugin/appender/data/MethodInfo.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.plugin.appender.data 2 | 3 | import com.likethesalad.android.aaper.plugin.appender.visitor.data.ClassName 4 | 5 | data class MethodInfo(val name: String, val descriptor: String, val className: ClassName) -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /aaper-api/src/main/java/com/likethesalad/android/aaper/api/strategy/RequestStrategyFactory.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.api.strategy 2 | 3 | /** 4 | * Provides instances of [RequestStrategy]. 5 | */ 6 | interface RequestStrategyFactory { 7 | 8 | fun > getStrategy(host: Any, type: Class): T 9 | } -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /aaper-api/src/main/java/com/likethesalad/android/aaper/internal/strategy/RequestStrategyFactoryProvider.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.internal.strategy 2 | 3 | import com.likethesalad.android.aaper.api.strategy.RequestStrategyFactory 4 | 5 | interface RequestStrategyFactoryProvider { 6 | 7 | fun getRequestStrategyFactory(): T 8 | } -------------------------------------------------------------------------------- /aaper-plugin/src/main/java/com/likethesalad/android/aaper/plugin/utils/AsmUtils.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.plugin.utils 2 | 3 | import org.objectweb.asm.Type 4 | 5 | object AsmUtils { 6 | 7 | fun getCombinedSize(types: List): Int { 8 | var size = 0 9 | 10 | types.forEach { 11 | size += it.size 12 | } 13 | 14 | return size 15 | } 16 | } -------------------------------------------------------------------------------- /aaper-plugin/src/test/kotlin/com/likethesalad/android/aaper/plugin/appender/visitor/testutils/GeneratedClassLoader.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.plugin.appender.visitor.testutils 2 | 3 | class GeneratedClassLoader(parent: ClassLoader?) : ClassLoader(parent) { 4 | 5 | fun defineClass(name: String, bytes: ByteArray): Class<*> { 6 | return defineClass(name, bytes, 0, bytes.size) 7 | } 8 | } -------------------------------------------------------------------------------- /aaper-plugin/src/test/assets/projects/nonVoidMethod/main/java/com/example/SomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import android.Manifest; 4 | import com.likethesalad.android.aaper.api.EnsurePermissions; 5 | 6 | public class SomeActivity extends android.app.Activity { 7 | 8 | @EnsurePermissions(permissions = {Manifest.permission.CAMERA}) 9 | public int someMethod() { 10 | return 1; 11 | } 12 | } -------------------------------------------------------------------------------- /app/gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | kotlin = "1.6.20" 3 | android = "7.4.0" 4 | 5 | [libraries] 6 | androidx-appCompat = "androidx.appcompat:appcompat:1.6.1" 7 | fragmentTesting = "androidx.fragment:fragment-testing:1.5.5" 8 | 9 | [plugins] 10 | android-application = { id = "com.android.application", version.ref = "android" } 11 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/likethesalad/android/aaper/sample/MyApp.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.sample 2 | 3 | import android.app.Application 4 | 5 | /** 6 | * Created by César Muñoz on 03/08/20. 7 | */ 8 | class MyApp : Application() { 9 | 10 | override fun onCreate() { 11 | super.onCreate() 12 | 13 | // Aaper.setDefaultStrategy(FinishActivityOnDeniedStrategy::class.java) 14 | } 15 | } -------------------------------------------------------------------------------- /aaper-api/src/main/java/com/likethesalad/android/aaper/api/errors/RequestExecutedAlreadyException.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.api.errors 2 | 3 | /** 4 | * Exception thrown when a request was previously launched and there was an attempt 5 | * to launch it again. 6 | */ 7 | class RequestExecutedAlreadyException(val permissions: List) : 8 | AaperException("Request for permissions $permissions has been executed already", null) -------------------------------------------------------------------------------- /aaper-plugin/src/test/assets/projects/voidMethod/main/java/com/example/SomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import android.Manifest; 4 | import com.likethesalad.android.aaper.api.EnsurePermissions; 5 | 6 | public class SomeActivity extends android.app.Activity { 7 | 8 | @EnsurePermissions(permissions = {Manifest.permission.CAMERA}) 9 | public void someMethod() { 10 | System.out.println("Permissions granted."); 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /aaper-plugin/src/main/java/com/likethesalad/android/aaper/plugin/utils/NamingUtils.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.plugin.utils 2 | 3 | object NamingUtils { 4 | 5 | fun getGeneratedClassSimpleName(methodClassSimpleName: String, methodName: String): String { 6 | return "Aaper_${methodClassSimpleName}_$methodName" 7 | } 8 | 9 | fun getWraapMethodName(methodName: String): String { 10 | return "wraaper_${methodName}" 11 | } 12 | } -------------------------------------------------------------------------------- /aaper/src/main/java/com/likethesalad/android/aaper/AaperInitializer.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper 2 | 3 | import android.content.Context 4 | import androidx.startup.Initializer 5 | 6 | class AaperInitializer : Initializer { 7 | 8 | override fun create(context: Context) { 9 | Aaper.initialize(context) 10 | } 11 | 12 | override fun dependencies(): List>> { 13 | return emptyList() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aaper-api/src/main/java/com/likethesalad/android/aaper/internal/data/CurrentRequest.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.internal.data 2 | 3 | import com.likethesalad.android.aaper.api.strategy.RequestStrategy 4 | import com.likethesalad.android.aaper.api.data.PermissionsRequest 5 | 6 | data class CurrentRequest( 7 | val host: Any, 8 | val data: PermissionsRequest, 9 | val strategy: RequestStrategy, 10 | internal val originalMethod: Runnable 11 | ) -------------------------------------------------------------------------------- /aaper-api/src/main/java/com/likethesalad/android/aaper/internal/data/PendingRequest.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.internal.data 2 | 3 | import com.likethesalad.android.aaper.api.strategy.RequestStrategy 4 | import com.likethesalad.android.aaper.api.data.PermissionsRequest 5 | 6 | data class PendingRequest( 7 | val host: Any, 8 | val data: PermissionsRequest, 9 | val strategy: RequestStrategy, 10 | internal val originalMethod: Runnable 11 | ) -------------------------------------------------------------------------------- /aaper-api/src/main/java/com/likethesalad/android/aaper/api/data/LaunchMetadata.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.api.data 2 | 3 | /** 4 | * It represents any sort of data that might be needed for a permission request. For example, 5 | * it can hold a requestCode for common permission requests. 6 | */ 7 | interface LaunchMetadata { 8 | 9 | /** 10 | * Checks if another [LaunchMetadata] is equal to self. 11 | */ 12 | fun isEqualTo(other: LaunchMetadata?): Boolean 13 | } -------------------------------------------------------------------------------- /aaper/src/main/java/com/likethesalad/android/aaper/errors/AaperNotInitializedException.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.errors 2 | 3 | import com.likethesalad.android.aaper.api.errors.AaperException 4 | 5 | /** 6 | * This exception is thrown when an attempt to access Aaper is made before initializing it. 7 | */ 8 | class AaperNotInitializedException 9 | : AaperException( 10 | "Aaper is not initialized. You must call Aaper.initialize before performing this operation", 11 | null 12 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/likethesalad/android/aaper/sample/test/SimpleFragment.kt: -------------------------------------------------------------------------------- 1 | package com.likethesalad.android.aaper.sample.test 2 | 3 | import android.Manifest 4 | import androidx.fragment.app.Fragment 5 | import com.likethesalad.android.aaper.api.EnsurePermissions 6 | import com.likethesalad.android.aaper.sample.test.utils.CallMe 7 | 8 | class SimpleFragment : Fragment() { 9 | 10 | @EnsurePermissions(permissions = [Manifest.permission.CAMERA]) 11 | fun someMethod(callMe: CallMe) { 12 | callMe.call() 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/my_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 |