From 5ea65699bcc419f6e3fce89da383820250f58621 Mon Sep 17 00:00:00 2001 From: codekid Date: Mon, 25 Mar 2019 14:23:33 +0530 Subject: [PATCH 1/3] androidx migration --- app/build.gradle | 16 ++++++++-------- .../storagechooserdemo/MainActivity.java | 4 ++-- .../storagechooserdemo/ReportBottomSheet.java | 2 +- build.gradle | 4 ++-- gradle.properties | 2 ++ gradle/wrapper/gradle-wrapper.properties | 4 ++-- storagechooser/build.gradle | 14 +++++++------- .../adapters/StorageChooserListAdapter.java | 2 +- .../fragments/SecondaryChooserFragment.java | 13 +++++++------ .../storagechooser/utils/ResourceUtil.java | 4 ++-- .../storagechooser/utils/ThumbnailUtil.java | 2 +- 11 files changed, 35 insertions(+), 32 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index aca1956..5cb7ecc 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 - buildToolsVersion "27.0.3" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.codekidlabs.storagechooserdemo" minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -23,13 +23,13 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', { exclude group: 'com.android.support', module: 'support-annotations' }) - implementation 'com.android.support:cardview-v7:27.1.1' - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:design:27.1.1' + implementation 'androidx.cardview:cardview:1.0.0-beta01' + implementation 'androidx.appcompat:appcompat:1.0.0-beta01' + implementation 'com.google.android.material:material:1.0.0-beta01' testImplementation 'junit:junit:4.12' implementation project (':storagechooser') diff --git a/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java b/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java index a7ce4f9..64670a7 100755 --- a/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java +++ b/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java @@ -6,8 +6,8 @@ import android.os.Bundle; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; diff --git a/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java b/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java index 0f929fd..e26879d 100755 --- a/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java +++ b/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java @@ -3,7 +3,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; -import android.support.v4.content.ContextCompat; +import androidx.core.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/build.gradle b/build.gradle index 6016a70..a0420cb 100755 --- a/build.gradle +++ b/build.gradle @@ -11,8 +11,8 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + classpath 'com.android.tools.build:gradle:3.3.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index f1c49f3..1e0c1d3 100755 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 08ea26a..3c249aa 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jul 08 10:09:20 IST 2018 +#Mon Mar 25 14:17:17 IST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/storagechooser/build.gradle b/storagechooser/build.gradle index 7aab2b9..05d3694 100755 --- a/storagechooser/build.gradle +++ b/storagechooser/build.gradle @@ -4,16 +4,16 @@ apply plugin: 'com.github.dcendents.android-maven' group = 'com.github.codekidX' android { - compileSdkVersion 27 - buildToolsVersion "27.0.3" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -28,11 +28,11 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', { exclude group: 'com.android.support', module: 'support-annotations' }) - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:design:27.1.1' + implementation 'androidx.appcompat:appcompat:1.0.0-beta01' + implementation 'com.google.android.material:material:1.0.0-beta01' testImplementation 'junit:junit:4.12' } diff --git a/storagechooser/src/main/java/com/codekidlabs/storagechooser/adapters/StorageChooserListAdapter.java b/storagechooser/src/main/java/com/codekidlabs/storagechooser/adapters/StorageChooserListAdapter.java index f31d617..aeadfca 100755 --- a/storagechooser/src/main/java/com/codekidlabs/storagechooser/adapters/StorageChooserListAdapter.java +++ b/storagechooser/src/main/java/com/codekidlabs/storagechooser/adapters/StorageChooserListAdapter.java @@ -2,7 +2,7 @@ import android.content.Context; import android.graphics.Typeface; -import android.support.v4.graphics.drawable.DrawableCompat; +import androidx.core.graphics.drawable.DrawableCompat; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.StyleSpan; diff --git a/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/SecondaryChooserFragment.java b/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/SecondaryChooserFragment.java index 408ec48..12fbdcb 100755 --- a/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/SecondaryChooserFragment.java +++ b/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/SecondaryChooserFragment.java @@ -11,10 +11,6 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.design.widget.FloatingActionButton; -import android.support.v4.content.ContextCompat; import android.util.Log; import android.util.TypedValue; import android.view.ContextThemeWrapper; @@ -45,6 +41,7 @@ import com.codekidlabs.storagechooser.utils.DiskUtil; import com.codekidlabs.storagechooser.utils.FileUtil; import com.codekidlabs.storagechooser.utils.ResourceUtil; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import java.io.File; import java.util.ArrayList; @@ -53,6 +50,10 @@ import java.util.List; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; + import static com.codekidlabs.storagechooser.StorageChooser.Theme; @@ -724,7 +725,7 @@ private void playTheAddressBarAnimation() { private void playTheMultipleButtonAnimation() { Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_multiple_button); - mMultipleOnSelectButton.setVisibility(View.VISIBLE); + mMultipleOnSelectButton.show(); mMultipleOnSelectButton.startAnimation(animation); } @@ -732,7 +733,7 @@ private void playTheMultipleButtonAnimation() { private void playTheMultipleButtonEndAnimation() { Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_multiple_button_end); mMultipleOnSelectButton.startAnimation(animation); - mMultipleOnSelectButton.setVisibility(View.INVISIBLE); + mMultipleOnSelectButton.hide(); } diff --git a/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ResourceUtil.java b/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ResourceUtil.java index 8b5ccb7..5491b50 100755 --- a/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ResourceUtil.java +++ b/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ResourceUtil.java @@ -2,8 +2,8 @@ import android.content.Context; -import android.support.v4.content.ContextCompat; -import android.support.v4.graphics.ColorUtils; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.ColorUtils; import com.codekidlabs.storagechooser.R; diff --git a/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ThumbnailUtil.java b/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ThumbnailUtil.java index be48c1e..36d249c 100755 --- a/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ThumbnailUtil.java +++ b/storagechooser/src/main/java/com/codekidlabs/storagechooser/utils/ThumbnailUtil.java @@ -2,7 +2,7 @@ import android.content.Context; import android.graphics.drawable.Drawable; -import android.support.v4.content.ContextCompat; +import androidx.core.content.ContextCompat; import android.widget.ImageView; import com.codekidlabs.storagechooser.R; From fc63466d01504c4584010b2f4c8023b22c929131 Mon Sep 17 00:00:00 2001 From: codekid Date: Mon, 25 Mar 2019 14:34:29 +0530 Subject: [PATCH 2/3] androidx: done missing layout migration --- .../codekidlabs/storagechooserdemo/MainActivity.java | 8 +++++--- .../storagechooserdemo/ReportBottomSheet.java | 5 +++-- app/src/main/res/layout/activity_main.xml | 10 +++++----- .../com/codekidlabs/storagechooser/StorageChooser.java | 5 ++--- .../fragments/ChooserDialogFragment.java | 5 +++-- .../src/main/res/layout-v21/custom_storage_list.xml | 2 +- .../src/main/res/layout/custom_storage_list.xml | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java b/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java index 64670a7..84cb41e 100755 --- a/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java +++ b/app/src/main/java/com/codekidlabs/storagechooserdemo/MainActivity.java @@ -4,11 +4,12 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; -import android.support.design.widget.CoordinatorLayout; -import android.support.design.widget.Snackbar; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; -import android.support.v7.app.AppCompatActivity; + import android.util.Log; import android.view.View; import android.widget.AdapterView; @@ -21,6 +22,7 @@ import com.codekidlabs.storagechooser.Content; import com.codekidlabs.storagechooser.StorageChooser; import com.codekidlabs.storagechooser.utils.DiskUtil; +import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; diff --git a/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java b/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java index e26879d..90b0644 100755 --- a/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java +++ b/app/src/main/java/com/codekidlabs/storagechooserdemo/ReportBottomSheet.java @@ -1,8 +1,8 @@ package com.codekidlabs.storagechooserdemo; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.design.widget.BottomSheetDialogFragment; + +import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; @@ -11,6 +11,7 @@ import android.widget.TextView; import com.codekidlabs.storagechooserdemo.utils.TypefaceUtil; +import com.google.android.material.bottomsheet.BottomSheetDialogFragment; /** * report any issue using logboard api diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 4e97930..7fa83c3 100755 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - - - + - - + diff --git a/storagechooser/src/main/java/com/codekidlabs/storagechooser/StorageChooser.java b/storagechooser/src/main/java/com/codekidlabs/storagechooser/StorageChooser.java index 2dd09f8..96ce896 100755 --- a/storagechooser/src/main/java/com/codekidlabs/storagechooser/StorageChooser.java +++ b/storagechooser/src/main/java/com/codekidlabs/storagechooser/StorageChooser.java @@ -4,19 +4,18 @@ import android.app.Dialog; import android.content.Context; import android.content.SharedPreferences; -import android.graphics.Typeface; import android.os.Environment; -import android.support.annotation.Nullable; import android.util.Log; import com.codekidlabs.storagechooser.fragments.ChooserDialogFragment; import com.codekidlabs.storagechooser.models.Config; import com.codekidlabs.storagechooser.utils.DiskUtil; -import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; +import androidx.annotation.Nullable; + public class StorageChooser { diff --git a/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/ChooserDialogFragment.java b/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/ChooserDialogFragment.java index 0b234bc..2a7e00e 100755 --- a/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/ChooserDialogFragment.java +++ b/storagechooser/src/main/java/com/codekidlabs/storagechooser/fragments/ChooserDialogFragment.java @@ -7,8 +7,6 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -33,6 +31,9 @@ import java.util.ArrayList; import java.util.List; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import static com.codekidlabs.storagechooser.StorageChooser.Theme.OVERVIEW_BG_INDEX; import static com.codekidlabs.storagechooser.StorageChooser.Theme.OVERVIEW_HEADER_INDEX; import static com.codekidlabs.storagechooser.StorageChooser.Theme.OVERVIEW_TEXT_INDEX; diff --git a/storagechooser/src/main/res/layout-v21/custom_storage_list.xml b/storagechooser/src/main/res/layout-v21/custom_storage_list.xml index dc146fa..647d9a6 100644 --- a/storagechooser/src/main/res/layout-v21/custom_storage_list.xml +++ b/storagechooser/src/main/res/layout-v21/custom_storage_list.xml @@ -152,7 +152,7 @@ android:layout_below="@id/custom_path_header" android:background="@color/inactiveGradientColor" /> - - Date: Mon, 25 Mar 2019 20:40:47 +0530 Subject: [PATCH 3/3] backport: changes related to older apis and layout dimens --- storagechooser/src/main/res/layout/custom_storage_list.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storagechooser/src/main/res/layout/custom_storage_list.xml b/storagechooser/src/main/res/layout/custom_storage_list.xml index c431fe5..f468a15 100755 --- a/storagechooser/src/main/res/layout/custom_storage_list.xml +++ b/storagechooser/src/main/res/layout/custom_storage_list.xml @@ -58,7 +58,9 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginEnd="16dp" + android:layout_marginRight="16dp" android:layout_marginStart="16dp" + android:layout_marginLeft="16dp" android:fontFamily="sans-serif-condensed" android:text="blahblahblah" android:textColor="@android:color/white" @@ -155,8 +157,9 @@