From 5be885b883b6ca88b01070d5769ae00de12321f5 Mon Sep 17 00:00:00 2001 From: dirk41 <1378902882@qq.com> Date: Tue, 29 Jun 2021 16:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.OPENSOURCE | 2 +- entry/src/main/config.json | 5 --- .../sample/DialogStyleAbility.java | 4 +- .../sample/MainAbility.java | 4 +- library/build.gradle | 1 + library/src/main/config.json | 5 --- .../MaterialTapTargetPrompt.java | 8 ++-- .../MaterialTapTargetSequence.java | 21 +++++----- .../extras/PromptBackground.java | 4 +- .../extras/PromptFocal.java | 5 ++- .../extras/PromptText.java | 10 +++-- .../extras/PromptUtils.java | 41 +++++++++++-------- .../backgrounds/CirclePromptBackground.java | 7 ++-- .../extras/focals/CirclePromptFocal.java | 2 +- .../extras/focals/RectanglePromptFocal.java | 8 ++-- 15 files changed, 66 insertions(+), 61 deletions(-) diff --git a/README.OPENSOURCE b/README.OPENSOURCE index 900aff8..a78038e 100644 --- a/README.OPENSOURCE +++ b/README.OPENSOURCE @@ -8,7 +8,7 @@ "License File": "LICENSE", - "Version Number": "Release v3.2.0" + "Version Number": "v3.2.0" "Upstream URL": "https://github.com/sjwall/MaterialTapTargetPrompt", diff --git a/entry/src/main/config.json b/entry/src/main/config.json index be61fe5..181cf44 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -5,11 +5,6 @@ "version": { "code": 1000000, "name": "1.0.0" - }, - "apiVersion": { - "compatible": 5, - "target": 5, - "releaseType": "Release" } }, "deviceConfig": {}, diff --git a/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/DialogStyleAbility.java b/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/DialogStyleAbility.java index fded84a..3c400d6 100644 --- a/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/DialogStyleAbility.java +++ b/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/DialogStyleAbility.java @@ -61,8 +61,8 @@ public class DialogStyleAbility extends CommonDialog implements Component.Clicke super.onCreate(); setAutoClosable(false); setTransparent(true); - Component contentView = LayoutScatter.getInstance(mAbility). - parse(ResourceTable.Layout_ability_dialog_style, null, false); + Component contentView = LayoutScatter.getInstance(mAbility) + .parse(ResourceTable.Layout_ability_dialog_style, null, false); setContentCustomComponent(contentView); initViews(); } diff --git a/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/MainAbility.java b/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/MainAbility.java index 91906a8..90c001f 100644 --- a/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/MainAbility.java +++ b/entry/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/MainAbility.java @@ -298,8 +298,8 @@ public class MainAbility extends FractionAbility implements Component.ClickedLis public void onResume(Animator animator) { } }); - animatorValue.setValueUpdateListener((animatorValue1, v) -> fabToast. - setHeight(DensityUtils.pxToFp(getContext(), NumUtil.INT_56 * v))); + animatorValue.setValueUpdateListener((animatorValue1, v) -> + fabToast.setHeight(DensityUtils.pxToFp(getContext(), NumUtil.INT_56 * v))); animatorValue.start(); } } diff --git a/library/build.gradle b/library/build.gradle index 71c5721..4fc67c4 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.huawei.ohos.library' +apply from: '../upload.gradle' ohos { compileSdkVersion 6 defaultConfig { diff --git a/library/src/main/config.json b/library/src/main/config.json index 45e35fe..1d55e3d 100644 --- a/library/src/main/config.json +++ b/library/src/main/config.json @@ -5,11 +5,6 @@ "version": { "code": 1000000, "name": "1.0.0" - }, - "apiVersion": { - "compatible": 5, - "target": 5, - "releaseType": "Release" } }, "deviceConfig": { diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java index 5912e9a..882c8d3 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java @@ -550,10 +550,10 @@ public class MaterialTapTargetPrompt { mAnimationFocalBreathing.setLoopedCount(AnimatorValue.INFINITE); AnimatorValue animatorValue1 = new AnimatorValue(); animatorValue1.setValueUpdateListener((animatorValue, value) -> - onAnimationUpdate(1 + Constants.NUM_01F * value,false)); + onAnimationUpdate(1 + Constants.NUM_01F * value, false)); AnimatorValue animatorValue2 = new AnimatorValue(); animatorValue2.setValueUpdateListener((animatorValue, value) -> - onAnimationUpdate(Constants.NUM_1_1F - Constants.NUM_01F * value,true)); + onAnimationUpdate(Constants.NUM_1_1F - Constants.NUM_01F * value, true)); mAnimationFocalBreathing.runSerially(animatorValue1, animatorValue2); mAnimationFocalRipple = new AnimatorValue(); mAnimationFocalRipple.setCurveType(mView.mPromptOptions.getAnimationCurveType()); @@ -914,7 +914,7 @@ public class MaterialTapTargetPrompt { * @param ability ability. */ public Builder(final ComponentContainer component, final Ability ability) { - this(component, ability,null); + this(component, ability, null); } /** @@ -940,7 +940,7 @@ public class MaterialTapTargetPrompt { * @param componentContainer componentContainer */ public Builder(final Ability ability, ComponentContainer componentContainer) { - this(ability, componentContainer,null); + this(ability, componentContainer, null); } /** diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetSequence.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetSequence.java index 1725430..9a582a0 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetSequence.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetSequence.java @@ -38,11 +38,18 @@ public class MaterialTapTargetSequence { * Pointer to the next prompt to be shown */ int nextPromptIndex = Constants.NUM_F1; + /** * The list of prompts to display when the sequence is shown */ private final List items = new ArrayList<>(); + /** + * The listener to call when this sequence completes + */ + @Nullable + private SequenceCompleteListener mOnCompleteListener; + /** * Listener added to a sequence item for it completing. */ @@ -68,12 +75,6 @@ public class MaterialTapTargetSequence { } }; - /** - * The listener to call when this sequence completes - */ - @Nullable - private SequenceCompleteListener mOnCompleteListener; - /** * Set the listener to listen with the action to call when the sequence ends * @@ -103,8 +104,8 @@ public class MaterialTapTargetSequence { * @param milliseconds The number of milliseconds to show the prompt for. * @return This. */ - public MaterialTapTargetSequence addPrompt(@Nullable MaterialTapTargetPrompt prompt, - final long milliseconds) { + public MaterialTapTargetSequence addPrompt( + @Nullable MaterialTapTargetPrompt prompt, final long milliseconds) { this.addItem(new SequenceItemShowFor(new SequenceState(prompt), milliseconds)); return this; } @@ -127,8 +128,8 @@ public class MaterialTapTargetSequence { * @param milliseconds The number of milliseconds to show the prompt for. * @return This. */ - public MaterialTapTargetSequence addPrompt(PromptOptions promptOptions, - final long milliseconds) { + public MaterialTapTargetSequence addPrompt( + PromptOptions promptOptions, final long milliseconds) { this.addItem(new SequenceItemShowFor(new SequenceStatePromptOptions(promptOptions), milliseconds)); return this; } diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptBackground.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptBackground.java index 22792d3..49208ea 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptBackground.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptBackground.java @@ -43,6 +43,6 @@ public abstract class PromptBackground implements PromptUIElement { * @param isClip Should the prompt be clipped to the supplied clipBounds. * @param clipBounds The bounds to clip the drawing to. */ - public abstract void prepare(PromptOptions options, - boolean isClip, Rect clipBounds); + public abstract void prepare( + PromptOptions options, boolean isClip, Rect clipBounds); } diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptFocal.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptFocal.java index 60d9bc4..103dae3 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptFocal.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptFocal.java @@ -134,6 +134,7 @@ public abstract class PromptFocal implements PromptUIElement { * @param revealModifier The amount to scale the ripple by where a 1 value is the same size as the focal. * @param alphaModifier The amount to modify the ripple alpha by. */ - public abstract void updateRipple(@Range(from = 0, to = 2) float revealModifier, - @Range(from = 0, to = 1) float alphaModifier); + public abstract void updateRipple( + @Range(from = 0, to = 2) float revealModifier, + @Range(from = 0, to = 1) float alphaModifier); } diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java index 0e82bfc..31db455 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java @@ -89,8 +89,9 @@ public class PromptText implements PromptUIElement { * @param isClip clipToBounds * @param clipBounds clipBounds */ - public void prepare(PromptOptions options, - boolean isClip, Rect clipBounds) { + public void prepare( + PromptOptions options, + boolean isClip, Rect clipBounds) { mPromptOptions = options; isClipToBounds = isClip; mClipBounds = clipBounds; @@ -219,8 +220,9 @@ public class PromptText implements PromptUIElement { * @param maxWidth The maximum width that the text can be * @param alphaModifier alphaModifier */ - void createTextLayout(final PromptOptions options, final float maxWidth, - final float alphaModifier) { + void createTextLayout( + final PromptOptions options, final float maxWidth, + final float alphaModifier) { if (options.getPrimaryText() != null) { mPrimaryTextLayout = PromptUtils.createStaticTextLayout(options.getPrimaryText(), mPaintPrimaryText, (int) maxWidth, mPrimaryTextAlignment, diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java index 63b975b..98d32c7 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java @@ -49,9 +49,10 @@ public class PromptUtils { * @param radius The radius of the circle. * @return True if the point (x, y) is in the circle. */ - public static boolean isPointInCircle(final float x, final float y, - final Point circleCentre, - final float radius) { + public static boolean isPointInCircle( + final float x, final float y, + final Point circleCentre, + final float radius) { return Math.pow(x - circleCentre.getPointX(), Constants.NUM_2) + Math.pow(y - circleCentre.getPointY(), Constants.NUM_2) < Math.pow(radius, Constants.NUM_2); } @@ -97,8 +98,9 @@ public class PromptUtils { * @param styleIndex styleIndex * @return Font */ - public static Font setFontFromAttrs(@Nullable String familyName, Font font, - @Range(from = 0,to = Constants.NUM_2) int styleIndex) { + public static Font setFontFromAttrs( + @Nullable String familyName, Font font, + @Range(from = 0, to = Constants.NUM_2) int styleIndex) { Font tf; if (familyName != null) { tf = new Font.Builder(familyName).build(); @@ -151,9 +153,10 @@ public class PromptUtils { * @param text text * @return absolute layout direction */ - public static int getTextAlignment(final ResourceManager resources, - final int gravity, - @Nullable final CharSequence text) { + public static int getTextAlignment( + final ResourceManager resources, + final int gravity, + @Nullable final CharSequence text) { return LayoutAlignment.CENTER; } @@ -186,9 +189,10 @@ public class PromptUtils { * @param scale The amount to scale the rectangle by. * @param isEven Should the rectangle be scaled evenly in both directions. */ - public static void scale(final Point origin, RectFloat base, - RectFloat out, - final float scale, final boolean isEven) { + public static void scale( + final Point origin, + RectFloat base, RectFloat out, + final float scale, final boolean isEven) { if (scale == 1) { out.modify(base); return; @@ -236,9 +240,11 @@ public class PromptUtils { * @param textPadding textPadding * @return Maximum width in pixels that the prompt can be. */ - public static float calculateMaxWidth(final float maxTextWidth, - @Nullable final Rect clipBounds, - final int parentWidth, final float textPadding) { + public static float calculateMaxWidth( + final float maxTextWidth, + @Nullable final Rect clipBounds, + final int parentWidth, + final float textPadding) { return Math.max(Constants.NUM_80, Math.min(maxTextWidth, (clipBounds != null ? clipBounds.right - clipBounds.left : parentWidth) - (textPadding * Constants.NUM_2))); @@ -269,8 +275,11 @@ public class PromptUtils { * @param y The point y coordinate. * @return True if the point is within the inset rectangle, false otherwise. */ - public static boolean containsInset(final Rect bounds, - final int inset, final int x, final int y) { + public static boolean containsInset( + final Rect bounds, + final int inset, + final int x, + final int y) { return x > bounds.left + inset && x < bounds.right - inset && y > bounds.top + inset diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/backgrounds/CirclePromptBackground.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/backgrounds/CirclePromptBackground.java index 0c701e0..d5b1444 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/backgrounds/CirclePromptBackground.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/backgrounds/CirclePromptBackground.java @@ -86,8 +86,9 @@ public class CirclePromptBackground extends PromptBackground { } @Override - public void prepare(final PromptOptions options, final boolean isClipToBounds, - final Rect clipBounds) { + public void prepare( + final PromptOptions options, final boolean isClipToBounds, + final Rect clipBounds) { mPromptOptions = options; // Obtain values from the prompt options. @@ -104,7 +105,7 @@ public class CirclePromptBackground extends PromptBackground { final float inset88dp = 88f * DensityUtils.getDeviceAttr(options.getResourceFinder().getContext()) .getAttributes().densityPixels; clipBoundsInset88dp.modify(clipBounds.left + inset88dp, clipBounds.top + inset88dp, - clipBounds.right - inset88dp,clipBounds.bottom - inset88dp); + clipBounds.right - inset88dp, clipBounds.bottom - inset88dp); // Is the focal centre more than 88dp from the clip bounds edge if ((focalCentreX - clipBoundsInset88dp.left > 0 diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/CirclePromptFocal.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/CirclePromptFocal.java index 672b8cd..2f4435f 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/CirclePromptFocal.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/CirclePromptFocal.java @@ -170,7 +170,7 @@ public class CirclePromptFocal extends PromptFocal { public void draw(Canvas canvas) { if (mPromptOptions.getTargetView() != null && mPromptOptions.getIconDrawable() == null) { RectFloat rectFloat = new RectFloat( - 0,0, + 0, 0, mPosition.getPointX() + mPromptOptions.getTargetView().getWidth() * Constants.NUM_2, mPosition.getPointY() + mPromptOptions.getTargetView().getHeight() * Constants.NUM_2); int layerId = canvas.saveLayer(rectFloat, new Paint()); diff --git a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java index 6a3dd5d..c77b0cd 100644 --- a/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java +++ b/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java @@ -106,7 +106,7 @@ public class RectanglePromptFocal extends PromptFocal { if (size == null) { mSize = null; } else { - mSize = new Point(size.getPointX(),size.getPointY()); + mSize = new Point(size.getPointX(), size.getPointY()); } return this; } @@ -129,7 +129,7 @@ public class RectanglePromptFocal extends PromptFocal { } @Override - public void prepare(PromptOptions options,final int[] promptViewPosition) { + public void prepare(PromptOptions options, final int[] promptViewPosition) { mPromptOptions = options; Component target = options.getTargetView(); final int[] targetPosition = target.getLocationOnScreen(); @@ -142,7 +142,7 @@ public class RectanglePromptFocal extends PromptFocal { mBaseBounds.top = top - mPadding; mBaseBounds.right = left + width + mPadding; mBaseBounds.bottom = top + height + mPadding; - mBaseBoundsCentre.modify(left + (width / Constants.NUM_2F),top + (height / Constants.NUM_2F)); + mBaseBoundsCentre.modify(left + (width / Constants.NUM_2F), top + (height / Constants.NUM_2F)); } else { prepare(options, left + (width / Constants.NUM_2F), top + (height / Constants.NUM_2F)); } @@ -193,7 +193,7 @@ public class RectanglePromptFocal extends PromptFocal { public void draw(Canvas canvas) { if (mPromptOptions.getTargetView() != null && mPromptOptions.getIconDrawable() == null) { RectFloat rectFloat = new RectFloat( - 0,0, + 0, 0, mBaseBoundsCentre.getPointX() + mPromptOptions.getTargetView().getWidth() * Constants.NUM_2F, mBaseBoundsCentre.getPointY() + mPromptOptions.getTargetView().getHeight() * Constants.NUM_2F); int layerId = canvas.saveLayer(rectFloat, new Paint()); -- Gitee