From d7091587ea5a029fc745ebdd5505386844effb24 Mon Sep 17 00:00:00 2001 From: HearSilent Date: Wed, 28 Oct 2020 17:32:27 +0800 Subject: [PATCH 1/3] Migrate to AndroidX --- .gitignore | 49 ++++- .idea/codeStyles/Project.xml | 199 ++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + app/build.gradle | 27 ++- .../ExampleInstrumentedTest.java | 4 +- app/src/main/AndroidManifest.xml | 4 +- .../amazingavatar/MainActivity.java | 26 +-- .../libs/AppBarStateChangeListener.java | 2 +- .../amazingavatar/libs/FlingBehavior.java | 10 +- .../amazingavatar/libs/NetworkHelper.java | 3 +- .../main/res/drawable/avatar_background.xml | 2 +- app/src/main/res/layout/activity_main.xml | 31 ++- app/src/main/res/layout/item_demo.xml | 22 +- build.gradle | 2 +- gradle.properties | 2 + gradle/wrapper/gradle-wrapper.properties | 4 +- 16 files changed, 318 insertions(+), 74 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.gitignore b/.gitignore index 5b11a39..f62226c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,10 +11,19 @@ # generated files bin/ gen/ +out/ + +# Gradle files +.gradle/ +build/ +release/ # Local configuration file (sdk path, etc) local.properties +# Proguard folder generated by Eclipse +proguard/ + # Windows thumbnail db Thumbs.db @@ -25,9 +34,39 @@ Thumbs.db .classpath .project -# Android Studio +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ *.iml -.idea -#.idea/workspace.xml - remove # and delete .idea if it better suit your needs. -.gradle -build/ +*/.idea/* +/.idea/* +!/.idea/codeStyles/ + +# Keystore files +# Uncomment the following line if you do not want to check your keystore files in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +#google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..cb74599 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,199 @@ + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index ac07678..f428f8d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 - buildToolsVersion "27.0.3" + compileSdkVersion 30 defaultConfig { applicationId "hearsilent.amazingavatar" minSdkVersion 17 - targetSdkVersion 27 + targetSdkVersion 30 versionCode 107 versionName "1.0.7" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { @@ -21,16 +20,16 @@ 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', { exclude group: 'com.android.support', module: 'support-annotations' }) - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:recyclerview-v7:27.1.1' - implementation 'com.android.support:design:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.2' - implementation 'de.hdodenhof:circleimageview:2.2.0' - implementation 'com.squareup.okhttp3:okhttp:3.11.0' - implementation 'com.github.bumptech.glide:glide:4.7.1' - annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1' - testImplementation 'junit:junit:4.12' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'com.google.android.material:material:1.2.1' + implementation 'androidx.constraintlayout:constraintlayout:2.0.3' + implementation 'de.hdodenhof:circleimageview:3.1.0' + implementation 'com.squareup.okhttp3:okhttp:4.8.1' + implementation 'com.github.bumptech.glide:glide:4.11.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' + testImplementation 'junit:junit:4.13' } diff --git a/app/src/androidTest/java/hearsilent/amazingavatar/ExampleInstrumentedTest.java b/app/src/androidTest/java/hearsilent/amazingavatar/ExampleInstrumentedTest.java index 799b814..15429e4 100644 --- a/app/src/androidTest/java/hearsilent/amazingavatar/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/hearsilent/amazingavatar/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package hearsilent.amazingavatar; 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/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ce1f6d1..a312f6e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ - + diff --git a/app/src/main/java/hearsilent/amazingavatar/MainActivity.java b/app/src/main/java/hearsilent/amazingavatar/MainActivity.java index 8d4a9b5..6c0aad8 100644 --- a/app/src/main/java/hearsilent/amazingavatar/MainActivity.java +++ b/app/src/main/java/hearsilent/amazingavatar/MainActivity.java @@ -3,14 +3,6 @@ import android.graphics.Paint; import android.os.Bundle; import android.os.Handler; -import android.support.annotation.NonNull; -import android.support.design.widget.AppBarLayout; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.DefaultItemAnimator; -import android.support.v7.widget.DividerItemDecoration; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.TypedValue; import android.view.LayoutInflater; @@ -20,9 +12,17 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.google.android.material.appbar.AppBarLayout; import java.util.Locale; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import de.hdodenhof.circleimageview.CircleImageView; import hearsilent.amazingavatar.callbacks.AvatarCallback; import hearsilent.amazingavatar.libs.AppBarStateChangeListener; @@ -48,8 +48,8 @@ public class MainActivity extends AppCompatActivity { private RecyclerView mRecyclerView; private AppBarStateChangeListener mAppBarStateChangeListener; - private float[] mAvatarPoint = new float[2], mSpacePoint = new float[2], mToolbarTextPoint = - new float[2], mTitleTextViewPoint = new float[2]; + private final float[] mAvatarPoint = new float[2], mSpacePoint = new float[2], + mToolbarTextPoint = new float[2], mTitleTextViewPoint = new float[2]; private float mTitleTextSize; @Override @@ -244,11 +244,11 @@ public void onWindowFocusChanged(boolean hasFocus) { resetPoints(false); } - private class Adapter extends RecyclerView.Adapter { + private static class Adapter extends RecyclerView.Adapter { - private class DemoViewHolder extends RecyclerView.ViewHolder { + private static class DemoViewHolder extends RecyclerView.ViewHolder { - private TextView textView; + private final TextView textView; private DemoViewHolder(View view) { super(view); diff --git a/app/src/main/java/hearsilent/amazingavatar/libs/AppBarStateChangeListener.java b/app/src/main/java/hearsilent/amazingavatar/libs/AppBarStateChangeListener.java index d390862..7289c8c 100644 --- a/app/src/main/java/hearsilent/amazingavatar/libs/AppBarStateChangeListener.java +++ b/app/src/main/java/hearsilent/amazingavatar/libs/AppBarStateChangeListener.java @@ -1,6 +1,6 @@ package hearsilent.amazingavatar.libs; -import android.support.design.widget.AppBarLayout; +import com.google.android.material.appbar.AppBarLayout; public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { diff --git a/app/src/main/java/hearsilent/amazingavatar/libs/FlingBehavior.java b/app/src/main/java/hearsilent/amazingavatar/libs/FlingBehavior.java index c2c0cbf..a270848 100644 --- a/app/src/main/java/hearsilent/amazingavatar/libs/FlingBehavior.java +++ b/app/src/main/java/hearsilent/amazingavatar/libs/FlingBehavior.java @@ -1,13 +1,15 @@ package hearsilent.amazingavatar.libs; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.design.widget.AppBarLayout; -import android.support.design.widget.CoordinatorLayout; -import android.support.v7.widget.RecyclerView; import android.util.AttributeSet; import android.view.View; +import com.google.android.material.appbar.AppBarLayout; + +import androidx.annotation.NonNull; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.recyclerview.widget.RecyclerView; + public final class FlingBehavior extends AppBarLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; diff --git a/app/src/main/java/hearsilent/amazingavatar/libs/NetworkHelper.java b/app/src/main/java/hearsilent/amazingavatar/libs/NetworkHelper.java index 2a61d29..fc9fd88 100644 --- a/app/src/main/java/hearsilent/amazingavatar/libs/NetworkHelper.java +++ b/app/src/main/java/hearsilent/amazingavatar/libs/NetworkHelper.java @@ -1,13 +1,12 @@ package hearsilent.amazingavatar.libs; -import android.support.annotation.NonNull; - import org.json.JSONArray; import org.json.JSONObject; import java.io.IOException; import java.util.concurrent.TimeUnit; +import androidx.annotation.NonNull; import hearsilent.amazingavatar.callbacks.AvatarCallback; import hearsilent.amazingavatar.models.AvatarModel; import okhttp3.Call; diff --git a/app/src/main/res/drawable/avatar_background.xml b/app/src/main/res/drawable/avatar_background.xml index 83c1290..6c11a31 100644 --- a/app/src/main/res/drawable/avatar_background.xml +++ b/app/src/main/res/drawable/avatar_background.xml @@ -1,6 +1,6 @@ + android:shape="oval"> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 9d46965..50a3c6a 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,22 +1,21 @@ - - - - + android:layout_marginStart="56dp" + android:layout_marginEnd="8dp"/> - @@ -92,7 +91,7 @@ app:layout_constraintStart_toStartOf="@+id/textView_title_shadow" app:layout_constraintTop_toTopOf="@+id/textView_title_shadow"/> - - - - + + + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_demo.xml b/app/src/main/res/layout/item_demo.xml index 9971e71..a35dc37 100644 --- a/app/src/main/res/layout/item_demo.xml +++ b/app/src/main/res/layout/item_demo.xml @@ -1,12 +1,12 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 55db43f..017511d 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'com.android.tools.build:gradle:4.1.0' // 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 aac7c9b..9e6fce1 100644 --- 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 505cb3f..a4d6b0b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu May 31 15:54:33 CST 2018 +#Wed Oct 28 17:24:19 CST 2020 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-6.5-all.zip From f4fb75c1424d7477fe64284ea0c90bfdd13d0a96 Mon Sep 17 00:00:00 2001 From: HearSilent Date: Wed, 28 Oct 2020 17:33:13 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 855a5eb..3f70045 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Avatars from [maximedegreve/TinyFaces](https://github.com/maximedegreve/TinyFace ## Let me know! -I'd be really happy if you sent me links to your projects where you use my component. Just send an email to hear.silent1995@gmail.com And do let me know if you have any questions or suggestion regarding the example. +I'd be really happy if you sent me links to your projects where you use my component. Just send an email to hear.silent1995+github@gmail.com And do let me know if you have any questions or suggestion regarding the example. ## License From 51f099ed39ce00045970355f95a556cd36090cef Mon Sep 17 00:00:00 2001 From: HearSilent Date: Wed, 28 Oct 2020 17:33:30 +0800 Subject: [PATCH 3/3] Update version to 1.1.0 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f428f8d..f632dec 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "hearsilent.amazingavatar" minSdkVersion 17 targetSdkVersion 30 - versionCode 107 - versionName "1.0.7" + versionCode 110 + versionName "1.1.0" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes {