Skip to content

Commit

Permalink
Merge pull request #135 from OpenSRP/issue134
Browse files Browse the repository at this point in the history
Migrate to AndroidX
  • Loading branch information
ndegwamartin authored Dec 1, 2020
2 parents c9e011f + fb01d99 commit 64b782a
Show file tree
Hide file tree
Showing 80 changed files with 331 additions and 252 deletions.
11 changes: 7 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.5.2-SNAPSHOT
VERSION_NAME=0.6.0-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Child Library
Expand All @@ -10,7 +10,10 @@ POM_SETTING_LICENCE_NAME=The Apache Software License, Version 2.0
POM_SETTING_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_SETTING_LICENCE_DIST=repo
POM_SETTING_DEVELOPER_ID=opensrp
POM_SETTING_DEVELOPER_NAME=OpenSRP Onadev

POM_SETTING_DEVELOPER_NAME=OpenSRP Onadev
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048m
org.gradle.jvmargs=-Xmx2048m
android.enableD8=true
android.enableD8.desugaring=true
android.enableJetifier=true
android.jetifier.blacklist=shadows
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Fri Aug 07 14:47:10 EAT 2020
#Mon Jun 29 18:30:21 EAT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
44 changes: 26 additions & 18 deletions opensrp-child/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -51,6 +51,13 @@ android {
abortOnError false
}

compileOptions {

coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// avoid errors with message 'Duplicate files copied in APK ...'
packagingOptions {
exclude 'LICENSE.txt'
Expand Down Expand Up @@ -86,8 +93,10 @@ allprojects {
}

dependencies {

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5'

api('org.smartregister:opensrp-client-core:2.2.4-PREVIEW-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-core:4.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
Expand All @@ -100,7 +109,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-v4'
}

api('org.smartregister:opensrp-client-native-form:1.14.5.0-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-native-form:1.14.6.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand All @@ -121,7 +130,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

api('org.smartregister:opensrp-client-immunization:2.0.4-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-immunization:3.0.0-SNAPSHOT@aar') {

transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
Expand All @@ -130,8 +139,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

api('org.smartregister:opensrp-client-growth-monitoring:1.1.23-SNAPSHOT@aar') {

api('org.smartregister:opensrp-client-growth-monitoring:2.0.1-SNAPSHOT@aar') {
transitive = true

exclude group: 'org.smartregister', module: 'opensrp-client-core'
Expand All @@ -140,24 +148,24 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'net.zetetic:android-database-sqlcipher:4.1.3@aar'
implementation 'net.zetetic:android-database-sqlcipher:4.4.0@aar'
implementation 'com.jakewharton.timber:timber:4.7.1'

implementation 'com.android.support:leanback-v17:28.0.0'
implementation 'org.pcollections:pcollections:3.1.0'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'org.pcollections:pcollections:3.1.3'


implementation 'com.google.guava:guava:28.1-android'
implementation 'com.google.guava:guava:29.0-android'
implementation 'id.zelory:compressor:2.1.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation "androidx.constraintlayout:constraintlayout:2.0.0"

testImplementation 'junit:junit:4.13'

def robolectricVersion = '4.1'
testImplementation("org.robolectric:robolectric:$robolectricVersion") {
exclude group: 'com.google.auto.service', module: 'auto-service'
Expand All @@ -166,7 +174,7 @@ dependencies {
testImplementation "org.robolectric:shadows-multidex:$robolectricVersion"
testImplementation "org.robolectric:shadows-support-v4:3.3.2"

androidTestImplementation('com.android.support.test.espresso:espresso-core:2.+') {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'junit', module: 'junit'
}
Expand All @@ -193,7 +201,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
getReports().getXml().setDestination(file("${buildDir}/reports/jacoco/jacocoRootReport/merged.xml"))
getReports().getHtml().setDestination(file("${buildDir}/reports/jacoco/jacocoRootReport/html"))

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', '**/*$ViewBinder*.*']
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', 'androidx/**/*.*', '**/*$ViewBinder*.*']
def debugTree = fileTree(dir: "$project.buildDir/intermediates/javac/debug/classes", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.support.annotation.StringRes;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import androidx.annotation.StringRes;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.snackbar.Snackbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
import android.os.Looper;
import android.os.StrictMode;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
Expand All @@ -32,6 +25,14 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.domain.Form;

Expand Down Expand Up @@ -463,7 +464,7 @@ private void updateGenderViews() {
Field field = TabLayout.class.getDeclaredField("mTabStrip");
field.setAccessible(true);
Object object = field.get(tabLayout);
Class<?> c = Class.forName("android.support.design.widget.TabLayout$SlidingTabStrip");
Class<?> c = Class.forName("com.google.android.material.snackbar.widget.TabLayout$SlidingTabStrip");
Method method = c.getDeclaredMethod("setSelectedIndicatorColor", int.class);
method.setAccessible(true);
method.invoke(object, getResources().getColor(normalShade)); //now its ok
Expand Down Expand Up @@ -593,6 +594,7 @@ protected void startJsonForm(String formName, String entityId) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
AllSharedPreferences allSharedPreferences = getOpenSRPContext().allSharedPreferences();
if (requestCode == REQUEST_CODE_GET_JSON && resultCode == RESULT_OK) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;

import com.vijay.jsonwizard.activities.JsonFormActivity;
import com.vijay.jsonwizard.constants.JsonFormConstants;
Expand Down Expand Up @@ -45,7 +47,11 @@ public class BaseChildFormActivity extends JsonFormActivity implements IMotherLo
@Override
protected void attachBaseContext(android.content.Context base) {
String language = LangUtils.getLanguage(base);
super.attachBaseContext(LangUtils.setAppLocale(base, language));
Configuration newConfiguration = LangUtils.setAppLocale(base, language);

super.attachBaseContext(base);

applyOverrideConfiguration(newConfiguration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -21,6 +17,11 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.google.android.material.snackbar.Snackbar;
import com.google.gson.Gson;

import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.design.bottomnavigation.LabelVisibilityMode;
import android.support.v4.app.Fragment;
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.View;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.smartregister.child.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.smartregister.child.adapter;

import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.smartregister.child.adapter;

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 java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.smartregister.child.contract;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

import org.apache.commons.lang3.tuple.Triple;
import org.json.JSONException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.app.AlertDialog;
import androidx.loader.content.CursorLoader;
import androidx.loader.content.Loader;
import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -17,6 +14,10 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.VisibleForTesting;
import androidx.loader.content.CursorLoader;
import androidx.loader.content.Loader;

import org.apache.commons.lang3.StringUtils;
import org.smartregister.Context;
import org.smartregister.CoreLibrary;
Expand Down Expand Up @@ -270,7 +271,7 @@ protected void updateLocationText() {
}

@VisibleForTesting
protected Context getOpenSRPContext(){
protected Context getOpenSRPContext() {
return context();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package org.smartregister.child.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.utils.NativeFormLangUtils;

Expand Down Expand Up @@ -77,7 +78,11 @@ public void setFields(List<Field> fields) {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
super.onCreate(savedInstanceState);
} catch (IllegalStateException e) {
Timber.e(e);
}
Form form = getForm();
setFields(form.getStep1().getFields());
unformattedNumberFields = addUnFormattedNumberFields("");
Expand Down
Loading

0 comments on commit 64b782a

Please sign in to comment.