diff --git a/.gitignore b/.gitignore index 520a863..bead640 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,105 @@ google-services.json freeline.py freeline/ freeline_project_description.json +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Android template +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# Intellij +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/dictionaries +.idea/libraries + +# Keystore files +*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +.idea/ diff --git a/LICENSE b/LICENSE index 8dada3e..73777a8 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright 2017 Daisuke Nomura Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/annotation/.gitignore b/annotation/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/annotation/.gitignore @@ -0,0 +1 @@ +/build diff --git a/annotation/build.gradle b/annotation/build.gradle new file mode 100644 index 0000000..0dc64f7 --- /dev/null +++ b/annotation/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.3" + + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { +} diff --git a/annotation/proguard-rules.pro b/annotation/proguard-rules.pro new file mode 100644 index 0000000..c7057e1 --- /dev/null +++ b/annotation/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/daisuke/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/annotation/src/main/AndroidManifest.xml b/annotation/src/main/AndroidManifest.xml new file mode 100644 index 0000000..777fbeb --- /dev/null +++ b/annotation/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/FrameworkChildFragmentManager.java b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/FrameworkChildFragmentManager.java new file mode 100644 index 0000000..c6be7c4 --- /dev/null +++ b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/FrameworkChildFragmentManager.java @@ -0,0 +1,9 @@ +package com.kyaracter.fragmentmanagerannotation.annotation; + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface FrameworkChildFragmentManager { +} diff --git a/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/FrameworkFragmentManager.java b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/FrameworkFragmentManager.java new file mode 100644 index 0000000..b3baab1 --- /dev/null +++ b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/FrameworkFragmentManager.java @@ -0,0 +1,9 @@ +package com.kyaracter.fragmentmanagerannotation.annotation; + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface FrameworkFragmentManager { +} diff --git a/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/SupportChildFragmentManager.java b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/SupportChildFragmentManager.java new file mode 100644 index 0000000..e76eddf --- /dev/null +++ b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/SupportChildFragmentManager.java @@ -0,0 +1,9 @@ +package com.kyaracter.fragmentmanagerannotation.annotation; + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface SupportChildFragmentManager { +} diff --git a/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/SupportFragmentManager.java b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/SupportFragmentManager.java new file mode 100644 index 0000000..395b116 --- /dev/null +++ b/annotation/src/main/java/com/kyaracter/fragmentmanagerannotation/annotation/SupportFragmentManager.java @@ -0,0 +1,9 @@ +package com.kyaracter.fragmentmanagerannotation.annotation; + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface SupportFragmentManager { +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..05bf044 --- /dev/null +++ b/build.gradle @@ -0,0 +1,27 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + maven { url "https://maven.google.com" } + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.3' + + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url "https://maven.google.com" } + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/example/.gitignore @@ -0,0 +1 @@ +/build diff --git a/example/build.gradle b/example/build.gradle new file mode 100644 index 0000000..26d4312 --- /dev/null +++ b/example/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.3" + defaultConfig { + applicationId "com.kyaracter.fragmentmanagerannotation.example" + minSdkVersion 21 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + testCompile 'junit:junit:4.12' + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile project(':library') + androidTestCompile project(':library') + compile 'com.android.support:appcompat-v7:25.4.0' + compile 'com.android.support:design:25.4.0' + compile 'com.android.support.constraint:constraint-layout:1.0.2' +} diff --git a/example/proguard-rules.pro b/example/proguard-rules.pro new file mode 100644 index 0000000..c7057e1 --- /dev/null +++ b/example/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/daisuke/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/example/src/androidTest/java/com/kyaracter/fragmentmanagerannotation/example/ExampleInstrumentedTest.java b/example/src/androidTest/java/com/kyaracter/fragmentmanagerannotation/example/ExampleInstrumentedTest.java new file mode 100644 index 0000000..60afdc1 --- /dev/null +++ b/example/src/androidTest/java/com/kyaracter/fragmentmanagerannotation/example/ExampleInstrumentedTest.java @@ -0,0 +1,49 @@ +package com.kyaracter.fragmentmanagerannotation.example; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import com.kyaracter.fragmentmanagerannotation.library.LookFragmentManager; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.junit.Assert.assertEquals; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false); + + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.kyaracter.fragmentmanagerannotation.example", appContext.getPackageName()); + } + + @Test + public void supportFragmentManagerTest() throws RuntimeException { + MainActivity mainActivity = mActivityRule.launchActivity(null); + LookFragmentManager.supportFragmentManager(mainActivity, com.kyaracter.fragmentmanagerannotation.example.R.id.fragment); + onView(withText("Hello World!")); + } + + @Test + public void supportChildFragmentManagerTest() throws RuntimeException { + MainActivity mainActivity = mActivityRule.launchActivity(null); + LookFragmentManager.supportFragmentManager(mainActivity, com.kyaracter.fragmentmanagerannotation.example.R.id.fragment); + onView(withText("Hello World!")); + } +} diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f201280 --- /dev/null +++ b/example/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/src/main/java/com/kyaracter/fragmentmanagerannotation/example/MainActivity.java b/example/src/main/java/com/kyaracter/fragmentmanagerannotation/example/MainActivity.java new file mode 100644 index 0000000..01320e3 --- /dev/null +++ b/example/src/main/java/com/kyaracter/fragmentmanagerannotation/example/MainActivity.java @@ -0,0 +1,39 @@ +package com.kyaracter.fragmentmanagerannotation.example; + +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.View; + +import com.kyaracter.fragmentmanagerannotation.library.LookFragmentManager; + + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(com.kyaracter.fragmentmanagerannotation.example.R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(com.kyaracter.fragmentmanagerannotation.example.R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(com.kyaracter.fragmentmanagerannotation.example.R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + protected void onStart() { + super.onStart(); + + //throw IllegalArgumentException due to MainFragment with SupportChildFragmentManager annotation + LookFragmentManager.supportFragmentManager(this, com.kyaracter.fragmentmanagerannotation.example.R.id.fragment); + } +} diff --git a/example/src/main/java/com/kyaracter/fragmentmanagerannotation/example/MainFragment.java b/example/src/main/java/com/kyaracter/fragmentmanagerannotation/example/MainFragment.java new file mode 100644 index 0000000..3cc3f02 --- /dev/null +++ b/example/src/main/java/com/kyaracter/fragmentmanagerannotation/example/MainFragment.java @@ -0,0 +1,22 @@ +package com.kyaracter.fragmentmanagerannotation.example; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.kyaracter.fragmentmanagerannotation.annotation.SupportChildFragmentManager; + +@SupportChildFragmentManager +public class MainFragment extends Fragment { + + public MainFragment() { + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(com.kyaracter.fragmentmanagerannotation.example.R.layout.fragment_main, container, false); + } +} diff --git a/example/src/main/res/drawable/ic_launcher_background.xml b/example/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..1cd2a36 --- /dev/null +++ b/example/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/src/main/res/layout/activity_main.xml b/example/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..0f4e107 --- /dev/null +++ b/example/src/main/res/layout/activity_main.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/example/src/main/res/layout/content_main.xml b/example/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..779276f --- /dev/null +++ b/example/src/main/res/layout/content_main.xml @@ -0,0 +1,9 @@ + diff --git a/example/src/main/res/layout/fragment_main.xml b/example/src/main/res/layout/fragment_main.xml new file mode 100644 index 0000000..4caa23e --- /dev/null +++ b/example/src/main/res/layout/fragment_main.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/example/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/example/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..00f9eaa --- /dev/null +++ b/example/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/example/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/example/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..00f9eaa --- /dev/null +++ b/example/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/example/src/main/res/mipmap-hdpi/ic_launcher.png b/example/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..5507303 Binary files /dev/null and b/example/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/example/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..4e526c9 Binary files /dev/null and b/example/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/example/src/main/res/mipmap-hdpi/ic_launcher_round.png b/example/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..8fab6a3 Binary files /dev/null and b/example/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/example/src/main/res/mipmap-mdpi/ic_launcher.png b/example/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..6bc7fcd Binary files /dev/null and b/example/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/example/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..2c38c71 Binary files /dev/null and b/example/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/example/src/main/res/mipmap-mdpi/ic_launcher_round.png b/example/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..1eecc0e Binary files /dev/null and b/example/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/example/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..ec87dce Binary files /dev/null and b/example/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/example/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..072467e Binary files /dev/null and b/example/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..05ca079 Binary files /dev/null and b/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/example/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..6f67f21 Binary files /dev/null and b/example/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/example/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..78a6b7a Binary files /dev/null and b/example/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..8bac0f2 Binary files /dev/null and b/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..0327e13 Binary files /dev/null and b/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/example/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..68ebe33 Binary files /dev/null and b/example/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..bacd3e7 Binary files /dev/null and b/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/example/src/main/res/values/colors.xml b/example/src/main/res/values/colors.xml new file mode 100644 index 0000000..3ab3e9c --- /dev/null +++ b/example/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/example/src/main/res/values/dimens.xml b/example/src/main/res/values/dimens.xml new file mode 100644 index 0000000..59a0b0c --- /dev/null +++ b/example/src/main/res/values/dimens.xml @@ -0,0 +1,3 @@ + + 16dp + diff --git a/example/src/main/res/values/strings.xml b/example/src/main/res/values/strings.xml new file mode 100644 index 0000000..e87001f --- /dev/null +++ b/example/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + FragmentManagerAnnotation + diff --git a/example/src/main/res/values/styles.xml b/example/src/main/res/values/styles.xml new file mode 100644 index 0000000..545b9c6 --- /dev/null +++ b/example/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + +