diff --git a/build.gradle b/build.gradle index 2e7212f3..e75091a5 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.2' + classpath 'com.android.tools.build:gradle:3.5.3' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 64517bd6..7d9a7b12 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Mar 29 13:11:06 GMT 2019 +#Thu Feb 06 22:30:22 IST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index 3db15f63..df19e339 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -19,4 +19,5 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:support-annotations:28.0.0' } diff --git a/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java b/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java index a8761645..f665789c 100644 --- a/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java +++ b/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java @@ -14,6 +14,7 @@ import android.graphics.Typeface; import android.os.Build; import android.os.Handler; +import android.support.annotation.IntDef; import android.text.TextUtils; import android.util.AttributeSet; import android.view.Gravity; @@ -22,9 +23,11 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; +import android.widget.Button; import android.widget.FrameLayout; import android.widget.TextView; +import java.lang.annotation.Retention; import java.util.ArrayList; import java.util.List; @@ -36,6 +39,8 @@ import uk.co.deanwild.materialshowcaseview.target.Target; import uk.co.deanwild.materialshowcaseview.target.ViewTarget; +import static java.lang.annotation.RetentionPolicy.SOURCE; + /** * Helper class to show a sequence of showcase views. @@ -44,6 +49,9 @@ public class MaterialShowcaseView extends FrameLayout implements View.OnTouchLis public static final int DEFAULT_SHAPE_PADDING = 10; public static final int DEFAULT_TOOLTIP_MARGIN = 10; + public static final int DISMISS_TYPE_TEXT = 1; + public static final int DISMISS_TYPE_BUTTON = 2; + private int dismissType = DISMISS_TYPE_TEXT; long DEFAULT_DELAY = 0; long DEFAULT_FADE_TIME = 300; @@ -63,7 +71,8 @@ public class MaterialShowcaseView extends FrameLayout implements View.OnTouchLis private View mContentBox; private TextView mTitleTextView; private TextView mContentTextView; - private TextView mDismissButton; + private TextView mDismissText; + private Button mDismissButton; private boolean mHasCustomGravity; private TextView mSkipButton; private int mGravity; @@ -135,9 +144,10 @@ private void init(Context context) { mContentBox = contentView.findViewById(R.id.content_box); mTitleTextView = contentView.findViewById(R.id.tv_title); mContentTextView = contentView.findViewById(R.id.tv_content); - mDismissButton = contentView.findViewById(R.id.tv_dismiss); + mDismissText = contentView.findViewById(R.id.tv_dismiss); + mDismissText.setOnClickListener(this); + mDismissButton = contentView.findViewById(R.id.btn_dismiss); mDismissButton.setOnClickListener(this); - mSkipButton = contentView.findViewById(R.id.tv_skip); mSkipButton.setOnClickListener(this); } @@ -267,7 +277,7 @@ private void notifyOnDismissed() { */ @Override public void onClick(View v) { - if (v.getId() == R.id.tv_dismiss) { + if (v.getId() == R.id.tv_dismiss || v.getId()==R.id.btn_dismiss) { hide(); } else if (v.getId() == R.id.tv_skip) { skip(); @@ -447,6 +457,10 @@ private void setIsSequence(Boolean isSequenceB) { } private void setDismissText(CharSequence dismissText) { + if (mDismissText != null) { + mDismissText.setText(dismissText); + updateDismissButton(); + } if (mDismissButton != null) { mDismissButton.setText(dismissText); updateDismissButton(); @@ -461,12 +475,20 @@ private void setSkipText(CharSequence skipText) { } private void setDismissStyle(Typeface dismissStyle) { + if (mDismissText != null) { + mDismissText.setTypeface(dismissStyle); + updateDismissButton(); + } if (mDismissButton != null) { mDismissButton.setTypeface(dismissStyle); updateDismissButton(); } } + private void setDismissType(int dismissType) { + this.dismissType = dismissType; + } + private void setSkipStyle(Typeface skipStyle) { if (mSkipButton != null) { mSkipButton.setTypeface(skipStyle); @@ -487,11 +509,21 @@ private void setContentTextColor(int textColour) { } private void setDismissTextColor(int textColour) { + if (mDismissText != null) { + mDismissText.setTextColor(textColour); + } if (mDismissButton != null) { mDismissButton.setTextColor(textColour); } } + private void setDismissButtonColor(int btnColour) { + if (mDismissButton != null) { + mDismissButton.setBackgroundColor(btnColour); + } + } + + private void setShapePadding(int padding) { mShapePadding = padding; } @@ -563,51 +595,60 @@ public void setAnimationFactory(IAnimationFactory animationFactory) { */ public void setConfig(ShowcaseConfig config) { - if(config.getDelay() > -1){ + if (config.getDelay() > -1) { setDelay(config.getDelay()); } - if(config.getFadeDuration() > 0){ + if (config.getFadeDuration() > 0) { setFadeDuration(config.getFadeDuration()); } - if(config.getContentTextColor() > 0){ + if (config.getContentTextColor() > 0) { setContentTextColor(config.getContentTextColor()); } - if(config.getDismissTextColor() > 0){ + if (config.getDismissTextColor() > 0) { setDismissTextColor(config.getDismissTextColor()); } - if(config.getDismissTextStyle() != null){ + if (config.getDismissTextStyle() != null) { setDismissStyle(config.getDismissTextStyle()); } - if(config.getMaskColor() > 0){ + if (config.getMaskColor() > 0) { setMaskColour(config.getMaskColor()); } - if(config.getShape() != null){ + if (config.getShape() != null) { setShape(config.getShape()); } - if(config.getShapePadding() > -1){ + if (config.getShapePadding() > -1) { setShapePadding(config.getShapePadding()); } - if(config.getRenderOverNavigationBar() != null){ + if (config.getRenderOverNavigationBar() != null) { setRenderOverNavigationBar(config.getRenderOverNavigationBar()); } } void updateDismissButton() { // hide or show button - if (mDismissButton != null) { + if (mDismissText != null && dismissType == DISMISS_TYPE_TEXT) { + if (TextUtils.isEmpty(mDismissText.getText())) { + mDismissText.setVisibility(GONE); + } else { + mDismissText.setVisibility(VISIBLE); + mDismissButton.setVisibility(GONE); + } + } + if (mDismissButton != null && dismissType == DISMISS_TYPE_BUTTON) { if (TextUtils.isEmpty(mDismissButton.getText())) { mDismissButton.setVisibility(GONE); } else { mDismissButton.setVisibility(VISIBLE); + mDismissText.setVisibility(GONE); } } } @@ -686,6 +727,17 @@ public Builder setSequence(Boolean isSequence) { /** * Set the dismiss button properties */ + + @Retention(SOURCE) + @IntDef({DISMISS_TYPE_TEXT, DISMISS_TYPE_BUTTON}) + @interface DismissType { + } + + public Builder setDismissType(@DismissType int dismissType) { + showcaseView.setDismissType(dismissType); + return this; + } + public Builder setDismissText(int resId) { return setDismissText(activity.getString(resId)); } @@ -805,6 +857,11 @@ public Builder setDismissTextColor(int textColour) { return this; } + public Builder setDismissButtonColor(int buttonColour) { + showcaseView.setDismissButtonColor(buttonColour); + return this; + } + public Builder setDelay(int delayInMillis) { showcaseView.setDelay(delayInMillis); return this; diff --git a/library/src/main/res/layout/showcase_content.xml b/library/src/main/res/layout/showcase_content.xml index 30bfeb19..32191cdf 100644 --- a/library/src/main/res/layout/showcase_content.xml +++ b/library/src/main/res/layout/showcase_content.xml @@ -39,6 +39,21 @@ android:textSize="22dp" android:visibility="gone" /> +