diff --git a/MaterialDialogLibrary/build.gradle b/MaterialDialogLibrary/build.gradle index f828b23..20876b9 100644 --- a/MaterialDialogLibrary/build.gradle +++ b/MaterialDialogLibrary/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -apply plugin: 'com.vanniktech.maven.publish' +apply plugin: 'maven-publish' android { compileSdkVersion 31 @@ -22,7 +22,26 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + namespace 'dev.shreyaspatil.MaterialDialog' + publishing { + singleVariant('release') { + withSourcesJar() + } + } +} + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + from components.release + groupId = GROUP + artifactId = POM_ARTIFACT_ID + version = VERSION_NAME + } + } + } } dependencies { diff --git a/MaterialDialogLibrary/src/main/AndroidManifest.xml b/MaterialDialogLibrary/src/main/AndroidManifest.xml index 8117570..cc947c5 100644 --- a/MaterialDialogLibrary/src/main/AndroidManifest.xml +++ b/MaterialDialogLibrary/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/AbstractDialog.java b/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/AbstractDialog.java index 9ab90fd..f2729b7 100644 --- a/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/AbstractDialog.java +++ b/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/AbstractDialog.java @@ -48,6 +48,7 @@ public abstract class AbstractDialog implements DialogInterface { protected DialogButton mNegativeButton; protected int mAnimationResId; protected String mAnimationFile; + protected String mAnimationUrl; protected LottieAnimationView mAnimationView; protected TextAlignment mTitleTextAlignment; @@ -64,7 +65,8 @@ protected AbstractDialog(@NonNull Activity mActivity, @NonNull DialogButton mPositiveButton, @NonNull DialogButton mNegativeButton, @RawRes int mAnimationResId, - @NonNull String mAnimationFile) { + @NonNull String mAnimationFile, + @NonNull String mAnimationUrl) { this.mActivity = mActivity; this.title = title; this.message = message; @@ -73,6 +75,7 @@ protected AbstractDialog(@NonNull Activity mActivity, this.mNegativeButton = mNegativeButton; this.mAnimationResId = mAnimationResId; this.mAnimationFile = mAnimationFile; + this.mAnimationUrl = mAnimationUrl; } @SuppressLint("WrongConstant") @@ -119,7 +122,7 @@ protected View createView(@NonNull LayoutInflater inflater, @Nullable ViewGroup mPositiveButton.getOnClickListener().onClick(AbstractDialog.this, BUTTON_POSITIVE) ); } else { - mPositiveButtonView.setVisibility(View.INVISIBLE); + mPositiveButtonView.setVisibility(View.GONE); } // Set Negative Button @@ -134,7 +137,7 @@ protected View createView(@NonNull LayoutInflater inflater, @Nullable ViewGroup mNegativeButton.getOnClickListener().onClick(AbstractDialog.this, BUTTON_NEGATIVE) ); } else { - mNegativeButtonView.setVisibility(View.INVISIBLE); + mNegativeButtonView.setVisibility(View.GONE); } // If Orientation is Horizontal, Hide AnimationView @@ -154,6 +157,12 @@ protected View createView(@NonNull LayoutInflater inflater, @Nullable ViewGroup mAnimationView.setAnimation(mAnimationFile); mAnimationView.playAnimation(); + // Set Animation from URL + } else if (mAnimationUrl != null) { + mAnimationView.setVisibility(View.VISIBLE); + mAnimationView.setAnimationFromUrl(mAnimationUrl); + mAnimationView.playAnimation(); + } else { mAnimationView.setVisibility(View.GONE); } @@ -332,6 +341,7 @@ public static abstract class Builder { protected DialogButton negativeButton; protected int animationResId = NO_ANIMATION; protected String animationFile; + protected String animationUrl; /** * @param activity where Material Dialog is to be built. @@ -486,6 +496,18 @@ public Builder setAnimation(@NonNull String fileName) { return this; } + /** + * It sets the json animation to the {@link com.airbnb.lottie.LottieAnimationView} by loading it from a URL. + * + * @param url URL of the Lottie JSON animation to load into {@link com.airbnb.lottie.LottieAnimationView}. + * @return this, for chaining. + */ + @NonNull + public Builder setAnimationUrl(@NonNull String url) { + this.animationUrl = url; + return this; + } + /** * Builds the dialog. */ diff --git a/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/BottomSheetMaterialDialog.java b/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/BottomSheetMaterialDialog.java index e70081a..d18dc13 100644 --- a/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/BottomSheetMaterialDialog.java +++ b/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/BottomSheetMaterialDialog.java @@ -35,8 +35,9 @@ private BottomSheetMaterialDialog(@NonNull final Activity mActivity, @NonNull DialogButton mPositiveButton, @NonNull DialogButton mNegativeButton, @RawRes int mAnimationResId, - @NonNull String mAnimationFile) { - super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile); + @NonNull String mAnimationFile, + @NonNull String mAnimationUrl) { + super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mAnimationUrl); // Init Dialog, Create Bottom Sheet Dialog mDialog = new BottomSheetDialog(mActivity); @@ -105,7 +106,8 @@ public BottomSheetMaterialDialog build() { positiveButton, negativeButton, animationResId, - animationFile + animationFile, + animationUrl ); } } diff --git a/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/MaterialDialog.java b/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/MaterialDialog.java index 2ada97f..4ae558a 100644 --- a/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/MaterialDialog.java +++ b/MaterialDialogLibrary/src/main/java/dev/shreyaspatil/MaterialDialog/MaterialDialog.java @@ -27,8 +27,9 @@ private MaterialDialog(@NonNull final Activity mActivity, @NonNull DialogButton mPositiveButton, @NonNull DialogButton mNegativeButton, @RawRes int mAnimationResId, - @NonNull String mAnimationFile) { - super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile); + @NonNull String mAnimationFile, + @NonNull String mAnimationUrl) { + super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mAnimationUrl); // Init Dialog final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); @@ -71,7 +72,8 @@ public MaterialDialog build() { positiveButton, negativeButton, animationResId, - animationFile + animationFile, + animationUrl ); } } diff --git a/MaterialDialogLibrary/src/main/res/layout/layout_alert_dialog.xml b/MaterialDialogLibrary/src/main/res/layout/layout_alert_dialog.xml index 49b40dd..7b38248 100644 --- a/MaterialDialogLibrary/src/main/res/layout/layout_alert_dialog.xml +++ b/MaterialDialogLibrary/src/main/res/layout/layout_alert_dialog.xml @@ -63,7 +63,7 @@ + xmlns:tools="http://schemas.android.com/tools"> + + + android:orientation="vertical" + android:padding="16dp"> + android:layout_marginTop="16dp" + android:text="Simple Bottomsheet Material Dialog" + android:textAllCaps="false" /> + android:layout_marginTop="16dp" + android:text="Animated Material Dialog" + android:textAllCaps="false" /> + + + android:layout_marginTop="16dp" + android:text="URL Animated Material Dialog" + android:textAllCaps="false" /> \ No newline at end of file diff --git a/build.gradle b/build.gradle index 21498aa..5b145f9 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' - classpath 'com.vanniktech:gradle-maven-publish-plugin:0.18.0' + classpath 'com.android.tools.build:gradle:8.0.0' } } diff --git a/gradle.properties b/gradle.properties index ba49c34..129b99c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,4 +33,7 @@ POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=https://github.com/PatilShreyas/MaterialDialog-Android/blob/master/LICENSE POM_DEVELOPER_ID=patilshreyas POM_DEVELOPER_NAME=Shreyas Patil -POM_DEVELOPER_URL=https://github.com/patilshreyas/ \ No newline at end of file +POM_DEVELOPER_URL=https://github.com/patilshreyas/ +android.nonTransitiveRClass=false +android.defaults.buildfeatures.buildconfig=true +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a66dd2d..0377cae 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Jan 08 10:47:24 IST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..efde7bf --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk17