├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ ├── undraw_a.png │ │ │ ├── undraw_b.png │ │ │ ├── undraw_c.png │ │ │ ├── tab_dot.xml │ │ │ └── tab_dot_background.xml │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.webp │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.webp │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.webp │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.webp │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.webp │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── themes.xml │ │ ├── values-night │ │ │ └── themes.xml │ │ └── layout │ │ │ ├── layout_two.xml │ │ │ ├── layout_three.xml │ │ │ ├── layout_one.xml │ │ │ ├── activity_main.xml │ │ │ └── activity_fragment.xml │ │ ├── java │ │ └── com │ │ │ └── androidpoet │ │ │ └── materialintrodemo │ │ │ ├── Extesntions.kt │ │ │ ├── FragmentTwo.kt │ │ │ ├── FragmentOne.kt │ │ │ ├── FragmentThree.kt │ │ │ ├── MainActivity.kt │ │ │ └── FragmentActivity.kt │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── spotless.license.kt ├── materialintro ├── .gitignore ├── consumer-rules.pro ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── androidpoet │ │ │ └── materialintro │ │ │ ├── IntroInterpolator.kt │ │ │ ├── OnIndexChangeListener.kt │ │ │ ├── FragmentExtensions.kt │ │ │ ├── IntroAnimation.kt │ │ │ ├── AnimationsExtenstions.kt │ │ │ ├── MaterialIntroView.kt │ │ │ └── MaterialIntroFragment.kt │ │ ├── res │ │ ├── values │ │ │ └── attrs.xml │ │ └── layout │ │ │ └── materialintro.xml │ │ └── AndroidManifest.xml ├── proguard-rules.pro ├── build.gradle └── api │ └── materialintro.api ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .github └── FUNDING.yml ├── .gitignore ├── usecases.md ├── settings.gradle ├── spotless.gradle ├── dependencies.gradle ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /spotless.license.kt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /materialintro/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /materialintro/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/undraw_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/drawable/undraw_a.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/undraw_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/drawable/undraw_b.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/undraw_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/drawable/undraw_c.png -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | github: AndroidPoet 3 | custom: ["https://www.buymeacoffee.com/AndroidPoet"] 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidPoet/Material-Intro/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /materialintro/src/main/java/com/androidpoet/materialintro/IntroInterpolator.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintro 3 | 4 | public enum class IntroInterpolator(public val value: Int) { 5 | Standard(2), 6 | Emphasized(3), 7 | Decelerated(4), 8 | Accelerated(5), 9 | Linear(6) 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /.idea 4 | /local.properties 5 | /.idea/caches 6 | /.idea/libraries 7 | /.idea/modules.xml 8 | /.idea/workspace.xml 9 | /.idea/navEditor.xml 10 | /.idea/assetWizardSettings.xml 11 | .DS_Store 12 | /build 13 | /captures 14 | .externalNativeBuild 15 | .cxx 16 | local.properties 17 | -------------------------------------------------------------------------------- /materialintro/src/main/java/com/androidpoet/materialintro/OnIndexChangeListener.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintro 3 | 4 | /** OnIndexChangeListener is an interface for listening to the index is changed. */ 5 | public fun interface OnIndexChangeListener { 6 | 7 | /** invoked when progress value is changed. */ 8 | public fun onChange(progress: Int) 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/androidpoet/materialintrodemo/Extesntions.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintrodemo 3 | 4 | import android.widget.ImageView 5 | import coil.ImageLoader 6 | import coil.decode.SvgDecoder 7 | import coil.request.CachePolicy 8 | import coil.request.ImageRequest 9 | 10 | fun ImageView.loadUrl(url: String) { 11 | 12 | val imageLoader = ImageLoader.Builder(this.context) 13 | .diskCachePolicy(CachePolicy.ENABLED) 14 | .componentRegistry { add(SvgDecoder(this@loadUrl.context)) } 15 | .build() 16 | 17 | val request = ImageRequest.Builder(this.context) 18 | .crossfade(true) 19 | .crossfade(500) 20 | .data(url) 21 | .target(this) 22 | .build() 23 | 24 | imageLoader.enqueue(request) 25 | } 26 | -------------------------------------------------------------------------------- /usecases.md: -------------------------------------------------------------------------------- 1 | 2 | # Who's using Material Intro? 3 | 4 | If your project uses Material Intro, let me know by creating a new issue or PR! 🤗 5 | 6 | 7 | 8 | # License 9 | ```xml 10 | Copyright 2022 AndroidPoet (Ranbir Singh) 11 | 12 | Licensed under the Apache License, Version 2.0 (the "License"); 13 | you may not use this file except in compliance with the License. 14 | You may obtain a copy of the License at 15 | 16 | http://www.apache.org/licenses/LICENSE-2.0 17 | 18 | Unless required by applicable law or agreed to in writing, software 19 | distributed under the License is distributed on an "AS IS" BASIS, 20 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | See the License for the specific language governing permissions and 22 | limitations under the License. 23 | ``` 24 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /materialintro/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * * Copyright 2022 AndroidPoet (Ranbir Singh) 4 | * * * 5 | * * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * * * you may not use this file except in compliance with the License. 7 | * * * You may obtain a copy of the License at 8 | * * * 9 | * * * http://www.apache.org/licenses/LICENSE-2.0 10 | * * * 11 | * * * Unless required by applicable law or agreed to in writing, software 12 | * * * distributed under the License is distributed on an "AS IS" BASIS, 13 | * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * * * See the License for the specific language governing permissions and 15 | * * * limitations under the License. 16 | * 17 | */ 18 | 19 | rootProject.name = "MaterialIntroDemo" 20 | include ':app' 21 | include ':materialintro' 22 | -------------------------------------------------------------------------------- /materialintro/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /materialintro/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # /* 3 | # * * Copyright 2022 AndroidPoet (Ranbir Singh) 4 | # * * 5 | # * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | # * * you may not use this file except in compliance with the License. 7 | # * * You may obtain a copy of the License at 8 | # * * 9 | # * * http://www.apache.org/licenses/LICENSE-2.0 10 | # * * 11 | # * * Unless required by applicable law or agreed to in writing, software 12 | # * * distributed under the License is distributed on an "AS IS" BASIS, 13 | # * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # * * See the License for the specific language governing permissions and 15 | # * * limitations under the License. 16 | # */ 17 | # 18 | 19 | #Thu Mar 17 12:59:32 IST 2022 20 | distributionBase=GRADLE_USER_HOME 21 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 22 | distributionPath=wrapper/dists 23 | zipStorePath=wrapper/dists 24 | zipStoreBase=GRADLE_USER_HOME 25 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/tab_dot.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 25 | 26 | -------------------------------------------------------------------------------- /materialintro/src/main/res/layout/materialintro.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/tab_dot_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 25 | 26 | -------------------------------------------------------------------------------- /spotless.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * 5 | * * * Copyright 2022 AndroidPoet (Ranbir Singh) 6 | * * * 7 | * * * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * * * you may not use this file except in compliance with the License. 9 | * * * You may obtain a copy of the License at 10 | * * * 11 | * * * http://www.apache.org/licenses/LICENSE-2.0 12 | * * * 13 | * * * Unless required by applicable law or agreed to in writing, software 14 | * * * distributed under the License is distributed on an "AS IS" BASIS, 15 | * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * * * See the License for the specific language governing permissions and 17 | * * * limitations under the License. 18 | * 19 | */ 20 | 21 | apply plugin: "com.diffplug.spotless" 22 | apply from: "$rootDir/dependencies.gradle" 23 | spotless { 24 | kotlin { 25 | target "**/*.kt" 26 | ktlint("$versions.ktlintGradle").userData(['indent_size': '2', 'continuation_indent_size': '2']) 27 | licenseHeaderFile "$rootDir/spotless.license.kt" 28 | trimTrailingWhitespace() 29 | endWithNewline() 30 | } 31 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | #FFBB86FC 22 | #FF6200EE 23 | #FF3700B3 24 | #FF03DAC5 25 | #FF018786 26 | #FF000000 27 | #FFFFFFFF 28 | -------------------------------------------------------------------------------- /materialintro/src/main/java/com/androidpoet/materialintro/FragmentExtensions.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintro 3 | 4 | import android.os.Build 5 | import androidx.annotation.RequiresApi 6 | import androidx.fragment.app.Fragment 7 | import androidx.transition.Transition 8 | 9 | /** applies Animation form attributes to a View instance. */ 10 | @JvmSynthetic 11 | internal fun Fragment.applyAnimation( 12 | materialIntroFragment: MaterialIntroFragment 13 | ) { 14 | 15 | val enterAnimation = 16 | getIntroAnimation(materialIntroFragment.enterAnimation)?.let { addAnimationProperties(it, materialIntroFragment, materialIntroFragment.enterDuration) } 17 | enterTransition = enterAnimation 18 | } 19 | 20 | /** applies Properties on Animation form attributes. */ 21 | @RequiresApi(Build.VERSION_CODES.LOLLIPOP) 22 | @JvmSynthetic 23 | internal fun Fragment.addAnimationProperties( 24 | transition: Transition, 25 | materialIntro: MaterialIntroFragment, 26 | animationDuration: Long 27 | ): Transition { 28 | transition.apply { 29 | duration = animationDuration 30 | allowEnterTransitionOverlap = materialIntro.enterTransitionOverlap 31 | allowReturnTransitionOverlap = materialIntro.returnTransitionOverlap 32 | } 33 | return transition 34 | } 35 | -------------------------------------------------------------------------------- /materialintro/src/main/java/com/androidpoet/materialintro/IntroAnimation.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.metaphor 3 | 4 | /* 5 | * 6 | * * Copyright 2022 AndroidPoet (Ranbir Singh) 7 | * * 8 | * * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * * you may not use this file except in compliance with the License. 10 | * * You may obtain a copy of the License at 11 | * * 12 | * * http://www.apache.org/licenses/LICENSE-2.0 13 | * * 14 | * * Unless required by applicable law or agreed to in writing, software 15 | * * distributed under the License is distributed on an "AS IS" BASIS, 16 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * * See the License for the specific language governing permissions and 18 | * * limitations under the License. 19 | * 20 | * 21 | */ 22 | 23 | /** MetaphorAnimation is an animation attribute of [IntroAnimation]'s the showing and dismissing. */ 24 | 25 | public enum class IntroAnimation(public val value: Int) { 26 | None(1), 27 | FadeThrough(3), 28 | Fade(4), 29 | SharedAxisXForward(5), 30 | SharedAxisYForward(6), 31 | SharedAxisZForward(7), 32 | SharedAxisXBackward(8), 33 | SharedAxisYBackward(9), 34 | SharedAxisZBackward(10), 35 | ElevationScaleGrow(11), 36 | ElevationScale(12), 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | MaterialIntroDemo 21 | 22 | Hello blank fragment 23 | Back 24 | Next 25 | Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /dependencies.gradle: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * 4 | * * * Copyright 2022 AndroidPoet (Ranbir Singh) 5 | * * * 6 | * * * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * * * you may not use this file except in compliance with the License. 8 | * * * You may obtain a copy of the License at 9 | * * * 10 | * * * http://www.apache.org/licenses/LICENSE-2.0 11 | * * * 12 | * * * Unless required by applicable law or agreed to in writing, software 13 | * * * distributed under the License is distributed on an "AS IS" BASIS, 14 | * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * * * See the License for the specific language governing permissions and 16 | * * * limitations under the License. 17 | * 18 | */ 19 | 20 | ext.versions = [ 21 | minSdk : 23, 22 | compileSdk : 31, 23 | versionCode : 42, 24 | versionName : '1.4.1', 25 | ktx : '1.7.0', 26 | 27 | gradleBuildTool : '7.1.0', 28 | spotlessGradle : '6.2.1', 29 | kotlin : '1.5.32', 30 | ktlintGradle : '0.43.2', 31 | dokkaGradle : '1.5.31', 32 | binaryValidator : '0.8.0', 33 | mavenPublish : '0.18.0', 34 | 35 | androidxAppcompat: '1.4.1', 36 | androidxFragment : '1.3.3', 37 | googleMaterial : '1.5.0', 38 | 39 | 40 | 41 | ] 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/androidpoet/materialintrodemo/FragmentTwo.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintrodemo 3 | 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import androidx.fragment.app.Fragment 9 | import coil.load 10 | import com.androidpoet.materialintrodemo.databinding.LayoutTwoBinding 11 | 12 | // TODO: Rename parameter arguments, choose names that match 13 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 14 | private const val ARG_PARAM1 = "param1" 15 | private const val ARG_PARAM2 = "param2" 16 | 17 | /** 18 | * A simple [Fragment] subclass. 19 | * Use the [FragmentTwo.newInstance] factory method to 20 | * create an instance of this fragment. 21 | */ 22 | class FragmentTwo : Fragment() { 23 | // TODO: Rename and change types of parameters 24 | private var param1: String? = null 25 | private var param2: String? = null 26 | private lateinit var viewBinding: LayoutTwoBinding 27 | override fun onCreate(savedInstanceState: Bundle?) { 28 | super.onCreate(savedInstanceState) 29 | arguments?.let { 30 | param1 = it.getString(ARG_PARAM1) 31 | param2 = it.getString(ARG_PARAM2) 32 | } 33 | } 34 | 35 | override fun onCreateView( 36 | inflater: LayoutInflater, 37 | container: ViewGroup?, 38 | savedInstanceState: Bundle? 39 | ): View { 40 | // Inflate the layout for this fragment 41 | viewBinding = LayoutTwoBinding.inflate(inflater, container, false) 42 | 43 | viewBinding.image.load(R.drawable.undraw_b) 44 | return viewBinding.root 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/androidpoet/materialintrodemo/FragmentOne.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintrodemo 3 | 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import androidx.fragment.app.Fragment 9 | import coil.load 10 | import com.androidpoet.materialintrodemo.databinding.LayoutOneBinding 11 | 12 | // TODO: Rename parameter arguments, choose names that match 13 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 14 | private const val ARG_PARAM1 = "param1" 15 | private const val ARG_PARAM2 = "param2" 16 | 17 | /** 18 | * A simple [Fragment] subclass. 19 | * Use the [FragmentOne.newInstance] factory method to 20 | * create an instance of this fragment. 21 | */ 22 | class FragmentOne : Fragment() { 23 | // TODO: Rename and change types of parameters 24 | private var param1: String? = null 25 | private var param2: String? = null 26 | 27 | private lateinit var viewBinding: LayoutOneBinding 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | arguments?.let { 31 | param1 = it.getString(ARG_PARAM1) 32 | param2 = it.getString(ARG_PARAM2) 33 | } 34 | } 35 | 36 | override fun onCreateView( 37 | inflater: LayoutInflater, 38 | container: ViewGroup?, 39 | savedInstanceState: Bundle? 40 | ): View { 41 | // Inflate the layout for this fragment 42 | viewBinding = LayoutOneBinding.inflate(inflater, container, false) 43 | 44 | viewBinding.image.load(R.drawable.undraw_a) 45 | return viewBinding.root 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/androidpoet/materialintrodemo/FragmentThree.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintrodemo 3 | 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import androidx.fragment.app.Fragment 9 | import coil.load 10 | import com.androidpoet.materialintrodemo.databinding.LayoutThreeBinding 11 | 12 | // TODO: Rename parameter arguments, choose names that match 13 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 14 | private const val ARG_PARAM1 = "param1" 15 | private const val ARG_PARAM2 = "param2" 16 | 17 | /** 18 | * A simple [Fragment] subclass. 19 | * Use the [FragmentThree.newInstance] factory method to 20 | * create an instance of this fragment. 21 | */ 22 | class FragmentThree : Fragment() { 23 | // TODO: Rename and change types of parameters 24 | private var param1: String? = null 25 | private var param2: String? = null 26 | private lateinit var viewBinding: LayoutThreeBinding 27 | override fun onCreate(savedInstanceState: Bundle?) { 28 | super.onCreate(savedInstanceState) 29 | arguments?.let { 30 | param1 = it.getString(ARG_PARAM1) 31 | param2 = it.getString(ARG_PARAM2) 32 | } 33 | } 34 | 35 | override fun onCreateView( 36 | inflater: LayoutInflater, 37 | container: ViewGroup?, 38 | savedInstanceState: Bundle? 39 | ): View { 40 | // Inflate the layout for this fragment 41 | viewBinding = LayoutThreeBinding.inflate(inflater, container, false) 42 | 43 | viewBinding.image.load(R.drawable.undraw_c) 44 | return viewBinding.root 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 21 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 21 | 35 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * * Copyright 2022 AndroidPoet (Ranbir Singh) 4 | * * * 5 | * * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * * * you may not use this file except in compliance with the License. 7 | * * * You may obtain a copy of the License at 8 | * * * 9 | * * * http://www.apache.org/licenses/LICENSE-2.0 10 | * * * 11 | * * * Unless required by applicable law or agreed to in writing, software 12 | * * * distributed under the License is distributed on an "AS IS" BASIS, 13 | * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * * * See the License for the specific language governing permissions and 15 | * * * limitations under the License. 16 | * 17 | */ 18 | 19 | apply plugin: 'com.android.application' 20 | apply plugin: 'org.jetbrains.kotlin.android' 21 | apply from: "$rootDir/dependencies.gradle" 22 | 23 | android { 24 | compileSdkVersion versions.compileSdk 25 | defaultConfig { 26 | applicationId "com.androidpoet.metaphordemo" 27 | minSdkVersion versions.minSdk 28 | targetSdkVersion versions.compileSdk 29 | vectorDrawables.useSupportLibrary = true 30 | versionCode versions.versionCode 31 | versionName versions.versionName 32 | } 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_11 35 | targetCompatibility JavaVersion.VERSION_11 36 | } 37 | kotlinOptions { 38 | jvmTarget = "11" 39 | } 40 | 41 | buildFeatures { 42 | viewBinding true 43 | } 44 | 45 | } 46 | 47 | dependencies { 48 | implementation "androidx.core:core-ktx:$versions.ktx" 49 | implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat" 50 | implementation "com.google.android.material:material:$versions.googleMaterial" 51 | implementation project(":materialintro") 52 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 53 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 54 | implementation("io.coil-kt:coil:1.2.0") 55 | implementation("io.coil-kt:coil-svg:1.2.0") 56 | } 57 | 58 | apply from: "$rootDir/spotless.gradle" 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_two.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 24 | 25 | 32 | 33 | 39 | 48 | 49 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_three.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 24 | 25 | 32 | 33 | 34 | 40 | 41 | 50 | 51 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_one.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 24 | 25 | 32 | 33 | 34 | 40 | 41 | 50 | 51 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # /* 3 | # * * Copyright 2022 AndroidPoet (Ranbir Singh) 4 | # * * 5 | # * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | # * * you may not use this file except in compliance with the License. 7 | # * * You may obtain a copy of the License at 8 | # * * 9 | # * * http://www.apache.org/licenses/LICENSE-2.0 10 | # * * 11 | # * * Unless required by applicable law or agreed to in writing, software 12 | # * * distributed under the License is distributed on an "AS IS" BASIS, 13 | # * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # * * See the License for the specific language governing permissions and 15 | # * * limitations under the License. 16 | # */ 17 | # 18 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 19 | # When configured, Gradle will run in incubating parallel mode. 20 | # This option should only be used with decoupled projects. More details, visit 21 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 22 | # org.gradle.parallel=true 23 | # AndroidX package structure to make it clearer which packages are bundled with the 24 | # Android operating system, and which are packaged with your app"s APK 25 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 26 | android.useAndroidX=true 27 | # Kotlin code style for this project: "official" or "obsolete": 28 | kotlin.code.style=official 29 | # Enables namespacing of each library's R class so that its R class includes only the 30 | # resources declared in the library itself and none from the library's dependencies, 31 | # thereby reducing the size of the R class for that library 32 | android.nonTransitiveRClass=true 33 | # Required to publish to Nexus 34 | systemProp.org.gradle.internal.publish.checksums.insecure=true 35 | # Increase timeout when pushing to Sonatype 36 | systemProp.org.gradle.internal.http.connectionTimeout=120000 37 | systemProp.org.gradle.internal.http.socketTimeout=120000 38 | # Maven 39 | GROUP=io.github.androidpoet 40 | POM_PACKAGING=aar 41 | VERSION_NAME=1.0.8 42 | POM_ARTIFACT_ID=materialintro 43 | POM_NAME=materialintro 44 | POM_DESCRIPTION=Sophisticated and cool intro with Material Motion Animation. 45 | POM_URL=https://github.com/AndroidPoet/MaterialIntro/ 46 | POM_SCM_URL=https://github.com/AndroidPoet/MaterialIntro/ 47 | POM_SCM_CONNECTION=scm:git:git://github.com/AndroidPoet/MaterialIntro.git 48 | POM_SCM_DEV_CONNECTION=scm:git:git://github.com/AndroidPoet/MaterialIntro.git 49 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 50 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 51 | POM_LICENCE_DIST=repo 52 | POM_DEVELOPER_ID=ranbirk66 53 | POM_DEVELOPER_NAME=Ranbir Singh 54 | POM_DEVELOPER_URL=https://github.com/AndroidPoet/ 55 | 56 | -------------------------------------------------------------------------------- /materialintro/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * * Copyright 2022 AndroidPoet (Ranbir Singh) 4 | * * * 5 | * * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * * * you may not use this file except in compliance with the License. 7 | * * * You may obtain a copy of the License at 8 | * * * 9 | * * * http://www.apache.org/licenses/LICENSE-2.0 10 | * * * 11 | * * * Unless required by applicable law or agreed to in writing, software 12 | * * * distributed under the License is distributed on an "AS IS" BASIS, 13 | * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * * * See the License for the specific language governing permissions and 15 | * * * limitations under the License. 16 | * 17 | */ 18 | 19 | apply plugin: 'com.android.library' 20 | apply plugin: 'kotlin-android' 21 | apply plugin: 'org.jetbrains.dokka' 22 | apply plugin: 'binary-compatibility-validator' 23 | 24 | apply from: "$rootDir/dependencies.gradle" 25 | 26 | android { 27 | compileSdkVersion versions.compileSdk 28 | defaultConfig { 29 | minSdkVersion versions.minSdk 30 | targetSdkVersion versions.compileSdk 31 | versionCode versions.versionCode 32 | versionName versions.versionName 33 | } 34 | 35 | resourcePrefix 'materialintro' 36 | 37 | 38 | compileOptions { 39 | sourceCompatibility JavaVersion.VERSION_1_8 40 | targetCompatibility JavaVersion.VERSION_1_8 41 | } 42 | 43 | kotlinOptions { 44 | jvmTarget = "1.8" 45 | } 46 | 47 | lintOptions { 48 | abortOnError false 49 | } 50 | } 51 | 52 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 53 | kotlinOptions.freeCompilerArgs += ["-Xexplicit-api=strict"] 54 | } 55 | 56 | apiValidation { 57 | 58 | nonPublicMarkers += [ 59 | "kotlin.PublishedApi", 60 | ] 61 | 62 | } 63 | 64 | dependencies { 65 | 66 | implementation "androidx.core:core-ktx:$versions.ktx" 67 | implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat" 68 | implementation "com.google.android.material:material:$versions.googleMaterial" 69 | implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat" 70 | implementation "androidx.fragment:fragment-ktx:$versions.androidxFragment" 71 | 72 | 73 | 74 | } 75 | 76 | dokkaHtml.configure { 77 | dokkaSourceSets { 78 | named("main") { 79 | noAndroidSdkLink.set(false) 80 | } 81 | } 82 | } 83 | 84 | 85 | allprojects { 86 | plugins.withId("com.vanniktech.maven.publish") { 87 | mavenPublish { 88 | sonatypeHost = "S01" 89 | } 90 | } 91 | } 92 | 93 | apply plugin: "com.vanniktech.maven.publish" 94 | apply from: "$rootDir/spotless.gradle" -------------------------------------------------------------------------------- /app/src/main/java/com/androidpoet/materialintrodemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintrodemo 3 | 4 | import android.os.Bundle 5 | import androidx.appcompat.app.AppCompatActivity 6 | import com.androidpoet.materialintro.MaterialIntroView 7 | import com.androidpoet.materialintrodemo.databinding.ActivityMainBinding 8 | import com.androidpoet.metaphor.IntroAnimation 9 | 10 | class MainActivity : AppCompatActivity() { 11 | 12 | private lateinit var binding: ActivityMainBinding 13 | private var list: MutableList = mutableListOf() 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | binding = ActivityMainBinding.inflate(layoutInflater) 17 | setContentView(binding.root) 18 | 19 | list.add(R.layout.layout_one) 20 | list.add(R.layout.layout_two) 21 | list.add(R.layout.layout_three) 22 | 23 | val meta = MaterialIntroView.Builder(this) 24 | .setViewsList(list) 25 | .setNextAnimation(IntroAnimation.Fade) 26 | .setPreviousAnimation(IntroAnimation.Fade) 27 | .setEnterDuration(300) 28 | .setExitDuration(300) 29 | .build() 30 | 31 | binding.root.addView(meta) 32 | setDotsTabLayout() 33 | // binding.materialintroView.setViewsList(list) 34 | 35 | // go next view with animation 36 | binding.nextButton.setOnClickListener { 37 | meta.next() 38 | } 39 | 40 | // go previous view with animation 41 | binding.backButton.setOnClickListener { 42 | meta.previous() 43 | } 44 | 45 | meta.setOnIndexChangeListener { 46 | binding.nextButton.isEnabled = it < list.size - 1 47 | binding.backButton.isEnabled = it > 0 48 | binding.tabLayout.apply { 49 | selectTab(getTabAt(it)) 50 | } 51 | } 52 | 53 | // with(binding.materialintroView) { 54 | // setViewsList(list) 55 | // nextAnimation = IntroAnimation.Fade 56 | // previousAnimation = IntroAnimation.Fade 57 | // nextDuration = 500 58 | // previousDuration = 500 59 | // 60 | // 61 | // 62 | // 63 | // } 64 | // 65 | // // go next view with animation 66 | // binding.nextButton.setOnClickListener { 67 | // next() 68 | // } 69 | // 70 | // // go previous view with animation 71 | // binding.backButton.setOnClickListener { 72 | // previous() 73 | // } 74 | // 75 | // setOnIndexChangeListener { 76 | // binding.nextButton.isEnabled = it < list.size - 1 77 | // binding.backButton.isEnabled = it > 0 78 | // binding.tabLayout.apply { 79 | // selectTab(getTabAt(it)) 80 | // } 81 | // } 82 | // 83 | // } 84 | } 85 | 86 | private fun setDotsTabLayout() { 87 | 88 | list.forEach { _ -> 89 | binding.tabLayout.addTab(binding.tabLayout.newTab()) 90 | } 91 | binding.tabLayout.touchables.forEach { it.isEnabled = false } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 51 | 59 | 60 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /materialintro/src/main/java/com/androidpoet/materialintro/AnimationsExtenstions.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintro 3 | 4 | import android.content.Context 5 | import android.content.ContextWrapper 6 | import android.view.ViewGroup 7 | import androidx.annotation.LayoutRes 8 | import androidx.appcompat.app.AppCompatActivity 9 | import androidx.transition.Scene 10 | import androidx.transition.Transition 11 | import androidx.transition.TransitionManager 12 | import com.androidpoet.metaphor.IntroAnimation 13 | import com.google.android.material.transition.MaterialElevationScale 14 | import com.google.android.material.transition.MaterialFade 15 | import com.google.android.material.transition.MaterialFadeThrough 16 | import com.google.android.material.transition.MaterialSharedAxis 17 | 18 | /** applies Metaphor form attributes to a View instance. */ 19 | @JvmSynthetic 20 | @PublishedApi 21 | internal fun getIntroAnimation(animation: IntroAnimation): Transition? { 22 | 23 | when (animation) { 24 | IntroAnimation.FadeThrough -> { 25 | 26 | return MaterialFadeThrough() 27 | } 28 | 29 | IntroAnimation.Fade -> { 30 | return MaterialFade() 31 | } 32 | IntroAnimation.SharedAxisXForward -> { 33 | 34 | return MaterialSharedAxis(MaterialSharedAxis.X, true) 35 | } 36 | 37 | IntroAnimation.SharedAxisYForward -> { 38 | 39 | return MaterialSharedAxis(MaterialSharedAxis.Y, true) 40 | } 41 | 42 | IntroAnimation.SharedAxisZForward -> { 43 | 44 | return MaterialSharedAxis(MaterialSharedAxis.Z, true) 45 | } 46 | IntroAnimation.SharedAxisXBackward -> { 47 | 48 | return MaterialSharedAxis(MaterialSharedAxis.X, false) 49 | } 50 | 51 | IntroAnimation.SharedAxisYBackward -> { 52 | return MaterialSharedAxis(MaterialSharedAxis.Y, false) 53 | } 54 | 55 | IntroAnimation.SharedAxisZBackward -> { 56 | 57 | return MaterialSharedAxis(MaterialSharedAxis.Z, false) 58 | } 59 | 60 | IntroAnimation.ElevationScale -> { 61 | return MaterialElevationScale(false) 62 | } 63 | IntroAnimation.ElevationScaleGrow -> { 64 | return MaterialElevationScale(true) 65 | } 66 | 67 | IntroAnimation.None -> { 68 | // trick for no animations 69 | return null 70 | } 71 | } 72 | } 73 | 74 | /*go to next Scene with TransitionManager*/ 75 | public fun showScene( 76 | @LayoutRes layoutId: Int, 77 | introAnimation: IntroAnimation, 78 | duration: Long, 79 | root: ViewGroup? 80 | ) { 81 | if (root == null) { 82 | return 83 | } 84 | val transition = getIntroAnimation(introAnimation) 85 | if (transition != null) { 86 | transition.duration = duration 87 | } 88 | val scene = Scene.getSceneForLayout(root, layoutId, root.context) 89 | transition?.let { 90 | TransitionManager.go(scene, transition) 91 | } ?: run { 92 | TransitionManager.go(scene) 93 | } 94 | } 95 | public fun Context.activity(): AppCompatActivity? = when (this) { 96 | is AppCompatActivity -> this 97 | else -> (this as? ContextWrapper)?.baseContext?.activity() 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 36 | 50 | 51 | 59 | 60 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/androidpoet/materialintrodemo/FragmentActivity.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintrodemo 3 | 4 | import android.os.Build 5 | import android.os.Bundle 6 | import android.view.View 7 | import android.widget.FrameLayout 8 | import androidx.appcompat.app.AppCompatActivity 9 | import androidx.core.view.ViewCompat 10 | import androidx.core.view.WindowInsetsCompat 11 | import androidx.fragment.app.Fragment 12 | import com.androidpoet.materialintrodemo.databinding.ActivityFragmentBinding 13 | import com.androidpoet.metaphor.IntroAnimation 14 | 15 | class FragmentActivity : AppCompatActivity() { 16 | private lateinit var binding: ActivityFragmentBinding 17 | private var list: MutableList = arrayListOf() 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | binding = ActivityFragmentBinding.inflate(layoutInflater) 21 | setContentView(binding.root) 22 | 23 | list.add(FragmentOne()) 24 | list.add(FragmentTwo()) 25 | list.add(FragmentThree()) 26 | binding.materialIntroFragment.apply { 27 | setFragmentsList(list) 28 | enterAnimation = IntroAnimation.SharedAxisXForward 29 | enterDuration = 500 30 | exitDuration = 500 31 | } 32 | 33 | setDotsTabLayout() 34 | 35 | binding.materialIntroFragment.setOnIndexChangeListener { 36 | binding.nextButton.isEnabled = it < list.size - 1 37 | binding.backButton.isEnabled = it > 0 38 | binding.tabLayout.apply { 39 | selectTab(getTabAt(it)) 40 | } 41 | } 42 | 43 | // go next view with animation 44 | binding.nextButton.setOnClickListener { 45 | binding.materialIntroFragment.next() 46 | } 47 | 48 | // go previous view with animation 49 | binding.backButton.setOnClickListener { 50 | binding.materialIntroFragment.previous() 51 | } 52 | 53 | if (Build.VERSION.SDK_INT >= 30) { 54 | 55 | // Root ViewGroup of my activity 56 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 57 | val decor: View = window.decorView 58 | decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) 59 | } 60 | ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, windowInsets -> 61 | 62 | val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) 63 | 64 | // Apply the insets as a margin to the view. Here the system is setting 65 | // only the bottom, left, and right dimensions, but apply whichever insets are 66 | // appropriate to your layout. You can also update the view padding 67 | // if that's more appropriate. 68 | 69 | view.layoutParams = (view.layoutParams as FrameLayout.LayoutParams).apply { 70 | leftMargin = insets.left 71 | bottomMargin = insets.bottom 72 | rightMargin = insets.right 73 | } 74 | 75 | // Return CONSUMED if you don't want want the window insets to keep being 76 | // passed down to descendant views. 77 | WindowInsetsCompat.CONSUMED 78 | } 79 | } 80 | } 81 | 82 | private fun setDotsTabLayout() { 83 | 84 | list.forEach { _ -> 85 | binding.tabLayout.addTab(binding.tabLayout.newTab()) 86 | } 87 | binding.tabLayout.touchables.forEach { it.isEnabled = false } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /materialintro/src/main/java/com/androidpoet/materialintro/MaterialIntroView.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintro 3 | 4 | import android.content.Context 5 | import android.util.AttributeSet 6 | import android.view.View 7 | import android.widget.FrameLayout 8 | import androidx.annotation.MainThread 9 | import com.androidpoet.metaphor.IntroAnimation 10 | 11 | @DslMarker 12 | internal annotation class MaterialIntroViewInlineDsl 13 | 14 | /** 15 | * Creates an instance of the [MaterialIntroView] by scope of the [MaterialIntroView.Builder] using kotlin dsl. 16 | * 17 | * @param Context A context for creating resources of the [MaterialIntroView]. 18 | * @param block A dsl scope lambda from the [MaterialIntroView.Builder]. 19 | * */ 20 | @MainThread 21 | @JvmSynthetic 22 | @MaterialIntroViewInlineDsl 23 | public inline fun materialIntroView( 24 | context: Context, 25 | crossinline block: MaterialIntroView.Builder.() -> Unit 26 | ): MaterialIntroView = 27 | MaterialIntroView.Builder(context).apply(block).build() 28 | 29 | /** 30 | * MetaphorFragment implements material motion animations. 31 | * 32 | * @see [MaterialIntroView](https://github.com/AndroidPoet/Metaphor) 33 | * 34 | * @param builder A [MaterialIntroView.Builder] for creating an instance of the [MaterialIntroView]. 35 | */ 36 | public class MaterialIntroView : FrameLayout { 37 | 38 | /** views list. */ 39 | public var layoutList: MutableList = mutableListOf() 40 | 41 | /**current fragment index */ 42 | public var index: Int = 0 43 | 44 | /** duration of enter the animations. */ 45 | public var nextDuration: Long = 300 46 | 47 | /** duration of exit the animations. */ 48 | public var previousDuration: Long = 300 49 | 50 | /** Next Animation of View. */ 51 | public var nextAnimation: IntroAnimation = IntroAnimation.None 52 | 53 | /** Previous Animation of View. */ 54 | public var previousAnimation: IntroAnimation = IntroAnimation.None 55 | 56 | /** Enter AnimationOverlap of fragment. */ 57 | public var enterTransitionOverlap: Boolean = false 58 | 59 | /** Return AnimationOverlap of fragment. */ 60 | public var returnTransitionOverlap: Boolean = false 61 | 62 | /** interface for listening to the progress is changed. */ 63 | private var onIndexChangeListener: OnIndexChangeListener? = null 64 | 65 | /** sets a progress change listener. */ 66 | public fun setOnIndexChangeListener(onIndexChangeListener: OnIndexChangeListener) { 67 | this.onIndexChangeListener = onIndexChangeListener 68 | } 69 | 70 | /** sets a progress change listener. */ 71 | @JvmSynthetic 72 | public fun setOnIndexChangeListener(block: (Int) -> Unit) { 73 | this.onIndexChangeListener = OnIndexChangeListener { index -> block(index) } 74 | } 75 | 76 | public constructor(context: Context) : super(context) 77 | 78 | public constructor( 79 | context: Context, 80 | attributeSet: AttributeSet 81 | ) : this(context, attributeSet, 0) 82 | 83 | public constructor( 84 | context: Context, 85 | attributeSet: AttributeSet, 86 | defStyle: Int 87 | ) : super( 88 | context, 89 | attributeSet, 90 | defStyle 91 | ) { 92 | } 93 | 94 | init { 95 | val v: View = inflate(context, R.layout.materialintro, this) 96 | 97 | post { 98 | if (layoutList.isNotEmpty()) { 99 | showScene(this.layoutList[0], this.nextAnimation, this.nextDuration, this) 100 | } 101 | } 102 | } 103 | 104 | /** Builder class for [MaterialIntroView]. */ 105 | @MaterialIntroViewInlineDsl 106 | public class Builder(context: Context) { 107 | private val materialIntroView = MaterialIntroView(context) 108 | 109 | /** sets the duration of the Animation. */ 110 | public fun setEnterDuration(value: Long): Builder = 111 | apply { this.materialIntroView.nextDuration = value } 112 | 113 | /** sets the duration of the Animation. */ 114 | public fun setExitDuration(value: Long): Builder = 115 | apply { this.materialIntroView.previousDuration = value } 116 | 117 | /** sets enter the Animation of the Fragment. */ 118 | public fun setNextAnimation(value: IntroAnimation): Builder = 119 | apply { this.materialIntroView.nextAnimation = value } 120 | 121 | /** sets the enter Overlap of the Fragment. */ 122 | public fun setPreviousAnimation(value: IntroAnimation): Builder = 123 | apply { this.materialIntroView.previousAnimation = value } 124 | 125 | /** set ViewsList . */ 126 | public fun setViewsList(value: MutableList): Builder = 127 | apply { 128 | this.materialIntroView.layoutList = value 129 | } 130 | 131 | public fun setOnIndexChangeListener(value: OnIndexChangeListener): Builder = apply { 132 | this.materialIntroView.onIndexChangeListener = value 133 | } 134 | 135 | @JvmSynthetic 136 | public fun setOnIndexChangeListener(block: (Int) -> Unit): Builder = apply { 137 | this.materialIntroView.onIndexChangeListener = 138 | OnIndexChangeListener { index -> block(index) } 139 | } 140 | 141 | public fun build(): MaterialIntroView = materialIntroView 142 | } 143 | 144 | /*go to previous fragment*/ 145 | public fun previous() { 146 | if (indexExists(layoutList, index - 1)) { 147 | index -= 1 148 | showScene(this.layoutList[index], this.previousAnimation, this.previousDuration, this) 149 | onIndexChangeListener?.onChange(index) 150 | } 151 | } 152 | 153 | /*go to next fragment*/ 154 | 155 | public fun next() { 156 | if (indexExists(layoutList, index + 1)) { 157 | index += 1 158 | showScene(this.layoutList[index], this.nextAnimation, this.nextDuration, this) 159 | onIndexChangeListener?.onChange(index) 160 | } 161 | } 162 | 163 | /*check index is valid or not*/ 164 | private fun indexExists(list: List<*>, index: Int): Boolean { 165 | return index >= 0 && index < list.size 166 | } 167 | 168 | public fun setViewsList(list: List) { 169 | layoutList.clear() 170 | layoutList.addAll(list) 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Material Intro

4 | 5 |

6 | Sophisticated and cool intro with Material Motion Animations. 7 |

8 | 9 | 10 |

11 | Google 12 |
13 |
14 | License 15 | Profile 16 | 17 |


18 | 19 | 20 |

21 | 22 | 23 |


24 | 25 |

26 | 27 | 28 | 29 | ## Who's using Material Intro? 30 | **👉 [Check out who's using Material Intro](/usecases.md)** 31 | 32 | ## Include in your project 33 | [![Maven Central](https://img.shields.io/maven-central/v/io.github.androidpoet/materialintro.svg?label=Maven%20Central)](https://search.maven.org/artifact/io.github.androidpoet/materialintro) 34 | 35 | ### Gradle 36 | Add the dependency below to your **module**'s `build.gradle` file: 37 | 38 | ```gradle 39 | dependencies { 40 | implementation("io.github.androidpoet:materialintro:1.0.8") 41 | } 42 | ``` 43 | 44 | 45 | ## SetUp for Views 46 | 47 | 48 | ```xml 49 | 50 | 54 | 55 | ``` 56 | 57 | ```kotlin 58 | //add views into list 59 | list.add(R.layout.layout_one) 60 | list.add(R.layout.layout_two) 61 | list.add(R.layout.layout_three) 62 | 63 | 64 | with(binding.materialintroView) { 65 | setViewsList(list) 66 | nextAnimation = IntroAnimation.Fade 67 | previousAnimation = IntroAnimation.Fade 68 | nextDuration = 500 69 | previousDuration = 500 70 | } 71 | 72 | 73 | // go next view with animation 74 | binding.nextButton.setOnClickListener { 75 | binding.materialIntroFragment.next() 76 | } 77 | 78 | // go previous view with animation 79 | binding.backButton.setOnClickListener { 80 | binding.materialIntroFragment.previous() 81 | } 82 | ``` 83 | 84 | 85 | 86 | ## SetUp for Fragments 87 | 88 | 89 | 90 | ```xml 91 | 95 | 96 | ``` 97 | 98 | 99 | ```kotlin 100 | //add fragments into list 101 | list.add(FragmentOne()) 102 | list.add(FragmentTwo()) 103 | list.add(FragmentThree()) 104 | 105 | binding.materialIntroFragment.apply { 106 | setFragmentsList(list) 107 | enterAnimation = IntroAnimation.SharedAxisXForward 108 | 109 | enterDuration = 500 110 | 111 | } 112 | 113 | 114 | // go next view with animation 115 | binding.nextButton.setOnClickListener { 116 | binding.materialintroView.next() 117 | } 118 | 119 | // go previous view with animation 120 | binding.backButton.setOnClickListener { 121 | binding.materialintroView.previous() 122 | } 123 | ``` 124 | 125 | 126 | 127 | ## Supported Animations 128 | 129 | ```kotlin 130 | 131 | IntroAnimation.None 132 | IntroAnimation.FadeThrough 133 | IntroAnimation.Fade 134 | IntroAnimation.SharedAxisXForward 135 | IntroAnimation.SharedAxisYForward 136 | IntroAnimation.SharedAxisZForward 137 | IntroAnimation.SharedAxisXBackward 138 | IntroAnimation.SharedAxisYBackward 139 | IntroAnimation.SharedAxisZBackward 140 | IntroAnimation.ElevationScaleGrow 141 | IntroAnimation.ElevationScale 142 | ``` 143 | 144 | ## Create using Builder 145 | 146 | 147 | 148 | 149 | We can create the MaterialIntro using MaterialIntro.Builder. 150 | 151 | ```kotlin 152 | val meta = MaterialIntroFragment.Builder(this) 153 | .setFragmentsList(list) 154 | .setEnterAnimation(IntroAnimation.Fade) 155 | .setEnterDuration(300) 156 | .setEnterOverlap(true) 157 | .build() 158 | 159 | meta.next() 160 | meta.previous() 161 | ``` 162 | This is how to create an instance of the MaterialIntro using kotlin dsl. 163 | ```kotlin 164 | 165 | val meta = materialIntroFragment(this) { 166 | setFragmentsList(list) 167 | setEnterAnimation(IntroAnimation.Fade) 168 | setEnterDuration(300) 169 | setEnterOverlap(true) 170 | build() 171 | } 172 | meta.next() 173 | meta.previous() 174 | ``` 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | ## MaterialFade 183 | 184 |

185 | 186 | 187 |


188 | 189 | 190 | ## Fade 191 | 192 |

193 | 194 |


195 | 196 | ## SharedAxis 197 | 198 |

199 | 200 |


201 | 202 | 203 | Card icons created by Freepik - Flaticon 204 | 205 | 206 | 207 | ## Find this library useful? :heart: 208 | Support it by joining __[stargazers](https://github.com/androidpoet/MaterialIntro/stargazers)__ for this repository. :star: 209 | 210 | Buy Me A Coffee 211 | 212 | 213 | # License 214 | ```xml 215 | Copyright 2022 AndroidPoet (Ranbir Singh) 216 | 217 | Licensed under the Apache License, Version 2.0 (the "License"); 218 | you may not use this file except in compliance with the License. 219 | You may obtain a copy of the License at 220 | 221 | http://www.apache.org/licenses/LICENSE-2.0 222 | 223 | Unless required by applicable law or agreed to in writing, software 224 | distributed under the License is distributed on an "AS IS" BASIS, 225 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 226 | See the License for the specific language governing permissions and 227 | limitations under the License. 228 | ``` 229 | 230 | 231 | 232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /materialintro/src/main/java/com/androidpoet/materialintro/MaterialIntroFragment.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.androidpoet.materialintro 3 | 4 | import android.content.Context 5 | import android.util.AttributeSet 6 | import android.view.View 7 | import android.widget.FrameLayout 8 | import androidx.annotation.MainThread 9 | import androidx.fragment.app.Fragment 10 | import androidx.fragment.app.commit 11 | import com.androidpoet.metaphor.IntroAnimation 12 | 13 | @DslMarker 14 | internal annotation class MaterialFragmentInlineDsl 15 | 16 | /** 17 | * Creates an instance of the [MaterialIntroFragment] by scope of the [MaterialIntroFragment.Builder] using kotlin dsl. 18 | * 19 | * @param Context A context for creating resources of the [MaterialIntroFragment]. 20 | * @param block A dsl scope lambda from the [MaterialIntroFragment.Builder]. 21 | * */ 22 | @MainThread 23 | @JvmSynthetic 24 | @MaterialFragmentInlineDsl 25 | public inline fun materialIntroFragment( 26 | context: Context, 27 | crossinline block: MaterialIntroFragment.Builder.() -> Unit 28 | ): MaterialIntroFragment = 29 | MaterialIntroFragment.Builder(context).apply(block).build() 30 | 31 | /** 32 | * MetaphorFragment implements material motion animations. 33 | * 34 | * @see [MaterialIntroFragment](https://github.com/AndroidPoet/Metaphor) 35 | * 36 | * @param builder A [MaterialIntroFragment.Builder] for creating an instance of the [MaterialIntroFragment]. 37 | */ 38 | public class MaterialIntroFragment : FrameLayout { 39 | 40 | /** fragments list. */ 41 | 42 | public var fragmentList: MutableList = mutableListOf() 43 | 44 | /**current fragment index */ 45 | private var index: Int = 0 46 | 47 | /** duration of enter the animations. */ 48 | public var enterDuration: Long = 300 49 | 50 | /** duration of reenter the animations. */ 51 | public var reenterDuration: Long = 300 52 | 53 | /** duration of exit the animations. */ 54 | public var exitDuration: Long = 300 55 | 56 | /** duration of return the animations. */ 57 | public var returnDuration: Long = 300 58 | 59 | /** Enter Animation of fragment. */ 60 | public var enterAnimation: IntroAnimation = IntroAnimation.None 61 | 62 | /** Enter AnimationOverlap of fragment. */ 63 | public var enterTransitionOverlap: Boolean = false 64 | 65 | /** Return AnimationOverlap of fragment. */ 66 | public var returnTransitionOverlap: Boolean = false 67 | 68 | /** interface for listening to the progress is changed. */ 69 | private var onIndexChangeListener: OnIndexChangeListener? = null 70 | 71 | /** sets a progress change listener. */ 72 | public fun setOnIndexChangeListener(onIndexChangeListener: OnIndexChangeListener) { 73 | this.onIndexChangeListener = onIndexChangeListener 74 | } 75 | 76 | /** sets a progress change listener. */ 77 | @JvmSynthetic 78 | public fun setOnIndexChangeListener(block: (Int) -> Unit) { 79 | this.onIndexChangeListener = OnIndexChangeListener { index -> block(index) } 80 | } 81 | 82 | init { 83 | val v: View = inflate(context, R.layout.materialintro, this) 84 | 85 | post { 86 | if (fragmentList.isNotEmpty()) { 87 | if (fragmentList.isNotEmpty()) { 88 | showFragment(fragmentList[0]) 89 | } 90 | } 91 | } 92 | } 93 | 94 | public constructor(context: Context) : super(context) 95 | 96 | public constructor( 97 | context: Context, 98 | attributeSet: AttributeSet 99 | ) : this(context, attributeSet, 0) 100 | 101 | public constructor( 102 | context: Context, 103 | attributeSet: AttributeSet, 104 | defStyle: Int 105 | ) : super( 106 | context, 107 | attributeSet, 108 | defStyle 109 | ) { 110 | } 111 | 112 | /** Builder class for [MaterialIntroView]. */ 113 | @MaterialIntroViewInlineDsl 114 | public class Builder(context: Context) { 115 | private val materialIntroFragment = MaterialIntroFragment(context) 116 | 117 | /** sets the duration of the Animation. */ 118 | public fun setEnterDuration(value: Long): Builder = 119 | apply { this.materialIntroFragment.enterDuration = value } 120 | 121 | /** sets the duration of the Animation. */ 122 | public fun setExitDuration(value: Long): Builder = 123 | apply { this.materialIntroFragment.exitDuration = value } 124 | 125 | /** sets the duration of the Animation. */ 126 | public fun setReenterDuration(value: Long): Builder = 127 | apply { this.materialIntroFragment.reenterDuration = value } 128 | 129 | /** sets the duration of the Animation. */ 130 | public fun setReturnDuration(value: Long): Builder = 131 | apply { this.materialIntroFragment.returnDuration = value } 132 | 133 | /** sets enter the Animation of the Fragment. */ 134 | public fun setEnterAnimation(value: IntroAnimation): Builder = 135 | apply { this.materialIntroFragment.enterAnimation = value } 136 | 137 | /** sets the enter Overlap of the Fragment. */ 138 | public fun setEnterOverlap(value: Boolean): Builder = 139 | apply { this.materialIntroFragment.enterTransitionOverlap = value } 140 | 141 | /** sets the return Overlap of the Fragment. */ 142 | public fun setReturnOverlap(value: Boolean): Builder = 143 | apply { this.materialIntroFragment.returnTransitionOverlap = value } 144 | 145 | /** sets the ScrimColor of the Fragment. */ 146 | public fun setFragmentList(value: MutableList): Builder = 147 | apply { this.materialIntroFragment.fragmentList = value } 148 | 149 | public fun setOnIndexChangeListener(value: OnIndexChangeListener): Builder = apply { 150 | this.materialIntroFragment.onIndexChangeListener = value 151 | } 152 | 153 | @JvmSynthetic 154 | public fun setOnIndexChangeListener(block: (Int) -> Unit): Builder = apply { 155 | this.materialIntroFragment.onIndexChangeListener = 156 | OnIndexChangeListener { index -> block(index) } 157 | } 158 | 159 | public fun build(): MaterialIntroFragment = materialIntroFragment 160 | } 161 | 162 | /*go to previous fragment*/ 163 | public fun previous() { 164 | if (indexExists(fragmentList, index - 1)) { 165 | index -= 1 166 | showFragment(fragmentList[index]) 167 | onIndexChangeListener?.onChange(index) 168 | } 169 | } 170 | 171 | /*go to next fragment*/ 172 | 173 | public fun next() { 174 | 175 | if (indexExists(fragmentList, index + 1)) { 176 | index += 1 177 | showFragment(fragmentList[index]) 178 | onIndexChangeListener?.onChange(index) 179 | } 180 | } 181 | 182 | /*check index is valid or not*/ 183 | private fun indexExists(list: List<*>, index: Int): Boolean { 184 | return index >= 0 && index < list.size 185 | } 186 | 187 | /** starts animation. */ 188 | private fun showFragment(fragment: Fragment) { 189 | fragment.applyAnimation(this) 190 | 191 | /*replace fragment with currant fragment*/ 192 | context.activity()?.supportFragmentManager?.commit { 193 | replace(R.id.fragment_container, fragment) 194 | } 195 | } 196 | 197 | /*set views list*/ 198 | public fun setFragmentsList(list: List) { 199 | fragmentList.clear() 200 | fragmentList.addAll(list) 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /materialintro/api/materialintro.api: -------------------------------------------------------------------------------- 1 | public final class com/androidpoet/materialintro/AnimationsExtenstionsKt { 2 | public static final fun activity (Landroid/content/Context;)Landroidx/appcompat/app/AppCompatActivity; 3 | public static final fun showScene (ILcom/androidpoet/metaphor/IntroAnimation;JLandroid/view/ViewGroup;)V 4 | } 5 | 6 | public final class com/androidpoet/materialintro/BuildConfig { 7 | public static final field BUILD_TYPE Ljava/lang/String; 8 | public static final field DEBUG Z 9 | public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; 10 | public fun ()V 11 | } 12 | 13 | public final class com/androidpoet/materialintro/IntroInterpolator : java/lang/Enum { 14 | public static final field Accelerated Lcom/androidpoet/materialintro/IntroInterpolator; 15 | public static final field Decelerated Lcom/androidpoet/materialintro/IntroInterpolator; 16 | public static final field Emphasized Lcom/androidpoet/materialintro/IntroInterpolator; 17 | public static final field Linear Lcom/androidpoet/materialintro/IntroInterpolator; 18 | public static final field Standard Lcom/androidpoet/materialintro/IntroInterpolator; 19 | public final fun getValue ()I 20 | public static fun valueOf (Ljava/lang/String;)Lcom/androidpoet/materialintro/IntroInterpolator; 21 | public static fun values ()[Lcom/androidpoet/materialintro/IntroInterpolator; 22 | } 23 | 24 | public final class com/androidpoet/materialintro/MaterialIntroFragment : android/widget/FrameLayout { 25 | public fun (Landroid/content/Context;)V 26 | public fun (Landroid/content/Context;Landroid/util/AttributeSet;)V 27 | public fun (Landroid/content/Context;Landroid/util/AttributeSet;I)V 28 | public final fun getEnterAnimation ()Lcom/androidpoet/metaphor/IntroAnimation; 29 | public final fun getEnterDuration ()J 30 | public final fun getEnterTransitionOverlap ()Z 31 | public final fun getExitDuration ()J 32 | public final fun getFragmentList ()Ljava/util/List; 33 | public final fun getReenterDuration ()J 34 | public final fun getReturnDuration ()J 35 | public final fun getReturnTransitionOverlap ()Z 36 | public final fun next ()V 37 | public final fun previous ()V 38 | public final fun setEnterAnimation (Lcom/androidpoet/metaphor/IntroAnimation;)V 39 | public final fun setEnterDuration (J)V 40 | public final fun setEnterTransitionOverlap (Z)V 41 | public final fun setExitDuration (J)V 42 | public final fun setFragmentList (Ljava/util/List;)V 43 | public final fun setFragmentsList (Ljava/util/List;)V 44 | public final fun setOnIndexChangeListener (Lcom/androidpoet/materialintro/OnIndexChangeListener;)V 45 | public final synthetic fun setOnIndexChangeListener (Lkotlin/jvm/functions/Function1;)V 46 | public final fun setReenterDuration (J)V 47 | public final fun setReturnDuration (J)V 48 | public final fun setReturnTransitionOverlap (Z)V 49 | } 50 | 51 | public final class com/androidpoet/materialintro/MaterialIntroFragment$Builder { 52 | public fun (Landroid/content/Context;)V 53 | public final fun build ()Lcom/androidpoet/materialintro/MaterialIntroFragment; 54 | public final fun setEnterAnimation (Lcom/androidpoet/metaphor/IntroAnimation;)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 55 | public final fun setEnterDuration (J)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 56 | public final fun setEnterOverlap (Z)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 57 | public final fun setExitDuration (J)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 58 | public final fun setFragmentList (Ljava/util/List;)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 59 | public final fun setOnIndexChangeListener (Lcom/androidpoet/materialintro/OnIndexChangeListener;)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 60 | public final synthetic fun setOnIndexChangeListener (Lkotlin/jvm/functions/Function1;)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 61 | public final fun setReenterDuration (J)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 62 | public final fun setReturnDuration (J)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 63 | public final fun setReturnOverlap (Z)Lcom/androidpoet/materialintro/MaterialIntroFragment$Builder; 64 | } 65 | 66 | public final class com/androidpoet/materialintro/MaterialIntroFragmentKt { 67 | public static final synthetic fun materialIntroFragment (Landroid/content/Context;Lkotlin/jvm/functions/Function1;)Lcom/androidpoet/materialintro/MaterialIntroFragment; 68 | } 69 | 70 | public final class com/androidpoet/materialintro/MaterialIntroView : android/widget/FrameLayout { 71 | public fun (Landroid/content/Context;)V 72 | public fun (Landroid/content/Context;Landroid/util/AttributeSet;)V 73 | public fun (Landroid/content/Context;Landroid/util/AttributeSet;I)V 74 | public final fun getEnterTransitionOverlap ()Z 75 | public final fun getIndex ()I 76 | public final fun getLayoutList ()Ljava/util/List; 77 | public final fun getNextAnimation ()Lcom/androidpoet/metaphor/IntroAnimation; 78 | public final fun getNextDuration ()J 79 | public final fun getPreviousAnimation ()Lcom/androidpoet/metaphor/IntroAnimation; 80 | public final fun getPreviousDuration ()J 81 | public final fun getReturnTransitionOverlap ()Z 82 | public final fun next ()V 83 | public final fun previous ()V 84 | public final fun setEnterTransitionOverlap (Z)V 85 | public final fun setIndex (I)V 86 | public final fun setLayoutList (Ljava/util/List;)V 87 | public final fun setNextAnimation (Lcom/androidpoet/metaphor/IntroAnimation;)V 88 | public final fun setNextDuration (J)V 89 | public final fun setOnIndexChangeListener (Lcom/androidpoet/materialintro/OnIndexChangeListener;)V 90 | public final synthetic fun setOnIndexChangeListener (Lkotlin/jvm/functions/Function1;)V 91 | public final fun setPreviousAnimation (Lcom/androidpoet/metaphor/IntroAnimation;)V 92 | public final fun setPreviousDuration (J)V 93 | public final fun setReturnTransitionOverlap (Z)V 94 | public final fun setViewsList (Ljava/util/List;)V 95 | } 96 | 97 | public final class com/androidpoet/materialintro/MaterialIntroView$Builder { 98 | public fun (Landroid/content/Context;)V 99 | public final fun build ()Lcom/androidpoet/materialintro/MaterialIntroView; 100 | public final fun setEnterDuration (J)Lcom/androidpoet/materialintro/MaterialIntroView$Builder; 101 | public final fun setExitDuration (J)Lcom/androidpoet/materialintro/MaterialIntroView$Builder; 102 | public final fun setNextAnimation (Lcom/androidpoet/metaphor/IntroAnimation;)Lcom/androidpoet/materialintro/MaterialIntroView$Builder; 103 | public final fun setOnIndexChangeListener (Lcom/androidpoet/materialintro/OnIndexChangeListener;)Lcom/androidpoet/materialintro/MaterialIntroView$Builder; 104 | public final synthetic fun setOnIndexChangeListener (Lkotlin/jvm/functions/Function1;)Lcom/androidpoet/materialintro/MaterialIntroView$Builder; 105 | public final fun setPreviousAnimation (Lcom/androidpoet/metaphor/IntroAnimation;)Lcom/androidpoet/materialintro/MaterialIntroView$Builder; 106 | public final fun setViewsList (Ljava/util/List;)Lcom/androidpoet/materialintro/MaterialIntroView$Builder; 107 | } 108 | 109 | public final class com/androidpoet/materialintro/MaterialIntroViewKt { 110 | public static final synthetic fun materialIntroView (Landroid/content/Context;Lkotlin/jvm/functions/Function1;)Lcom/androidpoet/materialintro/MaterialIntroView; 111 | } 112 | 113 | public abstract interface class com/androidpoet/materialintro/OnIndexChangeListener { 114 | public abstract fun onChange (I)V 115 | } 116 | 117 | public final class com/androidpoet/metaphor/IntroAnimation : java/lang/Enum { 118 | public static final field ElevationScale Lcom/androidpoet/metaphor/IntroAnimation; 119 | public static final field ElevationScaleGrow Lcom/androidpoet/metaphor/IntroAnimation; 120 | public static final field Fade Lcom/androidpoet/metaphor/IntroAnimation; 121 | public static final field FadeThrough Lcom/androidpoet/metaphor/IntroAnimation; 122 | public static final field None Lcom/androidpoet/metaphor/IntroAnimation; 123 | public static final field SharedAxisXBackward Lcom/androidpoet/metaphor/IntroAnimation; 124 | public static final field SharedAxisXForward Lcom/androidpoet/metaphor/IntroAnimation; 125 | public static final field SharedAxisYBackward Lcom/androidpoet/metaphor/IntroAnimation; 126 | public static final field SharedAxisYForward Lcom/androidpoet/metaphor/IntroAnimation; 127 | public static final field SharedAxisZBackward Lcom/androidpoet/metaphor/IntroAnimation; 128 | public static final field SharedAxisZForward Lcom/androidpoet/metaphor/IntroAnimation; 129 | public final fun getValue ()I 130 | public static fun valueOf (Ljava/lang/String;)Lcom/androidpoet/metaphor/IntroAnimation; 131 | public static fun values ()[Lcom/androidpoet/metaphor/IntroAnimation; 132 | } 133 | 134 | --------------------------------------------------------------------------------