From 2965b12b3941fef562ffe5decd3006d2e3a36cff Mon Sep 17 00:00:00 2001 From: Wajahat Karim Date: Tue, 12 May 2020 00:43:58 +0500 Subject: [PATCH] Fixes issue #8. Adds AndroidX widgets support and bumps up the minimum API level to 21 --- app/build.gradle | 15 ++++++++------- .../demo/ExampleInstrumentedTest.kt | 4 ++-- .../demo/BookOnboardingActivity.kt | 16 +++++++--------- .../demo/BookPageIntroFragment.java | 6 +++--- .../demo/GalleryImageFragment.kt | 2 +- .../easyflipviewpager/demo/MainActivity.kt | 18 ++++++++---------- .../easyflipviewpager/demo/MyFragment.java | 6 +++--- .../demo/PictureGalleryDemoActivity.kt | 10 +++++----- .../demo/PokerCardDemoActivity.java | 11 +++++------ .../demo/ScreenSlidePagerAdapter.kt | 6 +++--- .../res/layout/activity_book_onboarding.xml | 6 +++--- app/src/main/res/layout/activity_main.xml | 2 +- .../layout/activity_picture_gallery_demo.xml | 4 ++-- .../res/layout/activity_poker_card_demo.xml | 4 ++-- app/src/main/res/layout/card_image_layout.xml | 2 +- .../res/layout/fragment_book_page_layout.xml | 6 +++--- .../main/res/layout/fragment_demo_layout.xml | 2 +- .../main/res/layout/fragment_dummy_layout.xml | 4 ++-- .../layout/fragment_gallery_page_layout.xml | 6 +++--- easyflipviewpager/build.gradle | 12 ++++++------ .../ExampleInstrumentedTest.java | 4 ++-- .../BookFlipPageTransformer.java | 6 +++--- .../CardFlipPageTransformer.java | 2 +- gradle.properties | 2 ++ 24 files changed, 77 insertions(+), 79 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4241854..db43329 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,11 +8,11 @@ android { compileSdkVersion 28 defaultConfig { applicationId "com.wajahatkarim3.easyflipviewpager.demo" - minSdkVersion 15 + minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { @@ -25,15 +25,16 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' implementation 'net.alexandroid.utils:indicators:1.6' + implementation "androidx.viewpager2:viewpager2:1.0.0" implementation project(":easyflipviewpager") - implementation 'com.android.support:cardview-v7:28.0.0' + implementation 'androidx.cardview:cardview:1.0.0' implementation 'me.relex:circleindicator:1.2.2' } diff --git a/app/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/demo/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/demo/ExampleInstrumentedTest.kt index dad32ad..b09569c 100644 --- a/app/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/demo/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/demo/ExampleInstrumentedTest.kt @@ -1,7 +1,7 @@ package com.wajahatkarim3.easyflipviewpager.demo -import android.support.test.InstrumentationRegistry -import android.support.test.runner.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookOnboardingActivity.kt b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookOnboardingActivity.kt index 9e17cbe..ee1a3df 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookOnboardingActivity.kt +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookOnboardingActivity.kt @@ -1,15 +1,13 @@ package com.wajahatkarim3.easyflipviewpager.demo -import android.graphics.Color -import android.support.v7.app.AppCompatActivity import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentPagerAdapter -import android.support.v4.view.PagerAdapter -import android.support.v4.view.ViewPager +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager import com.wajahatkarim3.easyflipviewpager.BookFlipPageTransformer -import com.wajahatkarim3.easyflipviewpager.CardFlipPageTransformer class BookOnboardingActivity : AppCompatActivity() { @@ -21,7 +19,7 @@ class BookOnboardingActivity : AppCompatActivity() { setContentView(R.layout.activity_book_onboarding) // Instantiate a ViewPager and a PagerAdapter. - mPager = findViewById(R.id.pager) + mPager = findViewById(R.id.pager) mPagerAdapter = BookOnboardingPagerAdapter(supportFragmentManager) mPager.adapter = mPagerAdapter mPager.clipToPadding = true diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookPageIntroFragment.java b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookPageIntroFragment.java index a590db4..6337099 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookPageIntroFragment.java +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/BookPageIntroFragment.java @@ -1,9 +1,9 @@ package com.wajahatkarim3.easyflipviewpager.demo; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/GalleryImageFragment.kt b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/GalleryImageFragment.kt index 3739a3e..9fdfc46 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/GalleryImageFragment.kt +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/GalleryImageFragment.kt @@ -2,7 +2,7 @@ package com.wajahatkarim3.easyflipviewpager.demo import android.content.Intent import android.os.Bundle -import android.support.v4.app.Fragment +import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MainActivity.kt b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MainActivity.kt index 3855383..f193866 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MainActivity.kt +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MainActivity.kt @@ -1,16 +1,14 @@ package com.wajahatkarim3.easyflipviewpager.demo -import android.graphics.Color -import android.support.v7.app.AppCompatActivity import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentPagerAdapter -import android.support.v4.app.FragmentStatePagerAdapter -import android.support.v4.view.PagerAdapter -import android.support.v4.view.ViewPager import android.widget.CheckBox import android.widget.RadioGroup +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager import com.wajahatkarim3.easyflipviewpager.BookFlipPageTransformer import com.wajahatkarim3.easyflipviewpager.CardFlipPageTransformer @@ -29,7 +27,7 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.activity_main) radioGroupFlipAnimation = findViewById(R.id.rgFlipAnimation) - checkEnableScale = findViewById(R.id.checkEnableScale) + checkEnableScale = findViewById(R.id.checkEnableScale) // Book Flip Transformer bookFlipTransformer.isEnableScale = true @@ -40,7 +38,7 @@ class MainActivity : AppCompatActivity() { cardFlipTransformer.flipOrientation = CardFlipPageTransformer.VERTICAL // Instantiate a ViewPager and a PagerAdapter. - mPager = findViewById(R.id.pager) + mPager = findViewById(R.id.pager) mPagerAdapter = DemoPagerAdapter(supportFragmentManager) mPager.adapter = mPagerAdapter mPager.clipToPadding = false diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MyFragment.java b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MyFragment.java index 15c1d1f..cf1ee43 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MyFragment.java +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/MyFragment.java @@ -2,9 +2,9 @@ import android.graphics.Color; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PictureGalleryDemoActivity.kt b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PictureGalleryDemoActivity.kt index 1ad3b4a..c50b285 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PictureGalleryDemoActivity.kt +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PictureGalleryDemoActivity.kt @@ -1,11 +1,11 @@ package com.wajahatkarim3.easyflipviewpager.demo -import android.support.v4.view.ViewPager -import android.support.v7.app.AppCompatActivity +import androidx.viewpager.widget.ViewPager +import androidx.appcompat.app.AppCompatActivity import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentPagerAdapter +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter import com.wajahatkarim3.easyflipviewpager.CardFlipPageTransformer import me.relex.circleindicator.CircleIndicator diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PokerCardDemoActivity.java b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PokerCardDemoActivity.java index 6ae29e6..d110401 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PokerCardDemoActivity.java +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/PokerCardDemoActivity.java @@ -1,16 +1,15 @@ package com.wajahatkarim3.easyflipviewpager.demo; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.NonNull; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatImageView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.SimpleAdapter; import com.wajahatkarim3.easyflipviewpager.CardFlipPageTransformer; diff --git a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/ScreenSlidePagerAdapter.kt b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/ScreenSlidePagerAdapter.kt index 2663139..804199d 100644 --- a/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/ScreenSlidePagerAdapter.kt +++ b/app/src/main/java/com/wajahatkarim3/easyflipviewpager/demo/ScreenSlidePagerAdapter.kt @@ -1,9 +1,9 @@ package com.wajahatkarim3.easyflipviewpager.demo import android.graphics.Color -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentStatePagerAdapter +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentStatePagerAdapter /** * A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in diff --git a/app/src/main/res/layout/activity_book_onboarding.xml b/app/src/main/res/layout/activity_book_onboarding.xml index e073757..1072278 100644 --- a/app/src/main/res/layout/activity_book_onboarding.xml +++ b/app/src/main/res/layout/activity_book_onboarding.xml @@ -1,5 +1,5 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 77a6919..6c65bce 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" tools:context=".MainActivity"> - - + android:layout_centerInParent="true"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/card_image_layout.xml b/app/src/main/res/layout/card_image_layout.xml index b806726..a172a69 100644 --- a/app/src/main/res/layout/card_image_layout.xml +++ b/app/src/main/res/layout/card_image_layout.xml @@ -3,7 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/app/src/main/res/layout/fragment_book_page_layout.xml b/app/src/main/res/layout/fragment_book_page_layout.xml index 939a3ac..a5101ef 100644 --- a/app/src/main/res/layout/fragment_book_page_layout.xml +++ b/app/src/main/res/layout/fragment_book_page_layout.xml @@ -1,5 +1,5 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_demo_layout.xml b/app/src/main/res/layout/fragment_demo_layout.xml index 961915b..4bf15d1 100644 --- a/app/src/main/res/layout/fragment_demo_layout.xml +++ b/app/src/main/res/layout/fragment_demo_layout.xml @@ -18,7 +18,7 @@ android:textStyle="bold" tools:text="Image Title" /> - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_gallery_page_layout.xml b/app/src/main/res/layout/fragment_gallery_page_layout.xml index 6865ff7..763c821 100644 --- a/app/src/main/res/layout/fragment_gallery_page_layout.xml +++ b/app/src/main/res/layout/fragment_gallery_page_layout.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" android:layout_margin="20dp"> - - - + \ No newline at end of file diff --git a/easyflipviewpager/build.gradle b/easyflipviewpager/build.gradle index 4671b94..5bbd2cb 100644 --- a/easyflipviewpager/build.gradle +++ b/easyflipviewpager/build.gradle @@ -11,7 +11,7 @@ ext { libraryName = 'easyflipviewpager' artifact = 'easyflipviewpager' - libraryVersion = '1.0.0' + libraryVersion = '1.2.0' libraryDescription = 'The library for creating book and card flip animations in ViewPager in Android' @@ -31,12 +31,12 @@ android { compileSdkVersion 28 defaultConfig { - minSdkVersion 15 + minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -52,10 +52,10 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'androidx.appcompat:appcompat:1.0.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' } //Add these lines to publish library to bintray. This is the ready-made scripts to make uploading to bintray easy. diff --git a/easyflipviewpager/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/ExampleInstrumentedTest.java b/easyflipviewpager/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/ExampleInstrumentedTest.java index 1b61cf3..2cff207 100644 --- a/easyflipviewpager/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/ExampleInstrumentedTest.java +++ b/easyflipviewpager/src/androidTest/java/com/wajahatkarim3/easyflipviewpager/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.wajahatkarim3.easyflipviewpager; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/BookFlipPageTransformer.java b/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/BookFlipPageTransformer.java index a63a0d0..36be9ce 100644 --- a/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/BookFlipPageTransformer.java +++ b/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/BookFlipPageTransformer.java @@ -16,9 +16,9 @@ package com.wajahatkarim3.easyflipviewpager; -import android.support.annotation.NonNull; -import android.support.v4.view.ViewPager; -import android.util.Log; +import androidx.annotation.NonNull; +import androidx.viewpager.widget.ViewPager; + import android.view.View; /** diff --git a/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/CardFlipPageTransformer.java b/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/CardFlipPageTransformer.java index 9ee1e27..9256c8c 100644 --- a/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/CardFlipPageTransformer.java +++ b/easyflipviewpager/src/main/java/com/wajahatkarim3/easyflipviewpager/CardFlipPageTransformer.java @@ -16,7 +16,7 @@ package com.wajahatkarim3.easyflipviewpager; -import android.support.v4.view.ViewPager; +import androidx.viewpager.widget.ViewPager; import android.view.View; /** diff --git a/gradle.properties b/gradle.properties index 85be9ea..3d8ce0c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,3 +13,5 @@ org.gradle.jvmargs=-Xmx1536m # org.gradle.parallel=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official +android.useAndroidX=true +android.enableJetifier=true