(targetView);
}
- public View getTargetView() {
+ /**
+ * getTargetView
+ *
+ * @return Component
+ */
+ public Component getTargetView() {
return mTargetViewWeakReference.get();
}
+ /**
+ * alpha
+ *
+ * @param alpha
+ */
@Override
public void setAlpha(float alpha) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setAlpha(alpha);
}
}
+ /**
+ * rotation
+ *
+ * @param rotation
+ */
@Override
public void setRotation(float rotation) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setRotation(rotation);
}
}
+ /**
+ * rotationX
+ *
+ * @param rotationX
+ */
@Override
public void setRotationX(float rotationX) {
- View targetView;
- if ((targetView = getTargetView()) != null){
- targetView.setRotationX(rotationX);
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
+ targetView.setRotation(rotationX);
}
}
+ /**
+ * rotationY
+ *
+ * @param rotationY
+ */
@Override
public void setRotationY(float rotationY) {
- View targetView;
- if ((targetView = getTargetView()) != null){
- targetView.setRotationY(rotationY);
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
+ targetView.setRotation(rotationY);
}
}
+ /**
+ * scaleX
+ *
+ * @param scaleX
+ */
@Override
public void setScaleX(float scaleX) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setScaleX(scaleX);
}
}
+ /**
+ * scaleY
+ *
+ * @param scaleY
+ */
@Override
public void setScaleY(float scaleY) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setScaleY(scaleY);
}
}
+ /**
+ * scrollX
+ *
+ * @param scrollX
+ */
@Override
public void setScrollX(int scrollX) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setScaleX(scrollX);
}
}
+ /**
+ * scrollY
+ *
+ * @param scrollY
+ */
@Override
public void setScrollY(int scrollY) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setScaleY(scrollY);
}
-
+
}
+ /**
+ * translationX
+ *
+ * @param translationX
+ */
@Override
public void setTranslationX(float translationX) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setTranslationX(translationX);
}
}
+ /**
+ * translationY
+ *
+ * @param translationY
+ */
@Override
public void setTranslationY(float translationY) {
- View targetView;
- if ((targetView = getTargetView()) != null){
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
targetView.setTranslationY(translationY);
}
}
+ /**
+ * x
+ *
+ * @param x
+ */
@Override
public void setX(float x) {
- View targetView;
- if ((targetView = getTargetView()) != null){
- targetView.setX(x);
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
+ targetView.setTranslationX(x);
}
}
+ /**
+ * y
+ *
+ * @param y
+ */
@Override
public void setY(float y) {
- View targetView;
- if ((targetView = getTargetView()) != null){
- targetView.setY(y);
+ Component targetView;
+ if ((targetView = getTargetView()) != null) {
+ targetView.setTranslationY(y);
}
}
-
+ /**
+ * createSpringByBouncinessAndSpeed
+ *
+ * @param bounciness
+ * @param speed
+ * @return Spring
+ */
@Override
public Spring createSpringByBouncinessAndSpeed(double bounciness, double speed) {
return mSpringSystem.createSpring()
.setSpringConfig(SpringConfig.fromBouncinessAndSpeed(bounciness, speed));
}
+ /**
+ * createSpringByTensionAndFriction
+ *
+ * @param tension
+ * @param friction
+ * @return Spring
+ */
@Override
public Spring createSpringByTensionAndFriction(double tension, double friction) {
return mSpringSystem.createSpring()
.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(tension, friction));
}
+ /**
+ * transition
+ *
+ * @param progress
+ * @param startValue
+ * @param endValue
+ * @return float
+ */
@Override
public float transition(double progress, float startValue, float endValue) {
return (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, startValue, endValue);
}
-
-
- public void clear(){
- View view = getTargetView();
- if (view != null){
- ViewParent viewParent = view.getParent();
- if (viewParent instanceof ViewGroup){
- ViewGroup parent = (ViewGroup) viewParent;
- parent.removeView(view);
+
+ /**
+ * clear
+ */
+ public void clear() {
+ Component view = getTargetView();
+ if (view != null) {
+ ComponentContainer viewParent = (ComponentContainer) view.getComponentParent();
+ if (viewParent instanceof ComponentContainer) {
+ ComponentContainer parent = viewParent;
+ parent.removeComponent(view);
mTargetViewWeakReference.clear();
}
}
}
-
+
}
diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/util/LogUtil.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/util/LogUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..6cea79c31fe1e860425a55bf51101b5959e32525
--- /dev/null
+++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/util/LogUtil.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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 an 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 com.ufreedom.floatingview.util;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * LogUtil 工具类
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public final class LogUtil {
+ private static final int DOMAIN = 0x001;
+
+ private LogUtil() {
+ throw new Error("请不要实例化!");
+ }
+
+ /** info日志打印
+ *
+ * @param tag
+ * @param format
+ * @param objects
+ */
+ public static void info(String tag, String format, Object... objects) {
+ HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, DOMAIN, tag);
+ HiLog.info(logLabel, format, objects);
+ }
+
+ /** debug日志打印
+ *
+ * @param tag
+ * @param format
+ * @param objects
+ */
+ public static void debug(String tag, String format, Object... objects) {
+ HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, DOMAIN, tag);
+ HiLog.debug(logLabel, format, objects);
+ }
+
+ /** error日志打印
+ *
+ * @param tag
+ * @param format
+ * @param objects
+ */
+ public static void error(String tag, String format, Object... objects) {
+ HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, DOMAIN, tag);
+ HiLog.error(logLabel, format, objects);
+ }
+
+ /** warn日志打印
+ *
+ * @param tag
+ * @param format
+ * @param objects
+ */
+ public static void warn(String tag, String format, Object... objects) {
+ HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, DOMAIN, tag);
+ HiLog.warn(logLabel, format, objects);
+ }
+
+ /** fatal日志打印
+ *
+ * @param tag
+ * @param format
+ * @param objects
+ */
+ public static void fatal(String tag, String format, Object... objects) {
+ HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, DOMAIN, tag);
+ HiLog.fatal(logLabel, format, objects);
+ }
+}
diff --git a/FloatingViewLib/src/main/res/values/ids.xml b/FloatingViewLib/src/main/res/values/ids.xml
deleted file mode 100644
index 8fefcc523678f8a33acc0d1b19ccbc2d927f84c0..0000000000000000000000000000000000000000
--- a/FloatingViewLib/src/main/res/values/ids.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/FloatingViewLib/src/main/res/values/strings.xml b/FloatingViewLib/src/main/res/values/strings.xml
deleted file mode 100644
index 86ebe52edcae2d4d6a82abf52171439ec9bab947..0000000000000000000000000000000000000000
--- a/FloatingViewLib/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- FloatingView
-
diff --git a/FloatingViewLib/src/main/resources/base/element/string.json b/FloatingViewLib/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..157e044df7c9626ba9485c4c8db36fada10c4fad
--- /dev/null
+++ b/FloatingViewLib/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "FloatingViewLib"
+ }
+ ]
+}
diff --git a/FloatingViewLib/src/main/resources/base/layout/floating_fecor_view.xml b/FloatingViewLib/src/main/resources/base/layout/floating_fecor_view.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5d495e88cfe04097f057abd4af2f645db14f6efb
--- /dev/null
+++ b/FloatingViewLib/src/main/resources/base/layout/floating_fecor_view.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/demo/src/main/res/drawable-xxhdpi/bike.png b/FloatingViewLib/src/main/resources/base/media/bike.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/bike.png
rename to FloatingViewLib/src/main/resources/base/media/bike.png
diff --git a/FloatingViewLib/src/test/java/com/ufreedom/floatingview/ExampleTest.java b/FloatingViewLib/src/test/java/com/ufreedom/floatingview/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8e940a2923f709cb2f5b8dedfa4089d074989d82
--- /dev/null
+++ b/FloatingViewLib/src/test/java/com/ufreedom/floatingview/ExampleTest.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International Co., Ltd.
+ * 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 an 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 com.ufreedom.floatingview;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/FloatingViewLib/src/test/java/com/ufreedom/floatingview/ExampleUnitTest.java b/FloatingViewLib/src/test/java/com/ufreedom/floatingview/ExampleUnitTest.java
deleted file mode 100644
index 7a4ef401101f31594bcf040d8d94c0bd4a5f42bb..0000000000000000000000000000000000000000
--- a/FloatingViewLib/src/test/java/com/ufreedom/floatingview/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.ufreedom.floatingview;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/README.md b/README.md
index cb9f592678b2b198fba63cef14bb6d990c96d169..8f30c52e4bcecd367abe061f7a02771799876b5c 100644
--- a/README.md
+++ b/README.md
@@ -1,137 +1,97 @@
-
-
-
-
-
+# FloatingView
-FloatingView
+**本项目基于开源项目FloatingView进行openharmony化的移植和开发,可以通过项目标签以及github地址( https://github.com/UFreedom/FloatingView )追踪到原安卓项目版本**
-
- FloatingView can make the target view floating above the anchor view with cool animation
-
+#### 项目介绍
+- 项目名称:FloatingView
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:可以让Component在别的Component上执行的漂浮动画。
+- 项目移植状态:主功能完成
+- 调用差异:有
+- 基线版本:release 1.0.2
+- 开发版本:sdk5,DevEco Studio2.1 beta3
+- 项目作者和维护人:许建宏
+- 联系方式:xujianhong050@chinasoftinc.com
+- 原项目Doc地址:https://github.com/UFreedom/FloatingView
-
-
-
-
-
-
+#### 效果演示
-
+
-
-
-
-
-
-
-Links
------
-- [中文版 README](https://github.com/UFreedom/FloatingView/blob/master/README_CN.md)
-- [Blog about FloatingView](http://www.jianshu.com/p/6aaa258d77f1)
-- [demo.apk](http://oeapkptbn.bkt.clouddn.com/FloatingView-demo-v1.0.1.apk)
-
-
-Usage
------
-
-### Step 1
+#### 调用差异说明
+```java
+ 由于openharmony无对应API Window.ID_ANDROID_CONTENT所以需要传递当前的顶层Component在其上面进行操作
+ 所以在初始化Floating的时候需要传递当前的Component
+```
+#### 安装教程
-Add dependencies in build.gradle.
-```groovy
- dependencies {
- compile 'com.ufreedom.uikit:FloatingViewLib:1.0.2'
+1.在项目根目录下的build.gradle文件中,
+```java
+ allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
}
-
+ }
+```
+2.在entry模块的build.gradle文件中,
+```java
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:FloatingViewLib:0.0.1-SNAPSHOT')
+ ......
+ }
```
+在sdk5,DevEco Studio2.1 beta3下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
+#### 使用说明
-### Step 2
-
-Use FloatingBuilder to create a FloatingElement
-
+初始化
```java
-
- FloatingElement builder = new FloatingBuilder()
- .anchorView(View)
- .targetView(View)
+ FloatingElement builder = new FloatingBuilder()
+ .anchorView(Component)
+ .targetView(Component)
.offsetX(int)
.offsetY(int)
.floatingTransition(FloatingTransition)
.build();
-
```
-
-The use of FloatingBuilder can be configured to have:
-
-* anchorView :Anchor, is you want to float animation in which View above
-* target:Target, The view which you want to float
-* offsetX:X direction of offset, unit PX
-* offsetY: Y direction of offset, unit PX
-* floatingTransition : Floating effect, the default is ScaleFloatingTransition
-
-
-### Step 3
-
-Create a Floating as a FloatingElement container, and then let your View fly up
-
+创建一个 `Floating` 作为 `FloatingElement` 的容器,然后让你的 `Component` 飞起来
```java
- Floating floating = new Floating(getActivity());
+ Floating floating = new Floating(AbilitySlice activity, Component topComponent);
floating.startFloating(builder);
```
-
-
-Customisation
--------------
-
-
-####1.Coordinates
-
-
-
-
-####2.Class Diagram
-
-
-
-####3.Floating Animation
-
-Implementation of floating animation is very simple, you only need to implement the [FloatingTransition][4] interface.
-
+实现漂浮动画很简单,你只需要实现 `FloatingTransition` 接口就可以
```java
-
public interface FloatingTransition {
- public void applyFloating(YumFloating yumFloating);
+ void applyFloating(YumFloating yumFloating);
}
-
```
+在 `applyFloating` 方法,你可以使用 `Animation` 创建动画,然后使用 `YumFloating` 进行 `Alpha`,`Scale`,`Translate`,`Rotate` 等变换
-
-In the `applyFloating` method, you can use Android Animation to do the animation, and then use the [YumFloating][6] to do Alpha , Scale, Translate, Rotate and other transformations.
-If you want to add the [Facebook Rebound][5] animation effect, you can use the [SpringHelper][7], for example, [ScaleFloatingTransition][8]:
-
+如果你想加入 Facebook Rebound 回弹动画效果,你可以使用 SpringHelper,例如 ScaleFloatingTransition:
```java
- public class ScaleFloatingTransition implements FloatingTransition {
+public class ScaleFloatingTransition implements FloatingTransition {
...
-
- @Override
+
+ @Override
public void applyFloating(final YumFloating yumFloating) {
-
- ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f);
- alphaAnimator.setDuration(duration);
- alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ AnimatorValue alphaAnimator = new AnimatorValue();
+ alphaAnimator.setDuration(mDuration);
+ alphaAnimator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
@Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- yumFloating.setAlpha((Float) valueAnimator.getAnimatedValue());
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ yumFloating.setAlpha(1 - v);
}
});
alphaAnimator.start();
-
- SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f,bounciness, speed)
- .reboundListener(new SimpleReboundListener(){
+ SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f, mBounciness, mSpeed)
+ .reboundListener(new SimpleReboundListener() {
@Override
public void onReboundUpdate(double currentValue) {
yumFloating.setScaleX((float) currentValue);
@@ -139,85 +99,103 @@ If you want to add the [Facebook Rebound][5] animation effect, you can use the
}
}).start(yumFloating);
}
-
-}
-
+}
```
+如果 `SpringHelper` 无法满足你的需求,你可以直接使用 `YumFloating `的
+`createSpringByBouncinessAndSpeed(double bounciness, double speed)` 或者 `createSpringByTensionAndFriction(double tension, double friction)` 创建 `Spring`, 然后使用 `transition(double progress, float startValue, float endValue)` 进行数值转换
-If [SpringHelper][7] can not meet your needs, you can directly use the `createSpringByBouncinessAndSpeed(double bounciness, double speed)` or
-`createSpringByTensionAndFriction(double tension, double friction)` to create the Spring, and then use `transition (Progress double, startValue float, endValue float)` for numerical conversion
-
-####4.Floating Path Animation
-The floating path animation is also very simple, such as [CurveFloatingPathTransition][9], first you need to inherit from the [BaseFloatingPathTransition][10] class ,The difference is, you need to implement a `getFloatingPath (`) method.
-Use `Path` in the `getFloatingPath () `method to create the path you want to float, and then call `FloatingPath.create (path, false)` to return. For example, [CurveFloatingPathTransition][9] implementation:
+路径漂浮动画 实现路径漂浮同样很简单,例如 `CurveFloatingPathTransition` ,首先你需要继承 `BaseFloatingPathTransition` 类.和继承 `FloatingTransition` 类不同的是,你需要再实现一个 `getFloatingPath()` 方法. 在 `getFloatingPath()` 方法内使用 Path 创建你想漂浮的路径,然后调用 `FloatingPath.create(path, false)` 进行返回. 例如 `CurveFloatingPathTransition` 实现:
```java
- public class CurveFloatingPathTransition extends BaseFloatingPathTransition {
+public class CurveFloatingPathTransition extends BaseFloatingPathTransition {
...
-
+
@Override
public FloatingPath getFloatingPath() {
- if (path == null){
- path = new Path();
- path.moveTo(0, 0);
- path.quadTo(-100, -200, 0, -300);
- path.quadTo(200, -400, 0, -500);
+ if (mPath == null) {
+ mPath = new Path();
+ mPath.moveTo(0, 0);
+ mPath.quadTo(-100, -200, 0, -300);
+ mPath.quadTo(200, -400, 0, -500);
}
- return FloatingPath.create(path, false);
+ return FloatingPath.create(mPath, false);
}
@Override
public void applyFloating(final YumFloating yumFloating) {
- ValueAnimator translateAnimator;
- ValueAnimator alphaAnimator;
-
-
- translateAnimator = ObjectAnimator.ofFloat(getStartPathPosition(), getEndPathPosition());
- translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- float value = (float) valueAnimator.getAnimatedValue();
- PathPosition floatingPosition = getFloatingPosition(value);
- yumFloating.setTranslationX(floatingPosition.x);
- yumFloating.setTranslationY(floatingPosition.y);
-
- }
- });
-
- ...
- }
-
+ AnimatorValue translateAnimator;
+ AnimatorValue alphaAnimator;
+
+ // 需要指定算法 translateAnimator = ObjectAnimator.ofFloat(getStartPathPosition(), getEndPathPosition());
+ translateAnimator = new AnimatorValue();
+ translateAnimator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ PathPosition floatingPosition = getFloatingPosition(v * getEndPathPosition());
+ yumFloating.setTranslationX(floatingPosition.x);
+ yumFloating.setTranslationY(floatingPosition.y);
+ }
+ });
+ }
+ ...
}
```
+使用 `Path`将你想要漂浮的路径的描绘出来,然后在 `applyFloating(final YumFloating yumFloating)` 方法中:
+使用 `getStartPathPosition()` 方法获取路径的开始位置
+使用 `getEndPathPosition()`方法获取路径的结束位置
+使用 `getFloatingPosition(float progress)` 获取当前进度的位置
+`getFloatingPosition(float progress)` 方法会返回一个 `PathPosition` 对象,其属性 `x`,`y` 分别代表当前路径动画的` x `坐标,和 `y `坐标.
-Use Path to describe the path you want to float, and then in `applyFloating (YumFloating yumFloating)`:
-* Use `getStartPathPosition () ` method to obtain the starting position of the path
-* Use `getEndPathPosition () ` method to obtain the end position of the path
-* Use `getFloatingPosition(float progress)` to get the position of the current progress
-
-`getFloatingPosition(float progress)`method will return a `PathPosition` object, its properties x an y representing the current path animation x coordinates and Y coordinates.
+3.接口说明:
+```java
+/**
+ * 锚点,也就是你想在哪个 Component 上面进行漂浮动画
+ */
+FloatingBuilder anchorView(Component view)
+
+/**
+ * 目标,你想漂浮的 Component
+ */
+FloatingBuilder targetView(Component view)
+
+/**
+ * x 方向的偏移量,单位 px
+ */
+FloatingBuilder offsetX(int offsetX)
+
+/**
+ * y 方向的偏移量,单位 px
+ */
+FloatingBuilder offsetY(int offsetY)
+
+/**
+ * 漂浮效果,默认是 ScaleFloatingTransition,也可以自己实现漂浮效果
+ */
+FloatingBuilder floatingTransition(FloatingTransition floatingTransition)
+```
-Release Log
------------
+#### 测试信息
+CodeCheck代码测试无异常
-#### v1.0.2
-[Fix bug](https://github.com/UFreedom/FloatingView/pull/6)
+CloudTest代码测试无异常
+火绒安全病毒安全检测通过
-#### v1.0.1
-First Version
+当前版本demo功能与原组件基本无差异
+测试员:常小俊
+#### 版本迭代
+- 0.0.1-SNAPSHOT
-License
---------
+## License
Copyright 2015 UFreedom
@@ -232,15 +210,3 @@ License
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.
-
-
-[1]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingBuilder.java
-[2]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingElement.java
-[3]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/Floating.java
-[4]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingTransition.java
-[5]:http://facebook.github.io/rebound/
-[6]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/YumFloating.java
-[7]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SpringHelper.java
-[8]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/ScaleFloatingTransition.java
-[9]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/CurveFloatingPathTransition.java
-[10]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/BaseFloatingPathTransition.java
\ No newline at end of file
diff --git a/README_CN.md b/README_CN.md
deleted file mode 100644
index d6853cd03cea0b4a52efd8e2191403f942e735d4..0000000000000000000000000000000000000000
--- a/README_CN.md
+++ /dev/null
@@ -1,241 +0,0 @@
-
-
-
-
-
-
-FloatingView
-
-
- FloatingView can make the target view floating above the anchor view with cool animation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Links
------
-- [FloatingView 介绍博客](http://www.jianshu.com/p/6aaa258d77f1)
-- [演示程序 apk](http://oeapkptbn.bkt.clouddn.com/FloatingView-demo-v1.0.1.apk)
-
-
-Usage
------
-
-### Step 1
-
-在 build.gradle 文件中添加库依赖
-
-```groovy
- dependencies {
- compile 'com.ufreedom.uikit:FloatingViewLib:1.0.2'
- }
-
-```
-
-
-
-### Step 2
-
-使用 [FloatingBuilder][1] 创建一个 [FloatingElement][2]
-
-```java
-
- FloatingElement builder = new FloatingBuilder()
- .anchorView(View)
- .targetView(View)
- .offsetX(int)
- .offsetY(int)
- .floatingTransition(FloatingTransition)
- .build();
-
-```
-
-使用 FloatingBuilder 可以设置的有
-* anchorView :锚点,也就是你想在哪个 View 上面进行漂浮动画
-* target:目标,你想漂浮的 View
-* offsetX:x 方向的偏移量,单位 px
-* offsetY: y 方向的偏移量,单位 px
-* floatingTransition : 漂浮效果,默认是 ScaleFloatingTransition,也可以自己实现漂浮效果
-
-### Step 3
-
-创建一个 [Floating][3] 作为 [FloatingElement][2] 的容器,然后让你的 View 飞起来
-
-```java
- Floating floating = new Floating(getActivity());
- floating.startFloating(builder);
-```
-
-
-自定义
------
-
-
-####1.坐标系
-
-
-
-
-####2.类图
-
-
-
-
-
-####3.漂浮动画
-
-实现漂浮动画很简单,你只需要实现 [FloatingTransition][4] 接口就可以:
-
-```java
-
- public interface FloatingTransition {
- public void applyFloating(YumFloating yumFloating);
- }
-
-```
-
-在 `applyFloating` 方法,你可以使用 Android Animation 创建动画,然后使用 [YumFloating][6] 进行 Alpha,Scale,Translate,Rotate 等变换
-
-如果你想加入 [Facebook Rebound][5] 回弹动画效果,你可以使用 [SpringHelper][7],例如 [ScaleFloatingTransition][8]:
-
-```java
- public class ScaleFloatingTransition implements FloatingTransition {
-
- ...
-
- @Override
- public void applyFloating(final YumFloating yumFloating) {
-
- ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f);
- alphaAnimator.setDuration(duration);
- alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- yumFloating.setAlpha((Float) valueAnimator.getAnimatedValue());
- }
- });
- alphaAnimator.start();
-
- SpringHelper.createWidthBouncinessAndSpeed(0.0f, 1.0f,bounciness, speed)
- .reboundListener(new SimpleReboundListener(){
- @Override
- public void onReboundUpdate(double currentValue) {
- yumFloating.setScaleX((float) currentValue);
- yumFloating.setScaleY((float) currentValue);
- }
- }).start(yumFloating);
- }
-
-}
-
-
-```
-
-如果 [SpringHelper][7] 无法满足你的需求,你可以直接使用 [YumFloating][6] 的 `createSpringByBouncinessAndSpeed(double bounciness, double speed)` 或者
- `createSpringByTensionAndFriction(double tension, double friction)` 创建 Spring, 然后使用 `transition(double progress, float startValue, float endValue)` 进行数值转换
-
-
-####4.路径漂浮动画
-实现路径漂浮同样很简单,例如 [CurveFloatingPathTransition][9] ,首先你需要继承 [BaseFloatingPathTransition][10] 类.和继承 [FloatingTransition][4] 类不同的是,你需要再实现一个 `getFloatingPath()` 方法.
-在 `getFloatingPath()` 方法内使用 `Path` 创建你想漂浮的路径,然后调用 `FloatingPath.create(path, false)` 进行返回. 例如 [CurveFloatingPathTransition][9] 实现:
-
-```java
- public class CurveFloatingPathTransition extends BaseFloatingPathTransition {
-
- ...
-
- @Override
- public FloatingPath getFloatingPath() {
- if (path == null){
- path = new Path();
- path.moveTo(0, 0);
- path.quadTo(-100, -200, 0, -300);
- path.quadTo(200, -400, 0, -500);
- }
- return FloatingPath.create(path, false);
- }
-
- @Override
- public void applyFloating(final YumFloating yumFloating) {
- ValueAnimator translateAnimator;
- ValueAnimator alphaAnimator;
-
-
- translateAnimator = ObjectAnimator.ofFloat(getStartPathPosition(), getEndPathPosition());
- translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- float value = (float) valueAnimator.getAnimatedValue();
- PathPosition floatingPosition = getFloatingPosition(value);
- yumFloating.setTranslationX(floatingPosition.x);
- yumFloating.setTranslationY(floatingPosition.y);
-
- }
- });
-
- ...
- }
-
-}
-```
-
-使用 Path 将你想要漂浮的路径的描绘出来,然后在 `applyFloating(final YumFloating yumFloating)` 方法中:
-
-* 使用 `getStartPathPosition()` 方法获取路径的开始位置
-* 使用 `getEndPathPosition()`方法获取路径的结束位置
-* 使用 `getFloatingPosition(float progress)` 获取当前进度的位置
-
-`getFloatingPosition(float progress)` 方法会返回一个 `PathPosition` 对象,其属性 x,y 分别代表当前路径动画的 x 坐标,和 y 坐标.
-
-
- Release Log
------------
-
-
- #### v1.0.2
- [修复 bug](https://github.com/UFreedom/FloatingView/pull/6)
-
-
- #### v1.0.1
- 初始版本
-
-
-
-License
---------
-
- Copyright 2015 UFreedom
-
- 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.
-
-[1]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingBuilder.java
-[2]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingElement.java
-[3]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/Floating.java
-[4]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingTransition.java
-[5]:http://facebook.github.io/rebound/
-[6]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/YumFloating.java
-[7]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SpringHelper.java
-[8]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/ScaleFloatingTransition.java
-[9]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/CurveFloatingPathTransition.java
-[10]:https://github.com/UFreedom/FloatingView/blob/master/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/BaseFloatingPathTransition.java
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index a96dcf3e5d5c81376134eeb2552b518a7d5904f4..9097118df06bf21081277518b0bbb0f5c1a2d129 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,26 +1,40 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+}
buildscript {
repositories {
+ maven {
+ url 'https://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
-
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
+ classpath 'com.huawei.ohos:hap:2.4.2.7'
+ classpath 'com.huawei.ohos:decctest:1.0.0.6'
}
}
allprojects {
repositories {
+ maven {
+ url 'https://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/changeLog.md b/changeLog.md
new file mode 100644
index 0000000000000000000000000000000000000000..4b5290ce1d4b7458f2718358f723929c223d9f29
--- /dev/null
+++ b/changeLog.md
@@ -0,0 +1,7 @@
+# 基本功能:Component在别的Component上执行的漂浮动画
+
+# 修改点:
+ 由于openharmony不支持Window.ID_ANDROID_CONTENT所以需要传递当前的Component在其上面进行操作
+
+# 遗留问题(暂不支持的功能):
+ 无
\ No newline at end of file
diff --git a/demo/build.gradle b/demo/build.gradle
deleted file mode 100644
index 795ae3873ecc158fae215151ca5d610040c99477..0000000000000000000000000000000000000000
--- a/demo/build.gradle
+++ /dev/null
@@ -1,32 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 24
- buildToolsVersion "24.0.0"
- defaultConfig {
- applicationId "com.ufreedom.demo"
- minSdkVersion 14
- targetSdkVersion 24
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- compile 'com.android.support:appcompat-v7:24.2.1'
- testCompile 'junit:junit:4.12'
- compile project(':FloatingViewLib')
- compile 'com.android.support:recyclerview-v7:24.2.1'
- compile 'com.android.support:design:24.2.1'
-}
diff --git a/demo/proguard-rules.pro b/demo/proguard-rules.pro
deleted file mode 100644
index ff11ede7761c2d3d8e001ee02fdd3e0f3b45da78..0000000000000000000000000000000000000000
--- a/demo/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/yummy/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/demo/src/androidTest/java/com/ufreedom/floatingview/ExampleInstrumentedTest.java b/demo/src/androidTest/java/com/ufreedom/floatingview/ExampleInstrumentedTest.java
deleted file mode 100644
index 2d5e1ddb194b5702a40153118001cec25ef27c66..0000000000000000000000000000000000000000
--- a/demo/src/androidTest/java/com/ufreedom/floatingview/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.ufreedom.floatingview;
-
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- /*Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.ufreedom.floatingview", appContext.getPackageName());*/
- }
-}
diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml
deleted file mode 100644
index 53ad268d5d6377e7928254b97683f83e7cff726f..0000000000000000000000000000000000000000
--- a/demo/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/java/com/ufreedom/demo/MainActivity.java b/demo/src/main/java/com/ufreedom/demo/MainActivity.java
deleted file mode 100644
index 5ee400a97d56a41435ed102ba60b73f193077c4f..0000000000000000000000000000000000000000
--- a/demo/src/main/java/com/ufreedom/demo/MainActivity.java
+++ /dev/null
@@ -1,339 +0,0 @@
-package com.ufreedom.demo;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.graphics.Path;
-import android.os.Build;
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.ufreedom.floatingview.Floating;
-import com.ufreedom.floatingview.FloatingBuilder;
-import com.ufreedom.floatingview.FloatingElement;
-import com.ufreedom.floatingview.effect.ScaleFloatingTransition;
-import com.ufreedom.floatingview.effect.TranslateFloatingTransition;
-import com.ufreedom.floatingview.spring.ReboundListener;
-import com.ufreedom.floatingview.spring.SimpleReboundListener;
-import com.ufreedom.floatingview.spring.SpringHelper;
-import com.ufreedom.floatingview.transition.BaseFloatingPathTransition;
-import com.ufreedom.floatingview.transition.FloatingPath;
-import com.ufreedom.floatingview.transition.FloatingTransition;
-import com.ufreedom.floatingview.transition.PathPosition;
-import com.ufreedom.floatingview.transition.YumFloating;
-
-public class MainActivity extends AppCompatActivity {
-
- private Floating mFloating;
- private View mIcPlaneView;
- private View mIcPaperAirPlaneView;
- private int mScreenWidth;
- private int mScreenHeight;
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mFloating = new Floating(this);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
- localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
- }
-
- mScreenWidth = UIUtils.getScreenWidth(this);
- mScreenHeight = UIUtils.getScreenWidth(this);
- initLayout();
- }
-
- private void initLayout() {
-
- int margin = UIUtils.dip2px(this,15);
- int w = mScreenWidth - margin * 2;
- int h = (int) (w * 0.53f);
-
- RelativeLayout bikeRootView = (RelativeLayout) findViewById(R.id.itemBikeContainerView);
- RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) bikeRootView.getLayoutParams();
- layoutParams.width = w;
- layoutParams.height = h;
-
- RelativeLayout clockRootView = (RelativeLayout) findViewById(R.id.itemClockContainerView);
- RelativeLayout.LayoutParams clockRootViewLayoutParams = (RelativeLayout.LayoutParams) clockRootView.getLayoutParams();
- clockRootViewLayoutParams.width = w;
- clockRootViewLayoutParams.height = h;
-
- mIcPlaneView = findViewById(R.id.icPlane);
- mIcPlaneView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- ImageView imageView = new ImageView(MainActivity.this);
- imageView.setLayoutParams(new ViewGroup.LayoutParams(mIcPlaneView.getMeasuredWidth(), mIcPlaneView.getMeasuredHeight()));
- imageView.setImageResource(R.drawable.floating_plane);
-
- FloatingElement floatingElement = new FloatingBuilder()
- .anchorView(v)
- .targetView(imageView)
- .floatingTransition(new PlaneFloating())
- .build();
- mFloating.startFloating(floatingElement);
- }
- });
-
- mIcPaperAirPlaneView = findViewById(R.id.icPaperAirPlane);
- mIcPaperAirPlaneView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ImageView imageView = new ImageView(MainActivity.this);
- imageView.setLayoutParams(new ViewGroup.LayoutParams(mIcPaperAirPlaneView.getMeasuredWidth(), mIcPaperAirPlaneView.getMeasuredHeight()));
- imageView.setImageResource(R.drawable.paper_airplane);
-
- FloatingElement floatingElement = new FloatingBuilder()
- .anchorView(v)
- .targetView(imageView)
- .floatingTransition(new TranslateFloatingTransition())
- .build();
- mFloating.startFloating(floatingElement);
- }
- });
-
- View icCommandLineView = findViewById(R.id.icCommandLine);
- icCommandLineView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- TextView textView = new TextView(MainActivity.this);
- textView.setText("Hello FloatingView");
-
- FloatingElement floatingElement = new FloatingBuilder()
- .anchorView(v)
- .targetView(textView)
- .offsetY(-v.getMeasuredHeight())
- .floatingTransition(new ScaleFloatingTransition())
- .build();
- mFloating.startFloating(floatingElement);
- }
- });
-
- View icLikeView = findViewById(R.id.icLike);
- icLikeView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatingElement floatingElement = new FloatingBuilder()
- .anchorView(v)
- .targetView(R.layout.ic_like)
- .floatingTransition(new TranslateFloatingTransition())
- .build();
- mFloating.startFloating(floatingElement);
-
- }
- });
-
-
- final View icStarView = findViewById(R.id.icStar);
- icStarView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(final View v) {
-
- ImageView imageView = new ImageView(MainActivity.this);
- imageView.setLayoutParams(new ViewGroup.LayoutParams(icStarView.getMeasuredWidth(), icStarView.getMeasuredHeight()));
- imageView.setImageResource(R.drawable.star_floating);
-
- final FloatingElement floatingElement = new FloatingBuilder()
- .anchorView(v)
- .targetView(imageView)
- .floatingTransition(new StarFloating())
- .build();
-
- SpringHelper.createWithBouncinessAndSpeed(0f,1f,11,15).reboundListener(new ReboundListener() {
- @Override
- public void onReboundUpdate(double currentValue) {
- v.setScaleX((float) currentValue);
- v.setScaleY((float) currentValue);
- }
-
- @Override
- public void onReboundEnd() {
- mFloating.startFloating(floatingElement);
- }
- }).start();
-
-
-
- }
- });
-
-
- final View icBeerView = findViewById(R.id.icBeer);
- icBeerView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ImageView imageView = new ImageView(MainActivity.this);
- imageView.setLayoutParams(new ViewGroup.LayoutParams(icBeerView.getMeasuredWidth(), icBeerView.getMeasuredHeight()));
- imageView.setImageResource(R.drawable.beer);
-
- FloatingElement floatingElement = new FloatingBuilder()
- .anchorView(v)
- .targetView(imageView)
- .floatingTransition(new BeerFloating())
- .build();
- mFloating.startFloating(floatingElement);
- }
- });
- }
-
- class PlaneFloating extends BaseFloatingPathTransition {
-
- @Override
- public FloatingPath getFloatingPath() {
- Path path = new Path();
- path.moveTo(0, 0);
- path.quadTo(100, -300, 0, -600);
- path.rLineTo(0, -mScreenHeight - 300);
- return FloatingPath.create(path, false);
- }
-
- @Override
- public void applyFloating(final YumFloating yumFloating) {
-
- ValueAnimator translateAnimator = ObjectAnimator.ofFloat(getStartPathPosition(), getEndPathPosition());
- translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- float value = (float) valueAnimator.getAnimatedValue();
- PathPosition floatingPosition = getFloatingPosition(value);
- yumFloating.setTranslationX(floatingPosition.x);
- yumFloating.setTranslationY(floatingPosition.y);
-
- }
- });
- translateAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- yumFloating.setTranslationX(0);
- yumFloating.setTranslationY(0);
- yumFloating.setAlpha(0f);
- yumFloating.clear();
- }
- });
-
-
- SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f, 14, 15)
- .reboundListener(new SimpleReboundListener() {
- @Override
- public void onReboundUpdate(double currentValue) {
- yumFloating.setScaleX((float) currentValue);
- yumFloating.setScaleY((float) currentValue);
- }
- }).start(yumFloating);
-
- translateAnimator.setDuration(3000);
- translateAnimator.start();
- }
- }
-
- class StarFloating implements FloatingTransition {
-
- @Override
- public void applyFloating(final YumFloating yumFloating) {
- SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f,10, 15)
- .reboundListener(new SimpleReboundListener(){
- @Override
- public void onReboundUpdate(double currentValue) {
- yumFloating.setScaleX((float) currentValue);
- yumFloating.setScaleY((float) currentValue);
- }
- }).start(yumFloating);
-
-
- ValueAnimator rotateAnimator = ObjectAnimator.ofFloat(0, 360);
- rotateAnimator.setDuration(500);
- rotateAnimator.setRepeatCount(ValueAnimator.INFINITE);
- rotateAnimator.setRepeatMode(ValueAnimator.RESTART);
- rotateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- yumFloating.setRotation((float) valueAnimator.getAnimatedValue());
- }
- });
-
- ValueAnimator translateAnimator = ObjectAnimator.ofFloat(0, 500);
- translateAnimator.setDuration(600);
- translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- yumFloating.setTranslationY(-(Float) valueAnimator.getAnimatedValue());
- }
- });
- translateAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- yumFloating.setAlpha(0f);
- yumFloating.clear();
- }
- });
- rotateAnimator.start();
- translateAnimator.start();
- }
- }
-
-
- class BeerFloating extends BaseFloatingPathTransition{
-
-
- @Override
- public FloatingPath getFloatingPath() {
- Path path = new Path();
- path.rLineTo(-100,0);
- path.quadTo(0,-200,100,0);
- path.quadTo(0,200,-100,0);
- return FloatingPath.create(path, false);
- }
-
- @Override
- public void applyFloating(final YumFloating yumFloating) {
- ValueAnimator translateAnimator = ObjectAnimator.ofFloat(0, 500);
- translateAnimator.setDuration(600);
- translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- float value = (float) valueAnimator.getAnimatedValue();
- PathPosition floatingPosition = getFloatingPosition(value);
- yumFloating.setTranslationX(floatingPosition.x);
- yumFloating.setTranslationY(floatingPosition.y);
-
- }
- });
-
-
- ValueAnimator alphaAnimation = ObjectAnimator.ofFloat(1f,0f);
- alphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- yumFloating.setAlpha((Float) animation.getAnimatedValue());
- }
- });
- alphaAnimation.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- yumFloating.clear();
- }
- });
- alphaAnimation.setStartDelay(550);
- alphaAnimation.setDuration(300);
- translateAnimator.start();
- alphaAnimation.start();
- }
- }
-
-}
diff --git a/demo/src/main/java/com/ufreedom/demo/UIUtils.java b/demo/src/main/java/com/ufreedom/demo/UIUtils.java
deleted file mode 100644
index 43ffcc3a6c581ee16cf7b24a2fe37f91c08578bc..0000000000000000000000000000000000000000
--- a/demo/src/main/java/com/ufreedom/demo/UIUtils.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.ufreedom.demo;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.util.DisplayMetrics;
-import android.util.TypedValue;
-import android.view.WindowManager;
-
-/**
- * Utils for UI
- * Author UFreedom
- * Date : 2016 十月 28
- */
-
-public class UIUtils {
-
- public static int dip2px(Context context, float dp) {
- Resources r = context.getResources();
- float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
- return Math.round(px);
- }
-
- public static int getScreenWidth(Context context){
- DisplayMetrics dm = new DisplayMetrics();
- WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getMetrics(dm);
- return dm.widthPixels;
-
- }
- public static int getScreenHeight(Context context){
- DisplayMetrics dm = new DisplayMetrics();
- WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getMetrics(dm);
- return dm.heightPixels;
- }
-}
diff --git a/demo/src/main/res/drawable-xxhdpi/bg_item.9.png b/demo/src/main/res/drawable-xxhdpi/bg_item.9.png
deleted file mode 100644
index 7704c70eccbbc3c75ab3b79ad505010575b46590..0000000000000000000000000000000000000000
Binary files a/demo/src/main/res/drawable-xxhdpi/bg_item.9.png and /dev/null differ
diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml
deleted file mode 100644
index 602a1993df9af66cfaf91e95879dd82a1c059c45..0000000000000000000000000000000000000000
--- a/demo/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/src/main/res/layout/fragment_rv.xml b/demo/src/main/res/layout/fragment_rv.xml
deleted file mode 100644
index 9bb297b58143633598ab8baaaeb597dd9e23e5a2..0000000000000000000000000000000000000000
--- a/demo/src/main/res/layout/fragment_rv.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/layout/fragment_simple.xml b/demo/src/main/res/layout/fragment_simple.xml
deleted file mode 100644
index 1f31ddd90b6104aba1bbdc8cd6c395750188cfb9..0000000000000000000000000000000000000000
--- a/demo/src/main/res/layout/fragment_simple.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/demo/src/main/res/layout/ic_like.xml b/demo/src/main/res/layout/ic_like.xml
deleted file mode 100644
index 8c0981de8bd6658e6e56cad0766b41dbaac510f9..0000000000000000000000000000000000000000
--- a/demo/src/main/res/layout/ic_like.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/layout/rv_item.xml b/demo/src/main/res/layout/rv_item.xml
deleted file mode 100644
index 9328f242ae973b99253b0f95c5a3acd9e823e1d1..0000000000000000000000000000000000000000
--- a/demo/src/main/res/layout/rv_item.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/menu/menu.xml b/demo/src/main/res/menu/menu.xml
deleted file mode 100644
index 52469792ecc79f3064cad99d6fb47d90838e32fa..0000000000000000000000000000000000000000
--- a/demo/src/main/res/menu/menu.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/mipmap-hdpi/ic_launcher.png b/demo/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index 14dd0e04ff494fbdf70aed73cb4aea38cc37a902..0000000000000000000000000000000000000000
Binary files a/demo/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/demo/src/main/res/mipmap-mdpi/ic_launcher.png b/demo/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index 1603b79a260385de33361abbbe8bff4ec31af715..0000000000000000000000000000000000000000
Binary files a/demo/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/demo/src/main/res/mipmap-xhdpi/ic_launcher.png b/demo/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index adb4a389daedd4f44b464b3b0614733036baf735..0000000000000000000000000000000000000000
Binary files a/demo/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png b/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index f505df2e14823017b4606487906151eb7b5228da..0000000000000000000000000000000000000000
Binary files a/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 0b587d93b8f3dac0d6b4ae1f3ca52e5988418cf6..0000000000000000000000000000000000000000
Binary files a/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/demo/src/main/res/values-v19/dimens.xml b/demo/src/main/res/values-v19/dimens.xml
deleted file mode 100644
index dcbc3d50bdd8278919613c2a10b35435cc8ea751..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values-v19/dimens.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
- 24dp
- 80dp
-
diff --git a/demo/src/main/res/values-v19/styles.xml b/demo/src/main/res/values-v19/styles.xml
deleted file mode 100644
index 1a90d1f50b98893edd4da579343400b0342b7001..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values-v19/styles.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/values-v21/dimens.xml b/demo/src/main/res/values-v21/dimens.xml
deleted file mode 100644
index f7cecae96a5e3627b3635436d5b37ee957707afb..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values-v21/dimens.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- 24dp
-
diff --git a/demo/src/main/res/values-v21/styles.xml b/demo/src/main/res/values-v21/styles.xml
deleted file mode 100644
index 005ce9916fa5f72222fcf4e59e0344d528c0d9df..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values-v21/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/values-w820dp/dimens.xml b/demo/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/demo/src/main/res/values/colors.xml b/demo/src/main/res/values/colors.xml
deleted file mode 100644
index 207098f7449f09e7870e08800bcca5474f7d0a57..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- #6d5f88
- #6d5f88
- #6d5f88
- #6d5f88
-
diff --git a/demo/src/main/res/values/dimens.xml b/demo/src/main/res/values/dimens.xml
deleted file mode 100644
index 6ea94ab346724de17dc220218175d7ea2ed48ea1..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- 16dp
- 16dp
- 0dp
- 48dp
- 28dp
- 28dp
-
-
-
diff --git a/demo/src/main/res/values/strings.xml b/demo/src/main/res/values/strings.xml
deleted file mode 100644
index 86ebe52edcae2d4d6a82abf52171439ec9bab947..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- FloatingView
-
diff --git a/demo/src/main/res/values/styles.xml b/demo/src/main/res/values/styles.xml
deleted file mode 100644
index be71ed5f000b00e6106bbbf555dd07b3ba0abe5e..0000000000000000000000000000000000000000
--- a/demo/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
diff --git a/demo/src/test/java/com/ufreedom/floatingview/ExampleUnitTest.java b/demo/src/test/java/com/ufreedom/floatingview/ExampleUnitTest.java
deleted file mode 100644
index 7a4ef401101f31594bcf040d8d94c0bd4a5f42bb..0000000000000000000000000000000000000000
--- a/demo/src/test/java/com/ufreedom/floatingview/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.ufreedom.floatingview;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/demo/.gitignore b/entry/.gitignore
similarity index 100%
rename from demo/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..e55c852ec53092596cb6fcdaae44e003fa3a9a1b
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,13 @@
+apply plugin: 'com.huawei.ohos.hap'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testCompile 'junit:junit:4.12'
+ implementation project(":FloatingViewLib")
+}
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..13e88a428c12de8610689fca3613180ff63a9164
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,57 @@
+{
+ "app": {
+ "bundleName": "com.ufreedom.demo",
+ "vendor": "ufreedom",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.ufreedom.demo",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.ufreedom.demo.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard",
+ "metaData":{
+ "customizeData":[
+ {
+ "name": "hwc-theme",
+ "value": "androidhwext:style/Theme.Emui.NoTitleBar",
+ "extra":""
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/ufreedom/demo/MainAbility.java b/entry/src/main/java/com/ufreedom/demo/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..2f67c892387ff4769d0dbef400885f2b4c214035
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/MainAbility.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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 an 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 com.ufreedom.demo;
+
+import com.ufreedom.demo.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * MainAbility
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public class MainAbility extends Ability {
+ /**
+ * onStart
+ *
+ * @param intent
+ */
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/ufreedom/demo/MyApplication.java b/entry/src/main/java/com/ufreedom/demo/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..a3134654c583c3ddb8a62a224451f87eb97daa69
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/MyApplication.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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 an 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 com.ufreedom.demo;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/**
+ * MyApplication
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public class MyApplication extends AbilityPackage {
+ /**
+ * onInitialize
+ */
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/ufreedom/demo/UiUtils.java b/entry/src/main/java/com/ufreedom/demo/UiUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..9fce7eb2e92fc2342fed568b553ec1e42c3a3a00
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/UiUtils.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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 an 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 com.ufreedom.demo;
+
+import ohos.agp.window.service.Display;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.app.Context;
+
+import java.util.Optional;
+
+/**
+ * 尺寸转换
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public final class UiUtils {
+ private UiUtils() {
+ }
+
+ /** px转换成dip
+ *
+ * @param context
+ * @param dp
+ * @return 转换后的数据
+ */
+ public static int dip2px(Context context, float dp) {
+ Optional display = DisplayManager.getInstance().getDefaultDisplay(context);
+ DisplayAttributes displayAttributes = display.get().getAttributes();
+ return Math.round(displayAttributes.scalDensity * dp);
+ }
+
+ /** 获取屏幕宽度
+ *
+ * @param context
+ * @return 屏幕宽度
+ */
+ public static int getScreenWidth(Context context) {
+ Optional display = DisplayManager.getInstance().getDefaultDisplay(context);
+ DisplayAttributes displayAttributes = display.get().getAttributes();
+ return displayAttributes.width;
+ }
+}
diff --git a/entry/src/main/java/com/ufreedom/demo/slice/MainAbilitySlice.java b/entry/src/main/java/com/ufreedom/demo/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..736bd709c0cd3ebc477936eb44d6cab8e4019475
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/slice/MainAbilitySlice.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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 an 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 com.ufreedom.demo.slice;
+
+import com.ufreedom.demo.ResourceTable;
+import com.ufreedom.demo.UiUtils;
+import com.ufreedom.demo.transition.BeerFloating;
+import com.ufreedom.demo.transition.PlaneFloating;
+import com.ufreedom.demo.transition.StarFloating;
+import com.ufreedom.floatingview.Floating;
+import com.ufreedom.floatingview.FloatingBuilder;
+import com.ufreedom.floatingview.FloatingElement;
+import com.ufreedom.floatingview.effect.ScaleFloatingTransition;
+import com.ufreedom.floatingview.effect.TranslateFloatingTransition;
+import com.ufreedom.floatingview.spring.ReboundListener;
+import com.ufreedom.floatingview.spring.SpringHelper;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.Image;
+import ohos.agp.components.Text;
+import ohos.agp.utils.Color;
+
+/**
+ * MainAbilitySlice
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public class MainAbilitySlice extends AbilitySlice {
+ private Floating mFloating;
+ private Component mIcPlaneView;
+ private Component mIcPaperPlane;
+ private int mScreenHeight;
+ private Component dependentLayout;
+ private final int marginAll = 15;
+ private final int two = 2;
+ private final float heightUtil = 0.53f;
+ private final double bounciness = 11;
+ private final double speed = 15;
+ private final int starOffsetX = -80;
+
+ /**
+ * onStart
+ *
+ * @param intent
+ */
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ getWindow().setStatusBarColor(Color.getIntColor("#6d5f88"));
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ dependentLayout = findComponentById(ResourceTable.Id_dependent_layout);
+ mFloating = new Floating(this, dependentLayout);
+ mScreenHeight = UiUtils.getScreenWidth(this);
+ initLayout();
+ }
+
+ /**
+ * 初始化动画
+ */
+ private void initLayout() {
+ // 底部大飞机
+ setIcPlaneView();
+
+ // 纸飞机
+ setIcPaperAirPlaneView();
+
+ // C代码
+ setIcCommandLineView();
+
+ // 点赞
+ setIcLikeView();
+
+ // 旋转星星
+ setIcStarView();
+
+ // 啤酒
+ setIcBeerView();
+ }
+
+ /**
+ * 底部飞机
+ */
+ private void setIcPlaneView() {
+ mIcPlaneView = findComponentById(ResourceTable.Id_icPlane);
+ mIcPlaneView.setClickedListener(view -> {
+ Image iv = new Image(this);
+ iv.setLayoutConfig(new ComponentContainer.LayoutConfig(mIcPlaneView.getWidth(), mIcPlaneView.getHeight()));
+ iv.setPixelMap(ResourceTable.Media_floating_plane);
+ FloatingElement floatingElement = new FloatingBuilder()
+ .anchorView(mIcPlaneView)
+ .targetView(iv)
+ .floatingTransition(new PlaneFloating(this))
+ .build();
+ mFloating.startFloating(floatingElement);
+ });
+ }
+
+ /**
+ * 纸飞机
+ */
+ private void setIcPaperAirPlaneView() {
+ mIcPaperPlane = findComponentById(ResourceTable.Id_icPaperAirPlane);
+ mIcPaperPlane.setClickedListener(view -> {
+ Image iv = new Image(this);
+ iv.setLayoutConfig(new ComponentContainer.LayoutConfig(mIcPaperPlane.getWidth(),
+ mIcPaperPlane.getHeight()));
+ iv.setPixelMap(ResourceTable.Media_paper_airplane);
+ FloatingElement floatingElement = new FloatingBuilder()
+ .anchorView(mIcPaperPlane)
+ .targetView(iv)
+ .floatingTransition(new TranslateFloatingTransition())
+ .build();
+ mFloating.startFloating(floatingElement);
+ });
+ }
+
+ /**
+ * C代码
+ */
+ private void setIcCommandLineView() {
+ Component icCommandLineView = findComponentById(ResourceTable.Id_icCommandLine);
+ icCommandLineView.setClickedListener(view -> {
+ Text textView = new Text(this);
+ textView.setText("Hello FloatingView");
+ FloatingElement floatingElement = new FloatingBuilder()
+ .anchorView(view)
+ .targetView(textView)
+ .offsetY(-view.getHeight())
+ .offsetX(-view.getWidth())
+ .floatingTransition(new ScaleFloatingTransition())
+ .build();
+ mFloating.startFloating(floatingElement);
+ });
+ }
+
+ /**
+ * 点赞
+ */
+ private void setIcLikeView() {
+ Image icLikeView = (Image) findComponentById(ResourceTable.Id_icLike);
+ icLikeView.setClickedListener(view -> {
+ FloatingElement floatingElement = new FloatingBuilder()
+ .anchorView(icLikeView)
+ .targetView(ResourceTable.Layout_ic_like)
+ .offsetX(-icLikeView.getWidth())
+ .offsetY(-icLikeView.getHeight())
+ .floatingTransition(new TranslateFloatingTransition())
+ .build();
+ mFloating.startFloating(floatingElement);
+ });
+ }
+
+ /**
+ * 旋转星星
+ */
+ private void setIcStarView() {
+ final Component icStarView = findComponentById(ResourceTable.Id_icStar);
+ icStarView.setClickedListener(view -> {
+ Image iv = new Image(this);
+ iv.setLayoutConfig(new ComponentContainer.LayoutConfig(icStarView.getWidth(), icStarView.getHeight()));
+ iv.setPixelMap(ResourceTable.Media_star_floating);
+ final FloatingElement floatingElement = new FloatingBuilder()
+ .anchorView(view)
+ .targetView(iv)
+ .offsetX(starOffsetX)
+ .floatingTransition(new StarFloating())
+ .build();
+ SpringHelper.createWithBouncinessAndSpeed(0f, 1f, bounciness, speed).reboundListener(new ReboundListener() {
+ @Override
+ public void onReboundUpdate(double currentValue) {
+ view.setScaleX((float) currentValue);
+ view.setScaleY((float) currentValue);
+ }
+
+ @Override
+ public void onReboundEnd() {
+ mFloating.startFloating(floatingElement);
+ }
+ }).start();
+ });
+ }
+
+ /**
+ * 啤酒
+ */
+ private void setIcBeerView() {
+ final Component icBeerView = findComponentById(ResourceTable.Id_icBeer);
+ icBeerView.setClickedListener(view -> {
+ Image iv = new Image(this);
+ iv.setLayoutConfig(new ComponentContainer.LayoutConfig(icBeerView.getWidth(), icBeerView.getHeight()));
+ iv.setPixelMap(ResourceTable.Media_beer);
+
+ FloatingElement floatingElement = new FloatingBuilder()
+ .anchorView(view)
+ .targetView(iv)
+ .floatingTransition(new BeerFloating())
+ .build();
+ mFloating.startFloating(floatingElement);
+ });
+ }
+
+ /**
+ * onActive
+ */
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ /**
+ * onForeground
+ *
+ * @param intent
+ */
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/java/com/ufreedom/demo/transition/BeerFloating.java b/entry/src/main/java/com/ufreedom/demo/transition/BeerFloating.java
new file mode 100644
index 0000000000000000000000000000000000000000..33bce918838c0d3fca501f6843826d906016b2ab
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/transition/BeerFloating.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2015 UFreedom
+ *
+ * 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 com.ufreedom.demo.transition;
+
+import com.ufreedom.demo.util.AnimatorStateChangedListener;
+import com.ufreedom.floatingview.transition.BaseFloatingPathTransition;
+import com.ufreedom.floatingview.transition.FloatingPath;
+import com.ufreedom.floatingview.transition.PathPosition;
+import com.ufreedom.floatingview.transition.YumFloating;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.render.Path;
+
+/**
+ * BeerFloating
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public class BeerFloating extends BaseFloatingPathTransition {
+ private static final float MXCOOR0 = -100;
+ private static final float MYCOOR1 = -200;
+ private static final float MXCOOR1 = 100;
+
+ private static final float MYCOOR2 = 200;
+ private static final float MXCOOR2 = -100;
+
+ private static final int MANIMATORVALUE = 500;
+ private static final long MTRANSLATEDURATION = 600L;
+
+ private static final long MALPHASTARTDELAY = 550L;
+ private static final long MALPHADURATION = 300L;
+
+ /**
+ * getFloatingPath
+ *
+ * @return FloatingPath
+ */
+ @Override
+ public FloatingPath getFloatingPath() {
+ Path path = new Path();
+ path.rLineTo(MXCOOR0, 0);
+ path.quadTo(0, MYCOOR1, MXCOOR1, 0);
+ path.quadTo(0, MYCOOR2, MXCOOR2, 0);
+ return FloatingPath.create(path, false);
+ }
+
+ /**
+ * applyFloating
+ *
+ * @param yumFloating
+ */
+ @Override
+ public void applyFloating(final YumFloating yumFloating) {
+ AnimatorValue translateAnimator = new AnimatorValue();
+ translateAnimator.setDuration(MTRANSLATEDURATION);
+ translateAnimator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float value) {
+ PathPosition floatingPosition = getFloatingPosition(value * MANIMATORVALUE);
+ yumFloating.setTranslationX(floatingPosition.x);
+ yumFloating.setTranslationY(floatingPosition.y);
+ }
+ });
+ AnimatorValue alphaAnimation = new AnimatorValue();
+ alphaAnimation.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ yumFloating.setAlpha(1 - v);
+ }
+ });
+
+ alphaAnimation.setStateChangedListener(new AnimatorStateChangedListener() {
+ @Override
+ public void onEnd(Animator animator) {
+ yumFloating.clear();
+ }
+ });
+ alphaAnimation.setDelay(MALPHASTARTDELAY);
+ alphaAnimation.setDuration(MALPHADURATION);
+ translateAnimator.start();
+ alphaAnimation.start();
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/ufreedom/demo/transition/PlaneFloating.java b/entry/src/main/java/com/ufreedom/demo/transition/PlaneFloating.java
new file mode 100644
index 0000000000000000000000000000000000000000..8167e62f702dcf67fca46da7e665de506fdb860c
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/transition/PlaneFloating.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2015 UFreedom
+ *
+ * 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 com.ufreedom.demo.transition;
+
+import com.ufreedom.demo.UiUtils;
+import com.ufreedom.demo.util.AnimatorStateChangedListener;
+import com.ufreedom.floatingview.spring.SimpleReboundListener;
+import com.ufreedom.floatingview.spring.SpringHelper;
+import com.ufreedom.floatingview.transition.BaseFloatingPathTransition;
+import com.ufreedom.floatingview.transition.FloatingPath;
+import com.ufreedom.floatingview.transition.PathPosition;
+import com.ufreedom.floatingview.transition.YumFloating;
+import com.ufreedom.floatingview.util.LogUtil;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.render.Path;
+import ohos.app.Context;
+
+/**
+ * PlaneFloating
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public class PlaneFloating extends BaseFloatingPathTransition {
+ private static final float MXCOOR0 = 100;
+ private static final float MYCOOR0 = -300;
+ private static final float MYCOOR1 = -600;
+ private static final float MLINETOYCOOR1 = -100;
+ private static final float MPROGRESS = 2110;
+ private static final long MDURATION = 3000L;
+ private static final double MBOUNCINESS = 14;
+ private static final double MSPEED = 15;
+ private int mScreenHeight;
+
+ /**
+ * PlaneFloating
+ *
+ * @param context
+ */
+ public PlaneFloating(Context context) {
+ mScreenHeight = UiUtils.getScreenWidth(context);
+ }
+
+ /**
+ * getFloatingPath
+ *
+ * @return FloatingPath
+ */
+ @Override
+ public FloatingPath getFloatingPath() {
+ Path path = new Path();
+ path.moveTo(0, 0);
+ path.quadTo(MXCOOR0, MYCOOR0, 0, MYCOOR1);
+ path.rLineTo(0, -mScreenHeight + MLINETOYCOOR1);
+ return FloatingPath.create(path, false);
+ }
+
+ /**
+ * applyFloating
+ *
+ * @param yumFloating
+ */
+ @Override
+ public void applyFloating(final YumFloating yumFloating) {
+ AnimatorValue translateAnimator = new AnimatorValue();
+ translateAnimator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ PathPosition floatingPosition = getFloatingPosition(v * MPROGRESS);
+ yumFloating.setTranslationX(floatingPosition.x);
+ yumFloating.setTranslationY(floatingPosition.y);
+ LogUtil.error("animatorValue", "x" + floatingPosition.x + " y" + floatingPosition.y);
+ }
+ });
+
+ translateAnimator.setStateChangedListener(new AnimatorStateChangedListener() {
+ @Override
+ public void onEnd(Animator animator) {
+ yumFloating.setTranslationX(0);
+ yumFloating.setTranslationY(0);
+ yumFloating.setAlpha(0f);
+ yumFloating.clear();
+ }
+ });
+ SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f, MBOUNCINESS, MSPEED)
+ .reboundListener(new SimpleReboundListener() {
+ @Override
+ public void onReboundUpdate(double currentValue) {
+ yumFloating.setScaleX((float) currentValue);
+ yumFloating.setScaleY((float) currentValue);
+ }
+ }).start(yumFloating);
+
+ translateAnimator.setDuration(MDURATION);
+ translateAnimator.start();
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/ufreedom/demo/transition/StarFloating.java b/entry/src/main/java/com/ufreedom/demo/transition/StarFloating.java
new file mode 100644
index 0000000000000000000000000000000000000000..205ca5cdd4c22c8fd9be692c9063258caf526f71
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/transition/StarFloating.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2015 UFreedom
+ *
+ * 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 com.ufreedom.demo.transition;
+
+import com.ufreedom.demo.util.AnimatorStateChangedListener;
+import com.ufreedom.floatingview.spring.SimpleReboundListener;
+import com.ufreedom.floatingview.spring.SpringHelper;
+import com.ufreedom.floatingview.transition.FloatingTransition;
+import com.ufreedom.floatingview.transition.YumFloating;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorValue;
+
+/**
+ * StarFloating
+ *
+ * @author xujianhong
+ * @since 2021-03-31
+ */
+public class StarFloating implements FloatingTransition {
+ private static final double MBOUNCINESS = 10;
+ private static final double MSPEED = 15;
+ private static final long MROTATEDURATION = 500L;
+ private static final int MROTATEANIMATORVALUE = 360;
+ private static final long MTRANSLATEDURATION = 600L;
+ private static final long MTRANSLATEANIMATORVALUE = 500L;
+
+ /**
+ * applyFloating
+ *
+ * @param yumFloating
+ */
+ @Override
+ public void applyFloating(final YumFloating yumFloating) {
+ SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f, MBOUNCINESS, MSPEED)
+ .reboundListener(new SimpleReboundListener() {
+ @Override
+ public void onReboundUpdate(double currentValue) {
+ yumFloating.setScaleX((float) currentValue);
+ yumFloating.setScaleY((float) currentValue);
+ }
+ }).start(yumFloating);
+ AnimatorValue translateAnimator = new AnimatorValue();
+ translateAnimator.setDuration(MTRANSLATEDURATION);
+ translateAnimator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ yumFloating.setTranslationY(-v * MTRANSLATEANIMATORVALUE);
+ }
+ });
+
+ translateAnimator.setStateChangedListener(new AnimatorStateChangedListener() {
+ @Override
+ public void onEnd(Animator animator) {
+ yumFloating.setAlpha(0f);
+ yumFloating.clear();
+ }
+ });
+ setRotateAnimator(yumFloating).start();
+ translateAnimator.start();
+ }
+
+ /**
+ * setRotateAnimator
+ *
+ * @param yumFloating
+ * @return AnimatorValue
+ */
+ private AnimatorValue setRotateAnimator(YumFloating yumFloating) {
+ AnimatorValue rotateAnimator = new AnimatorValue();
+
+ // 持续时长
+ rotateAnimator.setDuration(MROTATEDURATION);
+
+ // 循环次数
+ rotateAnimator.setLoopedCount(AnimatorValue.INFINITE);
+ rotateAnimator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ yumFloating.setRotation(v * MROTATEANIMATORVALUE);
+ }
+ });
+ return rotateAnimator;
+ }
+}
diff --git a/entry/src/main/java/com/ufreedom/demo/util/AnimatorStateChangedListener.java b/entry/src/main/java/com/ufreedom/demo/util/AnimatorStateChangedListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..9c61af788ca35fb8acc8d9051122cea480bcb838
--- /dev/null
+++ b/entry/src/main/java/com/ufreedom/demo/util/AnimatorStateChangedListener.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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 an 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 com.ufreedom.demo.util;
+
+import ohos.agp.animation.Animator;
+
+/**
+ * AnimatorStateChanged
+ *
+ * @author xujianhong
+ * @since 2021-04-23
+ */
+public class AnimatorStateChangedListener implements Animator.StateChangedListener {
+ /**
+ * 开始动画
+ *
+ * @param animator
+ */
+ @Override
+ public void onStart(Animator animator) {
+ }
+
+ /**
+ * 停止动画
+ *
+ * @param animator
+ */
+ @Override
+ public void onStop(Animator animator) {
+ }
+
+ /**
+ * 取消动画
+ *
+ * @param animator
+ */
+ @Override
+ public void onCancel(Animator animator) {
+ }
+
+ /**
+ * 结束动画
+ *
+ * @param animator
+ */
+ @Override
+ public void onEnd(Animator animator) {
+ }
+
+ /**
+ * Pause
+ *
+ * @param animator
+ */
+ @Override
+ public void onPause(Animator animator) {
+ }
+
+ /**
+ * Resume
+ *
+ * @param animator
+ */
+ @Override
+ public void onResume(Animator animator) {
+ }
+}
diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..11ae65be6152d082c98a860d8dba9c5b351e82e7
--- /dev/null
+++ b/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "color_them",
+ "value": "#6d5f88"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..211064a859ef63a15007cc7bbc5b7ae72c3f6bb3
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "FloatingView"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..707cf5bd9c6ce0cf1bbe77871e9eb4fcba2784ff
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,150 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/entry/src/main/resources/base/layout/ic_like.xml b/entry/src/main/resources/base/layout/ic_like.xml
new file mode 100644
index 0000000000000000000000000000000000000000..34f22a7b4b735069f16a0a256b26bd1454336a64
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ic_like.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demo/src/main/res/drawable-xxhdpi/beer.png b/entry/src/main/resources/base/media/beer.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/beer.png
rename to entry/src/main/resources/base/media/beer.png
diff --git a/entry/src/main/resources/base/media/bike.png b/entry/src/main/resources/base/media/bike.png
new file mode 100644
index 0000000000000000000000000000000000000000..169504c8d0e69fa6cf08cfb0e19557fa7c8579d9
Binary files /dev/null and b/entry/src/main/resources/base/media/bike.png differ
diff --git a/demo/src/main/res/drawable-xxhdpi/clock.png b/entry/src/main/resources/base/media/clock.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/clock.png
rename to entry/src/main/resources/base/media/clock.png
diff --git a/demo/src/main/res/drawable-xxhdpi/command_line.png b/entry/src/main/resources/base/media/command_line.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/command_line.png
rename to entry/src/main/resources/base/media/command_line.png
diff --git a/demo/src/main/res/drawable-xxhdpi/floating_plane.png b/entry/src/main/resources/base/media/floating_plane.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/floating_plane.png
rename to entry/src/main/resources/base/media/floating_plane.png
diff --git a/demo/src/main/res/drawable-xxhdpi/floating_view_title.png b/entry/src/main/resources/base/media/floating_view_title.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/floating_view_title.png
rename to entry/src/main/resources/base/media/floating_view_title.png
diff --git a/demo/src/main/res/drawable-xxhdpi/ice_cream.png b/entry/src/main/resources/base/media/ice_cream.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/ice_cream.png
rename to entry/src/main/resources/base/media/ice_cream.png
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/demo/src/main/res/drawable-xxhdpi/like.png b/entry/src/main/resources/base/media/like.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/like.png
rename to entry/src/main/resources/base/media/like.png
diff --git a/demo/src/main/res/drawable-xxhdpi/milk.png b/entry/src/main/resources/base/media/milk.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/milk.png
rename to entry/src/main/resources/base/media/milk.png
diff --git a/demo/src/main/res/drawable-xxhdpi/paper_airplane.png b/entry/src/main/resources/base/media/paper_airplane.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/paper_airplane.png
rename to entry/src/main/resources/base/media/paper_airplane.png
diff --git a/demo/src/main/res/drawable-xxhdpi/soda.png b/entry/src/main/resources/base/media/soda.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/soda.png
rename to entry/src/main/resources/base/media/soda.png
diff --git a/demo/src/main/res/drawable-xxhdpi/star.png b/entry/src/main/resources/base/media/star.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/star.png
rename to entry/src/main/resources/base/media/star.png
diff --git a/demo/src/main/res/drawable-xxhdpi/star_floating.png b/entry/src/main/resources/base/media/star_floating.png
similarity index 100%
rename from demo/src/main/res/drawable-xxhdpi/star_floating.png
rename to entry/src/main/resources/base/media/star_floating.png
diff --git a/entry/src/test/java/com/ufreedom/demo/ExampleTest.java b/entry/src/test/java/com/ufreedom/demo/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ef0261b5aecdabef479f98eb4af432dfdaf7c7e7
--- /dev/null
+++ b/entry/src/test/java/com/ufreedom/demo/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.ufreedom.demo;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gif/floatView.gif b/gif/floatView.gif
new file mode 100644
index 0000000000000000000000000000000000000000..37f3c438164d31901171d2b4cdec6b96a85666f5
Binary files /dev/null and b/gif/floatView.gif differ
diff --git a/gradle.properties b/gradle.properties
index aac7c9b4614ccfde6c721f24994cf30885a791d0..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,17 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1536m
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e24af05341d49695ee84e5f9b594659..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 04e285f34080d98841a9fac832466aec720aecec..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+# https://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.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,26 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/images/classdiagram.png b/images/classdiagram.png
deleted file mode 100644
index feffb1d536c5c86d2e9f344927dede8ca96588f0..0000000000000000000000000000000000000000
Binary files a/images/classdiagram.png and /dev/null differ
diff --git a/images/coordinate.png b/images/coordinate.png
deleted file mode 100644
index d1a828122f06468fa01420a0e80a07424787b2c8..0000000000000000000000000000000000000000
Binary files a/images/coordinate.png and /dev/null differ
diff --git a/images/demo.gif b/images/demo.gif
deleted file mode 100644
index 9cab5eacaeb611b94eb07a5e7c96cfdb3453b22a..0000000000000000000000000000000000000000
Binary files a/images/demo.gif and /dev/null differ
diff --git a/images/floating_anim.gif b/images/floating_anim.gif
deleted file mode 100644
index 224b579edea69d9d15d16113999ee20c13f60878..0000000000000000000000000000000000000000
Binary files a/images/floating_anim.gif and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index a75c18be2a5dfe6dd9015f53ef9487748b5affae..8517c3f4e9f2e6222c0dccee292fd75d1cac5748 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':demo', ':FloatingViewLib'
+include ':entry', ':FloatingViewLib'