├── akatsuki_logo.ai ├── akatsuki_logo.png ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── sample ├── src │ ├── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ └── dimens.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── fragment_main.xml │ │ │ │ ├── fragment_serialize_example.xml │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── sora │ │ │ │ └── util │ │ │ │ └── akatsuki │ │ │ │ └── app │ │ │ │ ├── InheritedArgRetainedFragment.java │ │ │ │ ├── EmptyArgRetainedFragment.java │ │ │ │ ├── ArgRetainedFragment.java │ │ │ │ ├── MainActivityFragment.java │ │ │ │ ├── BaseRetainedFragment.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── SerializeExampleFragment.java │ │ │ │ └── LotsOfTypes.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── akatsuki │ │ └── util │ │ └── sora │ │ └── com │ │ └── akatsuki │ │ └── ApplicationTest.java ├── build.gradle └── proguard-rules.pro ├── akatsuki-api ├── src │ └── main │ │ └── java │ │ └── com │ │ └── sora │ │ └── util │ │ └── akatsuki │ │ ├── BundleUtils.java │ │ ├── RetainerCache.java │ │ ├── BundleRetainer.java │ │ ├── CollectionConverter.java │ │ ├── ArgConcludingBuilder.java │ │ ├── ServiceConcludingBuilder.java │ │ ├── IncludeClasses.java │ │ ├── IntentConcludingBuilder.java │ │ ├── ActivityConcludingBuilder.java │ │ ├── TypeFilter.java │ │ ├── Arg.java │ │ ├── RetainConfig.java │ │ ├── With.java │ │ ├── DeclaredConverter.java │ │ ├── InvalidTypeConverter.java │ │ ├── FragmentConcludingBuilder.java │ │ ├── Retained.java │ │ ├── TypeConverter.java │ │ ├── MultiKeyTypeConverter.java │ │ ├── TypeConstraint.java │ │ ├── TransformationTemplate.java │ │ ├── AkatsukiConfig.java │ │ ├── BundleBuilder.java │ │ └── ArgConfig.java ├── build.gradle └── proguard-rules.pro ├── akatsuki-compiler ├── src │ ├── test │ │ └── java │ │ │ ├── com │ │ │ └── sora │ │ │ │ └── util │ │ │ │ └── akatsuki │ │ │ │ ├── SourceClassModelUnitTest.java │ │ │ │ ├── TestEnvironment.java │ │ │ │ ├── AkatsukiProcessorIntegrationTest.java │ │ │ │ ├── PublicFacingApiIntegrationTest.java │ │ │ │ ├── ArgTestField.java │ │ │ │ ├── RetainedTestField.java │ │ │ │ ├── CodeGenUtils.java │ │ │ │ ├── EnclosingInstanceValidationIntegrationTest.java │ │ │ │ ├── IntegrationTestBase.java │ │ │ │ ├── ExtendedTypeSupportIntegrationTest.java │ │ │ │ ├── FieldValidationTest.java │ │ │ │ ├── AkatsukiConfigIntegrationTest.java │ │ │ │ ├── RetainedAnnotationIntegrationTest.java │ │ │ │ ├── AkatsukiProcessorSourceNameTest.java │ │ │ │ ├── TestField.java │ │ │ │ ├── BaseTestEnvironment.java │ │ │ │ ├── CompilerUtils.java │ │ │ │ ├── BuilderIntegrationTestBase.java │ │ │ │ ├── InternalClassDiscoveryIntegrationTest.java │ │ │ │ └── TestSource.java │ │ │ └── android │ │ │ └── util │ │ │ ├── Size.java │ │ │ └── SizeF.java │ └── main │ │ └── java │ │ └── com │ │ └── sora │ │ └── util │ │ └── akatsuki │ │ ├── models │ │ ├── BaseModel.java │ │ ├── GeneratedClass.java │ │ ├── SourceCollectingModel.java │ │ ├── SourceMappingModel.java │ │ ├── FieldModel.java │ │ └── ClassInfo.java │ │ ├── JavaPoetUtils.java │ │ ├── MustacheUtils.java │ │ ├── TransformationContext.java │ │ ├── BundleContext.java │ │ ├── SourceUtils.java │ │ ├── AndroidTypes.java │ │ ├── DeclaredConverterModel.java │ │ ├── analyzers │ │ ├── NestedTypeAnalyzer.java │ │ ├── ConverterAnalyzer.java │ │ ├── PrimitiveTypeAnalyzer.java │ │ ├── TemplateAnalyzer.java │ │ ├── ObjectTypeAnalyzer.java │ │ ├── GenericTypeAnalyzer.java │ │ ├── ArrayTypeAnalyzer.java │ │ └── Element.java │ │ ├── Log.java │ │ ├── ProcessorContext.java │ │ ├── Configuration.java │ │ ├── Utils.java │ │ ├── RetainedStateModel.java │ │ ├── ArgumentBuildersModel.java │ │ └── ProcessorUtils.java ├── proguard-rules.pro └── build.gradle ├── akatsuki-parceler ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── sora │ │ │ └── util │ │ │ └── akatsuki │ │ │ └── parceler │ │ │ └── ParcelerSupport.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── sora │ │ └── util │ │ └── akatsuki │ │ └── parceler │ │ └── ApplicationTest.java ├── build.gradle └── proguard-rules.pro ├── ROADMAP.md ├── .travis.yml ├── gradle.properties ├── deploy-sample.gradle ├── .gitignore ├── deploy-java.gradle ├── deploy-android.gradle ├── gradlew.bat ├── CHANGELOG.md └── gradlew /akatsuki_logo.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/akatsuki_logo.ai -------------------------------------------------------------------------------- /akatsuki_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/akatsuki_logo.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':akatsuki-api', ':akatsuki-compiler', ':akatsuki-parceler', 'sample' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/sample/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Akatsuki demo 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom91136/Akatsuki/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/BundleUtils.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | public class BundleUtils { 4 | 5 | 6 | 7 | } 8 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/test/java/com/sora/util/akatsuki/SourceClassModelUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | public class SourceClassModelUnitTest { 4 | } 5 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/test/java/com/sora/util/akatsuki/TestEnvironment.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | public interface TestEnvironment { 4 | 5 | String printReport(); 6 | } 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /akatsuki-parceler/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sora/util/akatsuki/app/InheritedArgRetainedFragment.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.app; 2 | 3 | import com.sora.util.akatsuki.Arg; 4 | 5 | public class InheritedArgRetainedFragment extends ArgRetainedFragment{ 6 | 7 | @Arg String someString; 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 04 17:33:20 GMT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip 7 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sora/util/akatsuki/app/EmptyArgRetainedFragment.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.app; 2 | 3 | public class EmptyArgRetainedFragment extends ArgRetainedFragment { 4 | // nothing here, the idea is that this class will be picked up by the processor without any other annotations 5 | } 6 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/models/BaseModel.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.models; 2 | 3 | import com.sora.util.akatsuki.ProcessorContext; 4 | 5 | public class BaseModel { 6 | 7 | protected final ProcessorContext context; 8 | 9 | public BaseModel(ProcessorContext context) { 10 | this.context = context; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/RetainerCache.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | /** 4 | * Used for caching class names to avoid reflection. This interface should be 5 | * implemented only by generated classes. 6 | */ 7 | public interface RetainerCache { 8 | 9 | Class> getCached(String clazz); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/BundleRetainer.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import android.os.Bundle; 4 | 5 | /** 6 | * Interface for all generated classes 7 | * @param the type of annotated field's enclosing instance 8 | */ 9 | public interface BundleRetainer { 10 | 11 | void save(T source, Bundle bundle); 12 | 13 | void restore(T source, Bundle bundle); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | Roadmap 2 | ======== 3 | 4 | 5 | NEXT 6 | ==== 7 | 8 | * Allow `@Retain` on methods 9 | * Extended type support (feature-ets) 10 | 11 | 12 | 0.1.0 13 | ==== 14 | 15 | * Arguments and builder support for `Fragment` and `Activity` 16 | * Multithreaded annotation processing 17 | * Better error messages and suggestions 18 | * Fine grained @RetainCofig 19 | 20 | 0.0.2~0.0.5 21 | ==== 22 | 23 | * Bug fix releases 24 | 25 | 0.0.1 26 | ==== 27 | Initial release -------------------------------------------------------------------------------- /sample/src/androidTest/java/akatsuki/util/sora/com/akatsuki/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package akatsuki.util.sora.com.akatsuki; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /akatsuki-parceler/src/androidTest/java/com/sora/util/akatsuki/parceler/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.parceler; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/CollectionConverter.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import java.util.Collection; 4 | 5 | import android.os.Bundle; 6 | 7 | public class CollectionConverter implements TypeConverter> { 8 | @Override 9 | public void save(Bundle bundle, Collection collection, String key) { 10 | 11 | } 12 | 13 | @Override 14 | public Collection restore(Bundle bundle, Collection collection, String key) { 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/JavaPoetUtils.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | class JavaPoetUtils { 7 | 8 | private static final String REPLACEMENT = Matcher.quoteReplacement("$$"); 9 | private static final Pattern PATTERN = Pattern.compile("\\$"); 10 | 11 | public static String escapeStatement(String statement) { 12 | return PATTERN.matcher(statement).replaceAll(REPLACEMENT); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/models/GeneratedClass.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.models; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.annotation.processing.Filer; 6 | 7 | import com.sora.util.akatsuki.ProcessorContext; 8 | 9 | public abstract class GeneratedClass extends BaseModel { 10 | 11 | protected GeneratedClass(ProcessorContext context) { 12 | super(context); 13 | } 14 | 15 | public abstract ClassInfo classInfo(); 16 | 17 | public abstract void writeToFile(Filer filer) throws IOException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /akatsuki-api/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { url 'http://repo.spring.io/plugins-release' } 4 | } 5 | dependencies { 6 | classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:2.2.2' 7 | } 8 | } 9 | 10 | apply plugin: 'java' 11 | apply plugin: 'provided-base' 12 | 13 | targetCompatibility = '1.7' 14 | sourceCompatibility = '1.7' 15 | 16 | 17 | dependencies { 18 | provided 'com.google.android:android:4.1.1.4' 19 | provided 'com.google.android:support-v4:r7' 20 | } 21 | 22 | apply from: file('../deploy-java.gradle') 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | script: "./gradlew build" 3 | android: 4 | components: 5 | - platform-tools 6 | - tools 7 | 8 | # The BuildTools version used by your project 9 | - build-tools-23.0.1 10 | 11 | # The SDK version used to compile your project 12 | - android-23 13 | 14 | # Additional components 15 | - extra-google-google_play_services 16 | - extra-google-m2repository 17 | - extra-android-m2repository 18 | 19 | jdk: 20 | - oraclejdk8 21 | before_install: 22 | - chmod +x gradlew 23 | addons: 24 | apt: 25 | packages: 26 | - oracle-java8-installer -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/ArgConcludingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | public abstract class ArgConcludingBuilder extends Internal.ArgBuilder { 4 | 5 | public ArgConcludingBuilder() { 6 | 7 | } 8 | 9 | public static class VoidBuilder extends ArgConcludingBuilder { 10 | 11 | public VoidBuilder() { 12 | throw new RuntimeException( 13 | "This is only used in place for default annotation values, do not use!"); 14 | } 15 | 16 | @Override 17 | protected Class targetClass() { 18 | return Void.class; 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/ServiceConcludingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import android.app.Service; 4 | import android.content.ComponentName; 5 | import android.content.Context; 6 | import android.os.Bundle; 7 | 8 | public class ServiceConcludingBuilder 9 | extends IntentConcludingBuilder { 10 | 11 | public ServiceConcludingBuilder(Bundle bundle, Class targetClass) { 12 | super(bundle, targetClass); 13 | } 14 | 15 | public ComponentName startService(Context context) { 16 | return context.startService(build(context)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/models/SourceCollectingModel.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.models; 2 | 3 | import java.util.List; 4 | 5 | import com.sora.util.akatsuki.ProcessorContext; 6 | 7 | public abstract class SourceCollectingModel extends GeneratedClass { 8 | 9 | private final List mappingModels; 10 | 11 | protected SourceCollectingModel(ProcessorContext context, List mappingModels) { 12 | super(context); 13 | this.mappingModels = mappingModels; 14 | } 15 | 16 | 17 | protected List mappingModels() { 18 | return mappingModels; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/IncludeClasses.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Includes a {@link TransformationTemplate} from another library so that the 10 | * compiler can see the annotation 11 | */ 12 | @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.PACKAGE, ElementType.ANNOTATION_TYPE }) 13 | @Retention(RetentionPolicy.CLASS) 14 | public @interface IncludeClasses { 15 | 16 | Class[]value(); 17 | } 18 | -------------------------------------------------------------------------------- /akatsuki-parceler/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '23.0.1' 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile project(':akatsuki-api') 23 | compile 'org.parceler:parceler-api:1.0.3' 24 | } 25 | 26 | apply from: file('../deploy-android.gradle') -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/MustacheUtils.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | 4 | import com.samskivert.mustache.Mustache; 5 | 6 | public class MustacheUtils { 7 | 8 | 9 | public static final Mustache.Compiler COMPILER = Mustache.compiler().escapeHTML(false); 10 | 11 | 12 | public static String render(Object scope, String template) { 13 | return COMPILER.compile(template).execute(scope); 14 | } 15 | 16 | // public static String render(Object scope, String template) { 17 | // final StringWriter writer = new StringWriter(); 18 | // FACTORY.compile(new StringReader(template), "").execute(writer, scope); 19 | // return writer.toString(); 20 | // } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/IntentConcludingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import com.sora.util.akatsuki.Internal.ClassArgBuilder; 8 | 9 | public abstract class IntentConcludingBuilder extends ClassArgBuilder { 10 | 11 | public IntentConcludingBuilder(Bundle bundle, Class targetClass) { 12 | super(bundle, targetClass); 13 | } 14 | 15 | protected Intent build() { 16 | return new Intent().putExtras(bundle); 17 | } 18 | 19 | public Intent build(Context context) { 20 | return build().setClass(context, targetClass()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/ActivityConcludingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | 7 | public class ActivityConcludingBuilder 8 | extends IntentConcludingBuilder { 9 | 10 | public ActivityConcludingBuilder(Bundle bundle, Class targetClass) { 11 | super(bundle, targetClass); 12 | } 13 | 14 | public void startActivity(Context context) { 15 | context.startActivity(build(context)); 16 | } 17 | 18 | public void startActivity(Context context, Bundle activityOptions) { 19 | context.startActivity(build(context), activityOptions); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /akatsuki-api/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/tom91136/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /akatsuki-compiler/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/tom91136/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/models/SourceMappingModel.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.models; 2 | 3 | import com.sora.util.akatsuki.ProcessorContext; 4 | 5 | public abstract class SourceMappingModel extends GeneratedClass { 6 | 7 | private final SourceClassModel classModel; 8 | private final SourceTreeModel treeModel; 9 | 10 | protected SourceMappingModel(ProcessorContext context, SourceClassModel classModel, 11 | SourceTreeModel treeModel) { 12 | super(context); 13 | this.classModel = classModel; 14 | this.treeModel = treeModel; 15 | } 16 | 17 | public SourceClassModel classModel() { 18 | return classModel; 19 | } 20 | 21 | protected SourceTreeModel treeModel() { 22 | return treeModel; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /akatsuki-parceler/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Program Files (x86)\Android\android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/TypeFilter.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Defines a type filter 10 | */ 11 | @Target(ElementType.ANNOTATION_TYPE) 12 | @Retention(RetentionPolicy.CLASS) 13 | public @interface TypeFilter { 14 | 15 | /** 16 | * The constraint of the type (eg: List.class will match {@code List 17 | * }) 18 | */ 19 | TypeConstraint type(); 20 | 21 | /** 22 | * The generic parameter constraint of the type (eg: String will match 23 | * {@code List}) 24 | */ 25 | TypeConstraint[]parameters() default {}; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/test/java/android/util/Size.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 WEI CHEN LIN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package android.util; 18 | /** 19 | * For testing use only 20 | */ 21 | public final class Size { 22 | public Size() { 23 | throw new RuntimeException("stub"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/test/java/android/util/SizeF.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 WEI CHEN LIN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package android.util; 18 | 19 | /** 20 | * For testing use only 21 | */ 22 | public class SizeF { 23 | 24 | public SizeF() { 25 | throw new RuntimeException("stub"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/Arg.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface Arg { 11 | 12 | int NO_INDEX = -1; 13 | 14 | /** 15 | * This field will not be used in the argument builder 16 | */ 17 | boolean skip() default false; 18 | 19 | /** 20 | * This field will be optional in the argument builder 21 | */ 22 | boolean optional() default false; 23 | 24 | /** 25 | * Use the given value as setter name of the builder, defaults to field name 26 | */ 27 | String value() default ""; 28 | 29 | /** 30 | * Custom index for field processing order, defaults to code ordering 31 | */ 32 | int index() default NO_INDEX; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/TransformationContext.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import javax.lang.model.type.TypeMirror; 4 | 5 | import com.sora.util.akatsuki.analyzers.CascadingTypeAnalyzer; 6 | import com.sora.util.akatsuki.analyzers.CascadingTypeAnalyzer.Analysis; 7 | import com.sora.util.akatsuki.analyzers.Element; 8 | 9 | public class TransformationContext extends ProcessorContext { 10 | 11 | private final TypeAnalyzerResolver resolver; 12 | 13 | public TransformationContext(ProcessorContext context, TypeAnalyzerResolver resolver) { 14 | super(context); 15 | this.resolver = resolver; 16 | } 17 | 18 | public TransformationContext(TransformationContext context) { 19 | this(context, context.resolver); 20 | } 21 | 22 | protected CascadingTypeAnalyzer resolve(Element element) { 23 | return resolver.resolve(element); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/RetainConfig.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.sora.util.akatsuki.Retained.RestorePolicy; 9 | 10 | /** 11 | * Compile time configuration for {@link Retained}, to be used on classes with 12 | * field annotated with {@code Retained} 13 | */ 14 | @Target({ ElementType.TYPE }) 15 | @Retention(RetentionPolicy.CLASS) 16 | public @interface RetainConfig { 17 | 18 | /** 19 | * Default {@link RestorePolicy} setting for the class, see 20 | * {@link Retained#restorePolicy()} 21 | */ 22 | RestorePolicy restorePolicy() default RestorePolicy.DEFAULT; 23 | 24 | /** 25 | * Whether the class should be processed; useful for debugging 26 | */ 27 | boolean enabled() default true; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/test/java/com/sora/util/akatsuki/AkatsukiProcessorIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | public class AkatsukiProcessorIntegrationTest extends IntegrationTestBase { 4 | 5 | 6 | // TODO not ready for this yet 7 | // // TODO might not be the best way to test this.. 8 | // @Test(expected = AssertionError.class) 9 | // public void testSourceNotGeneratedWhenAllSkipped() throws IOException { 10 | // AnnotationSpec spec = AnnotationSpec.builder(Retained.class).addMember("skip", "$L", true) 11 | // .build(); 12 | // final JavaFileObject testClass = CodeGenUtils 13 | // .createTestClass(field(STRING_TYPE, "foo", spec), field(STRING_TYPE, "bar", spec)); 14 | // 15 | // // the assertion error is expected because no file should be generated 16 | // assertTestClass(testClass).compilesWithoutError().and().generatesFileNamed( 17 | // StandardLocation.SOURCE_OUTPUT, TEST_PACKAGE, 18 | // Internal.generateRetainerClassName(TEST_CLASS) + ".java"); 19 | // } 20 | 21 | } -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/BundleContext.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import com.google.common.base.MoreObjects; 4 | 5 | 6 | public interface BundleContext { 7 | 8 | String sourceObjectName(); 9 | 10 | String bundleObjectName(); 11 | 12 | class SimpleBundleContext implements BundleContext { 13 | 14 | private final String sourceObjectName; 15 | private final String bundleObjectName; 16 | 17 | SimpleBundleContext(String sourceObjectName, String bundleObjectName) { 18 | this.sourceObjectName = sourceObjectName; 19 | this.bundleObjectName = bundleObjectName; 20 | } 21 | 22 | @Override 23 | public String sourceObjectName() { 24 | return sourceObjectName; 25 | } 26 | 27 | @Override 28 | public String bundleObjectName() { 29 | return bundleObjectName; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return MoreObjects.toStringHelper(this).add("sourceObjectName", sourceObjectName) 35 | .add("bundleObjectName", bundleObjectName).toString(); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /akatsuki-api/src/main/java/com/sora/util/akatsuki/With.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * This annotation allows you to specify different {@link TypeConverter} for the 10 | * annotated element. All annotations concerning Bundle serializations such as 11 | * {@link Retained} and {@link Arg} will respect this. 12 | */ 13 | @Target(ElementType.FIELD) 14 | @Retention(RetentionPolicy.SOURCE) 15 | public @interface With { 16 | 17 | /** 18 | * The specified {@link TypeConverter} will be used to persist this field 19 | * (this takes precedence over everything, including the built in type 20 | * support and {@link DeclaredConverter} annotated {@link TypeConverter}s) 21 | */ 22 | Class>value() default TypeConverter.DummyTypeConverter.class; 23 | 24 | // adding more stuff might change the meaning of this annotation a bit, 25 | // let's try not to do that :) 26 | } 27 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/SourceUtils.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import com.squareup.javapoet.ClassName; 4 | import com.squareup.javapoet.ParameterizedTypeName; 5 | import com.squareup.javapoet.TypeVariableName; 6 | 7 | public class SourceUtils { 8 | 9 | public static final TypeVariableName T = var("T"); 10 | 11 | 12 | public static TypeVariableName extend(String typeName, ClassName name) { 13 | return TypeVariableName.get(typeName, name); 14 | } 15 | 16 | public static TypeVariableName T_extends(ClassName name) { 17 | return extend("T", name); 18 | } 19 | 20 | 21 | public static TypeVariableName var(String name) { 22 | return TypeVariableName.get(name); 23 | } 24 | 25 | public static ParameterizedTypeName type(Class clazz, TypeVariableName... variableNames) { 26 | return ParameterizedTypeName.get(ClassName.get(clazz), variableNames); 27 | } 28 | 29 | public static ParameterizedTypeName type(ClassName name, TypeVariableName... variableNames) { 30 | return ParameterizedTypeName.get(name, variableNames); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/AndroidTypes.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki; 2 | 3 | import javax.lang.model.type.DeclaredType; 4 | 5 | public enum AndroidTypes { 6 | 7 | // @formatter:off 8 | Size("android.util.Size"), 9 | SizeF("android.util.SizeF"), 10 | String("java.lang.String"), 11 | CharSequence("java.lang.CharSequence"), 12 | IBinder("android.os.IBinder", "Binder"), 13 | Bundle("android.os.Bundle"), 14 | Parcelable("android.os.Parcelable"), 15 | Serializable("java.io.Serializable"), 16 | SparseArray("android.util.SparseArray"); 17 | // @formatter:on 18 | 19 | public final CharSequence className; 20 | public final CharSequence typeAlias; 21 | 22 | AndroidTypes(CharSequence className) { 23 | this.className = className; 24 | this.typeAlias = null; 25 | } 26 | 27 | AndroidTypes(CharSequence className, CharSequence typeAlias) { 28 | this.className = className; 29 | this.typeAlias = typeAlias; 30 | } 31 | 32 | 33 | 34 | public DeclaredType asMirror(ProcessorContext context) { 35 | return (DeclaredType) context.utils().of(className); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /akatsuki-compiler/src/main/java/com/sora/util/akatsuki/DeclaredConverterModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 WEI CHEN LIN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.sora.util.akatsuki; 18 | 19 | import javax.lang.model.type.DeclaredType; 20 | 21 | public class DeclaredConverterModel { 22 | 23 | public final DeclaredType converter; 24 | public final TypeFilter[] filters; 25 | 26 | public DeclaredConverterModel(DeclaredType converter, TypeFilter[] filters) { 27 | this.converter = converter; 28 | this.filters = filters; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 17 | 18 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sora/util/akatsuki/app/ArgRetainedFragment.java: -------------------------------------------------------------------------------- 1 | package com.sora.util.akatsuki.app; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | 6 | import com.sora.util.akatsuki.Akatsuki; 7 | import com.sora.util.akatsuki.Arg; 8 | import com.sora.util.akatsuki.ArgConfig; 9 | import com.sora.util.akatsuki.ArgConfig.BuilderType; 10 | 11 | public class ArgRetainedFragment extends Fragment { 12 | 13 | @Arg int a; 14 | @Arg double b; 15 | @Arg double c; 16 | @Arg(optional = true) int d; 17 | @Arg(optional = true) int e; 18 | @Arg boolean f; 19 | @Arg(optional = true) boolean g; 20 | 21 | @Override 22 | public void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | Akatsuki.restore(this, savedInstanceState); 25 | 26 | } 27 | 28 | @Override 29 | public void onSaveInstanceState(Bundle outState) { 30 | super.onSaveInstanceState(outState); 31 | Akatsuki.save(this, outState); 32 | } 33 | 34 | 35 | public static class Arg2 extends Fragment{ 36 | @Arg int a; 37 | 38 | public static class Arg3 extends Fragment{ 39 | @Arg int x; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /deploy-sample.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.github.dcendents.android-maven' 2 | 3 | 4 | install { 5 | repositories.mavenInstaller { 6 | pom { 7 | project { 8 | packaging 'apk' 9 | groupId publishedGroupId 10 | artifactId project.name 11 | name publishName 12 | url siteUrl 13 | description desc 14 | licenses { 15 | license { 16 | name 'The Apache Software License, Version 2.0' 17 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 18 | } 19 | } 20 | developers { 21 | developer { 22 | id userId 23 | name userName 24 | email userEmail 25 | } 26 | } 27 | scm { 28 | connection gitUrl 29 | developerConnection gitUrl 30 | url siteUrl 31 | 32 | } 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.neenbedankt.android-apt' 3 | repositories { 4 | 5 | // maven { url "https://jitpack.io" } 6 | } 7 | 8 | android { 9 | compileSdkVersion 23 10 | buildToolsVersion '23.0.1' 11 | 12 | defaultConfig { 13 | applicationId "com.sora.util.akatsuki.app" 14 | minSdkVersion 15 15 | targetSdkVersion 23 16 | versionCode 1 17 | versionName "1.0" 18 | } 19 | buildTypes { 20 | debug { 21 | minifyEnabled true 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | compile fileTree(include: ['*.jar'], dir: 'libs') 29 | compile 'com.android.support:appcompat-v7:23.0.0' 30 | compile project(':akatsuki-api') 31 | compile project(':akatsuki-parceler') 32 | apt project(':akatsuki-compiler') 33 | 34 | // compile 'com.github.tom91136.akatsuki:akatsuki-api:' 35 | // apt 'com.github.tom91136.akatsuki:akatsuki-compiler:' 36 | 37 | compile 'com.jakewharton:butterknife:7.0.1' 38 | } 39 | 40 | apply from: file('../deploy-sample.gradle') -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_serialize_example.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 15 | 16 |