├── app
├── .gitignore
├── release
│ ├── app-release.apk
│ └── output.json
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── iron_man.jpg
│ │ │ │ ├── black_widow.jpg
│ │ │ │ ├── captain_america.jpeg
│ │ │ │ ├── ic_apps_black_24dp.xml
│ │ │ │ ├── ic_build_black_24dp.xml
│ │ │ │ ├── ic_border_color_black_24dp.xml
│ │ │ │ ├── ic_archive_black_24dp.xml
│ │ │ │ └── ic_launcher_background.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
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── fragment_editor.xml
│ │ │ │ ├── fragment_setting.xml
│ │ │ │ └── fragment_gallery.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── sdsmdg
│ │ │ │ └── aridj
│ │ │ │ └── driftdrawerdemo
│ │ │ │ ├── fragments
│ │ │ │ ├── EditorFragment.kt
│ │ │ │ ├── GalleryFragment.kt
│ │ │ │ └── SettingFragment.kt
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── sdsmdg
│ │ │ └── aridj
│ │ │ └── driftdrawerdemo
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── sdsmdg
│ │ └── aridj
│ │ └── driftdrawerdemo
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── driftdrawer
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ └── values
│ │ │ ├── ids.xml
│ │ │ └── strings.xml
│ │ └── java
│ │ └── com
│ │ └── sdsmdg
│ │ └── aridj
│ │ └── driftdrawer
│ │ ├── transformations
│ │ ├── Transformation.kt
│ │ ├── RotationTransformation.kt
│ │ ├── CombineTransformation.kt
│ │ └── ScaleTransformation.kt
│ │ ├── DriftDrawer.kt
│ │ ├── DriftDrawerLayout.kt
│ │ ├── DriftDrawerBuilder.kt
│ │ └── DriftNavLayout.kt
├── proguard-rules.pro
├── build.gradle
└── deploy.gradle
├── settings.gradle
├── cacerts
├── images
└── sample.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── LICENSE
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/driftdrawer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | keystore.gradle
3 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':driftdrawer'
2 |
--------------------------------------------------------------------------------
/cacerts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/cacerts
--------------------------------------------------------------------------------
/images/sample.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/images/sample.gif
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/release/app-release.apk
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/iron_man.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/drawable/iron_man.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/black_widow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/drawable/black_widow.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/captain_america.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/drawable/captain_america.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/driftdrawer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arihant-001/DriftDrawer/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/driftdrawer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | lib
3 | Open
4 | Close
5 |
6 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #9C27B0
4 | #7B1FA2
5 | #FF4081
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DriftDrawer
3 |
4 |
5 | Hello blank fragment
6 |
7 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/transformations/Transformation.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer.transformations
2 |
3 | import android.view.View
4 |
5 | interface Transformation {
6 |
7 | fun transform(progress: Float, view: View)
8 |
9 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 23 01:40:44 IST 2018
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.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/transformations/RotationTransformation.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer.transformations
2 |
3 | import android.view.View
4 |
5 | class RotationTransformation: Transformation {
6 |
7 | override fun transform(progress: Float, view: View) {
8 | val rotation = 0 + progress * (360 - 0)
9 | view.rotation = rotation
10 | }
11 |
12 | }
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/DriftDrawer.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer
2 |
3 | interface DriftDrawer {
4 |
5 | fun isDrawerClosed(): Boolean
6 |
7 | fun closeDrawer()
8 |
9 | fun closeDrawer(animated: Boolean)
10 |
11 | fun openDrawer()
12 |
13 | fun openDrawer(animated: Boolean)
14 |
15 | fun getLayout(): DriftNavLayout
16 |
17 | fun setSelectedPosition(position: Int)
18 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/sdsmdg/aridj/driftdrawerdemo/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawerdemo
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/transformations/CombineTransformation.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer.transformations
2 |
3 | import android.view.View
4 |
5 | class CombineTransformation(private val transformations: List): Transformation {
6 |
7 | override fun transform(progress: Float, view: View) {
8 | for (transformation in transformations) {
9 | transformation.transform(progress, view)
10 | }
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_apps_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_build_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_border_color_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_archive_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/transformations/ScaleTransformation.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer.transformations
2 |
3 | import android.view.View
4 |
5 | class ScaleTransformation: Transformation {
6 |
7 | override fun transform(progress: Float, view: View) {
8 | val scale = 1/8f + progress * (1f - 1/8f)
9 | view.scaleX = scale
10 | view.scaleY = scale
11 |
12 | // val scale = 1f + progress * (8f - 1f)
13 | // view.layoutParams.height = (scale*view.layoutParams.height).toInt()
14 | // view.layoutParams.width = (scale*view.layoutParams.width).toInt()
15 | // view.invalidate()
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sdsmdg/aridj/driftdrawerdemo/fragments/EditorFragment.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawerdemo.fragments
2 |
3 | import android.os.Bundle
4 | import android.support.v4.app.Fragment
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import com.sdsmdg.aridj.driftdrawerdemo.R
9 |
10 |
11 | class EditorFragment : Fragment() {
12 |
13 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
14 | savedInstanceState: Bundle?): View? {
15 | // Inflate the layout for this fragment
16 | return inflater.inflate(R.layout.fragment_editor, container, false)
17 | }
18 |
19 |
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sdsmdg/aridj/driftdrawerdemo/fragments/GalleryFragment.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawerdemo.fragments
2 |
3 |
4 | import android.os.Bundle
5 | import android.support.v4.app.Fragment
6 | import android.view.LayoutInflater
7 | import android.view.View
8 | import android.view.ViewGroup
9 |
10 | import com.sdsmdg.aridj.driftdrawerdemo.R
11 |
12 | /**
13 | * A simple [Fragment] subclass.
14 | *
15 | */
16 | class GalleryFragment : Fragment() {
17 |
18 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
19 | savedInstanceState: Bundle?): View? {
20 | // Inflate the layout for this fragment
21 | return inflater.inflate(R.layout.fragment_gallery, container, false)
22 | }
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/sdsmdg/aridj/driftdrawerdemo/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawerdemo
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.sdsmdg.aridj.driftdrawerdemo", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/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
22 |
--------------------------------------------------------------------------------
/driftdrawer/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
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/DriftDrawerLayout.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer
2 |
3 | import android.content.Context
4 | import android.support.v4.widget.DrawerLayout
5 |
6 | class DriftDrawerLayout(context: Context) : DrawerLayout(context) {
7 |
8 | private lateinit var navLayout: DriftNavLayout
9 |
10 | fun setNavLayout(navLayout: DriftNavLayout) {
11 | this.navLayout = navLayout
12 | }
13 |
14 | override fun openDrawer(gravity: Int) {
15 | navLayout.openDrawer()
16 | }
17 |
18 | override fun closeDrawer(gravity: Int) {
19 | navLayout.closeDrawer()
20 | }
21 |
22 | override fun isDrawerVisible(drawerGravity: Int): Boolean {
23 | return !navLayout.isClosed
24 | }
25 |
26 | override fun getDrawerLockMode(edgeGravity: Int): Int {
27 | return LOCK_MODE_UNLOCKED
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_editor.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Arihant Jain
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 |
--------------------------------------------------------------------------------
/driftdrawer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'com.jfrog.bintray'
5 | apply plugin: 'org.jetbrains.dokka-android'
6 | apply plugin: 'maven-publish'
7 |
8 | android {
9 | compileSdkVersion 27
10 | defaultConfig {
11 | minSdkVersion 15
12 | targetSdkVersion 27
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 |
32 | implementation 'com.android.support:appcompat-v7:27.1.1'
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34 | }
35 |
36 | dokka {
37 | outputFormat = 'html'
38 | outputDirectory = "$buildDir/javadoc"
39 | }
40 |
41 | apply from: 'deploy.gradle'
42 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 27
9 | defaultConfig {
10 | applicationId "com.sdsmdg.aridj.driftdrawerdemo"
11 | minSdkVersion 15
12 | targetSdkVersion 27
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(include: ['*.jar'], dir: 'libs')
27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
28 | implementation 'com.android.support:appcompat-v7:27.1.1'
29 | implementation 'com.android.support:support-v4:27.1.1'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33 | implementation 'com.sdsmdg.aridj:driftdrawer:1.0.0'
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
26 |
27 |
34 |
35 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/driftdrawer/deploy.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 | apply from: 'keystore.gradle'//the file, containing the bintray API key
4 |
5 | ext {
6 | groupId = 'com.sdsmdg.aridj'
7 | artifactId = 'driftdrawer'
8 | libVersion = '1.0.0'
9 | }
10 |
11 | version = libVersion
12 | group = groupId
13 |
14 | bintray {
15 | user = 'arihantjain456'
16 | key = bintray_key // Defined in keystore.gradle file
17 | configurations = ['archives']
18 | publish = false //[Default: false] Whether version should be auto published after an upload
19 | override = false
20 |
21 | pkg {
22 | repo = "DriftDrawer"
23 | name = "driftdrawer"
24 | version {
25 | name = libVersion
26 | }
27 | }
28 | }
29 |
30 | install {
31 | repositories.mavenInstaller {
32 | pom.project {
33 | packaging 'aar'
34 | groupId groupId
35 | artifactId artifactId
36 | version libVersion
37 | name artifactId
38 | }
39 | }
40 | }
41 |
42 | if (project.hasProperty("kotlin")) { //Kotlin libraries
43 | task sourcesJar(type: Jar) {
44 | classifier = 'sources'
45 | from android.sourceSets.main.java.srcDirs
46 | }
47 |
48 | task javadoc(type: Javadoc, dependsOn: dokka) {
49 |
50 | }
51 | } else if (project.hasProperty("android")) {
52 | task sourcesJar(type: Jar) {
53 | classifier = 'sources'
54 | from android.sourceSets.main.java.srcDirs
55 | }
56 |
57 | task javadoc(type: Javadoc) {
58 | source = android.sourceSets.main.java.srcDirs
59 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
60 | }
61 | } else { // Java libraries
62 | task sourcesJar(type: Jar, dependsOn: classes) {
63 | classifier = 'sources'
64 | from sourceSets.main.allSource
65 | }
66 | }
67 |
68 | task javadocJar(type: Jar, dependsOn: javadoc) {
69 | classifier = 'javadoc'
70 | from javadoc.destinationDir
71 | // options.encoding = 'UTF-8'
72 | }
73 |
74 | artifacts {
75 | archives javadocJar
76 | archives sourcesJar
77 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_gallery.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
21 |
22 |
30 |
31 |
34 |
35 |
45 |
46 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DriftDrawer
2 | It is a library for custom Naviagation Drawer
3 |
4 | 
5 |
6 | ## Usage
7 |
8 | ### Gradle
9 |
10 | ```
11 | compile 'com.sdsmdg.aridj:driftdrawer:1.0.0'
12 | ```
13 | ### Builder
14 |
15 | 1. Create a list of icons for navigation items
16 |
17 | ``` kotlin
18 | val icons = ArrayList()
19 | icons.add(R.drawable.ic_archive_black_24dp)
20 | icons.add(R.drawable.ic_apps_black_24dp)
21 | icons.add(R.drawable.ic_border_color_black_24dp)
22 | icons.add(R.drawable.ic_build_black_24dp)
23 |
24 | ```
25 | 2. Build the drawer programmatically using `DriftDrawerBuilder`.
26 |
27 | ``` kotlin
28 | DriftDrawerBuilder(context, toolbar)
29 | .withMenus(icons)
30 | .build()
31 | ```
32 |
33 | ### ItemClickListener
34 |
35 | - Using lamdas
36 |
37 | ```kotlin
38 | val navItemListener: (Int, View) -> Unit = { pos: Int, view: View ->
39 | Toast.makeText(context, "Position: " + pos, Toast.LENGTH_SHORT).show()
40 | }
41 | ```
42 |
43 | - This itemClickListener can be easily pass in builder
44 |
45 | ``` kotlin
46 | DriftDrawerBuilder(context, toolbar)
47 | .withMenus(icons)
48 | .withItemClickListener(navItemListener)
49 | .build()
50 | ```
51 |
52 | ### Builder Extras
53 |
54 | ``` kotlin
55 | val driftDrawer = DriftDrawerBuilder(this, toolbar)
56 | .withMenus(icons)
57 | .withDrawerClosed(false) // set initial state of drawer
58 | .withSize(60) // set menu size in dp
59 | .withColors(Color.parseColor("#E91E63"), Color.parseColor("#9C27B0")) // sets background and item highlight colors
60 | .withItemClickListener(navItemListener) // sets item click listener
61 | .build()
62 | ```
63 |
64 | ### DriftDrawer
65 | `build` method of `DriftDrawerBuilder` returns `DriftDrawer`. This drawer can be used to control its behaviors.
66 |
67 | Methods | Definition
68 | ------------ | -------------
69 | isClosed | returns true if drawer is closed otherwise false
70 | closeDrawer | close the drawer with/ without animation control by argument `animated`. Default value for `animated` is `true`
71 | openDrawer | open the drawer with/ without animation control by argument `animated`. Default value for `animated` is `true`
72 | setSelectedPosition | sets the position passed in argument as selected position
73 | getLayout | returns the `DriftNavLayout` for drawer
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sdsmdg/aridj/driftdrawerdemo/fragments/SettingFragment.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawerdemo.fragments
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.support.v4.app.Fragment
6 | import android.view.LayoutInflater
7 | import android.view.View
8 | import android.view.ViewGroup
9 |
10 | import com.sdsmdg.aridj.driftdrawerdemo.R
11 | import kotlinx.android.synthetic.main.fragment_setting.*
12 |
13 | class SettingFragment : Fragment() {
14 | private var listener: SettingFragmentClickListener? = null
15 |
16 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
17 | savedInstanceState: Bundle?): View? {
18 | return inflater.inflate(R.layout.fragment_setting, container, false)
19 | }
20 |
21 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
22 | super.onViewCreated(view, savedInstanceState)
23 |
24 | close_drawer.setOnClickListener {
25 | onButtonPressed(it)
26 | }
27 | close_drawer_anim.setOnClickListener {
28 | onButtonPressed(it)
29 | }
30 | open_drawer.setOnClickListener {
31 | onButtonPressed(it)
32 | }
33 | open_drawer_anim.setOnClickListener {
34 | onButtonPressed(it)
35 | }
36 | }
37 | private fun onButtonPressed(view: View) {
38 | when(view.id) {
39 | R.id.close_drawer -> listener?.onButtonClicked(true, false)
40 | R.id.close_drawer_anim -> listener?.onButtonClicked(true, true)
41 | R.id.open_drawer -> listener?.onButtonClicked(false, false)
42 | R.id.open_drawer_anim -> listener?.onButtonClicked(false, true)
43 | }
44 | }
45 |
46 | override fun onAttach(context: Context) {
47 | super.onAttach(context)
48 | if (context is SettingFragmentClickListener) {
49 | listener = context
50 | } else {
51 | throw RuntimeException(context.toString() + " must implement SettingFragmentClickListener")
52 | }
53 | }
54 |
55 | override fun onDetach() {
56 | super.onDetach()
57 | listener = null
58 | }
59 |
60 | interface SettingFragmentClickListener {
61 |
62 | fun onButtonClicked(close: Boolean, animated: Boolean)
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sdsmdg/aridj/driftdrawerdemo/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawerdemo
2 |
3 | import android.graphics.Color
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import android.view.View
7 | import com.sdsmdg.aridj.driftdrawer.DriftDrawer
8 | import com.sdsmdg.aridj.driftdrawer.DriftDrawerBuilder
9 | import com.sdsmdg.aridj.driftdrawerdemo.fragments.EditorFragment
10 | import com.sdsmdg.aridj.driftdrawerdemo.fragments.GalleryFragment
11 | import com.sdsmdg.aridj.driftdrawerdemo.fragments.SettingFragment
12 | import kotlinx.android.synthetic.main.activity_main.*
13 |
14 | class MainActivity : AppCompatActivity(), SettingFragment.SettingFragmentClickListener {
15 |
16 | private lateinit var driftDrawer: DriftDrawer
17 |
18 | override fun onCreate(savedInstanceState: Bundle?) {
19 | super.onCreate(savedInstanceState)
20 | setContentView(R.layout.activity_main)
21 |
22 | setSupportActionBar(toolbar)
23 | supportActionBar?.title = "Sample App"
24 |
25 | val menus = ArrayList()
26 | menus.add(R.drawable.ic_archive_black_24dp)
27 | menus.add(R.drawable.ic_apps_black_24dp)
28 | menus.add(R.drawable.ic_border_color_black_24dp)
29 | menus.add(R.drawable.ic_build_black_24dp)
30 | // for demo
31 |
32 | driftDrawer = DriftDrawerBuilder(this, toolbar)
33 | .withMenus(menus)
34 | .withSize(60)
35 | .withDrawerClosed(false)
36 | .withColors(Color.parseColor("#E91E63"), Color.parseColor("#9C27B0"))
37 | .withItemClickListener(navItemListener)
38 | .build()
39 | driftDrawer.setSelectedPosition(2)
40 | }
41 |
42 | private val navItemListener: (Int, View) -> Unit = { pos: Int, view: View ->
43 | when (pos) {
44 | 1 -> {
45 | supportFragmentManager.beginTransaction().replace(R.id.container, GalleryFragment())
46 | .commit()
47 | supportActionBar?.title = "Gallery"
48 | }
49 | 2 -> {
50 | supportFragmentManager.beginTransaction().replace(R.id.container, EditorFragment())
51 | .commit()
52 | supportActionBar?.title = "Editor"
53 | }
54 | 3 -> {
55 | supportFragmentManager.beginTransaction().replace(R.id.container, SettingFragment())
56 | .commit()
57 | supportActionBar?.title = "Settings"
58 | }
59 | else -> {
60 |
61 | }
62 | }
63 | }
64 |
65 | override fun onButtonClicked(close: Boolean, animated: Boolean) {
66 | if (close) {
67 | driftDrawer.closeDrawer(animated)
68 | } else {
69 | driftDrawer.openDrawer(animated)
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/DriftDrawerBuilder.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer
2 |
3 | import android.app.Activity
4 | import android.support.v7.app.ActionBarDrawerToggle
5 | import android.support.v7.widget.Toolbar
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import com.sdsmdg.aridj.driftdrawer.transformations.CombineTransformation
9 | import com.sdsmdg.aridj.driftdrawer.transformations.RotationTransformation
10 | import com.sdsmdg.aridj.driftdrawer.transformations.ScaleTransformation
11 | import java.util.*
12 |
13 | class DriftDrawerBuilder(private val activity: Activity, private val toolbar: Toolbar) {
14 |
15 | private val navDrawerLayout: DriftNavLayout = DriftNavLayout(activity)
16 | private var menuIds: ArrayList
17 |
18 | init {
19 | menuIds = ArrayList()
20 | }
21 |
22 | fun withMenus(menus: ArrayList): DriftDrawerBuilder {
23 | this.menuIds = menus
24 |
25 | return this
26 | }
27 |
28 | fun withColors(backgroundColor: Int , itemHighlightColor: Int): DriftDrawerBuilder {
29 | this.navDrawerLayout.navColor = backgroundColor
30 | this.navDrawerLayout.itemHighlightColor = itemHighlightColor
31 |
32 | return this
33 | }
34 |
35 | fun withDrawerClosed(isClosed: Boolean): DriftDrawerBuilder {
36 | this.navDrawerLayout.isClosed = isClosed
37 |
38 | return this
39 | }
40 |
41 | fun withSize(menuSize: Int): DriftDrawerBuilder {
42 | this.navDrawerLayout.maxHorizontalDrag = dpToPx(menuSize)
43 |
44 | return this
45 | }
46 |
47 | fun withItemClickListener(itemClickedListener: (Int, View) -> Unit): DriftDrawerBuilder {
48 | this.navDrawerLayout.navItemClickListener = itemClickedListener
49 |
50 | return this
51 | }
52 |
53 | fun build(): DriftDrawer {
54 | val contentView = activity.findViewById(android.R.id.content) as ViewGroup
55 | val rootView = contentView.getChildAt(0)
56 | contentView.removeAllViews()
57 | prepareNavLayout(rootView)
58 | contentView.addView(navDrawerLayout)
59 |
60 | return navDrawerLayout
61 | }
62 |
63 | private fun prepareNavLayout(rootView: View): DriftNavLayout {
64 | navDrawerLayout.id = R.id.pop_out_layout
65 | navDrawerLayout.setMainView(rootView)
66 |
67 | navDrawerLayout.setTransformation(CombineTransformation(
68 | Arrays.asList(ScaleTransformation(),
69 | RotationTransformation())))
70 |
71 | navDrawerLayout.addMenus(menuIds)
72 | addDrawer(navDrawerLayout)
73 | navDrawerLayout.addView(rootView)
74 |
75 | return navDrawerLayout
76 | }
77 |
78 | private fun addDrawer(navDrawer: DriftNavLayout) {
79 | val drawerLayout = DriftDrawerLayout(activity)
80 | drawerLayout.setNavLayout(navDrawer)
81 |
82 | val toggle = ActionBarDrawerToggle(activity, drawerLayout, toolbar,
83 | R.string.drawer_open,
84 | R.string.drawer_close)
85 | toggle.syncState()
86 |
87 | navDrawer.setDrawerListener(toggle)
88 | }
89 |
90 | private fun dpToPx(dp: Int): Int {
91 | return Math.round(activity.resources.displayMetrics.density * dp)
92 | }
93 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/driftdrawer/src/main/java/com/sdsmdg/aridj/driftdrawer/DriftNavLayout.kt:
--------------------------------------------------------------------------------
1 | package com.sdsmdg.aridj.driftdrawer
2 |
3 | import android.content.Context
4 | import android.graphics.Color
5 | import android.os.Bundle
6 | import android.os.Parcelable
7 | import android.support.v4.view.ViewCompat
8 | import android.support.v4.widget.DrawerLayout
9 | import android.support.v4.widget.ViewDragHelper
10 | import android.view.Gravity
11 | import android.view.MotionEvent
12 | import android.view.View
13 | import android.view.ViewGroup
14 | import android.widget.FrameLayout
15 | import android.widget.ImageView
16 | import android.widget.LinearLayout
17 | import android.widget.ScrollView
18 | import com.sdsmdg.aridj.driftdrawer.transformations.Transformation
19 |
20 | private const val STATE_SUPER = "super_state"
21 | private const val STATE_IS_CLOSED = "is_opened"
22 | private const val STATE_SELECTED_ITEM = "selected_item"
23 |
24 | class DriftNavLayout(ctx: Context) : FrameLayout(ctx),
25 | DriftDrawer {
26 |
27 | private val dragHelper: ViewDragHelper
28 | private var transformation: Transformation ?= null
29 | private lateinit var mainView: View
30 |
31 | private var drawerListener: DrawerLayout.DrawerListener? = null
32 | var navItemClickListener: (Int, View)->Unit
33 | private val parentLayout: LinearLayout
34 | private var menus: ArrayList
35 |
36 | var maxHorizontalDrag: Int = 150
37 | var dragProgress: Float = 0f
38 | var dragState: Int = ViewDragHelper.STATE_IDLE
39 | var navColor: Int = Color.TRANSPARENT
40 | var itemHighlightColor: Int = Color.BLACK
41 | private var selectedItemPosition: Int = -1
42 | var isClosed: Boolean = true
43 |
44 | init {
45 | dragHelper = ViewDragHelper.create(this, 1.0f, ViewDragCallback())
46 | menus = ArrayList()
47 | parentLayout = LinearLayout(context)
48 | navItemClickListener = { _, _ -> }
49 | }
50 |
51 | fun setMainView(mainView: View) {
52 | this.mainView = mainView
53 | }
54 |
55 | fun setDrawerListener(listener: DrawerLayout.DrawerListener) {
56 | this.drawerListener = listener
57 | }
58 |
59 | fun setTransformation(transformation: Transformation) {
60 | this.transformation = transformation
61 | }
62 |
63 | override fun closeDrawer() {
64 | if (dragHelper.smoothSlideViewTo(mainView, 0, mainView.top)) {
65 | ViewCompat.postInvalidateOnAnimation(this)
66 | }
67 | }
68 |
69 | override fun closeDrawer(animated: Boolean) {
70 | if(animated) {
71 | closeDrawer()
72 | } else{
73 | isClosed = true
74 | dragProgress = 0f
75 | requestLayout()
76 | drawerListener?.onDrawerSlide(parentLayout, 0f)
77 | }
78 | }
79 |
80 | override fun openDrawer() {
81 | if (dragHelper.smoothSlideViewTo(mainView, maxHorizontalDrag, mainView.top)) {
82 | ViewCompat.postInvalidateOnAnimation(this)
83 | }
84 | }
85 |
86 | override fun openDrawer(animated: Boolean) {
87 | if(animated) {
88 | openDrawer()
89 | } else {
90 | isClosed = false
91 | dragProgress = 1f
92 | requestLayout()
93 | drawerListener?.onDrawerSlide(parentLayout, maxHorizontalDrag.toFloat())
94 | }
95 | }
96 |
97 | override fun isDrawerClosed(): Boolean {
98 | return isClosed
99 | }
100 |
101 | override fun getLayout(): DriftNavLayout {
102 | return this
103 | }
104 |
105 | override fun onAttachedToWindow() {
106 | super.onAttachedToWindow()
107 | setBackgroundColor(navColor)
108 | if(!isClosed) {
109 | openDrawer(false)
110 | }
111 | }
112 |
113 | override fun computeScroll() {
114 | if (dragHelper.continueSettling(true)) {
115 | ViewCompat.postInvalidateOnAnimation(this)
116 | }
117 | }
118 |
119 | override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
120 | return if (dragHelper.shouldInterceptTouchEvent(event)) {
121 | true
122 | } else super.onInterceptTouchEvent(event)
123 | }
124 |
125 | override fun onTouchEvent(event: MotionEvent): Boolean {
126 | dragHelper.processTouchEvent(event)
127 | return true
128 | }
129 |
130 | fun addMenus(menuIds: ArrayList) {
131 | val scrollView = ScrollView(context)
132 | val linearLayoutParams = LinearLayout.LayoutParams(maxHorizontalDrag, LinearLayout.LayoutParams.MATCH_PARENT)
133 | parentLayout.orientation = LinearLayout.VERTICAL
134 | linearLayoutParams.gravity = Gravity.CENTER_HORIZONTAL
135 | parentLayout.layoutParams = linearLayoutParams
136 | parentLayout.gravity = Gravity.CENTER_HORIZONTAL
137 | for (i in 0 until menuIds.size) {
138 | val menuLayout = LinearLayout(context)
139 | val menuParams = LinearLayout.LayoutParams(maxHorizontalDrag, maxHorizontalDrag)
140 | menuLayout.gravity = Gravity.CENTER
141 | val imagesView = ImageView(context)
142 | val params = ViewGroup.LayoutParams((maxHorizontalDrag*0.7f).toInt(), (maxHorizontalDrag*0.7f).toInt())
143 | imagesView.setImageResource(menuIds[i])
144 | parentLayout.addView(menuLayout, menuParams)
145 | menuLayout.addView(imagesView, params)
146 | menus.add(menuLayout)
147 |
148 | menuLayout.setOnClickListener {
149 | navItemClickListener.invoke(i, menuLayout)
150 | selectItem(i)
151 | closeDrawer()
152 | }
153 | }
154 | addView(scrollView)
155 | scrollView.addView(parentLayout, linearLayoutParams)
156 |
157 | selectItem(selectedItemPosition)
158 | }
159 |
160 | private fun selectItem(position: Int) {
161 | this.selectedItemPosition = position
162 | clearSelectedItem()
163 | if (position != -1) {
164 | menus[position].setBackgroundColor(itemHighlightColor)
165 | }
166 | }
167 |
168 | private fun clearSelectedItem() {
169 | for (menu in menus) {
170 | menu.setBackgroundColor(Color.TRANSPARENT)
171 | }
172 | }
173 |
174 | override fun setSelectedPosition(position: Int) {
175 | selectItem(position)
176 | }
177 |
178 | override fun onSaveInstanceState(): Parcelable? {
179 | super.onSaveInstanceState()
180 | val savedState = Bundle()
181 | savedState.putParcelable(STATE_SUPER, super.onSaveInstanceState())
182 | savedState.putBoolean(STATE_IS_CLOSED, isClosed)
183 | savedState.putInt(STATE_SELECTED_ITEM, selectedItemPosition)
184 | return savedState
185 | }
186 |
187 | override fun onRestoreInstanceState(state: Parcelable) {
188 | val savedState = state as Bundle
189 | super.onRestoreInstanceState(savedState.getParcelable(STATE_SUPER))
190 | isClosed = savedState.getBoolean(STATE_IS_CLOSED, true)
191 | selectedItemPosition = savedState.getInt(STATE_SELECTED_ITEM, -1)
192 |
193 | selectItem(selectedItemPosition)
194 | if (!isClosed) {
195 | openDrawer(false)
196 | }
197 | }
198 |
199 | override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
200 | super.onLayout(changed, left, top, right, bottom)
201 | for (i in 0 until childCount) {
202 | val child = getChildAt(i)
203 | if (child == mainView) {
204 | var rootLeft = 0
205 | if (!isClosed) {
206 | rootLeft = maxHorizontalDrag
207 | transformViews()
208 | }
209 | child.layout(rootLeft, top, rootLeft + (right - left), bottom)
210 | } else {
211 | child.layout(left, top, right, bottom)
212 | }
213 | }
214 | }
215 |
216 | private inner class ViewDragCallback : ViewDragHelper.Callback() {
217 |
218 | override fun tryCaptureView(child: View, pointerId: Int): Boolean {
219 | if (isClosed) {
220 | return child === mainView
221 | } else {
222 | if (child != mainView) {
223 | dragHelper.captureChildView(mainView, pointerId)
224 | return false
225 | }
226 | return true
227 | }
228 | }
229 |
230 | override fun getViewHorizontalDragRange(child: View): Int {
231 | return if (child === mainView) maxHorizontalDrag else 0
232 | }
233 |
234 | override fun clampViewPositionHorizontal(child: View, left: Int, dx: Int): Int {
235 | return Math.max(0, Math.min(left, maxHorizontalDrag))
236 | }
237 |
238 | override fun onViewReleased(releasedChild: View, xvel: Float, yvel: Float) {
239 | if (xvel > 0) {
240 | dragHelper.settleCapturedViewAt(maxHorizontalDrag, mainView.top)
241 | } else {
242 | dragHelper.settleCapturedViewAt(0, mainView.top)
243 | }
244 | invalidate()
245 | }
246 |
247 | override fun onViewPositionChanged(changedView: View, left: Int, top: Int, dx: Int, dy: Int) {
248 | dragProgress = left.toFloat() / maxHorizontalDrag
249 | drawerListener?.onDrawerSlide(parentLayout, dragProgress)
250 | transformViews()
251 | invalidate()
252 | }
253 |
254 | override fun onViewDragStateChanged(state: Int) {
255 | super.onViewDragStateChanged(state)
256 | isClosed = dragProgress == 0f
257 | if (state != ViewDragHelper.STATE_IDLE && dragState == ViewDragHelper.STATE_IDLE) {
258 | // starts
259 | drawerListener?.onDrawerStateChanged(DrawerLayout.STATE_DRAGGING)
260 | } else if (state == ViewDragHelper.STATE_IDLE && dragState != ViewDragHelper.STATE_IDLE) {
261 | // ends
262 | if (isClosed) {
263 | drawerListener?.onDrawerClosed(parentLayout)
264 | } else {
265 | drawerListener?.onDrawerOpened(parentLayout)
266 | }
267 |
268 | drawerListener?.onDrawerStateChanged(DrawerLayout.STATE_IDLE)
269 | }
270 | dragState = state
271 | }
272 | }
273 |
274 | private fun transformViews() {
275 | for (i in 0 until menus.size) {
276 | var progress = (dragProgress - i.toFloat()/menus.size)/(1f - i.toFloat()/menus.size)
277 | progress = Math.max(0f, progress)
278 | transformation?.transform(progress, menus[i].getChildAt(0))
279 | }
280 | }
281 | }
282 |
--------------------------------------------------------------------------------