From 5f401d200a47a1ae3c11f5d18b3e6010140ce418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20B?= Date: Fri, 3 Jun 2016 12:23:57 +0200 Subject: [PATCH 1/3] Update gitignore and remove idea files. --- .gitignore | 37 +++++-- .idea/.name | 1 - .idea/compiler.xml | 22 ----- .idea/copyright/SwipeSelector.xml | 6 -- .idea/copyright/profiles_settings.xml | 3 - .idea/encodings.xml | 6 -- .idea/gradle.xml | 20 ---- .idea/inspectionProfiles/Project_Default.xml | 11 --- .../inspectionProfiles/profiles_settings.xml | 7 -- .idea/misc.xml | 46 --------- .idea/modules.xml | 10 -- .idea/runConfigurations.xml | 12 --- .idea/vcs.xml | 6 -- SwipeSelector.iml | 19 ---- sample/sample.iml | 91 ----------------- swipe-selector/swipe-selector.iml | 99 ------------------- 16 files changed, 29 insertions(+), 367 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/SwipeSelector.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml delete mode 100644 SwipeSelector.iml delete mode 100644 sample/sample.iml delete mode 100644 swipe-selector/swipe-selector.iml diff --git a/.gitignore b/.gitignore index 68e3d8f..d41d8e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,30 @@ -.gradle -/local.properties -/.idea/workspace.xml -/.idea/tasks.xml -/.idea/libraries -.DS_Store -/build -/captures +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Key +*.jks + +# Local configuration file (sdk path, etc) +local.properties + +# Intellij project files +*.iml +*.ipr *.iws +.idea/ +*.prefs + +# Gradle +build/ +.gradle diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 58dcb30..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -SwipeSelector-master \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/SwipeSelector.xml b/.idea/copyright/SwipeSelector.xml deleted file mode 100644 index c9442bc..0000000 --- a/.idea/copyright/SwipeSelector.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 3ee4ec8..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 13cf8af..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 3b31283..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 1a3eaff..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index b1a074d..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/SwipeSelector.iml b/SwipeSelector.iml deleted file mode 100644 index d9213e1..0000000 --- a/SwipeSelector.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sample/sample.iml b/sample/sample.iml deleted file mode 100644 index 78f5648..0000000 --- a/sample/sample.iml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/swipe-selector/swipe-selector.iml b/swipe-selector/swipe-selector.iml deleted file mode 100644 index 55d82cf..0000000 --- a/swipe-selector/swipe-selector.iml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From cadb7a8e056cd401f0c3c49651d8276cd6f9e7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20B?= Date: Fri, 3 Jun 2016 12:32:17 +0200 Subject: [PATCH 2/3] Update dependencies. --- build.gradle | 4 ++-- gradle.properties | 7 ++++++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- sample/build.gradle | 10 +++++----- swipe-selector/build.gradle | 12 +++++------- swipe-selector/src/main/AndroidManifest.xml | 12 +----------- 6 files changed, 21 insertions(+), 28 deletions(-) diff --git a/build.gradle b/build.gradle index 630c771..21ce18c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' + classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle.properties b/gradle.properties index 1d3591c..7020ce9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,9 @@ # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +# org.gradle.parallel=true + +ANDROID_BUILD_MIN_SDK_VERSION=8 +ANDROID_BUILD_TARGET_SDK_VERSION=23 +ANDROID_BUILD_SDK_VERSION=23 +ANDROID_BUILD_TOOLS_VERSION=23.0.3 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f23df6e..933a325 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Oct 21 11:34:03 PDT 2015 +#Fri Jun 03 12:29:56 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/sample/build.gradle b/sample/build.gradle index 6ae75b6..3c02c21 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" + compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) + buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION defaultConfig { applicationId "com.example.swipeselectordemo" - minSdkVersion 8 - targetSdkVersion 23 + minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) + targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) versionCode 2 versionName "1.0" } @@ -22,6 +22,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.2.0' + compile 'com.android.support:appcompat-v7:23.4.0' compile project(':swipe-selector') } diff --git a/swipe-selector/build.gradle b/swipe-selector/build.gradle index 6d17349..d781c44 100644 --- a/swipe-selector/build.gradle +++ b/swipe-selector/build.gradle @@ -25,14 +25,12 @@ ext { } android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" + compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) + buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION defaultConfig { - minSdkVersion 8 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" + minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) + targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) } buildTypes { release { @@ -45,7 +43,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.2.0' + compile 'com.android.support:appcompat-v7:23.4.0' } apply plugin: 'com.github.dcendents.android-maven' diff --git a/swipe-selector/src/main/AndroidManifest.xml b/swipe-selector/src/main/AndroidManifest.xml index 3185cb1..4c5e846 100644 --- a/swipe-selector/src/main/AndroidManifest.xml +++ b/swipe-selector/src/main/AndroidManifest.xml @@ -1,11 +1 @@ - - - - - - - + From b65cba4a389456c6e6d8478c1e0608f2cdf669b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20B?= Date: Fri, 3 Jun 2016 12:54:11 +0200 Subject: [PATCH 3/3] Add RTL support. --- .../roughike/swipeselector/SwipeAdapter.java | 35 ++++++++++++++++++- .../swipeselector/ExampleUnitTest.java | 15 -------- 2 files changed, 34 insertions(+), 16 deletions(-) delete mode 100644 swipe-selector/src/test/java/com/iroughapps/swipeselector/ExampleUnitTest.java diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java index ecff7ef..1c88e63 100644 --- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java +++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java @@ -1,9 +1,13 @@ package com.roughike.swipeselector; import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; +import android.content.res.Configuration; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; import android.graphics.Typeface; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ShapeDrawable; import android.os.Build; import android.os.Bundle; @@ -99,9 +103,29 @@ private SwipeAdapter(ViewPager viewPager, ViewGroup indicatorContainer, int indi mLeftButton = leftButton; mLeftButton.setImageResource(leftButtonResource); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + mLeftButton.getDrawable().setAutoMirrored(true); + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + Configuration config = mContext.getResources().getConfiguration(); + if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { + mLeftButton.setImageDrawable(flip(leftButtonResource)); + } + } else { + // Not supported + } mRightButton = rightButton; mRightButton.setImageResource(rightButtonResource); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + mRightButton.getDrawable().setAutoMirrored(true); + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + Configuration config = mContext.getResources().getConfiguration(); + if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { + mRightButton.setImageDrawable(flip(rightButtonResource)); + } + } else { + // Not supported + } // Calculate paddings for the content so the left and right buttons // don't overlap. @@ -241,6 +265,7 @@ protected SwipeAdapter build() { /** * Protected methods used by SwipeSelector */ + protected void setOnItemSelectedListener(OnSwipeItemSelectedListener listener) { mOnItemSelectedListener = listener; } @@ -527,4 +552,12 @@ private void setAlpha(float alpha, ImageView button) { button.setAlpha((int) (alpha * 255)); } } + + private BitmapDrawable flip(int buttonRes) { + Matrix m = new Matrix(); + m.preScale(-1, 1); + Bitmap src = BitmapFactory.decodeResource(mContext.getResources(), buttonRes); + Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false); + return new BitmapDrawable(mContext.getResources(), dst); + } } diff --git a/swipe-selector/src/test/java/com/iroughapps/swipeselector/ExampleUnitTest.java b/swipe-selector/src/test/java/com/iroughapps/swipeselector/ExampleUnitTest.java deleted file mode 100644 index 9a917e9..0000000 --- a/swipe-selector/src/test/java/com/iroughapps/swipeselector/ExampleUnitTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.roughike.swipeselector; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * To work on unit tests, switch the Test Artifact in the Build Variants view. - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file