From 7e3af0c216ccebc9147c6af262a80fb84f0691f0 Mon Sep 17 00:00:00 2001 From: Sanku-Yogesh <72017713+Sanku-Yogesh@users.noreply.github.com> Date: Wed, 28 Jul 2021 19:10:08 +0530 Subject: [PATCH 1/5] Update Readme --- README.md | 89 +++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 0b873cd..d332ca7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ArcPageIndicator [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=applibgroup_ArcPageIndicator&metric=alert_status)](https://sonarcloud.io/dashboard?id=applibgroup_ArcPageIndicator) [![Build](https://github.com/applibgroup/ArcPageIndicator/actions/workflows/main.yml/badge.svg)](https://github.com/applibgroup/ArcPageIndicator/actions/workflows/main.yml) Bored of the usual small points or stressed by the space occupied by a tab bar?
Try this elevator-like elegant and original page indicator! -A fully customizable super-easy Page Indicator, with stunning animations and very original and discreet graphics, for Android. Needs a very small screen, perfect when many pages need to be shown and reached in a small time. +A fully customizable super-easy Page Indicator, with stunning animations and very original and discreet graphics, for HarmonyOS. Needs a very small screen, perfect when many pages need to be shown and reached in a small time.
@@ -42,57 +42,58 @@ An old elevator that inspired this project. ``` ### Minimal usage -Layout for bottom 180° ellipse: - - ... - xmlns:app="http://schemas.android.com/apk/res-auto" - ... +Layout for left 180° ellipse: +```xml - -Layout for upper-left 90° ellipse: - - ... - xmlns:app="http://schemas.android.com/apk/res-auto" - ... +``` +Layout for upper-right 90° ellipse: +```xml - +``` ### Attributes description List of attributes with description: - + - + - - - - + + + + - - - + + + - - - - + + + +
General
apiViewPagerThe ViewPager associated to the Indicator
pageSliderIdThe pageSlider Id associated to the Indicator
Arc appearance
apiArcOrientationOrientation of the "belly" of the arc. This parameter also affects if the arc will be 90° (corner arc) or 180° (edge arc)
arcOrientationOrientation of the "belly" of the arc. This parameter also affects if the arc will be 90° (corner arc) or 180° (edge arc)
Spot appearance
apiSpotsColorColor of the spots
apiSelectedSpotColorColor of the selected spot
apiSpotsRadiusSize of the spots
apiSpotsShapeShape of the spots: Circle, RoundedSquare or Square
spotsColorColor of the spots
selectedSpotColorColor of the selected spot
spotsRadiusSize of the spots
spotsShapeShape of the spots: Circle, RoundedSquare or Square
Spots distribution and movement
apiIntervalMeasureHow spots are distributed on the circumference: constant angle or constant arc length. With constant angle, the spots will not be distributed evenly, because of ellipse's eccentricity. Normally constant arc length is used: being a non-finite math problem, here an approximation function is used, as explained later on.
apiInvertDirectionIf spots will be selected in inverted direction
apiAnimationTypeSee below to detailed explanation of animation types
intervalMeasureHow spots are distributed on the circumference: constant angle or constant arc length. With constant angle, the spots will not be distributed evenly, because of ellipse's eccentricity. Normally constant arc length is used: being a non-finite math problem, here an approximation function is used, as explained later on.
invertDirectionIf spots will be selected in inverted direction
animationTypeSee below to detailed explanation of animation types
Hand appearance
apiHandEnabledIf hand is drawn
apiHandColorHand's color
apiHandWidthHand's width
apiHandRelativeLengthHand's relative length starting from center to edges (1 = full length)
handEnabledIf hand is drawn
handColorHand's color
handWidthHand's width
handRelativeLengthHand's relative length starting from center to edges (1 = full length)
### Animation types @@ -116,12 +117,8 @@ List of animation types: Example of rounded squared spots -### New in 1.0.2 -* Fixed a crash when the ViewPager was not found -* Added setViewPager(), to attach the Indicator to dynamically created viewpagers, by referring the Object and not the id reference number - ### Some maths -This question I made helped me solve the +This question Mr. Beppi Menozzi made helped him solve the ellipse's problem. Indeed, finding arcs of constant length on a known ellipse is a problem with a non-finite solution, that needs integrals to be calculated. There were at least 5 approaches to solve this problem with acceptable performance: * find the points recursively, by iteratively reducing the error until it's close enough to zero. Pros: easy to do. Cons: adds a indetermined (although very small) time to the drawing process @@ -130,7 +127,7 @@ ellipse's problem. Indeed, finding arcs of constant length on a known ellipse is * use an approximated function. Pros: fast and good enough. Cons: never perfect * calculate the elliptic integrals. Pros: perfect. Cons: very very very heavy on performance -I chose to find a good approximated function and that is what you can find inside the code, it's fast enough and the error is near to invisibility. In case you need more performance, you can remove the e6 part of the formula and have a slightly bigger error. +He chose to find a good approximated function and that is what you can find inside the code, it's fast enough and the error is near to invisibility. In case you need more performance, you can remove the e6 part of the formula and have a slightly bigger error. The formula used is the one of the referenced question, and thanks very much to its author, Ng Chung Tak that is both the author of the answer, and the author of the formula itself. From 91b50ebda88c1e3e8798264522392e1e51007d8d Mon Sep 17 00:00:00 2001 From: Sanku-Yogesh Date: Thu, 29 Jul 2021 09:40:00 +0530 Subject: [PATCH 2/5] add license --- .../java/it/beppi/arcpageindicator/RectF.java | 16 ++++ .../beppi/arcpageindicator/util/AttrUtil.java | 16 ++++ .../beppi/arcpageindicator/util/LogUtil.java | 16 ++++ .../beppi/arcpageindicator/MainAbility.java | 16 ++++ .../beppi/arcpageindicator/MyApplication.java | 16 ++++ .../arcpageindicator/TestPagerProvider.java | 16 ++++ .../slice/MainAbilitySlice.java | 16 ++++ .../resources/base/layout/ability_main.xml | 79 +++++++++---------- .../arcpageindicator/ExampleOhosTest.java | 33 +------- 9 files changed, 151 insertions(+), 73 deletions(-) diff --git a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/RectF.java b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/RectF.java index 91e5d3c..39cf056 100644 --- a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/RectF.java +++ b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/RectF.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2020-21 Application Library Engineering Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package it.beppi.arcpageindicator; import ohos.agp.utils.RectFloat; diff --git a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/AttrUtil.java b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/AttrUtil.java index 0382400..90ca54c 100644 --- a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/AttrUtil.java +++ b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/AttrUtil.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2020-21 Application Library Engineering Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package it.beppi.arcpageindicator.util; import it.beppi.arcpageindicator.ArcPageIndicator; diff --git a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/LogUtil.java b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/LogUtil.java index 72788bf..c35e79d 100644 --- a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/LogUtil.java +++ b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/util/LogUtil.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2020-21 Application Library Engineering Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package it.beppi.arcpageindicator.util; import ohos.hiviewdfx.HiLog; diff --git a/entry/src/main/java/it/beppi/arcpageindicator/MainAbility.java b/entry/src/main/java/it/beppi/arcpageindicator/MainAbility.java index 887b8ff..157a9e0 100644 --- a/entry/src/main/java/it/beppi/arcpageindicator/MainAbility.java +++ b/entry/src/main/java/it/beppi/arcpageindicator/MainAbility.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2020-21 Application Library Engineering Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package it.beppi.arcpageindicator; import it.beppi.arcpageindicator.slice.MainAbilitySlice; diff --git a/entry/src/main/java/it/beppi/arcpageindicator/MyApplication.java b/entry/src/main/java/it/beppi/arcpageindicator/MyApplication.java index 5496e6a..f9a439b 100644 --- a/entry/src/main/java/it/beppi/arcpageindicator/MyApplication.java +++ b/entry/src/main/java/it/beppi/arcpageindicator/MyApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2020-21 Application Library Engineering Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package it.beppi.arcpageindicator; import ohos.aafwk.ability.AbilityPackage; diff --git a/entry/src/main/java/it/beppi/arcpageindicator/TestPagerProvider.java b/entry/src/main/java/it/beppi/arcpageindicator/TestPagerProvider.java index f754d5b..3a48564 100644 --- a/entry/src/main/java/it/beppi/arcpageindicator/TestPagerProvider.java +++ b/entry/src/main/java/it/beppi/arcpageindicator/TestPagerProvider.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2020-21 Application Library Engineering Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package it.beppi.arcpageindicator; import java.io.IOException; diff --git a/entry/src/main/java/it/beppi/arcpageindicator/slice/MainAbilitySlice.java b/entry/src/main/java/it/beppi/arcpageindicator/slice/MainAbilitySlice.java index 9b0045b..70225ec 100644 --- a/entry/src/main/java/it/beppi/arcpageindicator/slice/MainAbilitySlice.java +++ b/entry/src/main/java/it/beppi/arcpageindicator/slice/MainAbilitySlice.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2020-21 Application Library Engineering Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package it.beppi.arcpageindicator.slice; import it.beppi.arcpageindicator.ArcPageIndicator; diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml index 953db27..d63e7be 100644 --- a/entry/src/main/resources/base/layout/ability_main.xml +++ b/entry/src/main/resources/base/layout/ability_main.xml @@ -1,6 +1,7 @@ \ No newline at end of file diff --git a/entry/src/ohosTest/java/it/beppi/arcpageindicator/ExampleOhosTest.java b/entry/src/ohosTest/java/it/beppi/arcpageindicator/ExampleOhosTest.java index 8fade8d..bd1b01b 100644 --- a/entry/src/ohosTest/java/it/beppi/arcpageindicator/ExampleOhosTest.java +++ b/entry/src/ohosTest/java/it/beppi/arcpageindicator/ExampleOhosTest.java @@ -15,14 +15,12 @@ public class ExampleOhosTest { - private Context context; - private AttrSet attrSet; private ArcPageIndicator arcPageIndicator; @Before public void setUp() { - context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext(); - attrSet = new AttrSet() { + Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext(); + AttrSet attrSet = new AttrSet() { @Override public Optional getStyle() { return Optional.empty(); @@ -43,174 +41,149 @@ public Optional getAttr(String s) { return Optional.empty(); } }; + arcPageIndicator = new ArcPageIndicator(context, attrSet); } @Test public void testSetPageSliderId() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setPageSliderId(1111); assertEquals(1111, arcPageIndicator.getPageSliderId()); } @Test public void testSetSpotsColor() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setSpotsColor(0x99CCCCCC); assertEquals(0x99CCCCCC, arcPageIndicator.getSpotsColor()); } @Test public void testSetSelectedSpotsColor() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setSelectedSpotColor(0x99CCCCCC); assertEquals(0x99CCCCCC, arcPageIndicator.getSelectedSpotColor()); } @Test public void testSetSpotRadius() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setSpotsRadius(9); assertEquals(9, arcPageIndicator.getSpotsRadius()); } @Test public void testSetIntervalMeasureAngle() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setIntervalMeasureAngle(true); assertTrue(arcPageIndicator.isIntervalMeasureAngle()); } @Test public void testSetAnimationType() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setAnimationType(ArcPageIndicator.AnimationType.BUMP); assertEquals(ArcPageIndicator.AnimationType.BUMP, arcPageIndicator.getAnimationType()); } @Test public void testSetArcOrientation() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setArcOrientation(ArcPageIndicator.ArcOrientation.TO_DOWN); assertEquals(ArcPageIndicator.ArcOrientation.TO_DOWN, arcPageIndicator.getArcOrientation()); } @Test public void testSetInvertDirection() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setInvertDirection(true); assertTrue(arcPageIndicator.isInvertDirection()); } @Test public void testSetHandEnabled() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setHandEnabled(true); assertTrue(arcPageIndicator.isHandEnabled()); } @Test public void testSetHandColor() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setHandColor(0x99CCCCCC); assertEquals(0x99CCCCCC, arcPageIndicator.getHandColor()); } @Test public void testSetHandWidth() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setHandWidth(6); assertEquals(6, arcPageIndicator.getHandWidth()); } @Test public void testSetHandRelativeLength() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setHandRelativeLength(0.6f); assertEquals(0.6f, arcPageIndicator.getHandRelativeLength(),0.0001f); } @Test public void testSetSpotShape() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); arcPageIndicator.setSpotShape(ArcPageIndicator.SpotShape.SQUARE); assertEquals(ArcPageIndicator.SpotShape.SQUARE, arcPageIndicator.getSpotShape()); } @Test public void testGetPageSliderId() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_PAGE_SLIDER_ID, arcPageIndicator.getPageSliderId()); } @Test public void testGetSpotsColor() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_SPOTS_COLOR, arcPageIndicator.getSpotsColor()); } @Test public void testGetSelectedSpotsColor() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_SELECTED_SPOT_COLOR, arcPageIndicator.getSelectedSpotColor()); } @Test public void testGetSpotRadius() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_SPOTS_RADIUS, arcPageIndicator.getSpotsRadius()); } @Test public void testIsIntervalMeasureAngle() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_INTERVAL_MEASURE_ANGLE, arcPageIndicator.isIntervalMeasureAngle()); } @Test public void testGetAnimationType() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_ANIMATION_TYPE,arcPageIndicator.getAnimationType()); } @Test public void testGetArcOrientation() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_ARC_ORIENTATION,arcPageIndicator.getArcOrientation()); } @Test public void testGetSpotShape() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_SPOT_SHAPE,arcPageIndicator.getSpotShape()); } @Test public void testIsInvertDirection() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_INVERT_DIRECTION, arcPageIndicator.isInvertDirection()); } @Test public void testIsHandEnabled() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_HAND_ENABLED, arcPageIndicator.isHandEnabled()); } @Test public void testGetHandColor() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_HAND_COLOR, arcPageIndicator.getHandColor()); } @Test public void testGetHandWidth() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); assertEquals(AttrUtil.DEFAULT_HAND_WIDTH, arcPageIndicator.getHandWidth()); } @Test public void testGetHandRelativeLength() { - arcPageIndicator = new ArcPageIndicator(context,attrSet); double delta = 0.0001f; assertEquals(AttrUtil.DEFAULT_HAND_RELATIVE_LENGTH, arcPageIndicator.getHandRelativeLength(),delta); } From aab571bb3338583c7ee36dd4fb77b6a5f3c7cfe0 Mon Sep 17 00:00:00 2001 From: Sanku-Yogesh Date: Thu, 29 Jul 2021 09:41:40 +0530 Subject: [PATCH 3/5] update readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d332ca7..9ad0b07 100644 --- a/README.md +++ b/README.md @@ -161,4 +161,3 @@ License LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - From 4d220ac1fa9fa17af59f3a2feab01a560a2013a8 Mon Sep 17 00:00:00 2001 From: Sanku-Yogesh Date: Thu, 29 Jul 2021 10:59:00 +0530 Subject: [PATCH 4/5] Author info --- .../main/java/it/beppi/arcpageindicator/ArcPageIndicator.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/ArcPageIndicator.java b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/ArcPageIndicator.java index 13a3324..4f8a4af 100644 --- a/arcpageindicator/src/main/java/it/beppi/arcpageindicator/ArcPageIndicator.java +++ b/arcpageindicator/src/main/java/it/beppi/arcpageindicator/ArcPageIndicator.java @@ -11,6 +11,8 @@ import ohos.agp.utils.Color; import ohos.app.Context; +//Created by Beppi on 30/12/2016. + /** * ArcPageIndicator is a custom page indicator with stunning animations. Needs a very small screen, prefect when * many pages need to be shown and reached in a small time. From 343c24c0a2a85de54e255c07a3e561ff26f81167 Mon Sep 17 00:00:00 2001 From: Sanku-Yogesh <72017713+Sanku-Yogesh@users.noreply.github.com> Date: Thu, 29 Jul 2021 13:15:56 +0530 Subject: [PATCH 5/5] update readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9ad0b07..f2ecd7e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ A fully customizable super-easy Page Indicator, with stunning animations and ver
An old elevator that inspired this project. +## Source +The code in this repository was inspired from [BeppiMenozzi/ArcPageIndicator - v1.0.2](https://github.com/BeppiMenozzi/ArcPageIndicator). +We are very thankful to Mr. BeppiMenozzi. + ### Dependency 1. For using ArcPageIndicator module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har. ```