Skip to content

Commit

Permalink
Migrate to AndroidX from Support Library (#33)
Browse files Browse the repository at this point in the history
This PR migrates all support artifacts usages to androidx.

Changes included:

    Mandatory bumping of MinSdk version to 14 from 11
    Migration to androidx
    Updated target and compile SDK to 29 (latest)
    Migrated gradle dependencies to use "implementation" instead of compile. No need to use "api"

Resolves: #31
  • Loading branch information
giorgosneokleous93 authored Feb 20, 2020
1 parent 1ff7612 commit 6513854
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 109 deletions.
29 changes: 17 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
language: android

jdk:
- openjdk8

android:
components:
- tools
- platform-tools
- build-tools-24.0.2
- android-24
- extra-android-m2repository
- sys-img-armeabi-v7a-android-18
- build-tools-29.0.0
- android-29
- android-22
- sys-img-armeabi-v7a-android-22

jdk:
- oraclejdk8
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+

before_script:
# Create and start an emulator for instrumentation tests.
- echo no | android create avd --force -n test -t android-18 --abi armeabi-v7a
- android list target
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82

script:
- ./gradlew build connectedCheck
- ./gradlew build connectedCheck

branches:
except:
Expand All @@ -30,6 +35,6 @@ sudo: false

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

cache:
- $HOME/.gradle
- $HOME/.gradle
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Usage is simple - just add it as a child view of your `ViewPager`!
### XML

```xml
<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -41,14 +41,14 @@ Usage is simple - just add it as a child view of your `ViewPager`!
android:layout_gravity="bottom|center_horizontal"
android:gravity="center_vertical"/>

</android.support.v4.view.ViewPager>
</androidx.viewpager.widget.ViewPager>
```

### Programatically
Or in code...

```java
import android.support.v4.view.ViewPager;
import androidx.viewpager.widget.ViewPager;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;

Expand Down Expand Up @@ -92,7 +92,7 @@ Add Material-ViewPagerIndicator to your app dependencies:
dependencies {
// x.y.z is the latest release version number.
compile 'com.github.ronaldsmartin:Material-ViewPagerIndicator:x.y.z'
implementation 'com.github.ronaldsmartin:Material-ViewPagerIndicator:x.y.z'
}
```
Expand Down
20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
versionCode 3
versionName "1.0.2"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}

Expand All @@ -51,15 +51,15 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':material-viewpagerindicator')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':material-viewpagerindicator')

compile deps.supportAnnotations
compile deps.supportAppCompat
compile deps.supportCardView
compile deps.supportDesign
compile deps.supportFragments
implementation deps.supportAnnotations
implementation deps.supportAppCompat
implementation deps.supportCardView
implementation deps.supportDesign
implementation deps.supportFragments

androidTestCompile deps.espresso
testCompile deps.junit
androidTestImplementation deps.espresso
testImplementation deps.junit
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@
package com.itsronald.materialviewpagerindicatorsample;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("com.itsronald.materialviewpagerindicatorsample", appContext.getPackageName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.content.res.AppCompatResources;
import android.support.v7.widget.Toolbar;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package com.itsronald.materialviewpagerindicatorsample;

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

package com.itsronald.materialviewpagerindicatorsample;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package com.itsronald.materialviewpagerindicatorsample;

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.ViewPager;
import android.support.v7.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AppCompatActivity;

public class SimpleXmlExampleActivity extends AppCompatActivity {

Expand Down
28 changes: 14 additions & 14 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
~
~ Last modified 10/13/16 11:34 AM.
-->
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand All @@ -26,34 +26,34 @@
tools:context=".MainActivity">

<!-- Toolbar -->
<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<android.support.design.widget.CollapsingToolbarLayout
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:subtitle="@string/subtitle_activity_main"/>

</android.support.design.widget.CollapsingToolbarLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>

<!-- Content -->
<android.support.v4.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
Expand All @@ -71,7 +71,7 @@
android:animateLayoutChanges="true">

<!-- Simple XML Example-->
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?selectableItemBackgroundBorderless"
Expand Down Expand Up @@ -130,10 +130,10 @@

</RelativeLayout>

</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>

<!-- Simple Java Example -->
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?attr/selectableItemBackgroundBorderless"
Expand Down Expand Up @@ -192,7 +192,7 @@

</RelativeLayout>

</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>

<TextView
android:layout_width="wrap_content"
Expand All @@ -205,9 +205,9 @@

</LinearLayout>

</android.support.v4.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onFABClick"
Expand All @@ -217,4 +217,4 @@
app:layout_anchorGravity="bottom|end|right"
app:useCompatPadding="true"/>

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_simple_java_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
android:background="#26A69A"
tools:context=".SimpleJavaExampleActivity">

<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_simple_xml_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
android:background="#607D8B"
tools:context="com.itsronald.materialviewpagerindicatorsample.SimpleXmlExampleActivity">

<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -43,6 +43,6 @@
android:layout_gravity="bottom|center_horizontal"
android:gravity="center_vertical"/>

</android.support.v4.view.ViewPager>
</androidx.viewpager.widget.ViewPager>

</RelativeLayout>
26 changes: 14 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.android.tools.build:gradle:3.5.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -32,6 +33,7 @@ buildscript {

allprojects {
repositories {
google()
jcenter()
}
}
Expand All @@ -41,20 +43,20 @@ task clean(type: Delete) {
}

ext {
compileSdkVersion = 24
minSdkVersion = 11
targetSdkVersion = 24
buildToolsVersion = "24.0.2"
compileSdkVersion = 29
minSdkVersion = 14
targetSdkVersion = 29
buildToolsVersion = "29.0.0"
}

ext.deps = [
supportAnnotations: 'com.android.support:support-annotations:24.2.1',
supportAppCompat: 'com.android.support:appcompat-v7:24.2.1',
supportCardView: 'com.android.support:cardview-v7:24.2.1',
supportCoreUi: 'com.android.support:support-core-ui:24.2.1',
supportDesign: 'com.android.support:design:24.2.1',
supportFragments: 'com.android.support:support-fragment:24.2.1',
supportAnnotations: 'androidx.annotation:annotation:1.0.0',
supportAppCompat: 'androidx.appcompat:appcompat:1.0.0',
supportCardView: 'androidx.cardview:cardview:1.0.0',
supportCoreUi: 'androidx.legacy:legacy-support-core-ui:1.0.0',
supportDesign: 'com.google.android.material:material:1.0.0',
supportFragments: 'androidx.fragment:fragment:1.0.0',

junit: 'junit:junit:4.12',
espresso: 'com.android.support.test.espresso:espresso-core:2.2.2'
espresso: 'androidx.test.espresso:espresso-core:3.1.0'
]
Loading

0 comments on commit 6513854

Please sign in to comment.