├── .gitignore
├── .idea
├── caches
│ └── build_file_checksums.ser
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
├── sonarIssues.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hololo
│ │ └── tutorial
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hololo
│ │ │ └── tutorial
│ │ │ └── sample
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── ic_launcher_for_playstore.png
│ │ ├── knob.png
│ │ ├── no_album.png
│ │ ├── ss_1.png
│ │ ├── ss_2.png
│ │ ├── ss_3.png
│ │ └── ss_4.png
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── hololo
│ └── tutorial
│ └── sample
│ └── ExampleUnitTest.java
├── assets
└── sample.gif
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hololo
│ │ └── tutorial
│ │ └── library
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hololo
│ │ │ └── tutorial
│ │ │ └── library
│ │ │ ├── CurrentFragmentListener.java
│ │ │ ├── PermissionStep.java
│ │ │ ├── Step.java
│ │ │ ├── StepFragment.java
│ │ │ ├── StepPagerAdapter.java
│ │ │ ├── StepView.java
│ │ │ └── TutorialActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── circle_black.xml
│ │ ├── circle_white.xml
│ │ ├── ic_navigate_before_black_24dp.xml
│ │ └── ic_navigate_next_black_24dp.xml
│ │ ├── layout
│ │ ├── activity_tutorial.xml
│ │ └── fragment_step.xml
│ │ ├── values-v19
│ │ └── styles.xml
│ │ └── values
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── hololo
│ └── tutorial
│ └── library
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/sonarIssues.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Mehmet Ayan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://jitpack.io/#msayan/tutorial-view)
2 |
3 | # Tutorial View
4 |
5 | Ready to use tutorial screen.
6 |
7 | 
8 |
9 | ## Usage
10 |
11 | Extend your activity from TutorialActivity and Add fragments in onCreate after super call
12 |
13 | ```java
14 |
15 | public class MainActivity extends TutorialActivity {
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 |
21 | addFragment(new Step.Builder().setTitle("This is header")
22 | .setContent("This is content")
23 | .setBackgroundColor(Color.parseColor("#FF0957")) // int background color
24 | .setDrawable(R.drawable.ss_1) // int top drawable
25 | .setSummary("This is summary")
26 | .build());
27 | // Permission Step
28 | addFragment(new PermissionStep.Builder().setTitle(getString(R.string.permission_title))
29 | .setContent(getString(R.string.permission_detail))
30 | .setBackgroundColor(Color.parseColor("#FF0957"))
31 | .setDrawable(R.drawable.ss_1)
32 | .setSummary(getString(R.string.continue_and_learn))
33 | .setPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
34 | .build());
35 | }
36 | }
37 |
38 | ```
39 |
40 | Some helper methods
41 | ```java
42 |
43 | setPrevText(text); // Previous button text
44 | setNextText(text); // Next button text
45 | setFinishText(text); // Finish button text
46 | setCancelText(text); // Cancel button text
47 | setIndicatorSelected(int drawable); // Indicator drawable when selected
48 | setIndicator(int drawable); // Indicator drawable
49 | setGivePermissionText(String text); // Permission button text
50 |
51 | ```
52 |
53 | If you want to open another activity on tutorial finish
54 | ```java
55 |
56 | @Override
57 | public void finishTutorial() {
58 | // Your implementation
59 | }
60 |
61 | ```
62 |
63 |
64 |
65 | ##### If you want change design of view you need following items
66 | * 1 Container layout with id of container
67 | * 3 Text view which is for Title id of title, Content id of content, Summary id of summary
68 | * 1 Image view with id of image
69 |
70 |
71 |
72 |
73 |
74 | ## Download
75 |
76 | ### Step 1. Add the JitPack repository to your build file
77 |
78 | Add it in your root build.gradle at the end of repositories:
79 |
80 | ```groovy
81 |
82 | allprojects {
83 | repositories {
84 | ...
85 | maven { url 'https://jitpack.io' }
86 | }
87 | }
88 | ```
89 |
90 | ### Step 2. Add the dependency
91 |
92 | ```groovy
93 |
94 | dependencies {
95 | implementation 'com.github.msayan:tutorial-view:v1.0.10'
96 | }
97 |
98 | ```
99 |
100 | ## License
101 |
102 | MIT License
103 |
104 | Copyright (c) 2017 Mehmet Ayan
105 |
106 | Permission is hereby granted, free of charge, to any person obtaining a copy
107 | of this software and associated documentation files (the "Software"), to deal
108 | in the Software without restriction, including without limitation the rights
109 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
110 | copies of the Software, and to permit persons to whom the Software is
111 | furnished to do so, subject to the following conditions:
112 |
113 | The above copyright notice and this permission notice shall be included in all
114 | copies or substantial portions of the Software.
115 |
116 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
117 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
118 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
119 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
120 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
121 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
122 | SOFTWARE.
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 |
5 | defaultConfig {
6 | applicationId "com.hololo.tutorial.sample"
7 | minSdkVersion 16
8 | targetSdkVersion 27
9 | compileSdkVersion 27
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | implementation 'com.android.support:appcompat-v7:27.0.2'
28 | implementation 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
29 | testImplementation 'junit:junit:4.12'
30 | implementation project(path: ':library')
31 | }
32 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/volkan/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hololo/tutorial/sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.sample;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.hololo.tutorial.sample", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hololo/tutorial/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.sample;
2 |
3 | import android.Manifest;
4 | import android.graphics.Color;
5 | import android.os.Bundle;
6 | import android.widget.Toast;
7 |
8 | import com.hololo.tutorial.library.PermissionStep;
9 | import com.hololo.tutorial.library.Step;
10 | import com.hololo.tutorial.library.TutorialActivity;
11 |
12 | public class MainActivity extends TutorialActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 |
18 | addFragment(
19 | new PermissionStep
20 | .Builder()
21 | .setPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
22 | .setTitle(getString(R.string.permission_title)).setContent(getString(R.string.permission_detail))
23 | .setBackgroundColor(Color.parseColor("#FF0957"))
24 | .setDrawable(R.drawable.ss_1)
25 | .setSummary(getString(R.string.continue_and_learn))
26 | .build());
27 | addFragment(
28 | new Step.Builder()
29 | .setTitle(getString(R.string.automatic_data))
30 | .setContent(getString(R.string.gm_finds_photos))
31 | .setBackgroundColor(Color.parseColor("#FF0957"))
32 | .setDrawable(R.drawable.ss_1)
33 | .setSummary(getString(R.string.continue_and_learn))
34 | .build());
35 | addFragment(
36 | new Step.Builder()
37 | .setTitle(getString(R.string.choose_the_song))
38 | .setContent(getString(R.string.swap_to_the_tab))
39 | .setBackgroundColor(Color.parseColor("#00D4BA"))
40 | .setDrawable(R.drawable.ss_2)
41 | .setSummary(getString(R.string.continue_and_update))
42 | .build());
43 | addFragment(
44 | new Step.Builder()
45 | .setTitle(getString(R.string.edit_data))
46 | .setContent(getString(R.string.update_easily))
47 | .setBackgroundColor(Color.parseColor("#1098FE"))
48 | .setDrawable(R.drawable.ss_3)
49 | .setSummary(getString(R.string.continue_and_result))
50 | .build());
51 | addFragment(
52 | new Step.Builder()
53 | .setTitle(getString(R.string.result_awesome))
54 | .setContent(getString(R.string.after_updating))
55 | .setBackgroundColor(Color.parseColor("#CA70F3"))
56 | .setDrawable(R.drawable.ss_4)
57 | .setSummary(getString(R.string.thank_you))
58 | .build());
59 | }
60 |
61 | @Override
62 | public void finishTutorial() {
63 | Toast.makeText(this, "Tutorial finished", Toast.LENGTH_SHORT).show();
64 | finish();
65 | }
66 |
67 | @Override
68 | public void currentFragmentPosition(int position) {
69 | Toast.makeText(this, "Position : " + position, Toast.LENGTH_SHORT).show();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_for_playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/drawable/ic_launcher_for_playstore.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/knob.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/drawable/knob.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/no_album.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/drawable/no_album.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ss_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/drawable/ss_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ss_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/drawable/ss_2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ss_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/drawable/ss_3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ss_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/drawable/ss_4.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sample
3 |
4 | Automatic Data
5 | Grant Access
6 | Give Music Player access to files
7 | Choose the song
8 | Edit Data
9 | Result is awesome!
10 | Continue and learn how to do
11 | Continue and learn how to update
12 | Continue and see the result
13 | Thank you, have fun
14 | GM Music Playlist automatically finds photos and genres of singers and albums and displays it.* (*) Music information data should be in a proper format for this feature to work.
15 | Swap to the songs tab and touch the (⋮) sign which located at every songs right side , and choose Update Data You can update Song/Singer Name, Album and Genre data easily
16 | After updating data album cover, wiki information of artist and genre screens looks brilliant, don\'t forget to do this process for the other songs of you
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hololo/tutorial/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/assets/sample.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/assets/sample.gif
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | maven {
7 | url 'https://maven.google.com/'
8 | name 'Google'
9 | }
10 | google()
11 | }
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:3.3.1'
14 |
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | jcenter()
23 | maven {
24 | url 'https://maven.google.com/'
25 | name 'Google'
26 | }
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msayan/tutorial-view/653fa79cbb39fa92749a3698c3da6423d6fad5a5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Apr 08 13:40:37 CEST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | defaultConfig {
5 | minSdkVersion 16
6 | targetSdkVersion 27
7 | compileSdkVersion 27
8 | versionCode 1
9 | versionName "1.0"
10 |
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 |
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | implementation 'com.android.support:appcompat-v7:27.0.2'
28 | testImplementation 'junit:junit:4.12'
29 | }
30 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/volkan/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/hololo/tutorial/library/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.hololo.tutorial.library.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/library/src/main/java/com/hololo/tutorial/library/CurrentFragmentListener.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | public interface CurrentFragmentListener {
4 | void currentFragmentPosition(int position);
5 | }
6 |
--------------------------------------------------------------------------------
/library/src/main/java/com/hololo/tutorial/library/PermissionStep.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import android.os.Build;
4 | import android.os.Parcelable;
5 | import android.support.annotation.RequiresApi;
6 |
7 | @RequiresApi(api = Build.VERSION_CODES.M)
8 | public class PermissionStep extends Step implements Parcelable {
9 |
10 | private String[] permissions;
11 |
12 | public String[] getPermissions() {
13 | return permissions;
14 | }
15 |
16 | public static class Builder {
17 |
18 | private PermissionStep step;
19 |
20 | public Builder() {
21 | step = new PermissionStep();
22 | }
23 |
24 | public PermissionStep build() {
25 | return step;
26 | }
27 |
28 | public Builder setTitle(String title) {
29 | step.setTitle(title);
30 | return this;
31 | }
32 |
33 | public Builder setContent(String content) {
34 | step.setContent(content);
35 | return this;
36 | }
37 |
38 | public Builder setSummary(String summary) {
39 | step.setSummary(summary);
40 | return this;
41 | }
42 |
43 | public Builder setDrawable(int drawable) {
44 | step.setDrawable(drawable);
45 | return this;
46 | }
47 |
48 | public Builder setBackgroundColor(int backgroundColor) {
49 | step.setBackgroundColor(backgroundColor);
50 | return this;
51 | }
52 |
53 | public Builder setPermissions(String[] permissions) {
54 | step.permissions = permissions;
55 | return this;
56 | }
57 |
58 | public Builder setView(int view) {
59 | step.setViewType(view);
60 | return this;
61 | }
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/library/src/main/java/com/hololo/tutorial/library/Step.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | public class Step implements Parcelable {
7 |
8 | private String title;
9 | private String content;
10 | private String summary;
11 | private int drawable;
12 | private int backgroundColor;
13 | private int viewType;
14 |
15 | public Step() {
16 | }
17 |
18 | public int getViewType() {
19 | return viewType;
20 | }
21 |
22 | public void setViewType(int viewType) {
23 | this.viewType = viewType;
24 | }
25 |
26 | public String getTitle() {
27 | return title;
28 | }
29 |
30 | public void setTitle(String title) {
31 | this.title = title;
32 | }
33 |
34 | public String getContent() {
35 | return content;
36 | }
37 |
38 | public void setContent(String content) {
39 | this.content = content;
40 | }
41 |
42 | public int getDrawable() {
43 | return drawable;
44 | }
45 |
46 | public void setDrawable(int drawable) {
47 | this.drawable = drawable;
48 | }
49 |
50 | public int getBackgroundColor() {
51 | return backgroundColor;
52 | }
53 |
54 | public void setBackgroundColor(int backgroundColor) {
55 | this.backgroundColor = backgroundColor;
56 | }
57 |
58 | public String getSummary() {
59 | return summary;
60 | }
61 |
62 | public void setSummary(String summary) {
63 | this.summary = summary;
64 | }
65 |
66 | public static class Builder {
67 |
68 | private Step step;
69 |
70 | public Builder() {
71 | step = new Step();
72 | }
73 |
74 | public Step build() {
75 | return step;
76 | }
77 |
78 | public Builder setTitle(String title) {
79 | step.title = title;
80 | return this;
81 | }
82 |
83 | public Builder setContent(String content) {
84 | step.content = content;
85 | return this;
86 | }
87 |
88 | public Builder setSummary(String summary) {
89 | step.summary = summary;
90 | return this;
91 | }
92 |
93 | public Builder setDrawable(int drawable) {
94 | step.drawable = drawable;
95 | return this;
96 | }
97 |
98 | public Builder setBackgroundColor(int backgroundColor) {
99 | step.backgroundColor = backgroundColor;
100 | return this;
101 | }
102 |
103 | public Builder setView(int view) {
104 | step.viewType = view;
105 | return this;
106 | }
107 | }
108 |
109 |
110 | @Override
111 | public int describeContents() {
112 | return 0;
113 | }
114 |
115 | @Override
116 | public void writeToParcel(Parcel dest, int flags) {
117 | dest.writeString(this.title);
118 | dest.writeString(this.content);
119 | dest.writeString(this.summary);
120 | dest.writeInt(this.drawable);
121 | dest.writeInt(this.backgroundColor);
122 | dest.writeInt(this.viewType);
123 | }
124 |
125 | protected Step(Parcel in) {
126 | this.title = in.readString();
127 | this.content = in.readString();
128 | this.summary = in.readString();
129 | this.drawable = in.readInt();
130 | this.backgroundColor = in.readInt();
131 | this.viewType = in.readInt();
132 | }
133 |
134 | public static final Creator CREATOR = new Creator() {
135 | @Override
136 | public Step createFromParcel(Parcel source) {
137 | return new Step(source);
138 | }
139 |
140 | @Override
141 | public Step[] newArray(int size) {
142 | return new Step[size];
143 | }
144 | };
145 | }
146 |
--------------------------------------------------------------------------------
/library/src/main/java/com/hololo/tutorial/library/StepFragment.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | public class StepFragment extends StepView {
12 |
13 | private TextView title;
14 | private TextView content;
15 | private TextView summary;
16 | private ImageView imageView;
17 | private View layout;
18 |
19 |
20 | static StepFragment createFragment(Step step) {
21 | StepFragment fragment = new StepFragment();
22 | Bundle bundle = new Bundle();
23 | bundle.putParcelable("step", step);
24 | fragment.setArguments(bundle);
25 | return fragment;
26 | }
27 |
28 | @Override
29 | public void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 |
32 | step = getArguments().getParcelable("step");
33 | }
34 |
35 | @Nullable
36 | @Override
37 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
38 | int layout = step.getViewType() > 0 ? step.getViewType() : R.layout.fragment_step;
39 |
40 | View view = inflater.inflate(layout, container, false);
41 |
42 | initViews(view);
43 | initData();
44 |
45 | return view;
46 | }
47 |
48 | private void initData() {
49 | if (title != null) {
50 | title.setText(step.getTitle());
51 | }
52 | if (content != null) {
53 | content.setText(step.getContent());
54 | }
55 | if (summary != null) {
56 | summary.setText(step.getSummary());
57 | }
58 | if (imageView != null) {
59 | imageView.setImageResource(step.getDrawable());
60 | }
61 |
62 | if (layout != null) {
63 | layout.setBackgroundColor(step.getBackgroundColor());
64 | }
65 | }
66 |
67 | private void initViews(View view) {
68 | title = view.findViewById(R.id.title);
69 | content = view.findViewById(R.id.content);
70 | summary = view.findViewById(R.id.summary);
71 | imageView = view.findViewById(R.id.image);
72 | layout = view.findViewById(R.id.container);
73 | }
74 |
75 | @Override
76 | public void onDestroy() {
77 | super.onDestroy();
78 |
79 | if (imageView != null) {
80 | imageView.setImageDrawable(null);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/library/src/main/java/com/hololo/tutorial/library/StepPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 | import android.support.v4.app.FragmentStatePagerAdapter;
7 |
8 | import java.util.List;
9 |
10 | public class StepPagerAdapter extends FragmentStatePagerAdapter {
11 | private List stepList;
12 |
13 | public StepPagerAdapter(FragmentManager fm, List stepList) {
14 | super(fm);
15 | this.stepList = stepList;
16 | }
17 |
18 | @Override
19 | public Fragment getItem(int position) {
20 | Step step = stepList.get(position);
21 |
22 | return StepFragment.createFragment(step);
23 | }
24 |
25 | @Override
26 | public int getCount() {
27 | return stepList.size();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/library/src/main/java/com/hololo/tutorial/library/StepView.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 |
7 | public class StepView extends Fragment {
8 |
9 | Step step;
10 |
11 | @Override
12 | public void onCreate(@Nullable Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 |
15 | step = getArguments().getParcelable("step");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/library/src/main/java/com/hololo/tutorial/library/TutorialActivity.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.pm.PackageManager;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.support.annotation.NonNull;
8 | import android.support.annotation.Nullable;
9 | import android.support.annotation.RequiresApi;
10 | import android.support.v4.view.ViewPager;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.view.MotionEvent;
13 | import android.view.View;
14 | import android.view.Window;
15 | import android.view.WindowManager;
16 | import android.widget.Button;
17 | import android.widget.FrameLayout;
18 | import android.widget.ImageView;
19 | import android.widget.LinearLayout;
20 | import android.widget.RelativeLayout;
21 |
22 | import java.util.ArrayList;
23 | import java.util.List;
24 |
25 | public abstract class TutorialActivity extends AppCompatActivity implements View.OnClickListener, CurrentFragmentListener {
26 |
27 | private List steps;
28 | private StepPagerAdapter adapter;
29 |
30 | private ViewPager pager;
31 | private Button next, prev;
32 | private LinearLayout indicatorLayout;
33 | private FrameLayout containerLayout;
34 | private RelativeLayout buttonContainer;
35 | private CurrentFragmentListener currentFragmentListener;
36 |
37 | private int currentItem;
38 |
39 | private String prevText, nextText, finishText, cancelText, givePermissionText;
40 | private int selectedIndicator = R.drawable.circle_black, indicator = R.drawable.circle_white;
41 |
42 | @Override
43 | protected void onCreate(@Nullable Bundle savedInstanceState) {
44 | setTheme(R.style.TutorialStyle);
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_tutorial);
47 | currentFragmentListener = this;
48 | init();
49 | }
50 |
51 | private void init() {
52 | steps = new ArrayList<>();
53 | initTexts();
54 | initViews();
55 | initAdapter();
56 | }
57 |
58 | private void initTexts() {
59 | prevText = "Back";
60 | cancelText = "Cancel";
61 | finishText = "Finish";
62 | nextText = "Next";
63 | givePermissionText = "Give";
64 | }
65 |
66 | private void initAdapter() {
67 | adapter = new StepPagerAdapter(getSupportFragmentManager(), steps);
68 | pager.setAdapter(adapter);
69 | pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
70 | @Override
71 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
72 |
73 | }
74 |
75 | @Override
76 | public void onPageSelected(int position) {
77 | currentItem = position;
78 | currentFragmentListener.currentFragmentPosition(position);
79 | controlPosition(position);
80 | }
81 |
82 | @Override
83 | public void onPageScrollStateChanged(int state) {
84 |
85 | }
86 | });
87 | }
88 |
89 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
90 | private void changeStatusBarColor(int backgroundColor) {
91 | Window window = getWindow();
92 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
93 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
94 | window.setStatusBarColor(backgroundColor);
95 | }
96 |
97 | private void controlPosition(int position) {
98 | notifyIndicator();
99 |
100 | if (position == steps.size() - 1) {
101 | next.setText(finishText);
102 | prev.setText(prevText);
103 | } else if (position == 0) {
104 | prev.setText(cancelText);
105 | next.setText(nextText);
106 | } else {
107 | prev.setText(prevText);
108 | next.setText(nextText);
109 | }
110 |
111 | if (controlPermission()) {
112 | prepareNormalView();
113 | } else {
114 | preparePermissionView();
115 | }
116 | if (!steps.isEmpty()) {
117 | containerLayout.setBackgroundColor(steps.get(position).getBackgroundColor());
118 | buttonContainer.setBackgroundColor(steps.get(position).getBackgroundColor());
119 | }
120 | }
121 |
122 | private void prepareNormalView() {
123 | pager.setOnTouchListener(null);
124 | }
125 |
126 | private void preparePermissionView() {
127 | next.setText(givePermissionText);
128 |
129 | pager.setOnTouchListener(new View.OnTouchListener() {
130 | @Override
131 | public boolean onTouch(View v, MotionEvent event) {
132 | return true;
133 | }
134 | });
135 | }
136 |
137 | private void initViews() {
138 | currentItem = 0;
139 |
140 | pager = (ViewPager) findViewById(R.id.viewPager);
141 | next = (Button) findViewById(R.id.next);
142 | prev = (Button) findViewById(R.id.prev);
143 | indicatorLayout = (LinearLayout) findViewById(R.id.indicatorLayout);
144 | containerLayout = (FrameLayout) findViewById(R.id.containerLayout);
145 | buttonContainer = (RelativeLayout) findViewById(R.id.buttonContainer);
146 |
147 | next.setOnClickListener(this);
148 | prev.setOnClickListener(this);
149 | }
150 |
151 | public void addFragment(Step step) {
152 | steps.add(step);
153 | adapter.notifyDataSetChanged();
154 | notifyIndicator();
155 | controlPosition(currentItem);
156 | }
157 |
158 | public void addFragment(Step step, int position) {
159 | steps.add(position, step);
160 | adapter.notifyDataSetChanged();
161 | notifyIndicator();
162 | }
163 |
164 | public void notifyIndicator() {
165 | if (indicatorLayout.getChildCount() > 0)
166 | indicatorLayout.removeAllViews();
167 |
168 | for (int i = 0; i < steps.size(); i++) {
169 | ImageView imageView = new ImageView(this);
170 | imageView.setPadding(8, 8, 8, 8);
171 | int drawable = indicator;
172 | if (i == currentItem)
173 | drawable = selectedIndicator;
174 |
175 | imageView.setImageResource(drawable);
176 |
177 | final int finalI = i;
178 | imageView.setOnClickListener(new View.OnClickListener() {
179 | @Override
180 | public void onClick(View v) {
181 | changeFragment(finalI);
182 | }
183 | });
184 |
185 | indicatorLayout.addView(imageView);
186 | }
187 |
188 | }
189 |
190 | @Override
191 | public void onBackPressed() {
192 | if (currentItem == 0) {
193 | super.onBackPressed();
194 | } else {
195 | changeFragment(false);
196 | }
197 | }
198 |
199 | @SuppressLint("NewApi")
200 | @Override
201 | public void onClick(View v) {
202 | if (v.getId() == R.id.next) {
203 | if (controlPermission())
204 | changeFragment(true);
205 | else
206 | requestPermissions(((PermissionStep) steps.get(pager.getCurrentItem())).getPermissions(), 1903);
207 | } else if (v.getId() == R.id.prev) {
208 | changeFragment(false);
209 | }
210 | }
211 |
212 | private void changeFragment(int position) {
213 | if (controlPermission())
214 | pager.setCurrentItem(position, true);
215 | }
216 |
217 | private boolean controlPermission() {
218 | if (!steps.isEmpty() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && steps.get(pager.getCurrentItem()) instanceof PermissionStep) {
219 |
220 | for (String permission : ((PermissionStep) steps.get(pager.getCurrentItem())).getPermissions()) {
221 | int permissionResult = checkSelfPermission(permission);
222 |
223 | if (permissionResult != PackageManager.PERMISSION_GRANTED) {
224 | return false;
225 | }
226 | }
227 | }
228 | return true;
229 | }
230 |
231 | private void changeFragment(boolean isNext) {
232 | int item = currentItem;
233 | if (isNext) {
234 | item++;
235 | } else {
236 | item--;
237 | }
238 |
239 | if (item < 0 || item == steps.size()) {
240 | finishTutorial();
241 | } else
242 | pager.setCurrentItem(item, true);
243 | }
244 |
245 | public void finishTutorial() {
246 | finish();
247 | }
248 |
249 | public void setPrevText(String text) {
250 | prevText = text;
251 | controlPosition(0);
252 | }
253 |
254 | public void setNextText(String text) {
255 | nextText = text;
256 | controlPosition(0);
257 | }
258 |
259 | public void setFinishText(String text) {
260 | finishText = text;
261 | controlPosition(0);
262 | }
263 |
264 | public void setCancelText(String text) {
265 | cancelText = text;
266 | controlPosition(0);
267 | }
268 |
269 | public void setGivePermissionText(String text) {
270 | givePermissionText = text;
271 | controlPosition(0);
272 | }
273 |
274 | public void setIndicatorSelected(int drawable) {
275 | selectedIndicator = drawable;
276 | }
277 |
278 | public void setIndicator(int drawable) {
279 | indicator = drawable;
280 | }
281 |
282 | @Override
283 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
284 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
285 |
286 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
287 | changeFragment(true);
288 | }
289 | }
290 |
291 |
292 | }
--------------------------------------------------------------------------------
/library/src/main/res/drawable/circle_black.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/circle_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_navigate_before_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_navigate_next_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/activity_tutorial.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
17 |
21 |
22 |
30 |
31 |
41 |
42 |
43 |
53 |
54 |
55 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/fragment_step.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
27 |
28 |
39 |
40 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/library/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library/src/test/java/com/hololo/tutorial/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hololo.tutorial.library;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------