Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion MaterialDialogLibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'com.vanniktech.maven.publish'
apply plugin: 'maven-publish'

android {
compileSdkVersion 31
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion MaterialDialogLibrary/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="dev.shreyaspatil.MaterialDialog" />
<manifest />
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -73,6 +75,7 @@ protected AbstractDialog(@NonNull Activity mActivity,
this.mNegativeButton = mNegativeButton;
this.mAnimationResId = mAnimationResId;
this.mAnimationFile = mAnimationFile;
this.mAnimationUrl = mAnimationUrl;
}

@SuppressLint("WrongConstant")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
}
Expand Down Expand Up @@ -332,6 +341,7 @@ public static abstract class Builder<D extends AbstractDialog> {
protected DialogButton negativeButton;
protected int animationResId = NO_ANIMATION;
protected String animationFile;
protected String animationUrl;

/**
* @param activity where Material Dialog is to be built.
Expand Down Expand Up @@ -486,6 +496,18 @@ public Builder<D> 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<D> setAnimationUrl(@NonNull String url) {
this.animationUrl = url;
return this;
}

/**
* Builds the dialog.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -105,7 +106,8 @@ public BottomSheetMaterialDialog build() {
positiveButton,
negativeButton,
animationResId,
animationFile
animationFile,
animationUrl
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -71,7 +72,8 @@ public MaterialDialog build() {
positiveButton,
negativeButton,
animationResId,
animationFile
animationFile,
animationUrl
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/button_negative"
style="@style/MaterialDialog.NegativeButton"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
app:iconGravity="textStart"
Expand All @@ -72,7 +72,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/button_positive"
style="@style/MaterialDialog.PositiveButton"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
app:iconGravity="textStart"
Expand Down
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'dev.shreyaspatil.MaterialDialogExample'
}

dependencies {
Expand All @@ -29,7 +30,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'

// Material Dialog Library
implementation 'dev.shreyaspatil.MaterialDialog:MaterialDialog:2.2.3'
// implementation 'dev.shreyaspatil.MaterialDialog:MaterialDialog:2.2.3'

// Material Design Library
implementation 'com.google.android.material:material:1.4.0'
Expand All @@ -40,5 +41,5 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// implementation project(path: ':MaterialDialogLibrary')
implementation project(path: ':MaterialDialogLibrary')
}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="dev.shreyaspatil.MaterialDialogExample">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

public class MainActivity extends AppCompatActivity implements View.OnClickListener, OnShowListener, OnCancelListener, OnDismissListener {

private static final String ANIMATION_URL =
"https://lottie.host/4a060328-7fad-4252-8587-9b92c1d301de/BQ7bxXDosi.json";
// "https://raw.githubusercontent.com/airbnb/lottie-android/master/sample/src/main/assets/AndroidWave.json";

private MaterialDialog mSimpleDialog;
private MaterialDialog mAnimatedDialog;
private MaterialDialog mUrlAnimatedDialog;
private BottomSheetMaterialDialog mSimpleBottomSheetDialog;
private BottomSheetMaterialDialog mAnimatedBottomSheetDialog;

Expand All @@ -33,6 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
Button mButtonAnimatedDialog = findViewById(R.id.button_animated_dialog);
Button mButtonBottomSheetDialog = findViewById(R.id.button_simple_bottomsheet_dialog);
Button mButtonAnimatedBottomSheetDialog = findViewById(R.id.button_animated_bottomsheet_dialog);
Button mButtonUrlAnimatedDialog = findViewById(R.id.button_url_animated_dialog);

// Simple Material Dialog
mSimpleDialog = new MaterialDialog.Builder(this)
Expand Down Expand Up @@ -120,10 +126,33 @@ public void onClick(DialogInterface dialogInterface, int which) {
.setAnimation("delete_anim.json")
.build();

// URL Animated Material Dialog
mUrlAnimatedDialog = new MaterialDialog.Builder(this)
.setTitle("Delete?")
.setMessage("Are you sure want to delete this file?")
.setCancelable(false)
.setPositiveButton("Delete", R.drawable.ic_delete, new MaterialDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(getApplicationContext(), "Deleted!", Toast.LENGTH_SHORT).show();
dialogInterface.dismiss();
}
})
.setNegativeButton("Cancel", R.drawable.ic_close, new MaterialDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
Toast.makeText(getApplicationContext(), "Cancelled!", Toast.LENGTH_SHORT).show();
dialogInterface.dismiss();
}
})
.setAnimationUrl(ANIMATION_URL)
.build();

mButtonSimpleDialog.setOnClickListener(this);
mButtonBottomSheetDialog.setOnClickListener(this);
mButtonAnimatedDialog.setOnClickListener(this);
mButtonAnimatedBottomSheetDialog.setOnClickListener(this);
mButtonUrlAnimatedDialog.setOnClickListener(this);
}

@SuppressLint("NonConstantResourceId")
Expand All @@ -145,6 +174,10 @@ public void onClick(View view) {
case R.id.button_animated_bottomsheet_dialog:
mAnimatedBottomSheetDialog.show();
break;

case R.id.button_url_animated_dialog:
mUrlAnimatedDialog.show();
break;
}
}

Expand Down
29 changes: 19 additions & 10 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
tools:context="dev.shreyaspatil.MaterialDialogExample.MainActivity">

<LinearLayout
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
android:orientation="vertical"
android:padding="16dp">

<com.google.android.material.button.MaterialButton
android:id="@+id/button_simple_dialog"
Expand All @@ -23,30 +23,39 @@

<com.google.android.material.button.MaterialButton
android:id="@+id/button_simple_bottomsheet_dialog"
android:layout_marginTop="16dp"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Simple Bottomsheet Material Dialog" />
android:layout_marginTop="16dp"
android:text="Simple Bottomsheet Material Dialog"
android:textAllCaps="false" />

<com.google.android.material.button.MaterialButton
android:id="@+id/button_animated_dialog"
android:layout_marginTop="16dp"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Animated Material Dialog" />
android:layout_marginTop="16dp"
android:text="Animated Material Dialog"
android:textAllCaps="false" />

<com.google.android.material.button.MaterialButton
android:id="@+id/button_animated_bottomsheet_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:textAllCaps="false"
android:text="Animated Bottomsheet Material Dialog"
android:textAllCaps="false" />

<com.google.android.material.button.MaterialButton
android:id="@+id/button_url_animated_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Animated Bottomsheet Material Dialog" />
android:layout_marginTop="16dp"
android:text="URL Animated Material Dialog"
android:textAllCaps="false" />
</LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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/
POM_DEVELOPER_URL=https://github.com/patilshreyas/
android.nonTransitiveRClass=false
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17