Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
MarsadMaqsood committed Mar 19, 2022
1 parent 4e1e83a commit d83d1df
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ getButton(/*StylishAlertDialog.Button)Type*/)
getButton(/*StylishAlertDialog.Button)Type*/).setBackgroundTintList()
setCancellable(boolean cancellable)
setCancelledOnTouchOutside(boolean cancelledOnTouchOutside)
<<<<<<< HEAD
setCustomView(View view, boolean withContent)
=======
setDismissOnClick(boolean dismissOnClick)

>>>>>>> 23dd967fa5b76fd9a240aa4e67c0572d1f54417f
```
thanks to the project [materialish-progress](https://github.com/pnikosis/materialish-progress)

Expand Down
12 changes: 9 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
plugins {
id 'com.android.application'
}
apply plugin: 'kotlin-android'

android {
compileSdkVersion 31
buildToolsVersion "32.0.0"
compileSdkVersion 32
buildToolsVersion "32.1.0-rc1"

defaultConfig {
applicationId "com.marsad.stylishdialogs"
minSdkVersion 16
targetSdkVersion 31
targetSdkVersion 32
multiDexEnabled true
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -38,4 +39,9 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.core:core-ktx:1.7.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:theme="@style/Theme.StylishDialogs"
tools:ignore="AllowBackup">
<activity
android:name=".MainActivityKotlin"
android:name=".ExampleActivity"
android:exported="true" />
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.marsad.stylishdialogs;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
maven{url 'https://jitpack.io'}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
9 changes: 3 additions & 6 deletions stylishdialogs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ plugins {
}

android {
compileSdkVersion 31
compileSdkVersion 32

defaultConfig {
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
targetSdkVersion 32
}

lintOptions {
lint {
abortOnError false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
Expand All @@ -23,9 +22,7 @@ public class AnimLoader {
public static Animation loadAnimation(Context context, int id)
throws Resources.NotFoundException {

XmlResourceParser parser = null;
try {
parser = context.getResources().getAnimation(id);
try (XmlResourceParser parser = context.getResources().getAnimation(id)) {
return createAnimationFromXml(context, parser);
} catch (XmlPullParserException ex) {
Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" +
Expand All @@ -37,9 +34,8 @@ public static Animation loadAnimation(Context context, int id)
Integer.toHexString(id));
rnf.initCause(ex);
throw rnf;
} finally {
if (parser != null) parser.close();
}

}

private static Animation createAnimationFromXml(Context c, XmlPullParser parser)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.marsad.stylishdialogs;

import android.annotation.SuppressLint;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.View;

public class Constants {
public static final View.OnTouchListener FOCUS_TOUCH_LISTENER = new View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
Drawable drawable = v.getBackground();
Expand All @@ -29,4 +31,4 @@ public boolean onTouch(View v, MotionEvent event) {
};


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.List;

public class StylishAlertDialog extends Dialog implements View.OnClickListener {

public static final int NORMAL = 0;
public static final int ERROR = 1;
public static final int SUCCESS = 2;
Expand All @@ -42,17 +43,20 @@ public class StylishAlertDialog extends Dialog implements View.OnClickListener {
public final static int BUTTON_CANCEL = DialogInterface.BUTTON_NEGATIVE;
public static boolean DARK_STYLE = false;
private final float defStrokeWidth;
//Made final
private final AnimationSet mModalInAnim;
private final AnimationSet mModalOutAnim;
private final Animation mOverlayOutAnim;
private final Animation mErrorInAnim;
private final AnimationSet mErrorXInAnim;
private final AnimationSet mSuccessLayoutAnimSet;
private final Animation mSuccessBowAnim;
//
boolean mCancelable = true;
boolean mCanceledOnTouchOutside = true;
boolean mDismissOnClick = false;
private View mDialogView;
private AnimationSet mModalInAnim;
private AnimationSet mModalOutAnim;
private Animation mOverlayOutAnim;
private Animation mErrorInAnim;
private AnimationSet mErrorXInAnim;
private AnimationSet mSuccessLayoutAnimSet;
private Animation mSuccessBowAnim;

private TextView mTitleTextView;
private TextView mContentTextView;
private FrameLayout mCustomViewContainer;
Expand Down Expand Up @@ -197,14 +201,18 @@ protected void onCreate(Bundle savedInstanceState) {
mWarningFrame = findViewById(R.id.warning_frame);
mButtonsContainer = findViewById(R.id.buttons_container);
mConfirmButton = findViewById(R.id.confirm_button);

mConfirmButton.setOnClickListener(this);
mConfirmButton.setOnTouchListener(Constants.FOCUS_TOUCH_LISTENER);

mCancelButton = findViewById(R.id.cancel_button);
mCancelButton.setOnClickListener(this);
mCancelButton.setOnTouchListener(Constants.FOCUS_TOUCH_LISTENER);

mNeutralButton = findViewById(R.id.neutral_button);
mNeutralButton.setOnClickListener(this);
mNeutralButton.setOnTouchListener(Constants.FOCUS_TOUCH_LISTENER);

mProgressHelper.setProgressWheel((ProgressWheel) findViewById(R.id.progressWheel));

setTitleText(mTitleText);
Expand All @@ -221,7 +229,7 @@ protected void onCreate(Bundle savedInstanceState) {
setNeutralButtonBackgroundColor(mNeutralButtonBackgroundColor);
setNeutralButtonTextColor(mNeutralButtonTextColor);
changeAlertType(mAlertType, true);
//todo:
//
setCancelable(mCancelable);
if (getCancellable())
setCanceledOnTouchOutside(mCanceledOnTouchOutside);
Expand Down Expand Up @@ -327,6 +335,7 @@ public boolean getCancellable() {
/**
* setCancellable
* This will prevent the dialog from dismissing
*
* @param cancelable value in boolean default is true
*/
public StylishAlertDialog setCancellable(boolean cancelable) {
Expand All @@ -337,6 +346,7 @@ public StylishAlertDialog setCancellable(boolean cancelable) {
/**
* setDismissOnClick
* This will close the dialog when the button clicked
*
* @param dismissOnClick in boolean default is false
*/
public StylishAlertDialog setDismissOnClick(boolean dismissOnClick) {
Expand All @@ -351,6 +361,7 @@ public boolean getCancelledOnTouchOutside() {
/**
* setCancelledOnTouchOutside
* This will prevent the dialog from dismissing when clicked outside the dialog
*
* @param cancelledOnTouchOutside in boolean default is true
*/
public StylishAlertDialog setCancelledOnTouchOutside(boolean cancelledOnTouchOutside) {
Expand All @@ -370,6 +381,7 @@ public String getTitleText() {
/**
* setTitleText
* set title to dialog
*
* @param text in String
*/
public StylishAlertDialog setTitleText(String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void init() {
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
// todo: changed int to float
//changed int to float
float totalW = getWidth();
float totalH = getHeight();
// rotate canvas first
Expand All @@ -62,10 +62,10 @@ public void draw(Canvas canvas) {
leftRect.right = (totalW + CONST_LEFT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1;
leftRect.left = leftRect.right - mLeftRectWidth;
}
//todo; extracted common part from if
//extracted common part from if
leftRect.top = (totalH + CONST_RIGHT_RECT_W) / 2;
leftRect.bottom = leftRect.top + CONST_RECT_WEIGHT;
//todo: and else
//and else
canvas.drawRoundRect(leftRect, CONST_RADIUS, CONST_RADIUS, mPaint);

RectF rightRect = new RectF();
Expand Down Expand Up @@ -103,9 +103,8 @@ protected void applyTransformation(float interpolatedTime, Transformation t) {
mLeftRectGrowMode = false;
mLeftRectWidth = mMaxLeftRectWidth * (1 - ((interpolatedTime - 0.7f) / 0.14f));
mLeftRectWidth = Math.max(mLeftRectWidth, MIN_LEFT_RECT_W);
// todo:changes//upper line with
// Math.max//
// mLeftRectWidth = mLeftRectWidth < MIN_LEFT_RECT_W ? MIN_LEFT_RECT_W : mLeftRectWidth;
// changed upper line Math.max
// mLeftRectWidth = mLeftRectWidth < MIN_LEFT_RECT_W ? MIN_LEFT_RECT_W : mLeftRectWidth;
mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f);
invalidate();
} else if (0.84 < interpolatedTime && 1 >= interpolatedTime) { // restore left rect width, shorten right rect to const
Expand Down
4 changes: 2 additions & 2 deletions stylishdialogs/src/main/res/anim/success_layout_rotate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
android:fromDegrees="0"
android:pivotX="110%"
android:pivotY="42%"
android:toDegrees="-45"/>
android:toDegrees="-45" />

<rotate
android:duration="0"
android:fillAfter="true"
android:fromDegrees="0"
android:pivotX="10%"
android:pivotY="42%"
android:toDegrees="-45"/>
android:toDegrees="-45" />
</set>
3 changes: 2 additions & 1 deletion stylishdialogs/src/main/res/layout/stylish_dialogs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="?attr/stylish_alert_bg_drawable"
android:layoutDirection="ltr"
tools:ignore="UnusedAttribute">
tools:targetApi="jelly_bean_mr1">

<LinearLayout
android:id="@+id/loading"
Expand Down Expand Up @@ -205,6 +205,7 @@
android:id="@+id/confirm_button"
style="@style/dialog_blue_button"
android:text="@string/dialog_ok"
android:contentDescription="@string/dialog_ok"
android:visibility="gone" />
</LinearLayout>

Expand Down

0 comments on commit d83d1df

Please sign in to comment.