= listOf(
131 | TransformerItem(DefaultTransformer::class.java),
132 | TransformerItem(AccordionTransformer::class.java),
133 | TransformerItem(BackgroundToForegroundTransformer::class.java),
134 | TransformerItem(CubeInTransformer::class.java),
135 | TransformerItem(CubeOutTransformer::class.java),
136 | TransformerItem(DepthPageTransformer::class.java),
137 | TransformerItem(FlipHorizontalTransformer::class.java),
138 | TransformerItem(FlipVerticalTransformer::class.java),
139 | TransformerItem(ForegroundToBackgroundTransformer::class.java),
140 | TransformerItem(RotateDownTransformer::class.java),
141 | TransformerItem(RotateUpTransformer::class.java),
142 | TransformerItem(ScaleInOutTransformer::class.java),
143 | TransformerItem(StackTransformer::class.java),
144 | TransformerItem(TabletTransformer::class.java),
145 | TransformerItem(ZoomInTransformer::class.java),
146 | TransformerItem(ZoomOutSlideTransformer::class.java),
147 | TransformerItem(ZoomOutTransformer::class.java),
148 | TransformerItem(DrawerTransformer::class.java)
149 | )
150 |
151 | }
152 |
153 | }
154 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ToxicBakery/ViewPagerTransforms/2c3ffe13c43467d5d0ae2ec5e2bcd95c6391817d/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
21 |
22 |
28 |
29 |
33 |
34 |
35 |
36 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | ViewPagerTransforms Example
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
22 |
23 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
18 |
19 | buildscript {
20 | ext.android_target_sdk = 28
21 | ext.android_build_tools_version = '28.0.3'
22 |
23 | ext.kotlin_version = '1.3.50'
24 | ext.jacoco_version = '0.8.1'
25 | ext.dokka_version = '0.9.17'
26 |
27 | ext.android_support_version = '28.0.0'
28 |
29 | repositories {
30 | google()
31 | jcenter()
32 | }
33 | dependencies {
34 | classpath 'com.android.tools.build:gradle:3.5.1'
35 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
36 | classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
37 | classpath 'digital.wup:android-maven-publish:3.6.2'
38 | classpath "org.jacoco:org.jacoco.core:$jacoco_version"
39 | }
40 | }
41 |
42 | ext {
43 | tagName = System.getenv('CIRCLE_TAG')
44 | isTag = tagName != null && !tagName.isEmpty()
45 | buildNumber = System.getenv('CIRCLE_BUILD_NUM') ?: "0"
46 | isCi = buildNumber != "0"
47 | maxDexHeap = "2g"
48 | }
49 |
50 | subprojects {
51 | group 'com.ToxicBakery.viewpager.transforms'
52 | version "2.0.${buildNumber}" + (isTag ? "" : "-SNAPSHOT")
53 |
54 | repositories {
55 | google()
56 | mavenCentral()
57 | jcenter()
58 | }
59 | }
60 |
61 | task clean(type: Delete) {
62 | delete rootProject.buildDir
63 | }
64 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2014 Toxic Bakery
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | POM_NAME=ViewPagerTransforms
18 | POM_ARTIFACT_ID=view-pager-transforms
19 | POM_PACKAGING=aar
20 | POM_DESCRIPTION=Library containing common animations needed for transforming ViewPager scrolling on Android v13+
21 | POM_URL=https://github.com/ToxicBakery/ViewPagerTransforms
22 | POM_SCM_URL=https://github.com/ToxicBakery/ViewPagerTransforms.git
23 | POM_SCM_CONNECTION=scm:git@github.com:ToxicBakery/ViewPagerTransforms.git
24 | POM_SCM_DEV_CONNECTION=scm:git@github.com:ToxicBakery/ViewPagerTransforms.git
25 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
26 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
27 | POM_LICENCE_DIST=repo
28 | POM_DEVELOPER_ID=toxicbakery
29 | POM_DEVELOPER_NAME=Ian Thomas
30 | POM_DEVELOPER_EMAIL=toxicbakery@gmail.com
31 | POM_DEVELOPER_ORGANIZATION=Toxic Bakery
32 | POM_DEVELOPER_ORGANIZATION_URL=https://github.com/ToxicBakery
33 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ToxicBakery/ViewPagerTransforms/2c3ffe13c43467d5d0ae2ec5e2bcd95c6391817d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Nov 02 19:53:49 CET 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-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | plugins {
18 | id("io.gitlab.arturbosch.detekt").version("1.0.0-RC12")
19 | }
20 |
21 | apply plugin: 'com.android.library'
22 | apply plugin: 'kotlin-android'
23 |
24 | repositories {
25 | google()
26 | jcenter()
27 | mavenCentral()
28 | }
29 |
30 | android {
31 | compileSdkVersion android_target_sdk
32 | buildToolsVersion = android_build_tools_version
33 |
34 | defaultConfig {
35 | minSdkVersion 14
36 | targetSdkVersion android_target_sdk
37 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
38 | }
39 |
40 | buildTypes {
41 | debug {
42 | testCoverageEnabled true
43 | }
44 | release {
45 | minifyEnabled false
46 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
47 | }
48 | }
49 |
50 | lintOptions {
51 | abortOnError false
52 | }
53 |
54 | testOptions {
55 | animationsDisabled true
56 | unitTests {
57 | returnDefaultValues = true
58 | includeAndroidResources = true
59 | }
60 | }
61 |
62 | dexOptions {
63 | // Skip pre-dexing when running on CI
64 | preDexLibraries = !isCi
65 | javaMaxHeapSize maxDexHeap
66 | }
67 | }
68 |
69 | dependencies {
70 | implementation "com.android.support:support-v4:$android_support_version"
71 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
72 | }
73 |
74 | detekt {
75 | input = files("src/main/java")
76 | config = files("$projectDir/detekt.yml")
77 | parallel = true
78 | reports {
79 | xml.enabled = false
80 | html {
81 | enabled = true
82 | destination = file("build/reports/detekt/detekt.html")
83 | }
84 | }
85 | }
86 | check.dependsOn('detekt')
87 |
88 | apply from: "${rootDir}/publish.gradle"
89 |
90 | task dokkaGhPages(type: org.jetbrains.dokka.gradle.DokkaAndroidTask) {
91 | outputFormat = 'html'
92 | outputDirectory = "$buildDir/gh-pages"
93 | sourceDirs = files('src/main/java')
94 | skipEmptyPackages = true
95 | skipDeprecated = false
96 | noStdlibLink = false
97 | }
98 |
99 | task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaAndroidTask) {
100 | outputFormat = 'javadoc'
101 | outputDirectory = "$buildDir/javadoc"
102 | sourceDirs = files('src/main/java')
103 | skipEmptyPackages = true
104 | skipDeprecated = false
105 | noStdlibLink = false
106 | }
107 |
--------------------------------------------------------------------------------
/library/detekt.yml:
--------------------------------------------------------------------------------
1 | autoCorrect: true
2 | failFast: false
3 |
4 | test-pattern: # Configure exclusions for test sources
5 | active: true
6 | patterns: # Test file regexes
7 | - '.*/test/.*'
8 | - '.*Test.kt'
9 | - '.*Spec.kt'
10 | exclude-rule-sets:
11 | - 'comments'
12 | exclude-rules:
13 | - 'NamingRules'
14 | - 'WildcardImport'
15 | - 'MagicNumber'
16 | - 'MaxLineLength'
17 | - 'LateinitUsage'
18 | - 'StringLiteralDuplication'
19 | - 'SpreadOperator'
20 | - 'TooManyFunctions'
21 | - 'ForEachOnRange'
22 | - 'FunctionMaxLength'
23 | - 'TooGenericExceptionCaught'
24 |
25 | build:
26 | maxIssues: 0
27 | weights:
28 | # complexity: 2
29 | # LongParameterList: 1
30 | # style: 1
31 | # comments: 1
32 |
33 | processors:
34 | active: true
35 | exclude:
36 | # - 'FunctionCountProcessor'
37 | # - 'PropertyCountProcessor'
38 | # - 'ClassCountProcessor'
39 | # - 'PackageCountProcessor'
40 | # - 'KtFileCountProcessor'
41 |
42 | console-reports:
43 | active: true
44 | exclude:
45 | # - 'ProjectStatisticsReport'
46 | # - 'ComplexityReport'
47 | # - 'NotificationReport'
48 | # - 'FindingsReport'
49 | # - 'BuildFailureReport'
50 |
51 | comments:
52 | active: true
53 | CommentOverPrivateFunction:
54 | active: false
55 | CommentOverPrivateProperty:
56 | active: false
57 | EndOfSentenceFormat:
58 | active: false
59 | endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!]$)
60 | UndocumentedPublicClass:
61 | active: false
62 | searchInNestedClass: true
63 | searchInInnerClass: true
64 | searchInInnerObject: true
65 | searchInInnerInterface: true
66 | UndocumentedPublicFunction:
67 | active: false
68 |
69 | complexity:
70 | active: true
71 | ComplexCondition:
72 | active: true
73 | threshold: 4
74 | ComplexInterface:
75 | active: false
76 | threshold: 10
77 | includeStaticDeclarations: false
78 | ComplexMethod:
79 | active: true
80 | threshold: 10
81 | ignoreSingleWhenExpression: false
82 | ignoreSimpleWhenEntries: false
83 | LabeledExpression:
84 | active: false
85 | ignoredLabels: ""
86 | LargeClass:
87 | active: true
88 | threshold: 150
89 | LongMethod:
90 | active: true
91 | threshold: 20
92 | LongParameterList:
93 | active: true
94 | threshold: 6
95 | ignoreDefaultParameters: false
96 | MethodOverloading:
97 | active: false
98 | threshold: 6
99 | NestedBlockDepth:
100 | active: true
101 | threshold: 4
102 | StringLiteralDuplication:
103 | active: false
104 | threshold: 3
105 | ignoreAnnotation: true
106 | excludeStringsWithLessThan5Characters: true
107 | ignoreStringsRegex: '$^'
108 | TooManyFunctions:
109 | active: true
110 | thresholdInFiles: 11
111 | thresholdInClasses: 11
112 | thresholdInInterfaces: 11
113 | thresholdInObjects: 11
114 | thresholdInEnums: 11
115 | ignoreDeprecated: false
116 | ignorePrivate: false
117 |
118 | empty-blocks:
119 | active: true
120 | EmptyCatchBlock:
121 | active: true
122 | allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
123 | EmptyClassBlock:
124 | active: true
125 | EmptyDefaultConstructor:
126 | active: true
127 | EmptyDoWhileBlock:
128 | active: true
129 | EmptyElseBlock:
130 | active: true
131 | EmptyFinallyBlock:
132 | active: true
133 | EmptyForBlock:
134 | active: true
135 | EmptyFunctionBlock:
136 | active: true
137 | ignoreOverriddenFunctions: false
138 | EmptyIfBlock:
139 | active: true
140 | EmptyInitBlock:
141 | active: true
142 | EmptyKtFile:
143 | active: true
144 | EmptySecondaryConstructor:
145 | active: true
146 | EmptyWhenBlock:
147 | active: true
148 | EmptyWhileBlock:
149 | active: true
150 |
151 | exceptions:
152 | active: true
153 | ExceptionRaisedInUnexpectedLocation:
154 | active: false
155 | methodNames: 'toString,hashCode,equals,finalize'
156 | InstanceOfCheckForException:
157 | active: false
158 | NotImplementedDeclaration:
159 | active: false
160 | PrintStackTrace:
161 | active: false
162 | RethrowCaughtException:
163 | active: false
164 | ReturnFromFinally:
165 | active: false
166 | SwallowedException:
167 | active: false
168 | ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException'
169 | ThrowingExceptionFromFinally:
170 | active: false
171 | ThrowingExceptionInMain:
172 | active: false
173 | ThrowingExceptionsWithoutMessageOrCause:
174 | active: false
175 | exceptions: 'IllegalArgumentException,IllegalStateException,IOException'
176 | ThrowingNewInstanceOfSameException:
177 | active: false
178 | TooGenericExceptionCaught:
179 | active: true
180 | exceptionNames:
181 | - ArrayIndexOutOfBoundsException
182 | - Error
183 | - Exception
184 | - IllegalMonitorStateException
185 | - NullPointerException
186 | - IndexOutOfBoundsException
187 | - RuntimeException
188 | - Throwable
189 | allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
190 | TooGenericExceptionThrown:
191 | active: true
192 | exceptionNames:
193 | - Error
194 | - Exception
195 | - Throwable
196 | - RuntimeException
197 |
198 | formatting:
199 | active: true
200 | android: false
201 | autoCorrect: true
202 | ChainWrapping:
203 | active: true
204 | autoCorrect: true
205 | CommentSpacing:
206 | active: true
207 | autoCorrect: true
208 | Filename:
209 | active: true
210 | FinalNewline:
211 | active: true
212 | autoCorrect: true
213 | ImportOrdering:
214 | active: true
215 | autoCorrect: true
216 | Indentation:
217 | active: true
218 | autoCorrect: true
219 | indentSize: 4
220 | continuationIndentSize: 4
221 | MaximumLineLength:
222 | active: true
223 | maxLineLength: 120
224 | ModifierOrdering:
225 | active: true
226 | autoCorrect: true
227 | NoBlankLineBeforeRbrace:
228 | active: true
229 | autoCorrect: true
230 | NoConsecutiveBlankLines:
231 | active: true
232 | autoCorrect: true
233 | NoEmptyClassBody:
234 | active: true
235 | autoCorrect: true
236 | NoItParamInMultilineLambda:
237 | active: true
238 | NoLineBreakAfterElse:
239 | active: true
240 | autoCorrect: true
241 | NoLineBreakBeforeAssignment:
242 | active: true
243 | autoCorrect: true
244 | NoMultipleSpaces:
245 | active: true
246 | autoCorrect: true
247 | NoSemicolons:
248 | active: true
249 | autoCorrect: true
250 | NoTrailingSpaces:
251 | active: true
252 | autoCorrect: true
253 | NoUnitReturn:
254 | active: true
255 | autoCorrect: true
256 | NoUnusedImports:
257 | active: true
258 | autoCorrect: true
259 | NoWildcardImports:
260 | active: true
261 | autoCorrect: true
262 | PackageName:
263 | active: true
264 | autoCorrect: true
265 | ParameterListWrapping:
266 | active: true
267 | autoCorrect: true
268 | indentSize: 4
269 | SpacingAroundColon:
270 | active: true
271 | autoCorrect: true
272 | SpacingAroundComma:
273 | active: true
274 | autoCorrect: true
275 | SpacingAroundCurly:
276 | active: true
277 | autoCorrect: true
278 | SpacingAroundKeyword:
279 | active: true
280 | autoCorrect: true
281 | SpacingAroundOperators:
282 | active: true
283 | autoCorrect: true
284 | SpacingAroundParens:
285 | active: true
286 | autoCorrect: true
287 | SpacingAroundRangeOperator:
288 | active: true
289 | autoCorrect: true
290 | StringTemplate:
291 | active: true
292 | autoCorrect: true
293 |
294 | naming:
295 | active: true
296 | ClassNaming:
297 | active: true
298 | classPattern: '[A-Z$][a-zA-Z0-9$]*'
299 | ConstructorParameterNaming:
300 | active: true
301 | parameterPattern: '[a-z][A-Za-z0-9]*'
302 | privateParameterPattern: '[a-z][A-Za-z0-9]*'
303 | excludeClassPattern: '$^'
304 | EnumNaming:
305 | active: true
306 | enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*'
307 | ForbiddenClassName:
308 | active: false
309 | forbiddenName: ''
310 | FunctionMaxLength:
311 | active: false
312 | maximumFunctionNameLength: 30
313 | FunctionMinLength:
314 | active: false
315 | minimumFunctionNameLength: 3
316 | FunctionNaming:
317 | active: true
318 | functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
319 | excludeClassPattern: '$^'
320 | ignoreOverridden: true
321 | FunctionParameterNaming:
322 | active: true
323 | parameterPattern: '[a-z][A-Za-z0-9]*'
324 | excludeClassPattern: '$^'
325 | ignoreOverriddenFunctions: true
326 | MatchingDeclarationName:
327 | active: true
328 | MemberNameEqualsClassName:
329 | active: false
330 | ignoreOverriddenFunction: true
331 | ObjectPropertyNaming:
332 | active: true
333 | constantPattern: '[A-Za-z][_A-Za-z0-9]*'
334 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
335 | privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*'
336 | PackageNaming:
337 | active: false
338 | packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$'
339 | TopLevelPropertyNaming:
340 | active: true
341 | constantPattern: '[A-Z][_A-Z0-9]*'
342 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
343 | privatePropertyPattern: '(_)?[A-Za-z][A-Za-z0-9]*'
344 | VariableMaxLength:
345 | active: false
346 | maximumVariableNameLength: 64
347 | VariableMinLength:
348 | active: false
349 | minimumVariableNameLength: 1
350 | VariableNaming:
351 | active: true
352 | variablePattern: '[a-z][A-Za-z0-9]*'
353 | privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
354 | excludeClassPattern: '$^'
355 | ignoreOverridden: true
356 |
357 | performance:
358 | active: true
359 | ArrayPrimitive:
360 | active: false
361 | ForEachOnRange:
362 | active: true
363 | SpreadOperator:
364 | active: true
365 | UnnecessaryTemporaryInstantiation:
366 | active: true
367 |
368 | potential-bugs:
369 | active: true
370 | DuplicateCaseInWhenExpression:
371 | active: true
372 | EqualsAlwaysReturnsTrueOrFalse:
373 | active: false
374 | EqualsWithHashCodeExist:
375 | active: true
376 | ExplicitGarbageCollectionCall:
377 | active: true
378 | InvalidRange:
379 | active: false
380 | IteratorHasNextCallsNextMethod:
381 | active: false
382 | IteratorNotThrowingNoSuchElementException:
383 | active: false
384 | LateinitUsage:
385 | active: false
386 | excludeAnnotatedProperties: ""
387 | ignoreOnClassesPattern: ""
388 | UnconditionalJumpStatementInLoop:
389 | active: false
390 | UnreachableCode:
391 | active: true
392 | UnsafeCallOnNullableType:
393 | active: false
394 | UnsafeCast:
395 | active: false
396 | UselessPostfixExpression:
397 | active: false
398 | WrongEqualsTypeParameter:
399 | active: false
400 |
401 | style:
402 | active: true
403 | CollapsibleIfStatements:
404 | active: false
405 | DataClassContainsFunctions:
406 | active: false
407 | conversionFunctionPrefix: 'to'
408 | EqualsNullCall:
409 | active: false
410 | EqualsOnSignatureLine:
411 | active: false
412 | ExplicitItLambdaParameter:
413 | active: false
414 | ExpressionBodySyntax:
415 | active: false
416 | includeLineWrapping: false
417 | ForbiddenComment:
418 | active: true
419 | values: 'TODO:,FIXME:,STOPSHIP:'
420 | ForbiddenImport:
421 | active: false
422 | imports: ''
423 | ForbiddenVoid:
424 | active: false
425 | FunctionOnlyReturningConstant:
426 | active: false
427 | ignoreOverridableFunction: true
428 | excludedFunctions: 'describeContents'
429 | LoopWithTooManyJumpStatements:
430 | active: false
431 | maxJumpCount: 1
432 | MagicNumber:
433 | active: true
434 | ignoreNumbers: '-1,0,1,2,0.5,-0.5,0.25,90,-90,180,-180'
435 | ignoreHashCodeFunction: true
436 | ignorePropertyDeclaration: false
437 | ignoreConstantDeclaration: true
438 | ignoreCompanionObjectPropertyDeclaration: true
439 | ignoreAnnotation: false
440 | ignoreNamedArgument: true
441 | ignoreEnums: false
442 | MandatoryBracesIfStatements:
443 | active: false
444 | MaxLineLength:
445 | active: true
446 | maxLineLength: 120
447 | excludePackageStatements: true
448 | excludeImportStatements: true
449 | excludeCommentStatements: false
450 | MayBeConst:
451 | active: false
452 | ModifierOrder:
453 | active: true
454 | NestedClassesVisibility:
455 | active: false
456 | NewLineAtEndOfFile:
457 | active: true
458 | NoTabs:
459 | active: false
460 | OptionalAbstractKeyword:
461 | active: true
462 | OptionalUnit:
463 | active: false
464 | OptionalWhenBraces:
465 | active: false
466 | PreferToOverPairSyntax:
467 | active: false
468 | ProtectedMemberInFinalClass:
469 | active: false
470 | RedundantVisibilityModifierRule:
471 | active: false
472 | ReturnCount:
473 | active: true
474 | max: 2
475 | excludedFunctions: "equals"
476 | excludeLabeled: false
477 | excludeReturnFromLambda: true
478 | SafeCast:
479 | active: true
480 | SerialVersionUIDInSerializableClass:
481 | active: false
482 | SpacingBetweenPackageAndImports:
483 | active: false
484 | ThrowsCount:
485 | active: true
486 | max: 2
487 | TrailingWhitespace:
488 | active: false
489 | UnnecessaryAbstractClass:
490 | active: false
491 | excludeAnnotatedClasses: "dagger.Module"
492 | UnnecessaryApply:
493 | active: false
494 | UnnecessaryInheritance:
495 | active: false
496 | UnnecessaryLet:
497 | active: false
498 | UnnecessaryParentheses:
499 | active: false
500 | UntilInsteadOfRangeTo:
501 | active: false
502 | UnusedImports:
503 | active: false
504 | UnusedPrivateClass:
505 | active: false
506 | UnusedPrivateMember:
507 | active: false
508 | allowedNames: "(_|ignored|expected|serialVersionUID)"
509 | UseDataClass:
510 | active: false
511 | excludeAnnotatedClasses: ""
512 | UtilityClassWithPublicConstructor:
513 | active: false
514 | VarCouldBeVal:
515 | active: false
516 | WildcardImport:
517 | active: true
518 | excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
--------------------------------------------------------------------------------
/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 C:/android/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 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/ABaseTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.support.v4.view.ViewPager.PageTransformer
20 | import android.view.View
21 |
22 | abstract class ABaseTransformer : PageTransformer {
23 |
24 | /**
25 | * Indicates if the default animations of the view pager should be used.
26 | *
27 | * @return
28 | */
29 | protected open val isPagingEnabled: Boolean
30 | get() = false
31 |
32 | /**
33 | * Called each [.transformPage].
34 | *
35 | * @param page
36 | * Apply the transformation to this page
37 | * @param position
38 | * Position of page relative to the current front-and-center position of the pager. 0 is front and
39 | * center. 1 is one full page position to the right, and -1 is one page position to the left.
40 | */
41 | protected abstract fun onTransform(page: View, position: Float)
42 |
43 | /**
44 | * Apply a property transformation to the given page. For most use cases, this method should not be overridden.
45 | * Instead use [.transformPage] to perform typical transformations.
46 | *
47 | * @param page
48 | * Apply the transformation to this page
49 | * @param position
50 | * Position of page relative to the current front-and-center position of the pager. 0 is front and
51 | * center. 1 is one full page position to the right, and -1 is one page position to the left.
52 | */
53 | override fun transformPage(page: View, position: Float) {
54 | val clampedPosition = clampPosition(position)
55 | onPreTransform(page, clampedPosition)
56 | onTransform(page, clampedPosition)
57 | onPostTransform(page, clampedPosition)
58 | }
59 |
60 | /**
61 | * Clamp the position. This step is required for some Android 4 devices.
62 | *
63 | * The position is dependant on the range of the ViewPager and whether it supports infinite scrolling in both
64 | * directions.
65 | *
66 | * On some devices it returns the position as NaN, so we set 0 as the fallback value
67 | *
68 | * @param position Position of page relative to the current front-and-center position of the pager.
69 | * @return A value between -1 and 1
70 | */
71 | private fun clampPosition(position: Float): Float {
72 | return when {
73 | position < -1f -> -1f
74 | position > 1f -> 1f
75 | position.isNaN() -> 0f
76 | else -> position
77 | }
78 | }
79 |
80 | /**
81 | * If the position offset of a fragment is less than negative one or greater than one, returning true will set the
82 | * fragment alpha to 0f. Otherwise fragment alpha is always defaulted to 1f.
83 | *
84 | * @return
85 | */
86 | protected open fun hideOffscreenPages(): Boolean {
87 | return true
88 | }
89 |
90 | /**
91 | * Called each [.transformPage] before {[.onTransform].
92 | *
93 | *
94 | * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
95 | * not modify the same page properties. For instance changing from a transformation that applies rotation to a
96 | * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
97 | * alpha.
98 | *
99 | * @param page
100 | * Apply the transformation to this page
101 | * @param position
102 | * Position of page relative to the current front-and-center position of the pager. 0 is front and
103 | * center. 1 is one full page position to the right, and -1 is one page position to the left.
104 | */
105 | protected open fun onPreTransform(page: View, position: Float) {
106 | val width = page.width.toFloat()
107 |
108 | page.rotationX = 0f
109 | page.rotationY = 0f
110 | page.rotation = 0f
111 | page.scaleX = 1f
112 | page.scaleY = 1f
113 | page.pivotX = 0f
114 | page.pivotY = 0f
115 | page.translationY = 0f
116 | page.translationX = if (isPagingEnabled) 0f else -width * position
117 |
118 | if (hideOffscreenPages()) {
119 | page.alpha = if (position <= -1f || position >= 1f) 0f else 1f
120 | page.isEnabled = false
121 | } else {
122 | page.isEnabled = true
123 | page.alpha = 1f
124 | }
125 | }
126 |
127 | /**
128 | * Called each [.transformPage] after [.onTransform].
129 | *
130 | * @param page
131 | * Apply the transformation to this page
132 | * @param position
133 | * Position of page relative to the current front-and-center position of the pager. 0 is front and
134 | * center. 1 is one full page position to the right, and -1 is one page position to the left.
135 | */
136 | protected open fun onPostTransform(page: View, position: Float) {}
137 |
138 | companion object {
139 |
140 | /**
141 | * Same as [Math.min] without double casting, zero closest to infinity handling, or NaN support.
142 | *
143 | * @param value
144 | * @param min
145 | * @return
146 | */
147 | @JvmStatic
148 | protected fun min(value: Float, min: Float): Float {
149 | return if (value < min) min else value
150 | }
151 | }
152 |
153 | }
154 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/AccordionTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class AccordionTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | page.pivotX = if (position < 0) 0f else page.width.toFloat()
25 | page.scaleX = if (position < 0) 1f + position else 1f - position
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/BackgroundToForegroundTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class BackgroundToForegroundTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | val height = page.height.toFloat()
25 | val width = page.width.toFloat()
26 | val scale = min(if (position < 0) 1f else Math.abs(1f - position), 0.5f)
27 |
28 | page.scaleX = scale
29 | page.scaleY = scale
30 | page.pivotX = width * 0.5f
31 | page.pivotY = height * 0.5f
32 | page.translationX = if (position < 0) width * position else -width * position * 0.25f
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/CubeInTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class CubeInTransformer : ABaseTransformer() {
22 |
23 | public override val isPagingEnabled: Boolean
24 | get() = true
25 |
26 | override fun onTransform(page: View, position: Float) {
27 | // Rotate the fragment on the left or right edge
28 | page.pivotX = if (position > 0) 0f else page.width.toFloat()
29 | page.pivotY = 0f
30 | page.rotationY = -90f * position
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/CubeOutTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class CubeOutTransformer @JvmOverloads constructor(
22 | private val distanceMultiplier: Int = 20
23 | ) : ABaseTransformer() {
24 |
25 | public override val isPagingEnabled: Boolean
26 | get() = true
27 |
28 | override fun onTransform(page: View, position: Float) {
29 | page.cameraDistance = (page.width * distanceMultiplier).toFloat()
30 | page.pivotX = if (position < 0f) page.width.toFloat() else 0f
31 | page.pivotY = page.height * 0.5f
32 | page.rotationY = 90f * position
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/DefaultTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class DefaultTransformer : ABaseTransformer() {
22 |
23 | public override val isPagingEnabled: Boolean
24 | get() = true
25 |
26 | override fun onTransform(page: View, position: Float) {}
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/DepthPageTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class DepthPageTransformer : ABaseTransformer() {
22 |
23 | override val isPagingEnabled: Boolean
24 | get() = true
25 |
26 | override fun onTransform(page: View, position: Float) {
27 | if (position <= 0f) {
28 | page.translationX = 0f
29 | page.scaleX = 1f
30 | page.scaleY = 1f
31 | } else if (position <= 1f) {
32 | val scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position))
33 | page.alpha = 1 - position
34 | page.pivotY = 0.5f * page.height
35 | page.translationX = page.width * -position
36 | page.scaleX = scaleFactor
37 | page.scaleY = scaleFactor
38 | }
39 | }
40 |
41 | companion object {
42 | private const val MIN_SCALE = 0.75f
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/DrawerTransformer.kt:
--------------------------------------------------------------------------------
1 | package com.ToxicBakery.viewpager.transforms
2 |
3 | import android.view.View
4 |
5 | /**
6 | * Created by dkzwm on 2017/3/2.
7 | *
8 | * @author dkzwm
9 | */
10 | open class DrawerTransformer : ABaseTransformer() {
11 |
12 | override fun onTransform(page: View, position: Float) {
13 | if (position <= 0) page.translationX = 0f
14 | else if (position <= 1) page.translationX = -page.width / 2 * position
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/FlipHorizontalTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class FlipHorizontalTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | val rotation = 180f * position
25 |
26 | page.alpha = if (rotation > 90f || rotation < -90f) 0f else 1f
27 | page.pivotX = page.width * 0.5f
28 | page.pivotY = page.height * 0.5f
29 | page.rotationY = rotation
30 | }
31 |
32 | override fun onPostTransform(page: View, position: Float) {
33 | super.onPostTransform(page, position)
34 |
35 | //resolve problem: new page can't handle click event!
36 | page.visibility = if (position > -0.5f && position < 0.5f) View.VISIBLE else View.INVISIBLE
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/FlipVerticalTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class FlipVerticalTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | val rotation = -180f * position
25 |
26 | page.alpha = if (rotation > 90f || rotation < -90f) 0f else 1f
27 | page.pivotX = page.width * 0.5f
28 | page.pivotY = page.height * 0.5f
29 | page.rotationX = rotation
30 | }
31 |
32 | override fun onPostTransform(page: View, position: Float) {
33 | super.onPostTransform(page, position)
34 | page.visibility = if (position > -0.5f && position < 0.5f) View.VISIBLE else View.INVISIBLE
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/ForegroundToBackgroundTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class ForegroundToBackgroundTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | val height = page.height.toFloat()
25 | val width = page.width.toFloat()
26 | val scale = min(if (position > 0) 1f else Math.abs(1f + position), 0.5f)
27 |
28 | page.scaleX = scale
29 | page.scaleY = scale
30 | page.pivotX = width * 0.5f
31 | page.pivotY = height * 0.5f
32 | page.translationX = if (position > 0) width * position else -width * position * 0.25f
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/RotateDownTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class RotateDownTransformer : ABaseTransformer() {
22 |
23 | override val isPagingEnabled: Boolean
24 | get() = true
25 |
26 | override fun onTransform(page: View, position: Float) {
27 | val width = page.width.toFloat()
28 | val height = page.height.toFloat()
29 | val rotation = ROT_MOD * position
30 |
31 | page.pivotX = width * 0.5f
32 | page.pivotY = height
33 | page.rotation = rotation
34 | }
35 |
36 | companion object {
37 | private const val ROT_MOD = 18.75f
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/RotateUpTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class RotateUpTransformer : ABaseTransformer() {
22 |
23 | override val isPagingEnabled: Boolean
24 | get() = true
25 |
26 | override fun onTransform(page: View, position: Float) {
27 | val width = page.width.toFloat()
28 | val rotation = ROT_MOD * position
29 |
30 | page.pivotX = width * 0.5f
31 | page.pivotY = 0f
32 | page.translationX = 0f
33 | page.rotation = rotation
34 | }
35 |
36 | companion object {
37 | private const val ROT_MOD = -15f
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/ScaleInOutTransformer.kt:
--------------------------------------------------------------------------------
1 | package com.ToxicBakery.viewpager.transforms
2 |
3 | import android.view.View
4 |
5 | open class ScaleInOutTransformer : ABaseTransformer() {
6 |
7 | override fun onTransform(page: View, position: Float) {
8 | page.pivotX = (if (position < 0) 0 else page.width).toFloat()
9 | page.pivotY = page.height / 2f
10 | val scale = if (position < 0) 1f + position else 1f - position
11 | page.scaleX = scale
12 | page.scaleY = scale
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/StackTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class StackTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | page.translationX = if (position < 0) 0f else -page.width * position
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/TabletTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.graphics.Camera
20 | import android.graphics.Matrix
21 | import android.view.View
22 |
23 | open class TabletTransformer : ABaseTransformer() {
24 |
25 | override fun onTransform(page: View, position: Float) {
26 | val rotation = if (position < 0) ROT_MOD else -ROT_MOD
27 | val rotationY = rotation * Math.abs(position)
28 |
29 | page.translationX = getOffsetXForRotation(rotationY, page.width, page.height)
30 | page.pivotX = page.width * 0.5f
31 | page.pivotY = 0f
32 | page.rotationY = rotationY
33 | }
34 |
35 | companion object {
36 | private val OFFSET_MATRIX = Matrix()
37 | private val OFFSET_CAMERA = Camera()
38 | private val OFFSET_TEMP_FLOAT = FloatArray(2)
39 | private const val ROT_MOD = 30f
40 |
41 | protected fun getOffsetXForRotation(degrees: Float, width: Int, height: Int): Float {
42 | OFFSET_MATRIX.reset()
43 | OFFSET_CAMERA.save()
44 | OFFSET_CAMERA.rotateY(Math.abs(degrees))
45 | OFFSET_CAMERA.getMatrix(OFFSET_MATRIX)
46 | OFFSET_CAMERA.restore()
47 |
48 | OFFSET_MATRIX.preTranslate(-width * 0.5f, -height * 0.5f)
49 | OFFSET_MATRIX.postTranslate(width * 0.5f, height * 0.5f)
50 | OFFSET_TEMP_FLOAT[0] = width.toFloat()
51 | OFFSET_TEMP_FLOAT[1] = height.toFloat()
52 | OFFSET_MATRIX.mapPoints(OFFSET_TEMP_FLOAT)
53 | return (width - OFFSET_TEMP_FLOAT[0]) * if (degrees > 0.0f) 1.0f else -1.0f
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/ZoomInTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class ZoomInTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | val scale = if (position < 0) position + 1f else Math.abs(1f - position)
25 | page.scaleX = scale
26 | page.scaleY = scale
27 | page.pivotX = page.width * 0.5f
28 | page.pivotY = page.height * 0.5f
29 | page.alpha = if (position < -1f || position > 1f) 0f else 1f - (scale - 1f)
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/ZoomOutSlideTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class ZoomOutSlideTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | if (position >= -1 || position <= 1) {
25 | // Modify the default slide transition to shrink the page as well
26 | val height = page.height.toFloat()
27 | val width = page.width.toFloat()
28 | val scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position))
29 | val vertMargin = height * (1 - scaleFactor) / 2
30 | val horzMargin = width * (1 - scaleFactor) / 2
31 |
32 | // Center vertically
33 | page.pivotY = 0.5f * height
34 | page.pivotX = 0.5f * width
35 |
36 | page.translationX =
37 | if (position < 0) horzMargin - vertMargin / 2
38 | else -horzMargin + vertMargin / 2
39 |
40 | // Scale the page down (between MIN_SCALE and 1)
41 | page.scaleX = scaleFactor
42 | page.scaleY = scaleFactor
43 |
44 | // Fade the page relative to its size.
45 | page.alpha = MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA)
46 | }
47 | }
48 |
49 | companion object {
50 | private const val MIN_SCALE = 0.85f
51 | private const val MIN_ALPHA = 0.5f
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ToxicBakery/viewpager/transforms/ZoomOutTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ToxicBakery.viewpager.transforms
18 |
19 | import android.view.View
20 |
21 | open class ZoomOutTransformer : ABaseTransformer() {
22 |
23 | override fun onTransform(page: View, position: Float) {
24 | val scale = 1f + Math.abs(position)
25 | page.scaleX = scale
26 | page.scaleY = scale
27 | page.pivotX = page.width * 0.5f
28 | page.pivotY = page.height * 0.5f
29 | page.alpha = if (position < -1f || position > 1f) 0f else 1f - (scale - 1f)
30 | if (position == -1f) page.translationX = (page.width * -1).toFloat()
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/library/src/main/res/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ToxicBakery/ViewPagerTransforms/2c3ffe13c43467d5d0ae2ec5e2bcd95c6391817d/library/src/main/res/.gitignore
--------------------------------------------------------------------------------
/maven.keystore.gpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ToxicBakery/ViewPagerTransforms/2c3ffe13c43467d5d0ae2ec5e2bcd95c6391817d/maven.keystore.gpg
--------------------------------------------------------------------------------
/publish.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'org.jetbrains.dokka-android'
2 | apply plugin: 'digital.wup.android-maven-publish'
3 | apply plugin: 'signing'
4 | apply plugin: 'jacoco'
5 |
6 | jacoco {
7 | toolVersion = '0.8.1'
8 | }
9 |
10 | tasks.withType(Test) {
11 | jacoco.includeNoLocationClasses = true
12 | }
13 |
14 | task jacocoTestReport(type: JacocoReport) {
15 | group = "Reporting"
16 | description = "Combine code coverage to unified report."
17 |
18 | reports {
19 | xml.enabled = true
20 | html.enabled = true
21 | }
22 |
23 | def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
24 | def debugTree = fileTree(dir: "${project.buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes", excludes: fileFilter)
25 | def mainSrc = "${project.projectDir}/src/main/java"
26 | def ecSrc = fileTree(dir: "$project.buildDir", include: "**/*.ec")
27 | def execSrc = fileTree(dir: "$project.buildDir", include: "**/*.exec")
28 |
29 | doFirst {
30 | def files = files([ecSrc, execSrc]).files
31 | println "Creating Jacoco Report for ${files.size()} coverage files"
32 | files.each { file -> println file }
33 | }
34 |
35 | sourceDirectories = files([mainSrc])
36 | classDirectories = files([debugTree])
37 | executionData = files([ecSrc, execSrc])
38 | }
39 |
40 | dokka {
41 | outputFormat = 'javadoc'
42 | outputDirectory = "$buildDir/javadoc"
43 | sourceDirs = files('src/main/java')
44 | skipEmptyPackages = true
45 | skipDeprecated = false
46 | noStdlibLink = false
47 | }
48 |
49 | task dokkaJar(type: Jar, dependsOn: dokka) {
50 | classifier = 'javadoc'
51 | from "$buildDir/javadoc"
52 | }
53 |
54 | task androidSourcesJar(type: Jar) {
55 | classifier = 'sources'
56 | from android.sourceSets.main.java.srcDirs
57 | }
58 |
59 | publishing {
60 | publications {
61 | mavenAar(MavenPublication) {
62 | from components.android
63 | groupId group
64 | artifactId POM_ARTIFACT_ID
65 | version version
66 |
67 | artifact dokkaJar
68 | artifact androidSourcesJar
69 |
70 | pom.withXml {
71 | def root = asNode()
72 |
73 | root.children().last() + {
74 | resolveStrategy = DELEGATE_FIRST
75 |
76 | description POM_DESCRIPTION
77 | name POM_NAME
78 | url POM_URL
79 | scm {
80 | url POM_SCM_URL
81 | connection POM_SCM_CONNECTION
82 | developerConnection POM_SCM_DEV_CONNECTION
83 | }
84 | licenses {
85 | license {
86 | name POM_LICENCE_NAME
87 | url POM_LICENCE_URL
88 | distribution POM_LICENCE_DIST
89 | }
90 | }
91 | developers {
92 | developer {
93 | id POM_DEVELOPER_ID
94 | name POM_DEVELOPER_NAME
95 | email POM_DEVELOPER_EMAIL
96 | organization POM_DEVELOPER_ORGANIZATION
97 | organizationUrl POM_DEVELOPER_ORGANIZATION_URL
98 | }
99 | }
100 | }
101 | }
102 | }
103 | }
104 |
105 | repositories {
106 | def releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
107 | def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots"
108 |
109 | maven {
110 | url !version.contains("SNAPSHOT") ? releaseUrl : snapshotUrl
111 | credentials {
112 | username System.getenv('SONATYPE_USERNAME') ?: ""
113 | password System.getenv('SONATYPE_PASSWORD') ?: ""
114 | }
115 | }
116 | }
117 | }
118 |
119 | signing {
120 | required false
121 | sign publishing.publications
122 | }
123 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | include ':app', ':library'
18 |
--------------------------------------------------------------------------------