├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── values-v21 │ │ │ └── styles.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ ├── card.xml │ │ │ ├── activity_main.xml │ │ │ └── settings_card.xml │ │ ├── java │ │ └── com │ │ │ └── mutualmobile │ │ │ └── cardstack │ │ │ └── sample │ │ │ ├── interfaces │ │ │ └── OnRestartRequest.kt │ │ │ ├── SampleApplication.kt │ │ │ ├── MainActivity.kt │ │ │ ├── utils │ │ │ └── PrefsUtil.kt │ │ │ └── adapters │ │ │ └── MyCardStackAdapter.kt │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── cardstack ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── integers.xml │ │ │ ├── ids.xml │ │ │ ├── dimens.xml │ │ │ └── attrs.xml │ │ ├── values-hdpi │ │ │ └── integers.xml │ │ ├── values-ldpi │ │ │ └── integers.xml │ │ ├── values-mdpi │ │ │ └── integers.xml │ │ ├── values-xhdpi │ │ │ └── integers.xml │ │ ├── values-xxhdpi │ │ │ └── integers.xml │ │ └── values-xxxhdpi │ │ │ └── integers.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── mutualmobile │ │ └── cardstack │ │ ├── utils │ │ └── Units.kt │ │ ├── CardFrameLayout.kt │ │ ├── CardStackLayout.kt │ │ └── CardStackAdapter.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── images └── showcase │ ├── BasicDrag.gif │ ├── Card Click.gif │ ├── PrallaxDrag.gif │ ├── CardClick0.0.6.gif │ ├── InitAnimation.gif │ └── InitAnimation0.0.6.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .travis.yml ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /cardstack/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':cardstack' 2 | -------------------------------------------------------------------------------- /images/showcase/BasicDrag.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/images/showcase/BasicDrag.gif -------------------------------------------------------------------------------- /images/showcase/Card Click.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/images/showcase/Card Click.gif -------------------------------------------------------------------------------- /images/showcase/PrallaxDrag.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/images/showcase/PrallaxDrag.gif -------------------------------------------------------------------------------- /cardstack/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CardStack 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /images/showcase/CardClick0.0.6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/images/showcase/CardClick0.0.6.gif -------------------------------------------------------------------------------- /images/showcase/InitAnimation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/images/showcase/InitAnimation.gif -------------------------------------------------------------------------------- /images/showcase/InitAnimation0.0.6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/images/showcase/InitAnimation0.0.6.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mutualmobile/CardStackUI/HEAD/app/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /cardstack/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -2 4 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values-hdpi/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -3 4 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values-ldpi/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -1 4 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values-mdpi/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -2 4 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values-xhdpi/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -4 4 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values-xxhdpi/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -6 4 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values-xxxhdpi/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -8 4 | -------------------------------------------------------------------------------- /app/src/main/java/com/mutualmobile/cardstack/sample/interfaces/OnRestartRequest.kt: -------------------------------------------------------------------------------- 1 | package com.mutualmobile.cardstack.sample.interfaces 2 | 3 | interface OnRestartRequest { 4 | fun requestRestart() 5 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | android: 4 | components: 5 | - tools 6 | - build-tools-28.0.3 7 | - android-28 8 | - extra-android-m2repository 9 | script: 10 | - ./gradlew assemble 11 | -------------------------------------------------------------------------------- /cardstack/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Apr 25 11:12:14 IST 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.1.1-all.zip -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 60dp 4 | 5dp 5 | 30dp 6 | 8dp 7 | 10dp 8 | 80dp 9 | 5dp 10 | 16dp 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # IDEA files 26 | .idea/ 27 | *.iml 28 | 29 | # Mac files 30 | .DS_Store 31 | -------------------------------------------------------------------------------- /cardstack/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/mutualmobile/cardstack/sample/SampleApplication.kt: -------------------------------------------------------------------------------- 1 | package com.mutualmobile.cardstack.sample 2 | 3 | import android.app.Application 4 | import com.tramsun.libs.prefcompat.Pref 5 | import timber.log.Timber 6 | import timber.log.Timber.DebugTree 7 | 8 | class SampleApplication : Application() { 9 | override fun onCreate() { 10 | super.onCreate() 11 | 12 | Pref.init(this) 13 | 14 | if (BuildConfig.DEBUG) { 15 | Timber.plant(DebugTree()) 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /cardstack/src/main/java/com/mutualmobile/cardstack/utils/Units.kt: -------------------------------------------------------------------------------- 1 | package com.mutualmobile.cardstack.utils 2 | 3 | import android.content.Context 4 | import android.util.TypedValue 5 | import android.view.View 6 | 7 | object Units { 8 | fun dpToPx( 9 | context: Context, 10 | dp: Int 11 | ): Int { 12 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp.toFloat(), context.resources.displayMetrics) 13 | .toInt() 14 | } 15 | 16 | fun getAbsoluteTop(view: View): Int { 17 | val rect = IntArray(2) 18 | view.getLocationInWindow(rect) 19 | return rect[1] 20 | } 21 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/tushar/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /cardstack/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 /Users/tushar/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CardStack Sample 3 | CardStack Sample 4 | Show Init Animation 5 | Parallax Enabled 6 | Parallax Scale 7 | Gap Between Cards (in dp) 8 | Gap Between Cards when collapsed (in dp) 9 | Settings 10 | Apply and Restart 11 | Reset Defaults 12 | Card %1$d 13 | Reverse Click Animation 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #607D8B 4 | #37474F 5 | #FFC107 6 | 7 | #0e8df2 8 | #00a6b0 9 | #7094ed 10 | #ed7094 11 | #edca70 12 | #0b78ce 13 | #ed8b70 14 | #70edca 15 | #ed7093 16 | #59b0f6 17 | #ccb3c7 18 | #70ede9 19 | #455A64 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 22 | -------------------------------------------------------------------------------- /cardstack/src/main/java/com/mutualmobile/cardstack/CardFrameLayout.kt: -------------------------------------------------------------------------------- 1 | package com.mutualmobile.cardstack 2 | 3 | import android.annotation.SuppressLint 4 | import android.view.View 5 | import android.widget.FrameLayout 6 | 7 | /** 8 | * Created by tushar on 7/18/16. 9 | */ 10 | @SuppressLint("ViewConstructor") 11 | internal class CardFrameLayout(private val parent: CardStackLayout) : FrameLayout(parent.context) { 12 | 13 | override fun onMeasure( 14 | widthMeasureSpec: Int, 15 | heightMeasureSpec: Int 16 | ) { 17 | var heightMeasureSpecs = heightMeasureSpec 18 | val mAdapter = parent.adapter 19 | if (mAdapter != null) { 20 | val height = (mAdapter.fullCardHeight + (mAdapter.count - 1) * parent.cardGap).toInt() 21 | heightMeasureSpecs = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY) 22 | } 23 | 24 | super.onMeasure(widthMeasureSpec, heightMeasureSpecs) 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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android-extensions' 3 | apply plugin: 'kotlin-android' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.COMPILE_SDK_VERSION 7 | 8 | defaultConfig { 9 | applicationId "com.mutualmobile.cardstack.sample" 10 | 11 | minSdkVersion rootProject.ext.MIN_SDK_VERSION 12 | targetSdkVersion rootProject.ext.TARGET_SDK_VERSION 13 | 14 | versionCode 1 15 | versionName "1.0" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled true 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | debug { 23 | debuggable true 24 | minifyEnabled false 25 | } 26 | } 27 | } 28 | 29 | dependencies { 30 | compile fileTree(dir: 'libs', include: ['*.jar']) 31 | implementation "com.android.support:cardview-v7:${rootProject.ext.SUPPORT_LIB_VERSION}" 32 | implementation "com.android.support:animated-vector-drawable:${rootProject.ext.SUPPORT_LIB_VERSION}" 33 | implementation "com.android.support:appcompat-v7:${rootProject.ext.SUPPORT_LIB_VERSION}" 34 | implementation 'com.tramsun.libs:prefcompat:0.7' 35 | implementation 'com.mutualmobile.android:cardstack:0.5.3' 36 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 37 | implementation 'com.jakewharton.timber:timber:4.7.1' 38 | } 39 | repositories { 40 | mavenCentral() 41 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mutualmobile/cardstack/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mutualmobile.cardstack.sample 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import android.view.View 6 | 7 | import com.mutualmobile.cardstack.CardStackLayout 8 | import com.mutualmobile.cardstack.sample.adapters.MyCardStackAdapter 9 | import com.mutualmobile.cardstack.sample.interfaces.OnRestartRequest 10 | import com.mutualmobile.cardstack.sample.utils.PrefsUtil 11 | import com.mutualmobile.cardstack.utils.Units 12 | import timber.log.Timber 13 | 14 | class MainActivity : AppCompatActivity(), OnRestartRequest { 15 | 16 | private var mCardStackLayout: CardStackLayout? = null 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | setContentView(R.layout.activity_main) 21 | 22 | mCardStackLayout = findViewById(R.id.cardStack) as CardStackLayout 23 | setupAdapter() 24 | } 25 | 26 | private fun setupAdapter() { 27 | 28 | mCardStackLayout?.isShowInitAnimation = PrefsUtil.isShowInitAnimationEnabled 29 | 30 | mCardStackLayout?.isParallaxEnabled = PrefsUtil.isParallaxEnabled 31 | mCardStackLayout?.parallaxScale = PrefsUtil.getParallaxScale(this) 32 | 33 | mCardStackLayout?.cardGap = Units.dpToPx(this, PrefsUtil.getCardGap(this)) 34 | .toFloat() 35 | mCardStackLayout?.cardGapBottom = Units.dpToPx(this, PrefsUtil.getCardGapBottom(this)) 36 | .toFloat() 37 | 38 | mCardStackLayout?.adapter = MyCardStackAdapter(this) 39 | } 40 | 41 | override fun onBackPressed() { 42 | mCardStackLayout?.let { 43 | if (it.isCardSelected) { 44 | mCardStackLayout?.restoreCards() 45 | } else { 46 | super.onBackPressed() 47 | } 48 | } 49 | } 50 | 51 | override fun requestRestart() { 52 | Timber.d("Restarting MainActivity..") 53 | mCardStackLayout?.removeAdapter() 54 | 55 | mCardStackLayout?.postDelayed({ setupAdapter() }, 200) 56 | } 57 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CardStack 2 | An iOS Passbook-like highly customisable stack of cards implementation for Android. 3 | 4 | [![Build Status](https://travis-ci.org/mutualmobile/CardStackUI.svg?branch=master)](https://travis-ci.org/mutualmobile/CardStackUI) [![Version](https://api.bintray.com/packages/mutualmobile/Android/card-stack-ui/images/download.svg)](https://bintray.com/mutualmobile/Android/card-stack-ui) 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CardStackUI-green.svg?style=true)](https://android-arsenal.com/details/1/3096) 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

Init Animation

Card Click

17 | 18 | Complete Demo - https://www.youtube.com/watch?v=8VjEa_u3LkM 19 | 20 | Sample app APK - https://github.com/mutualmobile/CardStackUI/releases 21 | 22 | ### Gradle 23 | ``` 24 | dependencies { 25 | ... 26 | compile 'com.mutualmobile.android:cardstack:0.6.0' 27 | } 28 | ``` 29 | 30 | Usage 31 | ----- 32 | ```xml 33 | 43 | ``` 44 | 45 | Known Issues 46 | ------- 47 | 48 | ```parallax_enabled``` and ```parallax_scale``` are not working currently. Also the drag to move cards also is not working. 49 | 50 | License 51 | ------- 52 | 53 | Copyright 2015 - 2019 Mutual Mobile 54 | 55 | Licensed under the Apache License, Version 2.0 (the "License"); 56 | you may not use this file except in compliance with the License. 57 | You may obtain a copy of the License at 58 | 59 | http://www.apache.org/licenses/LICENSE-2.0 60 | 61 | Unless required by applicable law or agreed to in writing, software 62 | distributed under the License is distributed on an "AS IS" BASIS, 63 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 64 | See the License for the specific language governing permissions and 65 | limitations under the License. 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/mutualmobile/cardstack/sample/utils/PrefsUtil.kt: -------------------------------------------------------------------------------- 1 | package com.mutualmobile.cardstack.sample.utils 2 | 3 | import android.content.Context 4 | 5 | import com.mutualmobile.cardstack.CardStackLayout 6 | import com.mutualmobile.cardstack.sample.R.dimen 7 | import com.tramsun.libs.prefcompat.Pref 8 | 9 | object PrefsUtil { 10 | 11 | const val SHOW_INIT_ANIMATION = "showInitAnimation" 12 | const val PARALLAX_ENABLED = "parallaxEnabled" 13 | const val PARALLAX_SCALE = "parallaxScale" 14 | const val CARD_GAP = "cardGap" 15 | const val CARD_GAP_BOTTOM = "cardGapBottom" 16 | private const val REVERSE_CLICK_ANIMATION_ENABLED = "reverseClickAnimationEnabled" 17 | private const val REVERSE_CLICK_ANIMATION_ENABLED_DEFAULT = false 18 | 19 | val isShowInitAnimationEnabled: Boolean 20 | get() = Pref.getBoolean(SHOW_INIT_ANIMATION, CardStackLayout.SHOW_INIT_ANIMATION_DEFAULT) 21 | 22 | val isParallaxEnabled: Boolean 23 | get() = Pref.getBoolean(PARALLAX_ENABLED, CardStackLayout.PARALLAX_ENABLED_DEFAULT) 24 | 25 | var isReverseClickAnimationEnabled: Boolean 26 | get() = Pref.getBoolean( 27 | REVERSE_CLICK_ANIMATION_ENABLED, 28 | REVERSE_CLICK_ANIMATION_ENABLED_DEFAULT 29 | ) 30 | set(b) = Pref.putBoolean(REVERSE_CLICK_ANIMATION_ENABLED, b) 31 | 32 | fun getParallaxScale(context: Context): Int { 33 | return Pref.getInt(PARALLAX_SCALE, context.resources.getInteger(com.mutualmobile.cardstack.R.integer.parallax_scale_default)) 34 | } 35 | 36 | fun getCardGap(context: Context): Int { 37 | val cardGapDimenInDp = (context.resources.getDimension(dimen.card_gap) / context.resources.displayMetrics.density).toInt() 38 | return Pref.getInt(CARD_GAP, cardGapDimenInDp) 39 | } 40 | 41 | fun getCardGapBottom(context: Context): Int { 42 | val cardGapBottomDimenInDp = (context.resources.getDimension(dimen.card_gap_bottom) / context.resources.displayMetrics.density).toInt() 43 | return Pref.getInt(CARD_GAP_BOTTOM, cardGapBottomDimenInDp) 44 | } 45 | 46 | fun resetDefaults(context: Context) { 47 | val cardGapDimenInDp = (context.resources.getDimension(dimen.card_gap) / context.resources.displayMetrics.density).toInt() 48 | val cardGapBottomDimenInDp = (context.resources.getDimension(dimen.card_gap_bottom) / context.resources.displayMetrics.density).toInt() 49 | 50 | Pref.putBoolean(SHOW_INIT_ANIMATION, CardStackLayout.SHOW_INIT_ANIMATION_DEFAULT) 51 | Pref.putBoolean(PARALLAX_ENABLED, CardStackLayout.PARALLAX_ENABLED_DEFAULT) 52 | isReverseClickAnimationEnabled = 53 | REVERSE_CLICK_ANIMATION_ENABLED_DEFAULT 54 | Pref.putInt(PARALLAX_SCALE, context.resources.getInteger(com.mutualmobile.cardstack.R.integer.parallax_scale_default)) 55 | Pref.putInt(CARD_GAP, cardGapDimenInDp) 56 | Pref.putInt(CARD_GAP_BOTTOM, cardGapBottomDimenInDp) 57 | } 58 | } -------------------------------------------------------------------------------- /cardstack/build.gradle: -------------------------------------------------------------------------------- 1 | // Manifest version information! 2 | def versionMajor = 0 3 | def versionMinor = 6 4 | def versionPatch = 0 5 | 6 | apply plugin: 'com.android.library' 7 | apply plugin: 'kotlin-android-extensions' 8 | apply plugin: 'kotlin-android' 9 | apply plugin: 'com.github.dcendents.android-maven' 10 | apply plugin: 'com.jfrog.bintray' 11 | 12 | def siteUrl = 'https://github.com/mutualmobile/CardStackUI' 13 | def gitUrl = 'https://github.com/mutualmobile/CardStackUI.git' 14 | group = "com.mutualmobile.android" 15 | def vName = versionMajor + '.' + versionMinor + '.' + versionPatch 16 | def vCode = versionMajor * 100 + versionMinor * 10 + versionPatch 17 | 18 | // This is for bintray, DON'T REMOVE 19 | version = vName 20 | 21 | android { 22 | compileSdkVersion rootProject.ext.COMPILE_SDK_VERSION 23 | 24 | defaultConfig { 25 | minSdkVersion rootProject.ext.MIN_SDK_VERSION 26 | targetSdkVersion rootProject.ext.TARGET_SDK_VERSION 27 | versionCode vCode 28 | versionName vName 29 | } 30 | buildTypes { 31 | release { 32 | minifyEnabled true 33 | debuggable true 34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 35 | } 36 | debug { 37 | debuggable true 38 | minifyEnabled false 39 | } 40 | } 41 | } 42 | 43 | install { 44 | repositories.mavenInstaller { 45 | // This generates POM.xml with proper parameters 46 | pom { 47 | project { 48 | packaging 'aar' 49 | name 'card-stack-ui' 50 | url siteUrl 51 | 52 | // Set your license 53 | licenses { 54 | license { 55 | name 'The Apache Software License, Version 2.0' 56 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 57 | } 58 | } 59 | developers { 60 | developer { 61 | id 'tushar-acharya' 62 | name 'Tushar Acharya' 63 | email 'tushar.acharya@mutualmobile.com' 64 | } 65 | } 66 | scm { 67 | connection gitUrl 68 | developerConnection gitUrl 69 | url siteUrl 70 | } 71 | } 72 | } 73 | } 74 | } 75 | 76 | dependencies { 77 | compile fileTree(dir: 'libs', include: ['*.jar']) 78 | compile "com.android.support:appcompat-v7:${rootProject.ext.SUPPORT_LIB_VERSION}" 79 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 80 | } 81 | 82 | task sourcesJar(type: Jar) { 83 | from android.sourceSets.main.java.srcDirs 84 | classifier = 'sources' 85 | } 86 | 87 | artifacts { 88 | archives sourcesJar 89 | } 90 | 91 | // Fails in CI, un-comment only to deploy new binaries to Bintray 92 | 93 | Properties properties = new Properties() 94 | if (project.rootProject.file('local.properties').exists()) { 95 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 96 | } 97 | 98 | bintray { 99 | user = properties.getProperty("bintray.user") 100 | key = properties.getProperty("bintray.apikey") 101 | 102 | configurations = ['archives'] 103 | pkg { 104 | repo = "Android" 105 | name = "card-stack-ui" 106 | userOrg = "mutualmobile" 107 | websiteUrl = siteUrl 108 | vcsUrl = gitUrl 109 | licenses = ["Apache-2.0"] 110 | publish = true 111 | labels = ['aar', 'android', 'ui'] 112 | publicDownloadNumbers = true 113 | } 114 | } 115 | apply plugin: 'maven' 116 | repositories { 117 | mavenCentral() 118 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/settings_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 25 | 26 | 33 | 34 | 41 | 42 | 49 | 50 | 55 | 56 | 63 | 64 | 73 | 74 | 75 | 76 | 81 | 82 | 89 | 90 | 99 | 100 | 101 | 102 | 107 | 108 | 115 | 116 | 125 | 126 | 127 | 128 |