-
-
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..ff7f412774ce68c1d8cd79c3c69cf891bf31f9af
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,5 @@
+## 0.0.1-SNAPSHOT
+ohos 第一个版本
+ * 实现了原库的大部分 api
+ *Window.setBoundRect(Rect boundRect)设置移动窗口的边界。因为鸿蒙没有提供 获取底部导航栏高度,
+ 底部导航栏是否显示等API导致计算Rect的时候有点偏差,所以导致window窗口在滑动的时候不能紧贴上下边界
\ No newline at end of file
diff --git a/README.OPENSOURCE b/README.OPENSOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..e66d772019761dd8ad0026d6b6b5238dca484241
--- /dev/null
+++ b/README.OPENSOURCE
@@ -0,0 +1,19 @@
+[
+
+ {
+
+ "Name": "FloatUtil",
+
+ "License": "MIT License",
+
+ "License File": "LICENSE",
+
+ "Version Number": "1.0",
+
+ "Upstream URL": "https://github.com/liuguangli/FloatUtil",
+
+ "Description": "一个简单的浮窗工具,封装了浮窗的使用方法"
+
+ }
+
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index 800fe8f16a6faa0fd7b176b200fc77dc9f234913..e6d359cf848cf405b312c34bae9165a2fd2ba028 100644
--- a/README.md
+++ b/README.md
@@ -1,95 +1,135 @@
-## FloatUtil
-[](https://jitpack.io/#liuguangli/FloatUtil)
+# FloatUtil
-一个简单的浮窗工具。封装了浮窗的使用方法,并做了系统、版本的兼容处理,帮你绕过权限的限制。
+#### 项目介绍
+- 项目名称:FloatUtil
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:一个简单的浮窗工具。封装了浮窗的使用方法。
+- 项目移植状态:主功能完成
+- 调用差异:无
+- 开发版本:sdk6,DevEco Studio 2.2 Beta1
+- 基线版本:Release 1.0
-
-## 开始
-项目使用 [jitpack](https://jitpack.io) 做开源库的托管,你需要在 .gradle 中添加 [jitpack](https://jitpack.io)
-的仓库。
+#### 效果演示
- allprojects {
- repositories {
- jcenter()
- maven { url "https://jitpack.io" }
+
+
+#### 安装教程
+
+
+1.在项目根目录下的build.gradle文件中,
+```java
+ allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}
}
-
-在添加 FloatUtil 的依赖引用:
-
-
- dependencies {
- compile 'com.github.liuguangli:FloatUtil:-SNAPSHOT'
- }
+ }
+```
+2.在entry模块的build.gradle文件中,
+```java
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:FloatUtil:0.0.1-SNAPSHOT')
+ ......
+ }
+```
+
+在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
+
+#### 使用说明
+
+1.初始化:
+
+```java
+ SimpleView floatView = new SimpleView(this);
+ FloatUtil builder = new FloatUtil.Builder()
+ .Component(floatView)
+ .build(this);
+```
+SimpleView 是你自定义的 Component,就这么简单,浮窗显示出来了
+
+2.关闭浮窗
+```java
+builder.hideFloatView(floatView);
+```
+同一个 Component 类,同时只能显示一个实例, 关闭的时候指定一个 Component 对象便能知道关闭哪个浮窗实例
+
+3.向浮窗传递参数,在当前窗口的自定义Component定义函数onParamReceive(IntentParams args)通过
+IntentParams args进行传递参数
+```java
+IntentParams params = new IntentParams();
+floatView.onParamReceive(params);
+```
+4.指定层级和对其方式
+```java
+new FloatUtil.Builder()
+ .setComponent(smartFloatView) //window 窗口布局
+ .setGravity(LayoutAlignment.CENTER) //对其方式
+ .setTypeFlag(TypeFlag.MOD_APPLICATION_MEDIA) //指定层级
+ .build(this);
+
+//应用内窗体 TypeFlag.MOD_APPLICATION_MEDIA
+//应用外窗体 TypeFlag.MOD_APP_OVERLAY
+```
+5.接口说明:
-### 创建一个简单的浮窗
+```java
+/**
+ * view 自定义布局
+ */
+setComponent(Component view)
- SimpleView floatView = new SimpleView(this);
- FloatUtil.showFloatView(floatView, null);
-
-SimpleView 是你自定义的 View,就这么简单,浮窗显示出来了。
+/**
+ * gravity 对其方式
+ */
+setGravity(int gravity)
-
-
-### 关闭浮窗
+/**
+ * height 自定义窗体高度
+ */
+setHeight(int height)
- FloatUtil.hideFloatView(context, SimpleView.class, false);
-同一个 View 类,同时只能显示一个实例, 关闭的时候指定一个 class 对象便能知道关闭哪个浮窗实例。 最后一个参数
-决定要不要将当前实例缓存,以便下次快速显示并维持状态,false 代表不缓存,true 表示要缓存。
+/**
+ * width 自定义窗体高度
+ */
+setWidth(int width)
-### 向浮窗传递参数
+/**
+ * isMovable 是否可以拖动
+ */
+setIsMovable(boolean isMovable)
-FloatUtil 提供了一个接口:ParamReceiver。你自定义的 View 实现这个接口便能接收参数。
+/**
+ * typeFlag 窗口层级
+ */
+setTypeFlag(TypeFlag typeFlag)
- public class SimpleViewWitchParam extends FrameLayout implements ParamReceiver {
- public static final java.lang.String PARAM = "PARAM";
- public static final String CONTENT = "content";
- @Override
- public void onParamReceive(Bundle bundle) {
- // 在这个回调方法中接收参数并解析
- if (bundle != null) {
- String param = bundle.getString(PARAM);
-
- }
- }
- }
-
-然后在添加这个 SimpleViewWitchParam 到浮窗。
-
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- Bundle bundle = new Bundle();
- bundle.putString(SimpleViewWitchParam.PARAM, "我是传过来的参数");
- FloatUtil.showFloatView(floatView, bundle);
-
-
-
-### 指定层级和对齐方式
-
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- // 居中对齐,浮窗层级为 WindowManager.LayoutParams.TYPE_TOAST
- FloatUtil.showFloatView(floatView, Gravity.CENTER,WindowManager.LayoutParams.TYPE_TOAST , null);
-
-
-
-浮窗类型 type 决定了浮窗的层级,关于浮窗层级的详细理解可以参考我的博客:[《浮窗开发之窗口层级》](http://www.liuguangli.win/archives/476),
-Android 系统对窗体的某些层级有权限限制,例如 WindowManager.LayoutParams.TYPE_PHONE 类型的窗体需要授权。
+/**
+ * point 指定x,y位置
+ */
+point(Point point)
+```
+
+## 测试信息
+
+CodeCheck代码测试无异常
+
+CloudTest代码测试无异常
-### 智能浮窗(突破授权)
+病毒安全检测通过
-FloatUtil 提供智能方式添加浮窗,针对特定的系统版本、机型为你选择合适的浮窗 type ,越过授权(详细参考我的博客:[越过用户授权使用浮窗](http://www.liuguangli.win/archives/484)),你不需要再去关注复杂的处理过程。
-
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- Bundle bundle = new Bundle();
- bundle.putString(SimpleViewWitchParam.PARAM, "智能浮窗");
- // 指定浮窗显示的位置
- Point point = new Point();
- point.x = 0;
- point.y = 0;
- FloatUtil.showSmartFloat(floatView, Gravity.CENTER, point, bundle);
-
+当前版本demo功能与原组件基本无差异
-## MIT License
+## 版本迭代
+
+- 0.0.1-SNAPSHOT
+
+## 版权和许可信息
+```
+MIT License
Copyright (c) 2016 刘光利
@@ -110,5 +150,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-
-
+```
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index f6abf0a7979324f3fd71626fd812c4c29b5ce89f..49bd550bd2daf5240e23681f66bd1c5b835cc430 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,24 +1,36 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
buildscript {
repositories {
- jcenter()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.2'
- classpath "com.github.dcendents:android-maven-gradle-plugin:1.5"
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:hap:2.4.5.0'
+ classpath 'com.huawei.ohos:decctest:1.2.4.1'
}
}
allprojects {
repositories {
- jcenter()
- maven { url "https://jitpack.io" }
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/simple/.gitignore b/entry/.gitignore
similarity index 100%
rename from simple/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..455f27a7822959f8289e1f4d280e5a6e0d57bc97
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200'
+ implementation project(':library')
+}
+decc {
+ supportType = ['html', 'xml']
+}
diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/entry/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..db1cd6ff76f9754e9ea1349e44543a28985dc839
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,61 @@
+{
+ "app": {
+ "bundleName": "com.dalimao.floateutil",
+ "vendor": "dalimao",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.SYSTEM_FLOAT_WINDOW"
+ }
+ ],
+ "package": "com.dalimao.floateutil",
+ "name": ".MyApplication",
+ "mainAbility": "com.dalimao.floateutil.MainAbility",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "portrait",
+ "name": "com.dalimao.floateutil.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/dalimao/floateutil/FloatBallView.java b/entry/src/main/java/com/dalimao/floateutil/FloatBallView.java
new file mode 100644
index 0000000000000000000000000000000000000000..f430ac0be66823a782b96bf229c34cc99b4e5282
--- /dev/null
+++ b/entry/src/main/java/com/dalimao/floateutil/FloatBallView.java
@@ -0,0 +1,30 @@
+package com.dalimao.floateutil;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.StackLayout;
+import ohos.app.Context;
+
+/**
+ * FloatBallView
+ *
+ * @since 2021-07-01
+ */
+public class FloatBallView extends StackLayout {
+ private static final float RADIUSNUM = 100f;
+
+ /**
+ * FloatBallView
+ *
+ * @param context
+ */
+ public FloatBallView(Context context) {
+ super(context);
+ Component rootView = LayoutScatter.getInstance(context).
+ parse(ResourceTable.Layout_float_small_drag_ball,
+ this, true);
+ Image imageView = (Image) rootView.findComponentById(ResourceTable.Id_imageView);
+ imageView.setCornerRadius(RADIUSNUM);
+ }
+}
diff --git a/entry/src/main/java/com/dalimao/floateutil/MainAbility.java b/entry/src/main/java/com/dalimao/floateutil/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..f6a548bbb6bccb454f63bc9118d167ee502c8fe5
--- /dev/null
+++ b/entry/src/main/java/com/dalimao/floateutil/MainAbility.java
@@ -0,0 +1,49 @@
+/*
+ * 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 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.dalimao.floateutil;
+
+import com.dalimao.floateutil.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.utils.PacMap;
+
+/**
+ * MyApplication
+ *
+ * @since 2021-06-29
+ */
+public class MainAbility extends Ability {
+ /**
+ * onStart
+ *
+ * @param intent
+ */
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+
+ @Override
+ public void onSaveAbilityState(PacMap outState) {
+ super.onSaveAbilityState(outState);
+ }
+
+ @Override
+ protected void onActive() {
+ super.onActive();
+ }
+}
diff --git a/entry/src/main/java/com/dalimao/floateutil/MyApplication.java b/entry/src/main/java/com/dalimao/floateutil/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..da2cdd7bb162508d5525979049b40bd1d9fdf02a
--- /dev/null
+++ b/entry/src/main/java/com/dalimao/floateutil/MyApplication.java
@@ -0,0 +1,33 @@
+/*
+ * 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 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.dalimao.floateutil;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/**
+ * MyApplication
+ *
+ * @since 2021-06-29
+ */
+public class MyApplication extends AbilityPackage {
+ /**
+ * onInitialize
+ */
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/dalimao/floateutil/SimpleView.java b/entry/src/main/java/com/dalimao/floateutil/SimpleView.java
new file mode 100644
index 0000000000000000000000000000000000000000..43f1d58d5ca2ba30f52ebd7be5b661636d60ec13
--- /dev/null
+++ b/entry/src/main/java/com/dalimao/floateutil/SimpleView.java
@@ -0,0 +1,23 @@
+package com.dalimao.floateutil;
+
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.StackLayout;
+import ohos.app.Context;
+
+/**
+ * SimpleView
+ *
+ * @since 2021-06-28
+ */
+public class SimpleView extends StackLayout {
+ /**
+ * SimpleView
+ *
+ * @param context
+ */
+ public SimpleView(Context context) {
+ super(context);
+ LayoutScatter.getInstance(context).parse(ResourceTable.Layout_float_simple,
+ this, true);
+ }
+}
diff --git a/entry/src/main/java/com/dalimao/floateutil/SimpleViewWitchParam.java b/entry/src/main/java/com/dalimao/floateutil/SimpleViewWitchParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..1c315a0fe07a3b9c0c5148d0e2e50475f69bfb3c
--- /dev/null
+++ b/entry/src/main/java/com/dalimao/floateutil/SimpleViewWitchParam.java
@@ -0,0 +1,53 @@
+package com.dalimao.floateutil;
+
+import ohos.aafwk.content.IntentParams;
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.StackLayout;
+import ohos.agp.components.Text;
+import ohos.app.Context;
+
+/**
+ * SimpleViewWitchParam
+ *
+ * @since 2021-06-29
+ */
+public class SimpleViewWitchParam extends StackLayout {
+ /**
+ * PARAM
+ */
+ public static final String PARAM = "PARAM";
+ /**
+ * CONTENT
+ */
+ public static final String CONTENT = "content";
+ Component rootView;
+
+ /**
+ * SimpleViewWitchParam
+ *
+ * @param context
+ */
+ public SimpleViewWitchParam(Context context) {
+ super(context);
+ rootView = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_float_simple_witch_param, this, true);
+ }
+
+ /**
+ * onParamReceive
+ *
+ * @param args
+ */
+ public void onParamReceive(IntentParams args) {
+ if (args != null) {
+ String param = (String) args.getParam(PARAM);
+ Text textView = (Text) rootView.findComponentById(ResourceTable.Id_tv_param);
+ textView.setText(param);
+ String content = (String) args.getParam(CONTENT);
+ if (content != null && content.length() > 0) {
+ Text tvContent = (Text) rootView.findComponentById(ResourceTable.Id_tv_content);
+ tvContent.setText(content);
+ }
+ }
+ }
+}
diff --git a/entry/src/main/java/com/dalimao/floateutil/slice/MainAbilitySlice.java b/entry/src/main/java/com/dalimao/floateutil/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..d214884d135700bd1e5b25e3eead4c3b06d6429f
--- /dev/null
+++ b/entry/src/main/java/com/dalimao/floateutil/slice/MainAbilitySlice.java
@@ -0,0 +1,256 @@
+/*
+ * 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 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.dalimao.floateutil.slice;
+
+import com.dalimao.library.FloatUtil;
+import com.dalimao.floateutil.ResourceTable;
+import com.dalimao.floateutil.SimpleView;
+import com.dalimao.floateutil.FloatBallView;
+import com.dalimao.floateutil.SimpleViewWitchParam;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.IntentParams;
+import ohos.agp.components.Button;
+import ohos.agp.components.Component;
+import ohos.agp.utils.LayoutAlignment;
+import ohos.agp.utils.Point;
+import ohos.sysappcomponents.settings.AppSettings;
+import ohos.utils.net.Uri;
+
+/**
+ * SimpleViewWitchParam
+ *
+ * @since 2021-06-29
+ */
+public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener {
+ private static final int FLOATBALLVIEWSIZE = 45;
+ private static final int POINTX = 100;
+ private static final int POINTY = 300;
+ private static final int REQUESTCODE = 1000;
+ private static final String PARAMVALUE = "我是传过来的参数";
+ Button mAddSimpleView;
+ Button mAddSimpleViewWithParam;
+ Button mAddSimpleViewWithGravity;
+ Button mAddSimpleViewWithType;
+ Button mAddSimpleViewWithPoint;
+ Button mAddSimpleSmartFloatView;
+ Button mAddDragView;
+ IntentParams params;
+ SimpleViewWitchParam smartFloatView;
+ Point point;
+ FloatUtil builder;
+
+ /**
+ * onStart
+ *
+ * @param intent
+ */
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ mAddSimpleView = (Button) findComponentById(ResourceTable.Id_addSimpleView);
+ mAddSimpleViewWithParam = (Button) findComponentById(ResourceTable.Id_addSimpleViewWithParam);
+ mAddSimpleViewWithGravity = (Button) findComponentById(ResourceTable.Id_addSimpleViewWithGravity);
+ mAddSimpleViewWithType = (Button) findComponentById(ResourceTable.Id_addSimpleViewWithType);
+ mAddSimpleViewWithPoint = (Button) findComponentById(ResourceTable.Id_addSimpleViewWithPoint);
+ mAddSimpleSmartFloatView = (Button) findComponentById(ResourceTable.Id_addSimpleSmartFloatView);
+ mAddDragView = (Button) findComponentById(ResourceTable.Id_addDragView);
+ mAddSimpleView.setClickedListener(this);
+ mAddSimpleViewWithParam.setClickedListener(this);
+ mAddSimpleViewWithGravity.setClickedListener(this);
+ mAddSimpleViewWithType.setClickedListener(this);
+ mAddSimpleViewWithPoint.setClickedListener(this);
+ mAddSimpleSmartFloatView.setClickedListener(this);
+ mAddDragView.setClickedListener(this);
+ }
+
+ /**
+ * onActive
+ */
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ /**
+ * onForeground
+ *
+ * @param intent
+ */
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+
+ /**
+ * onClick
+ *
+ * @param component
+ */
+ @Override
+ public void onClick(Component component) {
+ params = new IntentParams();
+ smartFloatView = new SimpleViewWitchParam(this);
+ point = new Point();
+ boolean isAuthority = AppSettings.canShowFloating(this);
+ if (!isAuthority) {
+ Intent intent = new Intent();
+ intent.setAction("android.settings.action.MANAGE_OVERLAY_PERMISSION");
+ Uri parse = Uri.parse("package:" + getBundleName());
+ intent.setUri(parse);
+ startAbilityForResult(intent, REQUESTCODE);
+ return;
+ }
+ switch (component.getId()) {
+ case ResourceTable.Id_addSimpleView:
+ setIdAddSimpleView();
+ break;
+
+ case ResourceTable.Id_addSimpleViewWithParam:
+ setIdAddSimpleViewWithParam();
+ break;
+
+ case ResourceTable.Id_addSimpleViewWithGravity:
+ setIdAddSimpleViewWithGravity();
+ break;
+
+ case ResourceTable.Id_addSimpleViewWithType:
+ setIdAddSimpleViewWithType();
+ break;
+
+ case ResourceTable.Id_addSimpleViewWithPoint:
+ setIdAddSimpleViewWithPoint();
+ break;
+
+ case ResourceTable.Id_addSimpleSmartFloatView:
+ setIdAddSimpleSmartFloatView();
+ break;
+
+ case ResourceTable.Id_addDragView:
+ setIdAddDragView();
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void setIdAddSimpleView() {
+ SimpleView floatView = new SimpleView(this);
+
+ builder = new FloatUtil.Builder()
+ .setComponent(floatView)
+ .showFloatView(this);
+ floatView.findComponentById(ResourceTable.Id_close)
+ .setClickedListener(view -> {
+ builder.hideFloatView(floatView);
+ });
+ }
+
+ private void setIdAddSimpleViewWithParam() {
+ params.setParam(SimpleViewWitchParam.PARAM, PARAMVALUE);
+ smartFloatView.onParamReceive(params);
+ builder = new FloatUtil.Builder()
+ .setComponent(smartFloatView)
+ .showFloatView(this);
+ smartFloatView.findComponentById(ResourceTable.Id_close)
+ .setClickedListener(view -> {
+ builder.hideFloatView(smartFloatView);
+ });
+ }
+
+ private void setIdAddSimpleViewWithGravity() {
+ params.setParam(SimpleViewWitchParam.PARAM, PARAMVALUE);
+ params.setParam(SimpleViewWitchParam.CONTENT, getString(ResourceTable.String_add_simple_view_with_gravity));
+ smartFloatView.onParamReceive(params);
+ builder = new FloatUtil.Builder()
+ .setComponent(smartFloatView)
+ .setGravity(LayoutAlignment.CENTER)
+ .showFloatView(this);
+ smartFloatView.findComponentById(ResourceTable.Id_close)
+ .setClickedListener(view -> {
+ builder.hideFloatView(smartFloatView);
+ });
+ }
+
+ private void setIdAddSimpleViewWithType() {
+ params.setParam(SimpleViewWitchParam.PARAM, PARAMVALUE);
+ params.setParam(SimpleViewWitchParam.CONTENT, getString(ResourceTable.String_add_simple_view_with_type));
+ smartFloatView.onParamReceive(params);
+ builder = new FloatUtil.Builder()
+ .setComponent(smartFloatView)
+ .setGravity(LayoutAlignment.CENTER)
+ .showFloatView(this);
+ smartFloatView.findComponentById(ResourceTable.Id_close)
+ .setClickedListener(view -> {
+ builder.hideFloatView(smartFloatView);
+ });
+ }
+
+ private void setIdAddSimpleViewWithPoint() {
+ params.setParam(SimpleViewWitchParam.PARAM, PARAMVALUE);
+ params.setParam(SimpleViewWitchParam.CONTENT, getString(ResourceTable.String_add_simple_view_with_point));
+ point = new Point(POINTX, POINTY);
+
+ smartFloatView.onParamReceive(params);
+ builder = new FloatUtil.Builder()
+ .setComponent(smartFloatView)
+ .setGravity(LayoutAlignment.TOP)
+ .point(point)
+ .showFloatView(this);
+ smartFloatView.findComponentById(ResourceTable.Id_close)
+ .setClickedListener(view -> {
+ builder.hideFloatView(smartFloatView);
+ });
+ }
+
+ private void setIdAddSimpleSmartFloatView() {
+ params.setParam(SimpleViewWitchParam.PARAM, "智能浮窗");
+ params.setParam(SimpleViewWitchParam.CONTENT, getString(ResourceTable.String_add_simple_view_with_smart));
+ smartFloatView.onParamReceive(params);
+
+ builder = new FloatUtil.Builder()
+ .setComponent(smartFloatView)
+ .setGravity(LayoutAlignment.CENTER)
+ .point(point)
+ .showFloatView(this);
+ smartFloatView.findComponentById(ResourceTable.Id_close)
+ .setClickedListener(view -> {
+ builder.hideFloatView(smartFloatView);
+ });
+ }
+
+ private void setIdAddDragView() {
+ SimpleViewWitchParam simpleView = new SimpleViewWitchParam(this);
+ FloatBallView floatBallView = new FloatBallView(this);
+
+ new FloatUtil.Builder()
+ .setComponent(floatBallView)
+ .setWidth(FLOATBALLVIEWSIZE)
+ .setHeight(FLOATBALLVIEWSIZE)
+ .setIsMovable(false)
+ .showFloatView(this);
+ builder = new FloatUtil.Builder()
+ .setComponent(simpleView)
+ .setIsMovable(true)
+ .showFloatView(this);
+
+ simpleView.findComponentById(ResourceTable.Id_close)
+ .setClickedListener(view -> {
+ builder.hideFloatView(simpleView);
+ });
+ }
+}
\ 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..baa5cfcfb2c0a9b0886a5584366e36b41a72ace8
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,56 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "FloateUtil"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "add_simple_view",
+ "value": "显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,showFloatView(View view, null)。"
+ },
+ {
+ "name": "btn_show",
+ "value": "显示"
+ },
+ {
+ "name": "add_simple_view_with_param",
+ "value": "显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,showFloatView(View view,Bundle bundle)。"
+ },
+ {
+ "name": "add_simple_view_with_gravity",
+ "value": "显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,指定对齐方式为居中对齐,FloatUtil.showFloatView(floatView, Gravity.CENTER, bundle);。"
+ },
+ {
+ "name": "add_simple_view_with_type",
+ "value": "显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,指定对齐方式为居中对齐,指定浮窗层级为 WindowManager.LayoutParams.TYPE_TOAST,\n FloatUtil.showFloatView(floatView, Gravity.CENTER, WindowManager.LayoutParams.TYPE_PHONE, bundle);。"
+ },
+ {
+ "name": "add_simple_view_with_point",
+ "value": "显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,指定对齐方式为居中对齐,指定浮窗层级为 WindowManager.LayoutParams.TYPE_TOAST,指定坐标 point(x,y) FloatUtil.showFloatView(floatView, Gravity.CENTER, WindowManager.LayoutParams.TYPE_TOAST, point, bundle);。"
+ },
+ {
+ "name": "add_simple_view_with_smart",
+ "value": "添加智能浮窗,智能的意思是自动根据当前系统版本和机型选择何时的 type ,绕过系统权限限制使用浮窗"
+ },
+ {
+ "name": "add_simple_view_with_drag",
+ "value": "添加一个可拖动的浮窗,拖动的方法在自定义的 View 中实现"
+ },
+ {
+ "name": "title",
+ "value": "标题"
+ },
+ {
+ "name": "param",
+ "value": "参数:"
+ }
+ ]
+}
\ 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/graphic/background_btn.xml b/entry/src/main/resources/base/graphic/background_btn.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f13bd4b0381bf289b7b77e7f030e3781d3d19dc7
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_btn.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/shape1.xml b/entry/src/main/resources/base/graphic/shape1.xml
new file mode 100644
index 0000000000000000000000000000000000000000..23700217ea88646d67a6fae4dd4f0be81e795a84
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/shape1.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..c12ba9646aa8c98439df2fbb7f7785dd120bc0bf
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,199 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/float_simple.xml b/entry/src/main/resources/base/layout/float_simple.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2e8a2ee5b33eac23dcbbcfd97f0ee1f3422d6d83
--- /dev/null
+++ b/entry/src/main/resources/base/layout/float_simple.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/float_simple_witch_param.xml b/entry/src/main/resources/base/layout/float_simple_witch_param.xml
new file mode 100644
index 0000000000000000000000000000000000000000..10ef6a0d1eb8fe907354645a17bbc0974fc4469f
--- /dev/null
+++ b/entry/src/main/resources/base/layout/float_simple_witch_param.xml
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/float_small_drag_ball.xml b/entry/src/main/resources/base/layout/float_small_drag_ball.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ed07b78c71374cc03d4760761950dd16b5948a29
--- /dev/null
+++ b/entry/src/main/resources/base/layout/float_small_drag_ball.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/simple/src/main/res/mipmap-xhdpi/close.png b/entry/src/main/resources/base/media/close.png
old mode 100755
new mode 100644
similarity index 100%
rename from simple/src/main/res/mipmap-xhdpi/close.png
rename to entry/src/main/resources/base/media/close.png
diff --git a/simple/src/main/res/mipmap-xhdpi/github.jpg b/entry/src/main/resources/base/media/github.jpg
similarity index 100%
rename from simple/src/main/res/mipmap-xhdpi/github.jpg
rename to entry/src/main/resources/base/media/github.jpg
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/entry/src/main/resources/en/element/string.json b/entry/src/main/resources/en/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2ea4e02f16d90a11f2ed896c37989d264a17284f
--- /dev/null
+++ b/entry/src/main/resources/en/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "FloateUtil"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
diff --git a/entry/src/main/resources/zh/element/string.json b/entry/src/main/resources/zh/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..bf77dee45d83ef24f98dd38d281a01abb1322e52
--- /dev/null
+++ b/entry/src/main/resources/zh/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "FloateUtil"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "你好,世界"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/dalimao/floateutil/ExampleOhosTest.java b/entry/src/ohosTest/java/com/dalimao/floateutil/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..85930cdbf5ac0cdca73f5b126818876a9566d7f7
--- /dev/null
+++ b/entry/src/ohosTest/java/com/dalimao/floateutil/ExampleOhosTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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 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.dalimao.floateutil;
+
+import com.dalimao.library.FloatUtil;
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import ohos.app.Context;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * 单元测试
+ *
+ * @since 2021-07-07
+ */
+public class ExampleOhosTest {
+ private Context mContext = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility().getContext();
+
+ /**
+ * 包名测试
+ */
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.dalimao.floateutil", actualBundleName);
+ }
+
+ /**
+ * FloatBallView测试
+ */
+ @Test
+ public void testFloatBallView() {
+ FloatBallView floatBallView = new FloatBallView(mContext);
+ assertNotNull(floatBallView);
+ }
+
+ /**
+ * SimpleView测试
+ */
+ @Test
+ public void testSimpleView() {
+ SimpleView simpleView = new SimpleView(mContext);
+ assertNotNull(simpleView);
+ }
+
+ /**
+ * SimpleViewWitchParam测试
+ */
+ @Test
+ public void testSimpleViewWitchParam() {
+ SimpleViewWitchParam simpleViewWitchParam = new SimpleViewWitchParam(mContext);
+ assertNotNull(simpleViewWitchParam);
+ }
+
+ /**
+ * FloatUtil测试
+ */
+ @Test
+ public void testFloatUtil() {
+ SimpleView simpleView = new SimpleView(mContext);
+ FloatUtil builder = new FloatUtil.Builder().setComponent(simpleView).showFloatView(mContext);
+ assertNotNull(builder);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/dalimao/floateutil/ExampleTest.java b/entry/src/test/java/com/dalimao/floateutil/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1efde639ab3bec889ddb0a83fa1196b7f063d4f4
--- /dev/null
+++ b/entry/src/test/java/com/dalimao/floateutil/ExampleTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.dalimao.floateutil;
+
+import org.junit.Test;
+
+/**
+ * 单元测试
+ *
+ * @since 2021-07-07
+ */
+public class ExampleTest {
+ /**
+ * onStart
+ */
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/files/float_center.gif b/files/float_center.gif
deleted file mode 100644
index cf95e3aa795504dedfbfd72a0e18bd814079b248..0000000000000000000000000000000000000000
Binary files a/files/float_center.gif and /dev/null differ
diff --git a/files/float_drag.gif b/files/float_drag.gif
deleted file mode 100644
index ca3b630a406451187a5e21ca83b086d0cb017b4f..0000000000000000000000000000000000000000
Binary files a/files/float_drag.gif and /dev/null differ
diff --git a/files/float_param.gif b/files/float_param.gif
deleted file mode 100644
index 9d33bd2a1b19a03df76ff840c919d9063452d999..0000000000000000000000000000000000000000
Binary files a/files/float_param.gif and /dev/null differ
diff --git a/files/simple_float.gif b/files/simple_float.gif
deleted file mode 100644
index 281bf129bd843f028f76a4d800803e640286e7bd..0000000000000000000000000000000000000000
Binary files a/files/simple_float.gif and /dev/null differ
diff --git a/gif/videoView.gif b/gif/videoView.gif
new file mode 100644
index 0000000000000000000000000000000000000000..14c6230f2436bef3c2d594899b41428a79307953
Binary files /dev/null and b/gif/videoView.gif differ
diff --git a/gradle.properties b/gradle.properties
index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..be492496f9a20ac2d980ef4fc30061f4184c1c40 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,13 @@
# 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.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# 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
\ No newline at end of file
+# If the Chinese output is garbled, please configure the following parameter.
+# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
+# more information see https://docs.gradle.org/current/userguide/performance.html
+# org.gradle.parallel=false
+# org.gradle.jvmargs=-Dfile.encoding=GBK
\ No newline at end of file
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 f53c7e8deff79d25e8a45810d2f22f3792a932d6..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Wed Feb 08 10:31:32 HKT 2017
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/library/build.gradle b/library/build.gradle
index e55a70abba9d9a1642faa9b205637a8ae8e50931..2a9eadfcd45131140b6b6d25491c3f078e7d6945 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,25 +1,22 @@
-apply plugin: 'com.android.library'
-apply plugin: 'com.github.dcendents.android-maven'
-android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
-
+apply plugin: 'com.huawei.ohos.library'
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510
+ohos {
+ compileSdkVersion 6
defaultConfig {
- minSdkVersion 15
- targetSdkVersion 23
- versionCode 1
- versionName version
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
+
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.2.1'
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.13'
}
diff --git a/library/consumer-rules.pro b/library/consumer-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..9dccc613bc71b04b83531f550bdab2fb667ecfc9
--- /dev/null
+++ b/library/consumer-rules.pro
@@ -0,0 +1 @@
+# Add har specific ProGuard rules for consumer here.
\ No newline at end of file
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
index cddfa279f7a5baf52a5295e890af94855594baf4..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/library/proguard-rules.pro
+++ b/library/proguard-rules.pro
@@ -1,17 +1 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/liuguangli/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 *;
-#}
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/library/src/androidTest/java/com/dalimao/library/ApplicationTest.java b/library/src/androidTest/java/com/dalimao/library/ApplicationTest.java
deleted file mode 100644
index 389655b84272da174fac57a3c6ae670166875f95..0000000000000000000000000000000000000000
--- a/library/src/androidTest/java/com/dalimao/library/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.dalimao.library;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index 631b412ae159be1ac992f4796e7188fb385f7a5c..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/library/src/main/config.json b/library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..e770ee07691f7107fe10d46b51e28cbc09a38233
--- /dev/null
+++ b/library/src/main/config.json
@@ -0,0 +1,23 @@
+{
+ "app": {
+ "bundleName": "com.dalimao.floateutil",
+ "vendor": "dalimao",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.dalimao.library",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/dalimao/library/CommonWindowWrapper.java b/library/src/main/java/com/dalimao/library/CommonWindowWrapper.java
deleted file mode 100644
index d389166312d29f5e057dd384cdaf1eb5687fa393..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/CommonWindowWrapper.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package com.dalimao.library;
-
-import android.graphics.Point;
-import android.os.Bundle;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.WindowManager;
-import android.view.animation.Animation;
-import android.view.animation.ScaleAnimation;
-import android.widget.FrameLayout;
-
-
-import com.dalimao.library.constants.StandOutFlags;
-import com.dalimao.library.util.DeviceInfoUtil;
-
-/**
- * Created by liuguangli on 16/10/21.
- */
-public class CommonWindowWrapper extends WindowWrapper {
- private Animation mAnimationShowContainer;
- private Animation mAnimationCloseWindow;
-
- private boolean mAnimating;
-
-
- public CommonWindowWrapper(StandOutWindowManager manager, Integer id) {
- super(manager, id);
- }
-
- @Override
- public void setWindowAnchor(Window window) {
- super.setWindowAnchor(window);
- }
-
- @Override
- public StandOutLayoutParams onRequestLayoutParams() {
-
- return mStandOutLayoutParams;
- }
-
- @Override
- public int onRequestWindowFlags() {
-
- return StandOutFlags.FLAG_BODY_MOVE_ENABLE
- | StandOutFlags.FLAG_WINDOW_HIDE_ENABLE
- | StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TAP
- | StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE;
-
- }
-
- @Override
- protected boolean onPrepareMove(Window window, View view, MotionEvent event) {
- return !canMove;
- }
-
- @Override
- public void onCreateAndAttachView(FrameLayout frame) {
-
- prepareAnimations();
- }
- private void prepareAnimations() {
-
- updateOrInitAnimation();
- }
- @Override
- public boolean handleOutSideAction() {
- if (mAnimating) {
- return super.handleOutSideAction();
- }
-
-
- return super.handleOutSideAction();
- }
-
- private void updateOrInitAnimation() {
-
-
- if (mAnimationCloseWindow != null){
- mAnimationCloseWindow.cancel();
- }
- if (mAnimationShowContainer != null){
- mAnimationShowContainer.cancel();
- }
-
- mAnimationCloseWindow = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, Animation.RELATIVE_TO_SELF,
- 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
- mAnimationCloseWindow.setFillAfter(true);
- mAnimationCloseWindow.setDuration(300);
- mAnimationCloseWindow.setAnimationListener(new Animation.AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- mAnimating = true;
- }
-
- @Override
- public void onAnimationEnd(Animation animation) {
- mAnimating = false;
-
-
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
-
- }
- });
-
-
- mAnimationShowContainer = new ScaleAnimation(0.1f, 1.0f, 0.1f, 1.0f, Animation.RELATIVE_TO_SELF,
- 0.5f, Animation.RELATIVE_TO_SELF,
- 0.5f);
- mAnimationShowContainer.setFillAfter(true);
- mAnimationShowContainer.setDuration(300);
- mAnimationShowContainer.setAnimationListener(new Animation.AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- mAnimating = true;
- }
-
- @Override
- public void onAnimationEnd(Animation animation) {
- mAnimating = false;
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
- });
- }
-
-
- @Override
- public Animation getShowAnimation() {
- return mAnimationShowContainer;
- }
-
- @Override
- public Animation getHideAnimation() {
- return mAnimationCloseWindow;
- }
-
- @Override
- public Animation getCloseAnimation() {
- return mAnimationCloseWindow;
- }
-
- @Override
- protected void onInitParam(Bundle params) {
-
- }
-}
diff --git a/library/src/main/java/com/dalimao/library/DragView.java b/library/src/main/java/com/dalimao/library/DragView.java
deleted file mode 100644
index dd94a2905abd09f0ed93163c409543cd0e34e3ed..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/DragView.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.dalimao.library;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.FrameLayout;
-
-/**
- * Created by liuguangli on 16/11/11.
- */
-
-public class DragView extends FrameLayout implements ListenerGetAble {
- protected OnClickListener mOnClickListener;
- public DragView(Context context) {
- super(context);
- }
-
- public DragView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public DragView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
-
-
- @Override
- public void setOnClickListener(OnClickListener l) {
- mOnClickListener = l;
- //重写这个方法,不要调用 super.setOnClickListener(l),否则无法拖动
- //super.setOnClickListener(l);
- }
-
- @Override
- public OnClickListener getOnclickListener() {
- //务必返回这个监听器否则无法拖动
- return mOnClickListener;
- }
-}
diff --git a/library/src/main/java/com/dalimao/library/FloatUtil.java b/library/src/main/java/com/dalimao/library/FloatUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..c00675104229e628d7b6dcf5f4a792b52c268f68
--- /dev/null
+++ b/library/src/main/java/com/dalimao/library/FloatUtil.java
@@ -0,0 +1,455 @@
+package com.dalimao.library;
+
+import com.dalimao.library.util.BignessUtil;
+import com.dalimao.library.util.LogUtil;
+import com.dalimao.library.util.TypeFlag;
+import com.dalimao.library.util.WindowInfo;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.components.AttrHelper;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.utils.LayoutAlignment;
+import ohos.agp.utils.Point;
+import ohos.agp.utils.Rect;
+import ohos.agp.window.service.Window;
+import ohos.agp.window.service.WindowManager;
+import ohos.app.Context;
+
+/**
+ * FloatUtil
+ *
+ * @since 2021-06-28
+ */
+public class FloatUtil {
+ private static final int DURATIONVALUE = 300;
+
+ private static final int PIXELFORMATVALUE = -3;
+
+ // 状态栏高度
+ private static final int BARTITLE = 120;
+
+ // 导航栏偏移量
+ private static final int NAVIGATIONBAROFFSET = 100;
+
+ // 窗体界面
+ private Component view;
+
+ // 对其方式
+ private int gravity;
+
+ // 窗体高度
+ private int height;
+
+ // 窗体宽度
+ private int width;
+
+ // 是否可以移动
+ private boolean mIsMovable;
+
+ // 窗体层级
+ private TypeFlag typeFlag;
+
+ // 坐标
+ private Point point;
+ private Context mContext;
+ private Window window;
+ private WindowManager windowManager;
+
+ private FloatUtil(FloatUtil.Builder builder, Context context) {
+ this.mContext = context;
+ this.view = builder.mView;
+ this.gravity = builder.mGravity;
+ this.height = builder.mHeight;
+ this.width = builder.mWidth;
+ this.mIsMovable = builder.mIsMovable;
+ this.typeFlag = builder.mTypeFlag;
+ this.point = builder.mPoint;
+ showView();
+ }
+
+ /**
+ * 弹窗布局
+ *
+ * @return Component
+ */
+ public Component getView() {
+ return view;
+ }
+
+ /**
+ * 弹窗布局
+ *
+ * @param view
+ */
+ public void setView(Component view) {
+ this.view = view;
+ }
+
+ /**
+ * 对其方式
+ *
+ * @return int
+ */
+ public int getGravity() {
+ return gravity;
+ }
+
+ /**
+ * 对其方式
+ *
+ * @param gravity
+ */
+ public void setGravity(int gravity) {
+ this.gravity = gravity;
+ }
+
+ /**
+ * 窗口高度
+ *
+ * @return int
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ /**
+ * 窗口高度
+ *
+ * @param height
+ */
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ /**
+ * 窗口宽度
+ *
+ * @return int
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * 窗口宽度
+ *
+ * @param width
+ */
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ /**
+ * 是否可以移动
+ *
+ * @return boolean
+ */
+ public boolean isMovable() {
+ return mIsMovable;
+ }
+
+ /**
+ * 是否可以移动
+ *
+ * @param isMovable
+ */
+ public void setmIsMovable(boolean isMovable) {
+ this.mIsMovable = isMovable;
+ }
+
+ /**
+ * 弹窗层级
+ *
+ * @return TypeFlag
+ */
+ public TypeFlag getTypeFlag() {
+ return typeFlag;
+ }
+
+ /**
+ * 弹窗层级
+ *
+ * @param typeFlag
+ */
+ public void setTypeFlag(TypeFlag typeFlag) {
+ this.typeFlag = typeFlag;
+ }
+
+ /**
+ * 指定x,y位置
+ *
+ * @return Point
+ */
+ public Point getPoint() {
+ return point;
+ }
+
+ /**
+ * 指定x,y位置
+ *
+ * @param point
+ */
+ public void setPoint(Point point) {
+ this.point = point;
+ }
+
+ /**
+ * Builder
+ *
+ * @since 2021-06-28
+ */
+ public static class Builder {
+ private static final int WINDOWDEFAULTHEIGHT = 250;
+ private static final int WINDOWDEFAULTWIDTH = 230;
+
+ // 窗体界面
+ private Component mView;
+
+ // 对其方式
+ private int mGravity = LayoutAlignment.LEFT | LayoutAlignment.TOP;
+
+ // 窗体高度
+ private int mHeight = WINDOWDEFAULTHEIGHT;
+
+ // 窗体宽度
+ private int mWidth = WINDOWDEFAULTWIDTH;
+
+ // 是否可以移动
+ private boolean mIsMovable = false;
+
+ // 窗体层级
+ private TypeFlag mTypeFlag = TypeFlag.MOD_APP_OVERLAY;
+
+ // 坐标
+ private Point mPoint;
+
+ /**
+ * Component
+ *
+ * @param view
+ * @return FloatUtil.Builder
+ */
+ public FloatUtil.Builder setComponent(Component view) {
+ this.mView = view;
+ return this;
+ }
+
+ /**
+ * Gravity
+ *
+ * @param gravity
+ * @return FloatUtil.Builder
+ */
+ public FloatUtil.Builder setGravity(int gravity) {
+ this.mGravity = gravity;
+ return this;
+ }
+
+ /**
+ * height
+ *
+ * @param height
+ * @return FloatUtil.Builder
+ */
+ public FloatUtil.Builder setHeight(int height) {
+ this.mHeight = height;
+ return this;
+ }
+
+ /**
+ * width
+ *
+ * @param width
+ * @return FloatUtil.Builder
+ */
+ public FloatUtil.Builder setWidth(int width) {
+ this.mWidth = width;
+ return this;
+ }
+
+ /**
+ * mIsMovable
+ *
+ * @param isMovable
+ * @return FloatUtil.Builder
+ */
+ public FloatUtil.Builder setIsMovable(boolean isMovable) {
+ this.mIsMovable = isMovable;
+ return this;
+ }
+
+ /**
+ * typeFlag
+ *
+ * @param typeFlag
+ * @return FloatUtil.Builder
+ */
+ public FloatUtil.Builder setTypeFlag(TypeFlag typeFlag) {
+ this.mTypeFlag = typeFlag;
+ return this;
+ }
+
+ /**
+ * point
+ *
+ * @param point
+ * @return FloatUtil.Builder
+ */
+ public FloatUtil.Builder point(Point point) {
+ this.mPoint = point;
+ return this;
+ }
+
+ /**
+ * build
+ *
+ * @param context
+ * @return FloatUtil
+ */
+ public FloatUtil showFloatView(Context context) {
+ return new FloatUtil(this, context);
+ }
+ }
+
+ /**
+ * showView
+ */
+ public void showView() {
+ windowManager = WindowManager.getInstance();
+ String className = view.getClass().getName();
+ WindowInfo windowInfo = new WindowInfo();
+ windowInfo.setClassName(className);
+ hideView(BignessUtil.isExistComponent(windowInfo));
+ BignessUtil.deleteExistComponent(windowInfo);
+
+ // WindowManager.LayoutConfig.MOD_APPLICATION_OVERLAY 悬浮于应用之上没有传递事件
+ // WindowManager.LayoutConfig.MOD_APPLICATION 应用内
+ window = WindowManager.getInstance().addComponent((ComponentContainer) view, mContext, setTypeWindow(typeFlag));
+ window.setMovable(mIsMovable);
+ window.setTransparent(true);
+
+ windowInfo.setWindow(window);
+ BignessUtil.setInstanceComponent(windowInfo);
+
+ WindowManager.LayoutConfig layoutConfig1 = new WindowManager.LayoutConfig();
+
+ layoutConfig1.width = AttrHelper.vp2px(width, mContext);
+ layoutConfig1.height = AttrHelper.vp2px(height, mContext);
+ layoutConfig1.alignment = gravity;
+ layoutConfig1.flags = WindowManager.LayoutConfig.INPUT_ADJUST_PAN;
+ layoutConfig1.pixelFormat = PIXELFORMATVALUE;
+
+ // 设置窗口的xy坐标
+ if (point != null) {
+ layoutConfig1.x = point.getPointXToInt();
+ layoutConfig1.y = point.getPointYToInt();
+ }
+
+ Rect rect = new Rect();
+ rect.top = BignessUtil.getStatusBarHeight(mContext) - BARTITLE;
+ rect.left = 0;
+ rect.right = BignessUtil.getScreenPiex(mContext).width;
+ rect.bottom = BignessUtil.getScreenPiex(mContext).height + NAVIGATIONBAROFFSET;
+
+ window.setBoundRect(rect);
+ window.setLayoutConfig(layoutConfig1);
+ view.setScale(0f, 0f);
+ AnimatorValue animatorValue = setAnimator();
+ animatorValue.setValueUpdateListener((animatorValue1, v) -> {
+ view.setScale(v, v);
+ });
+ animatorValue.start();
+
+ window.setLayoutConfig(layoutConfig1);
+ }
+
+ private AnimatorValue setAnimator() {
+ AnimatorValue animatorValue = new AnimatorValue();
+ animatorValue.setDuration(DURATIONVALUE);
+ return animatorValue;
+ }
+
+ /**
+ * 关闭窗体
+ *
+ * @param componentView
+ */
+ public void hideFloatView(Component componentView) {
+ WindowInfo windowInfo = new WindowInfo();
+ windowInfo.setClassName(componentView.getClass().getName());
+ windowInfo = BignessUtil.isExistComponent(windowInfo);
+ if (BignessUtil.isExistComponent(windowInfo) != null) {
+ WindowInfo windowInfo1 = BignessUtil.isExistComponent(windowInfo);
+ view.setScale(1f, 1f);
+ AnimatorValue animatorValue = setAnimator();
+ animatorValue.setValueUpdateListener((animatorValue1, v) -> {
+ view.setScale(1 - v, 1 - v);
+ });
+
+ animatorValue.setStateChangedListener(new Animator.StateChangedListener() {
+ @Override
+ public void onStart(Animator animator) {
+ }
+
+ @Override
+ public void onStop(Animator animator) {
+ }
+
+ @Override
+ public void onCancel(Animator animator) {
+ hideView(windowInfo1);
+ }
+
+ @Override
+ public void onEnd(Animator animator) {
+ hideView(windowInfo1);
+ }
+
+ @Override
+ public void onPause(Animator animator) {
+ }
+
+ @Override
+ public void onResume(Animator animator) {
+ }
+ });
+
+ animatorValue.start();
+ }
+ }
+
+ /**
+ * hideView
+ *
+ * @param info
+ */
+ private void hideView(WindowInfo info) {
+ if (info != null) {
+ if (info.getWindow() != null && windowManager != null) {
+ try {
+ windowManager.destroyWindow(info.getWindow());
+ } catch (Exception e) {
+ LogUtil.error("hideView", "Exception");
+ }
+ }
+ BignessUtil.deleteExistComponent(info);
+ }
+ }
+
+ /**
+ * 窗体的显示层级
+ *
+ * @param enuTypeFlag
+ * @return int
+ */
+ private int setTypeWindow(TypeFlag enuTypeFlag) {
+ int windowFlag;
+ if (enuTypeFlag == TypeFlag.MOD_APP_OVERLAY) {
+ windowFlag = WindowManager.LayoutConfig.MOD_APPLICATION_OVERLAY;
+ } else {
+ windowFlag = WindowManager.LayoutConfig.INPUT_ADJUST_PAN;
+ }
+ return windowFlag;
+ }
+}
diff --git a/library/src/main/java/com/dalimao/library/ListenerGetAble.java b/library/src/main/java/com/dalimao/library/ListenerGetAble.java
deleted file mode 100644
index 117dcd82d366f7aaaa30b511958a2f1a6955e01d..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/ListenerGetAble.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.dalimao.library;
-
-import android.view.View;
-
-/**
- * 可获取监听器接口,在接口实现类中返回监听器
- * Created by liuguangli on 16/11/11.
- */
-
-public interface ListenerGetAble {
- public View.OnClickListener getOnclickListener();
-
-}
diff --git a/library/src/main/java/com/dalimao/library/ParamReceiver.java b/library/src/main/java/com/dalimao/library/ParamReceiver.java
deleted file mode 100644
index c990d7075d941f750a00b1601d61a0de55a0a932..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/ParamReceiver.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.dalimao.library;
-
-import android.os.Bundle;
-
-/**
- * Created by liuguangli on 16/10/25.
- */
-
-public interface ParamReceiver {
- void onParamReceive(Bundle bundle);
-}
diff --git a/library/src/main/java/com/dalimao/library/StandOutLayoutParams.java b/library/src/main/java/com/dalimao/library/StandOutLayoutParams.java
deleted file mode 100644
index 4622606139a3c81f75cac6acedce347e8dfa9011..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/StandOutLayoutParams.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package com.dalimao.library;
-
-import android.content.Context;
-import android.graphics.PixelFormat;
-import android.util.DisplayMetrics;
-import android.view.Gravity;
-import android.view.WindowManager;
-
-import com.dalimao.library.constants.StandOutFlags;
-import com.dalimao.library.util.Utils;
-
-
-
-public class StandOutLayoutParams extends WindowManager.LayoutParams {
- /**
- * Special value for x position that represents the left of the screen.
- */
- public static final int LEFT = 0;
- /**
- * Special value for y position that represents the top of the screen.
- */
- public static final int TOP = 0;
- /**
- * Special value for x position that represents the right of the screen.
- */
- public static final int RIGHT = Integer.MAX_VALUE;
- /**
- * Special value for y position that represents the bottom of the
- * screen.
- */
- public static final int BOTTOM = Integer.MAX_VALUE;
- /**
- * Special value for x or y position that represents the center of the
- * screen.
- */
- public static final int CENTER = Integer.MIN_VALUE;
- /**
- * Special value for x or y position which requests that the system
- * determine the position.
- */
- public static final int AUTO_POSITION = Integer.MIN_VALUE + 1;
-
- /**
- * The distance that distinguishes a tap from a drag.
- */
- public int threshold;
-
- /**
- * Optional constraints of the window.
- */
- public int minWidth, minHeight, maxWidth, maxHeight;
-
- /**
- * @param windowFlags
- * The flags of the window.
- */
- public StandOutLayoutParams(int type,int windowFlags) {
- super(200, 200, type,
- StandOutLayoutParams.FLAG_NOT_TOUCH_MODAL
- | StandOutLayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
- | FLAG_HARDWARE_ACCELERATED,
- PixelFormat.TRANSLUCENT);
-
- setFocusFlag(false);
-
- if (Utils.isSet(windowFlags,
- StandOutFlags.FLAG_WINDOW_INPUT_METHOD_RESIZE_ENABLE)) {
- flags |= (FLAG_LAYOUT_INSET_DECOR | FLAG_LAYOUT_IN_SCREEN | FLAG_NOT_FOCUSABLE);
- softInputMode = (SOFT_INPUT_STATE_UNSPECIFIED | SOFT_INPUT_ADJUST_RESIZE);
- } else if (!Utils.isSet(windowFlags,
- StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
- // windows may be moved beyond edges
- // 加上FLAG_LAYOUT_IN_SCREEN 之后,浮窗可以移动至通知栏所在的区域,但会被通知栏遮挡
- flags |= (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_NO_LIMITS);
- }
-
- gravity = Gravity.TOP | Gravity.LEFT;
-
- threshold = 10;
- minWidth = minHeight = 0;
- maxWidth = maxHeight = Integer.MAX_VALUE;
- }
-
- /**
- * @param flags
- * The flags of the window.
- * @param w
- * The width of the window.
- * @param h
- * The height of the window.
- */
- public StandOutLayoutParams(int type,int flags, int w, int h) {
- this(type,flags);
- width = w;
- height = h;
- }
-
- /**
- * @param context
- * The context from window.
- * @param flags
- * The flags of the window.
- * @param w
- * The width of the window.
- * @param h
- * The height of the window.
- * @param xpos
- * The x position of the window.
- * @param ypos
- * The y position of the window.
- */
- public StandOutLayoutParams(Context context,int type, int flags, int w, int h, int xpos, int ypos) {
- this(type,flags, w, h);
-
- if (xpos != AUTO_POSITION) {
- x = xpos;
- }
- if (ypos != AUTO_POSITION) {
- y = ypos;
- }
-
- WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- DisplayMetrics metrics = new DisplayMetrics();
- windowManager.getDefaultDisplay().getMetrics(metrics);
- int displayWidth = metrics.widthPixels;
- int displayHeight = metrics.heightPixels;
-
- if (x == RIGHT) {
- x = displayWidth - w;
- } else if (x == CENTER) {
- x = (displayWidth - w) / 2;
- }
-
- if (y == BOTTOM) {
- y = displayHeight - h;
- } else if (y == CENTER) {
- y = (displayHeight - h) / 2;
- }
- }
-
-
-
- /**
- * @param context
- * The context from window.
- * @param flags
- * The flags of the window.
- * @param w
- * The width of the window.
- * @param h
- * The height of the window.
- * @param xpos
- * The x position of the window.
- * @param ypos
- * The y position of the window.
- * @param minWidth
- * The minimum width of the window.
- * @param minHeight
- * The mininum height of the window.
- */
- public StandOutLayoutParams(Context context, int type,int flags, int w, int h, int xpos, int ypos,
- int minWidth, int minHeight) {
- this(context, type ,flags, w, h, xpos, ypos);
-
- this.minWidth = minWidth;
- this.minHeight = minHeight;
- }
-
- /**
- * @param context
- * The context from window.
-
- * @param flags
- * The flags of the window.
- * @param w
- * The width of the window.
- * @param h
- * The height of the window.
- * @param xpos
- * The x position of the window.
- * @param ypos
- * The y position of the window.
- * @param minWidth
- * The minimum width of the window.
- * @param minHeight
- * The mininum height of the window.
- * @param threshold
- * The touch distance threshold that distinguishes a tap from
- * a drag.
- */
- public StandOutLayoutParams(Context context,int type, int flags, int w, int h, int xpos, int ypos,
- int minWidth, int minHeight, int threshold) {
- this(context,type, flags, w, h, xpos, ypos, minWidth, minHeight);
-
- this.threshold = threshold;
- }
-
- public void setFocusFlag(boolean focused) {
- if (focused) {
- flags = flags ^ StandOutLayoutParams.FLAG_NOT_FOCUSABLE;
- } else {
- flags = flags | StandOutLayoutParams.FLAG_NOT_FOCUSABLE;
- }
- }
-}
\ No newline at end of file
diff --git a/library/src/main/java/com/dalimao/library/StandOutWindowManager.java b/library/src/main/java/com/dalimao/library/StandOutWindowManager.java
deleted file mode 100755
index 237369d436eab1ef7d7148f5f7ff6c914fdc0bb9..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/StandOutWindowManager.java
+++ /dev/null
@@ -1,1061 +0,0 @@
-package com.dalimao.library;
-
-import android.content.Context;
-import android.graphics.Point;
-import android.os.Bundle;
-import android.util.Log;
-import android.util.SparseArray;
-import android.view.Gravity;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.WindowManager;
-import android.view.animation.Animation;
-import android.view.animation.AnimationSet;
-
-import com.dalimao.library.constants.StandOutFlags;
-import com.dalimao.library.util.Utils;
-
-
-import java.lang.reflect.Constructor;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.logging.Handler;
-
-public class StandOutWindowManager {
-
- static final String TAG = "StandOutWindowManager";
- static final boolean DEBUG = false;
-
- public void Log(String msg) {
- if (DEBUG) Log.d(TAG, msg);
- }
-
- // internal map of ids to shown/hidden views
- static WindowCache sWindowCache;
- static Window sFocusedWindow;
-
- // static constructors
- static {
- if (sWindowCache == null) {
- sWindowCache = new WindowCache();
- }
- sFocusedWindow = null;
- }
-
- private static StandOutWindowManager instance;
- /**
- * Return the ids of all shown or hidden windows.
- * @param cls
- * @return A set of ids, or an empty set.
- */
- public final static Set getExistingIds(Class extends Context> cls) {
- return sWindowCache.getCacheIds(cls);
- }
-
- /**
- * check the special window wrapper if exited
- * @param servClass class of service which contains the target window wrapper
- * @param cls special window wrapper class
- * @return true if target is exit
- */
- public final static boolean isCached(Class extends Context> servClass, Class extends WindowWrapper> cls) {
- int id = cls.hashCode();
- return sWindowCache.isCached(id, servClass);
- }
-
- public final static void clearCache(Class extends Context> servClass) {
- if (sWindowCache != null) {
- sWindowCache.clear(servClass);
- }
- }
-
- /**
- * window 是否可见
- * @param cls window的类对象
- * @return
- */
- public boolean isWindowShowing(Class extends WindowWrapper> cls) {
- int id = cls.hashCode();
- Window window = getWindow(id);
- if (window != null) {
- return window.isShown();
- } else {
- return false;
- }
- }
-
- private Context mContext;
- //the class of service which contains this menuManager
- private Class extends Context> mServClass;
- //window wrapper cache, the key is wrapper's hash code, that it's the id of window too
- private SparseArray mWindowWrappers = new SparseArray();
- // internal system services
- private android.view.WindowManager mSysWindowManager;
-
- private StandOutWindowManager(Context context) {
- this.mContext = context;
- this.mServClass = context.getClass();
- this.mSysWindowManager = (android.view.WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- }
-
- public static StandOutWindowManager getInstance(Context context){
- if (instance == null){
- instance = new StandOutWindowManager(context);
- }
- return instance;
- }
- public Context getContext() {
- return mContext.getApplicationContext();
- }
-
- public Context getServiceContext() {
- return mContext;
- }
-
- /**
- * check WindowWrapper is exist(not close)
- * @param cls the check class of wrapper
- * @return is exist
- */
- public boolean isWindowExist(Class extends WindowWrapper> cls) {
- int id = cls.hashCode();
- WindowWrapper windowWrapper = mWindowWrappers.get(id);
- return windowWrapper != null;
- }
-
- /**
- * return a new one window wrapper if not exit in cache
- * @param cls the class of special wrapper
- * @return instance
- */
- public WindowWrapper getWindowWrapper(Class extends WindowWrapper> cls, Integer id) {
-
- WindowWrapper windowWrapper = mWindowWrappers.get(id);
- if (windowWrapper == null) {
- windowWrapper = createWindowWrapperInstance(cls, id);
- }else if (windowWrapper.getClass() != cls) {
-
- }
-
- if (windowWrapper == null) {
- String msg = String.format("%s can not be instant !", cls.getSimpleName());
- if (DEBUG) {
- throw new NullPointerException(msg);
- } else {
- Log.w(TAG, msg);
- }
- }
-
- return windowWrapper;
- }
-
- /**
- * return window wrapper that set with attach window
- * @param cls
- * @param anchor anchor for window calculate it's real showing position
- * @return
- */
- public WindowWrapper getWindowWrapper(Class extends WindowWrapper> cls, Window anchor, Integer id) {
- WindowWrapper windowWrapper = getWindowWrapper(cls, id);
- if (windowWrapper != null) {
- windowWrapper.setWindowAnchor(anchor);
- }
- return windowWrapper;
- }
-
- private WindowWrapper createWindowWrapperInstance(Class extends WindowWrapper> cls, Integer id) {
- WindowWrapper windowWrapper = null;
-
- if (cls != null) {
- try {
- Class[] paramTypes = { StandOutWindowManager.class, Integer.class };
- Object[] params = { this, id};
- Constructor con = cls.getConstructor(paramTypes);
- windowWrapper = (WindowWrapper) con.newInstance(params);
- } catch (InstantiationException e) {
- Log.e(TAG,e.getMessage());
- } catch (IllegalAccessException e) {
- Log.e(TAG, e.getMessage());
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
-
- if (windowWrapper != null) {
- mWindowWrappers.put(id, windowWrapper);
- }
-
- return windowWrapper;
- }
-
- private WindowWrapper getWindowWrapperFromCache(int windowId) {
- return mWindowWrappers.get(windowId);
- }
-
- //----------------------------------------------------------------------------------------------
-
- /**
- * Return whether the window corresponding to the id exists. This is useful
- * for testing if the id is being restored (return true) or shown for the
- * first time (return false).
- *
- * @param id
- * The id of the window.
- * @return True if the window corresponding to the id is either shown or
- * hidden, or false if it has never been shown or was previously
- * closed.
- */
- public final boolean isExistingId(int id) {
- return sWindowCache.isCached(id, mServClass);
- }
-
- /**
- * Return the ids of all shown or hidden windows.
- *
- * @return A set of ids, or an empty set.
- */
- public final Set getExistingIds() {
- return sWindowCache.getCacheIds(mServClass);
- }
-
- /**
- * Return the window corresponding to the id, if it exists in cache. The
- * window will not be created with
- * value will be null if the window is not shown or hidden.
- *
- * @param id
- * The id of the window.
- * @return The window if it is shown/hidden, or null if it is closed.
- */
- public final Window getWindow(int id) {
- return sWindowCache.getCache(id, mServClass);
- }
-
- /**
- * Return the window that currently has focus.
- *
- * @return The window that has focus.
- */
- public final Window getFocusedWindow() {
- return sFocusedWindow;
- }
-
- /**
- * Sets the window that currently has focus.
- */
- public final void setFocusedWindow(Window window) {
- sFocusedWindow = window;
- }
-
- //----------------------------------------------------------------------------------------------
-
- /**
- * open a window with special window wrapper class
- *
-
- *
- * @param cls
- * @param args the args will pass to the special window wrapper:
- *
- * @param shouldCloseAll close all showing window before target window is open
- */
- public void show(Class extends WindowWrapper> cls, Bundle args, boolean shouldCloseAll) {
-
- int targetId = cls.hashCode();
-
- if (shouldCloseAll) {
- closeAll(targetId);
- }
-
- Window window = getWindow(targetId);
- if (window != null) {
- Log("can not open an exited window: " + cls.getSimpleName());
- return;
- }
-
- show(cls, args, null);
- }
-
- public void showView(View view, Bundle args, int gravity) {
- final WindowWrapper wrapper = getWindowWrapper(CommonWindowWrapper.class, null , view.getClass().hashCode());
- StandOutLayoutParams params = wrapper.getStandOutLayoutParams();
- params.gravity = gravity;
- wrapper.setStandOutLayoutParams(params);
- showWrapper(wrapper, args, null, view);
- }
-
- /**
- *
- * @param view
- * @param args
- */
-
- public void showView(View view, Bundle args){
-
- showView(view, args, Gravity.TOP | Gravity.LEFT, WindowManager.LayoutParams.TYPE_PHONE);
- }
-
- /**
- *
- * @param view
- * @param args
- * @param gravity
- * @param type
- */
-
- public void showView(View view, Bundle args, int gravity ,int type){
-
- final WindowWrapper wrapper = getWindowWrapper(CommonWindowWrapper.class, null , view.getClass().hashCode());
- StandOutLayoutParams params = wrapper.getStandOutLayoutParams();
- params.gravity = gravity;
- params.type = type;
- wrapper.setStandOutLayoutParams(params);
- showWrapper(wrapper, args, null, view);
- }
- /**
- *
- * @param view
- * @param args
- * @param gravity
- * @param type
- */
-
- public void showView(View view, Bundle args, int gravity , int type, Point point){
-
- showView(view, args, gravity, type, point, false);
- }
-
- /**
- *
- * @param view
- * @param args
- * @param gravity
- * @param type
- * @param point
- * @param drag
- */
-
- public void showView(View view, Bundle args, int gravity, int type, Point point, boolean drag) {
- final WindowWrapper wrapper = getWindowWrapper(CommonWindowWrapper.class, null , view.getClass().hashCode());
- wrapper.setCanMove(drag);
- StandOutLayoutParams params = wrapper.getStandOutLayoutParams();
- params.gravity = gravity;
- params.type = type;
- params.x = point.x;
- params.y = point.y;
- wrapper.setStandOutLayoutParams(params);
- showWrapper(wrapper, args, null, view);
- }
-
- /**
- * open a window and pass it a anchor window object
- * or you can close the anchor window by pass it's wrapper class and closeAnchor with true, before open the target window
- *
- *
- * @param cls the class of target window
- * @param args the args will pass to the special window wrapper:
- * @param anchor wrapper class of anchor window,
- * @param closeAnchor if true close the anchor window before window open
- */
- public void show(Class extends WindowWrapper> cls, Bundle args, Class extends WindowWrapper> anchor, boolean closeAnchor) {
- int anchorId = anchor.hashCode();
- if (closeAnchor && isExistingId(anchorId)) {
- close(anchorId);
- }
-
- Log("start window : " + cls.getSimpleName());
-
- if (closeAnchor) {
- show(cls, args, null);
- return;
- }
-
- Window anchorWindow = getWindow(anchorId);
- if(anchorWindow == null) {
- Log("window caller is null: " + anchorId);
- return;
- }
-
- show(cls, args, anchorWindow);
- }
-
- protected final void show(Class extends WindowWrapper> cls) {
- show(cls, null, null);
- }
-
- protected final void show(Class extends WindowWrapper> cls, Bundle args) {
- show(cls, args, null);
- }
-
- /**
- * Show or restore a window corresponding to the wrapper class.
- * Return the window that was shown/restored.
- *
- * @param cls the class of target window
- * @param args the args will pass to the special window wrapper:
- * @param anchor wrapper class of anchor window,
- * you can get the anchor window object on target wrapper {@link WindowWrapper#onPrepareShow(Window, Window)}
- * @return The window shown.
- */
- public synchronized Window show(Class extends WindowWrapper> cls, Bundle args, Window anchor) {
- final WindowWrapper wrapper = getWindowWrapper(cls, anchor , cls.hashCode());
- Window window = showWrapper(wrapper, args, anchor, null);
-
- return window;
- }
-
- private Window showWrapper(WindowWrapper wrapper, Bundle args, Window anchor, View child) {
- if(wrapper == null) {
- return null;
- }
- final int id = wrapper.WindowId;
- wrapper.setParams(args);
- // get the window corresponding to the id
- Window cachedWindow = getWindow(id);
- if (cachedWindow != null && wrapper != cachedWindow.getWindowWrapper()) {
-
- }
-
- final Window window;
- // check cache first
- if (cachedWindow != null && wrapper.isCreated) {
- window = cachedWindow;
- } else {
- window = new Window(wrapper);
- }
- if (child != null && cachedWindow == null){
- window.addView(child);
- if (args != null) {
- try {
- ((ParamReceiver)child).onParamReceive(args);
- } catch (ClassCastException e) {
- Log.e(TAG, "Your custom view must implement ParamReceiver, or you can not receive params!");
- }
-
- }
- }
- if (window.visibility == Window.VISIBILITY_VISIBLE) {
-// String msg = "Tried to show " + cls.getSimpleName()+ " that is already shown.";
-// if (DEBUG) {
-// throw new IllegalStateException(msg);
-// } else {
-// Log.e(TAG, msg);
-// }
- wrapper.onReShown(window, args);
- return null;
- }
-
- // alert callbacks and cancel if instructed
- wrapper.onPrepareShow(window, anchor);
-
- window.visibility = Window.VISIBILITY_VISIBLE;
-
- // get animation
- Animation animation = wrapper.getShowAnimation();
- wrapper.onShown(window, args);
- // get the params corresponding to the id
- StandOutLayoutParams params = window.getLayoutParams();
-
-
- try {
-
-
- // add the view to the window menuManager
- mSysWindowManager.addView(window, params);
-
- // animate
- if (animation != null) {
- window.getChildAt(0).startAnimation(animation);
- }
- } catch (Exception ex) {
- Log.e(TAG, ex.getMessage());
- }
-
- // add view to internal map
- sWindowCache.putCache(id, mServClass, window);
-
- // mContext.startServiceForeground();
-
-
-
- focus(id);
- return window;
- }
-
-
- /**
- * Create a window corresponding to the wrapper class.
- * Return the window that was shown/restored.
- *
- * @param cls the class of target window
- * @param args the args will pass to the special window wrapper:
- * @param anchor wrapper class of anchor window,
- * you can get the anchor window object on target wrapper {@link WindowWrapper#onPrepareShow(Window, Window)}
- * @return The window shown.
- */
- public synchronized Window create(Class extends WindowWrapper> cls, Bundle args, Window anchor) {
- final WindowWrapper wrapper = getWindowWrapper(cls, anchor, cls.hashCode());
- if(wrapper == null) {
- return null;
- }
- final int id = wrapper.WindowId;
- wrapper.setParams(args);
- // get the window corresponding to the id
- Window cachedWindow = getWindow(id);
- if (cachedWindow != null && wrapper != cachedWindow.getWindowWrapper()) {
-
- }
- final Window window;
- // check cache first
- if (cachedWindow != null && wrapper.isCreated) {
- window = cachedWindow;
- } else {
- window = new Window(wrapper);
- }
-
- // add view to internal map
- sWindowCache.putCache(id, mServClass, window);
- // mContext.startServiceForeground();
- return window;
- }
-
- private void hide(int windowId, final boolean ignoreAnim) {
- WindowWrapper wrapper = mWindowWrappers.get(windowId);
- if (wrapper != null) {
- hide(wrapper, ignoreAnim);
- }
- }
-
- /**
- * Hide a window corresponding to the wrapper class, then will be invoke
- * this hide action request return
- * or it will be the same as invoke the method {@link #close(Class)}
- *
- * @param cls
- * The class of the window.
- */
- public final void hide(Class extends WindowWrapper> cls) {
-
- final int id = cls.hashCode();
- final WindowWrapper wrapper = getWindowWrapperFromCache(id);
- if (wrapper == null) {
- return;
- }
-
- hide(wrapper);
- }
-
- private void hide(final WindowWrapper wrapper) {
- hide(wrapper, false);
- }
-
- private synchronized void hide(final WindowWrapper wrapper, final boolean ignoreAnim) {
-
- final int id = wrapper.WindowId;
- // get the view corresponding to the id
- final Window window = getWindow(id);
-
- if (window == null) {
- /*final String windowName = wrapper.getClass().getSimpleName();
- String msg = "Tried to hide(" + windowName + ") a null window.";
- if (DEBUG) {
- throw new IllegalArgumentException(msg);
- } else {
- Log.e(TAG, msg);
- }*/
- return;
- }
-
- if (window.visibility == Window.VISIBILITY_GONE) {
- /*final String windowName = wrapper.getClass().getSimpleName();
- String msg = "Tried to hide(" + windowName + ") a window that is not shown.";
- if (DEBUG) {
- throw new IllegalStateException(msg);
- } else {
- Log.e(TAG, msg);
- }*/
- return;
- }
-
- // alert callbacks and cancel if instructed
- wrapper.onHidden(window);
-
- // check if hide enabled
- if (Utils.isSet(window.flags, StandOutFlags.FLAG_WINDOW_HIDE_ENABLE)) {
- window.visibility = Window.VISIBILITY_TRANSITION;
-
- // get animation
- Animation animation = wrapper.getHideAnimation();
-
- try {
- View windowContent = window.getChildAt(0);
- // animate
- if (!ignoreAnim && animation != null && windowContent!=null) {
- AnimationSet animationSet = new AnimationSet(false);
- animationSet.setAnimationListener(new Animation.AnimationListener() {
-
- @Override
- public void onAnimationStart(Animation animation) {
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
-
- @Override
- public void onAnimationEnd(Animation animation) {
- // remove the window from the window menuManager
- try {
- mSysWindowManager.removeView(window);
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- window.visibility = Window.VISIBILITY_GONE;
- }
- });
- animationSet.addAnimation(animation);
- windowContent.startAnimation(animationSet);
-
- } else {
- // remove the window from the window menuManager
- mSysWindowManager.removeView(window);
- window.visibility = Window.VISIBILITY_GONE;
- }
- } catch (Exception ex) {
- Log.e(TAG, ex.getMessage());
- }
-
- // mContext.updateNotificationOnHide();
-
- } else {
- // if hide not enabled, close window
- close(wrapper);
- }
- }
-
- public void hideAll() {
- for (int id : getExistingIds()) {
- hide(id, true);
- }
- }
-
- /**
- * Close a window corresponding to the wrapper class.
- *
- * @param cls
- * The class of the window.
- */
- public final synchronized void close(Class extends WindowWrapper> cls) {
- final int id = cls.hashCode();
- final WindowWrapper wrapper = getWindowWrapperFromCache(id);
- if (wrapper == null) {
- return;
- } else {
- close(wrapper);
- }
- }
-
- public final synchronized void close(final WindowWrapper wrapper) {
-
- final int id = wrapper.WindowId;
- // get the view corresponding to the id
- final Window window = getWindow(wrapper.WindowId);
-
- if (window == null) {
- return;
- }
-
- if (window.visibility == Window.VISIBILITY_TRANSITION) {
- return;
- }
-
- // mContext.cancelNotificationOnClose();
-
- unfocus(window);
-
- window.visibility = Window.VISIBILITY_TRANSITION;
-
- // get animation
- Animation animation = wrapper.getCloseAnimation();
- // remove window
- try {
- View windowContent = window.getChildAt(0);
- if (animation != null && windowContent != null) { // animate
- new android.os.Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- removeWindowView(id, window, wrapper);
- }
- }, animation.getDuration());
-
- windowContent.startAnimation(animation);
-
- } else {
- removeWindowView(id, window, wrapper);
- }
- } catch (Exception ex) {
- Log.e(TAG, ex.getMessage());
- }
-
- }
-
- private void removeWindowView(int id, Window window, WindowWrapper wrapper) {
- // remove the window from the window menuManager
- try{
- mSysWindowManager.removeView(window);
- } catch (IllegalArgumentException e) {
- //e.printStackTrace();
- Log.w(TAG, "View not attached to window menuManager, maybe it's a hided window ?");
- }
-
- window.visibility = Window.VISIBILITY_GONE;
-
- // remove view from internal map
- sWindowCache.removeCache(id, mContext.getClass());
-
- // if we just released the last window, quit
- if (sWindowCache.getCacheSize(mServClass) == 0) {
- // mContext.stopServiceForeground();
- }
-
- wrapper.onClosed(window);
- mWindowWrappers.remove(id);
- Log.d(TAG, "remove window id=" + id);
- }
-
- private void closeAll(int target) {
- LinkedList ids = new LinkedList();
- for (int id : getExistingIds()) {
- if(id==target) {
- continue;
- }
- ids.add(id);
- }
-
- close(ids);
- }
-
- public void closeAll() {
- for (int id : getExistingIds()) {
- close(id);
- }
- }
-
- private void close(LinkedList ids) {
- // close each window
- for (int id : ids) {
- if(isExistingId(id)) {
- close(id);
- } else {
- Log("try close a not exited window :" + id);
- }
- }
- }
-
- private void close(int windowId) {
- WindowWrapper wrapper = mWindowWrappers.get(windowId);
- if (wrapper != null) {
- close(wrapper);
- }
- }
-
- //----------------------------------------------------------------------------------------------
-
- /**
- * Internal touch handler for handling moving the window.
- *
- * @see {@link View#onTouchEvent(MotionEvent)}
- *
- * @param window
- * @param view
- * @param event
- * @return
- */
- public boolean onTouchHandleMove(Window window, View view, MotionEvent event) {
- WindowWrapper wrapper = mWindowWrappers.get(window.id);
- if (wrapper == null) {
- return true;
- }
-
- if (wrapper.onPrepareMove(window, view, event)){
- return true;
- }
-
- StandOutLayoutParams params = window.getLayoutParams();
-
- // how much you have to move in either direction in order for the
- // gesture to be a move and not tap
-
- int totalDeltaX = window.touchInfo.lastX - window.touchInfo.firstX;
- int totalDeltaY = window.touchInfo.lastY - window.touchInfo.firstY;
-
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- window.touchInfo.lastX = (int) event.getRawX();
- window.touchInfo.lastY = (int) event.getRawY();
-
- window.touchInfo.firstX = window.touchInfo.lastX;
- window.touchInfo.firstY = window.touchInfo.lastY;
- break;
-
- case MotionEvent.ACTION_MOVE:
- int deltaX = (int) event.getRawX() - window.touchInfo.lastX;
- int deltaY = (int) event.getRawY() - window.touchInfo.lastY;
-
- window.touchInfo.lastX = (int) event.getRawX();
- window.touchInfo.lastY = (int) event.getRawY();
-
- /**
- * 非长按的才执行移动window操作
- * **/
- if(!window.touchInfo.isLongPress) {
- if (window.touchInfo.moving
- || Math.abs(totalDeltaX) >= params.threshold
- || Math.abs(totalDeltaY) >= params.threshold) {
- window.touchInfo.moving = true;
-
- if (Utils.isSet(window.flags, StandOutFlags.FLAG_BODY_MOVE_X_ENABLE)) {
- //only move x axis
- if (event.getPointerCount() == 1) {
- params.x += deltaX;
- }
- window.edit().setPosition(params.x, params.y).commit();
- } else if (Utils.isSet(window.flags,
- StandOutFlags.FLAG_BODY_MOVE_ENABLE)) {
-
- // update the position of the window
- if (event.getPointerCount() == 1) {
- params.x += deltaX;
- params.y += deltaY;
- }
-
- window.edit().setPosition(params.x, params.y).commit();
- }
- }
- }
- break;
-
- case MotionEvent.ACTION_UP:
- window.touchInfo.moving = false;
- window.touchInfo.isLongPress = false;
-
- if (event.getPointerCount() == 1) {
-
- // bring to front on tap
- boolean tap = Math.abs(totalDeltaX) < params.threshold
- && Math.abs(totalDeltaY) < params.threshold;
- if (tap
- && Utils.isSet(
- window.flags,
- StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TAP)) {
- bringToFront(window.id);
- }
- }
-
- // bring to front on touch
- else if (Utils.isSet(window.flags,
- StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TOUCH)) {
- bringToFront(window.id);
- }
-
- break;
-
- case MotionEvent.ACTION_CANCEL:
- window.touchInfo.isLongPress = false;
- break;
- }
-
- if (wrapper != null) {
- wrapper.onMove(window, view, event);
- }
-
- return !window.touchInfo.isLongPress;
-
- }
-
- /**
- * Bring the window corresponding to this id in front of all other windows.
- * The window may flicker as it is removed and restored by the system.
- *
- * @param id
- * The id of the window to bring to the front.
- */
- public final synchronized void bringToFront(int id) {
- Window window = getWindow(id);
- if (window == null) {
- if (DEBUG) {
- throw new IllegalArgumentException("Tried to bringToFront(" + id
- + ") a null window.");
- }
- return;
- }
-
- if (window.visibility == Window.VISIBILITY_GONE) {
- if (DEBUG) {
- throw new IllegalStateException("Tried to bringToFront(" + id
- + ") a window that is not shown.");
- }
- return;
- }
-
- if (window.visibility == Window.VISIBILITY_TRANSITION) {
- return;
- }
-
- StandOutLayoutParams params = window.getLayoutParams();
-
- // remove from window menuManager then add back
- try {
- mSysWindowManager.removeView(window);
- } catch (Exception ex) {
- Log.e(TAG, ex.getMessage());
- }
- try {
- mSysWindowManager.addView(window, params);
- } catch (Exception ex) {
- Log.e(TAG, ex.getMessage());
- }
- }
-
- /**
- * Request focus for the window corresponding to this id. A maximum of one
- * window can have focus, and that window will receive all key events,
- * including Back and Menu.
- *
- * @param id
- * The id of the window.
- * @return True if focus changed successfully, false if it failed.
- */
- public final synchronized boolean focus(int id) {
- // check if that window is focusable
- final Window window = getWindow(id);
- if (window == null) {
- if (DEBUG) {
- throw new IllegalArgumentException("Tried to focus(" + id
- + ") a null window.");
- }
- return false;
- }
-
- if (!Utils.isSet(window.flags,
- StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE)) {
- // remove focus from previously focused window
- if (sFocusedWindow != null) {
- unfocus(sFocusedWindow);
- }
-
- return window.onFocus(true);
- }
-
- return false;
- }
-
- /**
- * Remove focus for the window corresponding to this id. Once a window is
- * unfocused, it will stop receiving key events.
- *
- * @param id
- * The id of the window.
- * @return True if focus changed successfully, false if it failed.
- */
- public final synchronized boolean unfocus(int id) {
- Window window = getWindow(id);
- return unfocus(window);
- }
-
- /**
- * Remove focus for the window, which could belong to another application.
- *
- * @param window
- * The window to unfocus.
- *
- * @return True if focus changed successfully, false if it failed.
- */
- public synchronized boolean unfocus(Window window) {
- if (window == null) {
- if (DEBUG) {
- throw new IllegalArgumentException(
- "Tried to unfocus a null window.");
- }
- return false;
- }
- return window.onFocus(false);
- }
-
- /**
- * Update the window corresponding to this id with the given params.
- *
- * @param id
- * The id of the window.
- * @param params
- * The updated layout params to apply.
- */
- public void updateViewLayout(int id, StandOutLayoutParams params) {
- Window window = getWindow(id);
-
- if (window == null) {
- if (DEBUG) {
- throw new IllegalArgumentException("Tried to updateViewLayout("
- + id + ") a null window.");
- }
- return;
- }
-
- if (window.visibility == Window.VISIBILITY_GONE) {
- return;
- }
-
- if (window.visibility == Window.VISIBILITY_TRANSITION) {
- return;
- }
-
- try {
- window.setLayoutParams(params);
- mSysWindowManager.updateViewLayout(window, params);
- } catch (Exception ex) {
- Log.e(TAG, ex.getMessage());
- }
- }
-
- //----------------------------------------------------------------------------------------------
-
- /**
- * sent a special command to a target window wrapper,
- * the target wrapper's method {@link WindowWrapper#onReceiveCommand(int, Bundle)} will be invoked when command get
- * @param cls the class of target window wrapper
- * @param type command type declared by custom window wrapper
- * @param data
- */
- public void sendWindowCommand(Class extends WindowWrapper> cls, int type, Bundle data) {
- int targetId = cls.hashCode();
- Window window = getWindow(targetId);
- if (window == null) {
- Log("can not send command to a null window");
- return;
- }
-
- WindowWrapper windowWrapper = mWindowWrappers.get(targetId);
- if (windowWrapper != null) {
- windowWrapper.onReceiveCommand(type, data);
- }
- }
-
-
- public void hideView(Class extends View> viewClass, boolean cache) {
- final WindowWrapper wrapper = getWindowWrapperFromCache(viewClass.hashCode());
- if (wrapper == null) {
- return;
- }
-
- if (cache) {
- hide(wrapper);
- } else {
- close(viewClass.hashCode());
- }
-
-
- }
-
-
-
-}
diff --git a/library/src/main/java/com/dalimao/library/TouchInfo.java b/library/src/main/java/com/dalimao/library/TouchInfo.java
deleted file mode 100644
index 22b338ed94de66694252316336d48b0e10392a11..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/TouchInfo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.dalimao.library;
-
-import java.util.Locale;
-
-/**
- * This class holds temporal touch and gesture information. Mainly used to hold
- * temporary data for onTouchEvent(MotionEvent).
- */
-public class TouchInfo {
- /**
- * The state of the window.
- */
- public int firstX, firstY, lastX, lastY;
- public double dist, scale, firstWidth, firstHeight;
- public float ratio;
-
- /**
- * Whether we're past the move threshold already.
- */
- public boolean moving;
-
- /***
- * 是否长按中
- * **/
- public boolean isLongPress;
-
- @Override
- public String toString() {
- return String
- .format(Locale.US,
- "WindowTouchInfo { firstX=%d, firstY=%d,lastX=%d, lastY=%d, firstWidth=%f, firstHeight=%f }",
- firstX, firstY, lastX, lastY, firstWidth, firstHeight);
- }
-}
diff --git a/library/src/main/java/com/dalimao/library/Window.java b/library/src/main/java/com/dalimao/library/Window.java
deleted file mode 100644
index b00a679f5a2467f7ab246355142210e3887e66dd..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/Window.java
+++ /dev/null
@@ -1,542 +0,0 @@
-package com.dalimao.library;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.os.Build;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.FrameLayout;
-
-import com.dalimao.library.constants.StandOutFlags;
-import com.dalimao.library.util.DeviceInfoUtil;
-import com.dalimao.library.util.Utils;
-
-
-/**
- * Special view that represents a floating window.
- */
-public final class Window extends FrameLayout {
-
- public static final int VISIBILITY_GONE = 0;
- public static final int VISIBILITY_VISIBLE = 1;
- public static final int VISIBILITY_TRANSITION = 2;
-
- static final String TAG = "Window";
-
- public final int id;
- /**
- * Whether the window is shown, hidden/closed, or in transition.
- */
- public int visibility;
-
- /**
- * Whether the window is focused.
- */
- public boolean focused;
-
- /**
- * Original params from {@link WindowWrapper#onRequestLayoutParams()} (int, Window)}.
- */
- public StandOutLayoutParams originalParams;
-
- /**
- * Original flags from {@link WindowWrapper#onRequestWindowFlags()} (int)}.
- */
- public int flags;
-
- /**
- * Touch information of the window.
- */
- public TouchInfo touchInfo;
-
- /**
- * Data attached to the window.
- */
- public Bundle data;
-
- /**
- * Width and height of the screen.
- */
- //int displayWidth, displayHeight;
-
- /**
- * Context of the window.
- */
- private final Context mContext;
-
- public WindowWrapper getWindowWrapper() {
- return mWindowWrapper;
- }
-
- private WindowWrapper mWindowWrapper;
- private View.OnClickListener mOnClickListener;
- private int mLastMotionX, mLastMotionY;
- //是否移动了
- private boolean isMoved;
- //长按的runnable
- private Runnable mLongPressRunnable;
- //移动的阈值
- private static final int TOUCH_SLOP = 20;
-
-
-
-
-
- public Window(WindowWrapper windowWrapper) {
- super(windowWrapper.getContext());
-
- mContext = windowWrapper.getContext();
- mWindowWrapper = windowWrapper;
-
- this.id = mWindowWrapper.WindowId;
- this.originalParams = windowWrapper.onRequestLayoutParams();
- this.flags = windowWrapper.onRequestWindowFlags();
- this.touchInfo = new TouchInfo();
- touchInfo.ratio = (float) originalParams.width / originalParams.height;
- this.data = new Bundle();
-
- // create the window contents
- FrameLayout content = new FrameLayout(mContext);
- content.setId(android.R.id.content);
- addView(content);
-
- mLongPressRunnable = new Runnable() {
-
- @Override
- public void run() {
- if (mWindowWrapper.handleLongClick()){
- touchInfo.isLongPress = true;
- mWindowWrapper.onLongPressed();
- }
- }
- };
-
- content.setOnTouchListener(new OnTouchListener() {
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
-
- // pass all touch events to the implementation
- boolean consumed = false;
-
- final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager();
-
-
- dispatchLongPress(event);
- // handle move and bring to front
- consumed = windowManager.onTouchHandleMove(Window.this, v, event)
- || consumed;
-
- // alert implementation
- consumed = mWindowWrapper.onTouchBody(Window.this, v, event)
- || consumed;
-
- return consumed;
- }
- });
-
-
- // attach the view corresponding to the id from the
- // implementation
- windowWrapper.onCreateAndAttachView(content);
-
- // make sure the implementation attached the view
- if (content.getChildCount() == 0) {
- Log.e(TAG, "You must attach your view to the given frame in onCreateAndAttachView()");
- }
-
- // attach the existing tag from the frame to the window
- setTag(content.getTag());
- windowWrapper.isCreated = true;
- }
-
-
- public OnClickListener getOnClickListener() {
- return mOnClickListener;
- }
- @Override
- public void addView(View child) {
- FrameLayout content = (FrameLayout) findViewById(android.R.id.content);
- if (content != null) {
- content.addView(child);
- } else {
- super.addView(child);
- }
-
- }
-
-
-
-
-
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent event) {
- // focus window
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager();
- if (windowManager.getFocusedWindow() != this) {
- if (windowManager.isExistingId(id)) {
- windowManager.focus(id);
- }
- }
- break;
- }
-
- return false;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- // handle touching outside
- switch (event.getAction()) {
- case MotionEvent.ACTION_OUTSIDE:
- final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager();
- // unfocus window
- if (windowManager.getFocusedWindow() == this) {
- windowManager.unfocus(this);
- }
- // notify implementation that ACTION_OUTSIDE occurred
- mWindowWrapper.onTouchBody(this, this, event);
- break;
- }
-
- return true;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (mWindowWrapper.onKeyEvent(event)) {
- Log.d(TAG, "Window " + id + " key event " + event
- + " cancelled by implementation.");
- return false;
- }
-
- if (event.getAction() == KeyEvent.ACTION_UP) {
- switch (event.getKeyCode()) {
- case KeyEvent.KEYCODE_BACK:
- final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager();
- windowManager.unfocus(this);
- mWindowWrapper.onBackKeyPressed();
- return true;
- }
- }
-
- return super.dispatchKeyEvent(event);
- }
-
- /**
- * Request or remove the focus from this window.
- *
- * @param focus Whether we want to gain or lose focus.
- * @return True if focus changed successfully, false if it failed.
- */
- public boolean onFocus(boolean focus) {
-
- if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE)) {
- // window is focusable
-
- if (focus == focused) {
- // window already focused/unfocused
- return false;
- }
-
- focused = focus;
-
- final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager();
- // alert callbacks and cancel if instructed
- if (mWindowWrapper.onFocusChange(this, focus)) {
- Log.d(TAG, "Window " + id + " focus change "
- + (focus ? "(true)" : "(false)")
- + " cancelled by implementation.");
- focused = !focus;
- return false;
- }
-
- // set window menuManager params
- StandOutLayoutParams params = getLayoutParams();
- params.setFocusFlag(focus);
- windowManager.updateViewLayout(id, params);
-
- if (focus) {
- windowManager.setFocusedWindow(this);
- } else {
- if (windowManager.getFocusedWindow() == this) {
- windowManager.setFocusedWindow(null);
- }
- }
-
- return true;
- }
- return false;
- }
-
- @Override
- public void setLayoutParams(ViewGroup.LayoutParams params) {
- if (params instanceof StandOutLayoutParams) {
- super.setLayoutParams(params);
- } else {
- throw new IllegalArgumentException(
- "Window"
- + id
- + ": LayoutParams must be an instance of StandOutLayoutParams.");
- }
- }
-
- /**
- * Convenience method to start editting the size and position of this
- * window. Make sure you call {@link android.content.SharedPreferences.Editor#commit()} when you are done to
- * update the window.
- *
- * @return The Editor associated with this window.
- */
- public Editor edit() {
- return new Editor();
- }
-
- @Override
- public StandOutLayoutParams getLayoutParams() {
- StandOutLayoutParams params = (StandOutLayoutParams) super
- .getLayoutParams();
- if (params == null) {
- params = originalParams;
- }
- return params;
- }
-
- @Override
- public void onWindowFocusChanged(boolean hasWindowFocus) {
- super.onWindowFocusChanged(hasWindowFocus);
- int apiLevel = Build.VERSION.SDK_INT;
- if (apiLevel >= 19) {
- //api 16以上,全屏模式
- hideNavigateBar();
- //setOnSystemUiVisibilityChangeListener(onSystemUiVisibilityChangeListener);
- }
- }
-
- @TargetApi(Build.VERSION_CODES.KITKAT)
- private void hideNavigateBar() {
- setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- );
- }
-
- /**
- * Convenient way to resize or reposition a Window. The Editor allows you to
- * easily resize and reposition the window around anchor points.
- *
- * @author Mark Wei
- */
- public class Editor {
- /**
- * Special value for width, height, x, or y positions that represents
- * that the value should not be changed.
- */
- public static final int UNCHANGED = Integer.MIN_VALUE;
-
- /**
- * Layout params of the window associated with this Editor.
- */
- StandOutLayoutParams mParams;
-
- /**
- * The position of the anchor point as a percentage of the window's
- * width/height. The anchor point is only used by the {@link android.content.SharedPreferences.Editor}.
- *
- *
- * The anchor point effects the following methods:
- *
- *
- * {@link #setPosition(int, int)}, {@link #setPosition(int, int)}.
- *
- * The window will move, expand, or shrink around the anchor point.
- *
- *
- * Values must be between 0 and 1, inclusive. 0 means the left/top, 0.5
- * is the center, 1 is the right/bottom.
- */
- float anchorX, anchorY;
-
- public Editor() {
- mParams = getLayoutParams();
- anchorX = anchorY = 0;
- }
-
-
- /**
- * Set the position of this window as percentages of max screen size.
- * The window's top-left corner will be positioned at the given x and y,
- * unless you've set a different anchor point with
-
- *
- * Changes will not applied until you {@link #commit()}.
- *
- * @param percentWidth
- * @param percentHeight
- * @return The same Editor, useful for method chaining.
- */
- public Editor setPosition(float percentWidth, float percentHeight) {
- return setPosition((int) (DeviceInfoUtil.getScreenLongSize(getContext()) * percentWidth),
- (int) (DeviceInfoUtil.getScreenShortSize(getContext()) * percentHeight));
- }
-
- /**
- * Set the position of this window in absolute pixels. The window's
- * top-left corner will be positioned at the given x and y, unless
- * you've set a different anchor point with
-
- *
- * Changes will not applied until you {@link #commit()}.
- *
- * @param x
- * @param y
- * @return The same Editor, useful for method chaining.
- */
- public Editor setPosition(int x, int y) {
- return setPosition(x, y, false);
- }
-
- /**
- * Set the position of this window in absolute pixels. The window's
- * top-left corner will be positioned at the given x and y, unless
- * you've set a different anchor point with
-
- *
- * Changes will not applied until you {@link #commit()}.
- *
- * @param x
- * @param y
- * @param skip Don't call {@link #setPosition(int, int)} and
- *
- * @return The same Editor, useful for method chaining.
- */
- private Editor setPosition(int x, int y, boolean skip) {
- if (mParams != null) {
- if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
- throw new IllegalStateException(
- "Anchor point must be between 0 and 1, inclusive.");
- }
-
- // sets the x and y correctly according to anchorX and
- // anchorY
- if (x != UNCHANGED) {
- mParams.x = (int) (x - mParams.width * anchorX);
- }
- if (y != UNCHANGED) {
- mParams.y = (int) (y - mParams.height * anchorY);
- }
-
- if (Utils.isSet(flags,
- StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
-
-
- // keep window inside edges
- if (DeviceInfoUtil.getOrientation(getContext()) == DeviceInfoUtil.LANDSCAPE){
- mParams.x = Math.min(Math.max(mParams.x, 0), DeviceInfoUtil.getScreenLongSize(getContext())
- - mParams.width);
- mParams.y = Math.min(Math.max(mParams.y, 0), DeviceInfoUtil.getScreenShortSize(getContext())
- - mParams.height);
- } else {
- mParams.y = Math.min(Math.max(mParams.y, 0), DeviceInfoUtil.getScreenLongSize(getContext())
- - mParams.width);
- mParams.x = Math.min(Math.max(mParams.x, 0), DeviceInfoUtil.getScreenShortSize(getContext())
- - mParams.height);
- }
-
- } else if (Utils.isSet(flags,
- StandOutFlags.FLAG_WINDOW_EDGE_Y_LIMITS_ENABLE)) {
- // if gravity is not TOP|LEFT throw exception
- if (mParams.gravity != (Gravity.TOP | Gravity.LEFT)) {
- throw new IllegalStateException(
- "The window "
- + id
- + " gravity must be TOP|LEFT if FLAG_WINDOW_EDGE_LIMITS_ENABLE or FLAG_WINDOW_EDGE_TILE_ENABLE is set.");
- }
-
- // keep window inside y edges
- mParams.y = Math.min(Math.max(mParams.y, 0), DeviceInfoUtil.getScreenShortSize(getContext())
- - mParams.height);
- }
- }
-
- return this;
- }
-
- /**
- * Commit the changes to this window. Updates the layout. This Editor
- * cannot be used after you commit.
- */
- public void commit() {
- if (mParams != null) {
- final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager();
- if (windowManager.isExistingId(id)) {
- windowManager.updateViewLayout(id, mParams);
- }
- mParams = null;
- }
- }
- }
-
- public boolean dispatchLongPress(MotionEvent event) {
- int x = (int) event.getX();
- int y = (int) event.getY();
- switch(event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mLastMotionX = x;
- mLastMotionY = y;
- isMoved = false;
- postDelayed(mLongPressRunnable, 380);
- break;
- case MotionEvent.ACTION_MOVE:
- if(isMoved) break;
- if(Math.abs(mLastMotionX - x) > TOUCH_SLOP
- || Math.abs(mLastMotionY - y) > TOUCH_SLOP) {
- //移动超过阈值,则表示移动了
- isMoved = true;
- removeCallbacks(mLongPressRunnable);
- }
- break;
- case MotionEvent.ACTION_CANCEL:
-
- case MotionEvent.ACTION_UP:
- //释放了
- removeCallbacks(mLongPressRunnable);
- if(!isMoved && !touchInfo.isLongPress) {
-
- handleOnClick();
-
- }
-
- break;
- }
- return !isMoved;
- }
-
- private void handleOnClick(){
- ViewGroup content = (ViewGroup) findViewById(android.R.id.content);
- if (content == null) {
- return;
- }
- View child = content.getChildAt(0);
- if (child instanceof ListenerGetAble) {
- mOnClickListener = ((ListenerGetAble)child).getOnclickListener();
- if (mOnClickListener != null) {
- mOnClickListener.onClick(getChildAt(0));
- }
- }
- };
-}
-
diff --git a/library/src/main/java/com/dalimao/library/WindowCache.java b/library/src/main/java/com/dalimao/library/WindowCache.java
deleted file mode 100644
index bac449115bfa2cf71b84a94d0c980e516469d6dd..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/WindowCache.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package com.dalimao.library;
-
-
-import android.content.Context;
-import android.util.SparseArray;
-
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-
-public class WindowCache {
- public Map, SparseArray> sWindows;
-
- public WindowCache() {
- sWindows = new HashMap, SparseArray>();
- }
-
- /**
- * Returns whether the window corresponding to the class and id exists in
- * the {@link #sWindows} cache.
- *
- * @param id
- * The id representing the window.
- * @param cls
- * Class corresponding to the window.
- * @return True if the window corresponding to the class and id exists in
- * the cache, or false if it does not exist.
- */
- public boolean isCached(int id, Class extends Context> cls) {
- return getCache(id, cls) != null;
- }
-
- /**
- * Returns the window corresponding to the id from the {@link #sWindows}
- * cache.
- *
- * @param id
- * The id representing the window.
- * @param cls
- * The class of the implementation of the window.
- * @return The window corresponding to the id if it exists in the cache, or
- * null if it does not.
- */
- public Window getCache(int id, Class extends Context> cls) {
- SparseArray l2 = sWindows.get(cls);
- if (l2 == null) {
- return null;
- }
-
- return l2.get(id);
- }
-
- /**
- * Add the window corresponding to the id in the {@link #sWindows} cache.
- *
- * @param id
- * The id representing the window.
- * @param cls
- * The class of the implementation of the window.
- * @param window
- * The window to be put in the cache.
- */
- public void putCache(int id, Class extends Context> cls, Window window) {
- SparseArray l2 = sWindows.get(cls);
- if (l2 == null) {
- l2 = new SparseArray();
- sWindows.put(cls, l2);
- }
-
- l2.put(id, window);
- }
-
- /**
- * Remove the window corresponding to the id from the {@link #sWindows}
- * cache.
- *
- * @param id
- * The id representing the window.
- * @param cls
- * The class of the implementation of the window.
- */
- public void removeCache(int id, Class extends Context> cls) {
- SparseArray l2 = sWindows.get(cls);
- if (l2 != null) {
- l2.remove(id);
- if (l2.size() == 0) {
- sWindows.remove(cls);
- }
- }
- }
-
- /**
- * Returns the size of the {@link #sWindows} cache.
- *
- * @return True if the cache corresponding to this class is empty, false if
- * it is not empty.
- * @param cls
- * The class of the implementation of the window.
- */
- public int getCacheSize(Class extends Context> cls) {
- SparseArray l2 = sWindows.get(cls);
- if (l2 == null) {
- return 0;
- }
-
- return l2.size();
- }
-
- /**
- * Returns the ids in the {@link #sWindows} cache.
- *
- * @param cls
- * The class of the implementation of the window.
- * @return The ids representing the cached windows.
- */
- public Set getCacheIds(Class extends Context> cls) {
- SparseArray l2 = sWindows.get(cls);
- if (l2 == null) {
- return new HashSet();
- }
-
- Set keys = new HashSet();
- for (int i = 0; i < l2.size(); i++) {
- keys.add(l2.keyAt(i));
- }
- return keys;
- }
-
- public void clear(Class extends Context> cls) {
- SparseArray l2 = sWindows.remove(cls);
- if(l2 != null && l2.size() > 0) {
- l2.clear();
- }
- }
-
- public int size() {
- return sWindows.size();
- }
-}
diff --git a/library/src/main/java/com/dalimao/library/WindowWrapper.java b/library/src/main/java/com/dalimao/library/WindowWrapper.java
deleted file mode 100755
index d4b7b731e419a336781ccdb4f3e303c2be0b7643..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/WindowWrapper.java
+++ /dev/null
@@ -1,329 +0,0 @@
-package com.dalimao.library;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.FrameLayout;
-
-import com.dalimao.library.util.DeviceInfoUtil;
-
-
-/**
- * a abstract business logic class, define a set of window life-cycle and logic callback
- * It's subclasses need to implement the abstract method to define the window's attributes (such as layout, view, action etc)
- *
- */
-public abstract class WindowWrapper {
-
- public final int WindowId;
-
- protected Context mContext;
- protected StandOutWindowManager mWindowManager;
- protected boolean mIsShowing = false;
- protected Window mAnchorWindow;
- private Bundle mParams;
- public boolean isCreated = false;
- protected StandOutLayoutParams mStandOutLayoutParams;
- protected boolean canMove;
-
- public WindowWrapper(StandOutWindowManager manager, int id) {
- mWindowManager = manager;
- mContext = manager.getContext();
- WindowId = id;
- mStandOutLayoutParams = new StandOutLayoutParams(mContext, WindowManager.LayoutParams.TYPE_PHONE, onRequestWindowFlags(),
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT,
- 0, 0);
- mStandOutLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
- }
-
- public boolean isCanMove() {
- return canMove;
- }
-
- public void setCanMove(boolean canMove) {
- this.canMove = canMove;
- }
-
- public StandOutLayoutParams getStandOutLayoutParams() {
- return mStandOutLayoutParams;
- }
-
- public void setStandOutLayoutParams(StandOutLayoutParams mStandOutLayoutParams) {
- this.mStandOutLayoutParams = mStandOutLayoutParams;
- }
-
- /**
- * return application context
- * @return
- */
- public Context getContext() {
- return mContext.getApplicationContext();
- }
-
- public StandOutWindowManager getWindowManager() {
- return mWindowManager;
- }
-
- public void setWindowAnchor(Window window) {
- this.mAnchorWindow = window;
- }
-
- public boolean isShowing() {
- return mIsShowing;
- }
-
- /**
-
- * Return the animation to play when the window corresponding to the id is
- * shown.
- *
- * @return The animation to play or null.
- */
- public Animation getShowAnimation() {
- return AnimationUtils.loadAnimation(mContext, android.R.anim.fade_in);
- }
-
- /**
- * Return the animation to play when the window corresponding to the id is
- * hidden.
- *
- * @return The animation to play or null.
- */
- public Animation getHideAnimation() {
- return AnimationUtils.loadAnimation(mContext, android.R.anim.fade_out);
- }
-
- /**
- * Return the animation to play when the window corresponding to the id is
- * closed.
- *
- * @return The animation to play or null.
- */
- public Animation getCloseAnimation() {
- return AnimationUtils.loadAnimation(mContext, android.R.anim.fade_out);
- }
-
- /**
- * Return the {@link StandOutLayoutParams} for define the initial layout of window.
- * The system will set the layout params on the view for this StandOut
- * window. The layout params may be reused.
- *
- * @return the {@link StandOutLayoutParams} for define the layout of window.
- * The layout params will be set on the window. The layout params
- * returned will be reused whenever possible, minimizing the number
- * of times onRequestLayoutParams() will be called.
- */
- public abstract StandOutLayoutParams onRequestLayoutParams();
-
- /**
- * Implement this method to change modify the behavior and appearance of the
- * window corresponding to the id.
- *
- *
- This
- * method will be called many times, so keep it fast.
- *
- *
- * Use bitwise OR (|) to set flags, and bitwise XOR (^) to unset flags.
- *
- * @return A combination of flags.
- */
- public int onRequestWindowFlags() {
- return 0;
- }
-
- /**
- * Create a new {@link View} and add it as a child
- * to the frame. The view will become the contents of this StandOut window.
- * The view MUST be newly created, and you MUST attach it to the frame.
- *
- *
- * If you are inflating your view from XML, make sure you use
- * {@link android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)} to attach your
- * view to frame. Set the ViewGroup to be frame, and the boolean to true.
- *
- *
- * If you are creating your view programmatically, make sure you use
- * {@link FrameLayout#addView(View)} to add your view to the frame.
- *
- * @param frame
- * The {@link FrameLayout} to attach your view as a child to.
- */
- public abstract void onCreateAndAttachView(FrameLayout frame);
-
- /**
- * one step of life-cycle, invoke this before add window to android.os.WindowManager,
- * the anchor window will not null if caller pass,
- * then can update the window's layout that created by {@link #onRequestLayoutParams()}
- *
- * @param window the window binding with this wrapper
- * @param anchor the anchor window, maybe null if caller not pass it
- */
- public void onPrepareShow(Window window, Window anchor) {
- }
-
- /**
- * one step of life-cycle, invoke this after window add to android.os.WindowManager,
- * subclasses can implement this to do something on window display on screen
- *
- * @param window the window binding with this wrapper
- * @param args
- * @return
- */
- public boolean onShown(Window window, Bundle args) {
- mIsShowing = true;
- /*final int apiLevel = Build.VERSION.SDK_INT;
- if (apiLevel >= 16) {
- //api 16以上,全屏模式
- window.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_IMMERSIVE);
- }*/
- return false;
- }
-
- /**
- * one step of life-cycle, invoke when window remove from android.os.WindowManage but not from WindowCache,,
- * the window and this wrapper can reuse when call by {@link StandOutWindowManager again
- *
- * @param window the window binding with this wrapper
- * @return
- */
- public boolean onHidden(Window window) {
- mAnchorWindow = null;
- mIsShowing = false;
- return false;
- }
-
- /**
- * one step of life-cycle, invoke when window remove from android.os.WindowManage and WindowCache
- *
- * @param window the window binding with this wrapper
- * @return
- */
- public boolean onClosed(Window window) {
- mAnchorWindow = null;
- mIsShowing = false;
- return false;
- }
-
- /**
- * implement for handle the command
- * @see StandOutWindowManager#sendWindowCommand(Class, int, Bundle)
- *
- * @param type
- * @param data
- * @return
- */
- public boolean onReceiveCommand(int type, Bundle data) {
- return false;
- }
-
- public boolean onKeyEvent(KeyEvent event) {
- return false;
- }
-
- public void onBackKeyPressed() { }
-
- /**
- * Implement this callback to be alerted when a window corresponding to the
- * id is about to have its focus changed. This callback will occur before
- * the window's focus is changed.
- *
- * @param window
- * The window about to be brought to the front.
- * @param focus
- * Whether the window is gaining or losing focus.
- * @return Return true to cancel the window's focus from being changed, or
- * false to continue.
- * @see StandOutWindowManager#focus(int)
- */
- public boolean onFocusChange(Window window, boolean focus) {
- return false;
- }
-
- /**
- * Implement this method to be alerted to touch events in the body of the
- * window corresponding to the id.
- *
- * @see {@link View.OnTouchListener#onTouch(View, MotionEvent)}
- *
- * @param window
- * The window corresponding to the id, provided as a courtesy.
- * @param view
- * The view where the event originated from.
- * @param event
- * See linked method.
- */
- public boolean onTouchBody(Window window, View view, MotionEvent event) {
- if(event.getAction()== MotionEvent.ACTION_OUTSIDE) {
- return handleOutSideAction();
- }
- return false;
- }
-
- public boolean handleOutSideAction() {
- return false;
- }
-
- /**
- * Implement this method to be alerted to when the window corresponding to
- * the id is moved.
- *
- * @param window
- * The window corresponding to the id, provided as a courtesy.
- * @param view
- * The view where the event originated from.
- * @param event
- * See linked method.
- *
- */
- public void onMove(Window window, View view, MotionEvent event) { }
-
- protected boolean onPrepareMove(Window window, View view, MotionEvent event) {
- return false;
- }
-
- /**
- * show window when a window is already show
- * @param window the shown window
- * @param args
- */
- protected void onReShown(Window window, Bundle args) {
-
- }
-
- /**
- * 是否响应长按事件
- * **/
- public boolean handleLongClick(){
- return false;
- }
-
- public void onLongPressed(){
-
- }
-
- void setParams(Bundle params) {
- mParams = params;
- onInitParam(params);
- }
-
- protected abstract void onInitParam(Bundle params);
-
- public Bundle getBundleParams() {
- return mParams;
- }
-
-}
diff --git a/library/src/main/java/com/dalimao/library/constants/StandOutFlags.java b/library/src/main/java/com/dalimao/library/constants/StandOutFlags.java
deleted file mode 100644
index bbb43b9bb7e57188efe700ad8e4277deccac4f8c..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/constants/StandOutFlags.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.dalimao.library.constants;
-
-public class StandOutFlags {
-
- // This counter keeps track of which primary bit to set for each flag
- private static int flag_bit = 0;
-
- /**
- * Setting this flag indicates that the window can be moved by dragging the
- * body.
- *
- */
- public static final int FLAG_BODY_MOVE_ENABLE = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that windows are able to be hidden
- */
- public static final int FLAG_WINDOW_HIDE_ENABLE = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that the window should be brought to the
- * front upon user interaction.
- *
- *
- * Note that if you set this flag, there is a noticeable flashing of the
- * window during {@link android.view.MotionEvent#ACTION_UP}. This the hack that allows
- * the system to bring the window to the front.
- */
- public static final int FLAG_WINDOW_BRING_TO_FRONT_ON_TOUCH = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that the window should be brought to the
- * front upon user tap.
- *
- *
- * Note that if you set this flag, there is a noticeable flashing of the
- * window during {@link android.view.MotionEvent#ACTION_UP}. This the hack that allows
- * the system to bring the window to the front.
- */
- public static final int FLAG_WINDOW_BRING_TO_FRONT_ON_TAP = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that the system should keep the window's
- * position within the edges of the screen. If this flag is not set, the
- * window will be able to be dragged off of the screen.
- *
- *
- * If this flag is set, the window's {@link android.view.Gravity} is recommended to be
- * {@link android.view.Gravity#TOP} | {@link android.view.Gravity#LEFT}. If the gravity is anything
- * other than TOP|LEFT, then even though the window will be displayed within
- * the edges, it will behave as if the user can drag it off the screen.
- *
- */
- public static final int FLAG_WINDOW_EDGE_LIMITS_ENABLE = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that the system should keep the window's
- * aspect ratio constant when resizing.
- *
- *
- * The aspect ratio will only be enforced in
- * {@link standout.StandOutWindowManager#onTouchHandleResize(standout.ui.Window, android.view.View, android.view.MotionEvent)}
- * . The aspect ratio will not be enforced if you set the width or height of
- * the window's LayoutParams manually.
- *
- * @see standout.StandOutWindowManager#onTouchHandleMove(standout.ui.Window, android.view.View, android.view.MotionEvent)
- */
- public static final int FLAG_WINDOW_ASPECT_RATIO_ENABLE = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that the window does not need focus. If this
- * flag is set, the system will not take care of setting and unsetting the
- * focus of windows based on user touch and key events.
- *
- *
- * You will most likely need focus if your window contains any of the
- * following: Button, ListView, EditText.
- *
- *
- * The benefit of disabling focus is that your window will not consume any
- * key events. Normally, focused windows will consume the Back and Menu
- * keys.
- *
- * @see {@link standout.StandOutWindowManager#focus(int)}
- * @see {@link standout.StandOutWindowManager#unfocus(int)}
- *
- */
- public static final int FLAG_WINDOW_FOCUSABLE_DISABLE = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that ignore the system status bar height in calculate the Window#displayHeight
- */
- public static final int FLAG_IGNORE_SYSTEM_STATUS_BAR = 1 << flag_bit++;
-
- /**
- * Setting this flag indicates that the window can be moved x axis by dragging the body.
- */
- public static final int FLAG_BODY_MOVE_X_ENABLE = 1 << flag_bit ++;
-
- /**
- * 将window限制在屏幕高度以内
- */
- public static final int FLAG_WINDOW_EDGE_Y_LIMITS_ENABLE = 1 << flag_bit ++;
-
- public static final int FLAG_WINDOW_INPUT_METHOD_RESIZE_ENABLE = 1 << flag_bit ++;
-
-}
\ No newline at end of file
diff --git a/library/src/main/java/com/dalimao/library/util/BignessUtil.java b/library/src/main/java/com/dalimao/library/util/BignessUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..02eea6d2e93fb0d37e089d8d3b53a5b7a21eba3b
--- /dev/null
+++ b/library/src/main/java/com/dalimao/library/util/BignessUtil.java
@@ -0,0 +1,155 @@
+/*
+ * 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 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.dalimao.library.util;
+
+import ohos.agp.utils.Point;
+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.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * BignessUtil
+ *
+ * @since 2021-06-25
+ */
+public class BignessUtil {
+ /**
+ * componentList
+ */
+ private static List componentList = new ArrayList<>();
+
+ private BignessUtil() {
+ }
+
+ public static List getComponentList() {
+ return componentList;
+ }
+
+ /**
+ * setComponentList
+ *
+ * @param component
+ * @return List
+ */
+ public static List setComponentList(WindowInfo component) {
+ componentList.add(component);
+ return componentList;
+ }
+
+ /**
+ * 获取屏幕密度
+ *
+ * @param context
+ * @return DisplayAttributes
+ */
+ public static DisplayAttributes getScreenPiex(Context context) {
+ Optional display = DisplayManager.getInstance().getDefaultDisplay(context);
+ DisplayAttributes displayAttributes = null;
+ if (display.isPresent()) {
+ displayAttributes = display.get().getAttributes();
+ }
+ return displayAttributes;
+ }
+
+ /**
+ * 获取屏幕高度,不包含状态栏的高度
+ *
+ * @param context 上下文
+ * @return 屏幕高度,不包含状态栏的高度
+ */
+ public static float getDisplayHeightInPx(Context context) {
+ Display display = DisplayManager.getInstance().getDefaultDisplay(context).get();
+ Point point = new Point();
+ display.getSize(point);
+ return point.getPointY();
+ }
+
+ /**
+ * getStatusBar
+ *
+ * @param context
+ * @return float
+ */
+ public static float getStatusBar(Context context) {
+ float barHeight = (float) NumberUtil.sub(getScreenPiex(context).height,getDisplayHeightInPx(context));
+ return barHeight;
+ }
+
+ /**
+ * 获取状态栏高度
+ *
+ * @param context
+ * @return int
+ */
+ public static int getStatusBarHeight(Context context) {
+ int result = 0;
+ Point point1 = new Point();
+ Point point2 = new Point();
+ Display display = DisplayManager.getInstance().getDefaultDisplay(context).get();
+ display.getSize(point1);
+ display.getRealSize(point2);
+ result = (int) NumberUtil.sub(point2.getPointY(),point1.getPointY());
+ return result;
+ }
+
+ /**
+ * 保存所有窗口view的实例 同一个 View 类,同时只能显示一个实例
+ *
+ * @param componentName
+ * @return List
+ */
+ public static List setInstanceComponent(WindowInfo componentName) {
+ return setComponentList(componentName);
+ }
+
+ /**
+ * 当前实例 是否存在
+ *
+ * @param componentName
+ * @return boolean
+ */
+ public static WindowInfo isExistComponent(WindowInfo componentName) {
+ WindowInfo info = null;
+ for (int index = 0; index < getComponentList().size(); index++) {
+ WindowInfo mComponent = getComponentList().get(index);
+ if (mComponent.getClassName().equals(componentName.getClassName())) {
+ info = mComponent;
+ break;
+ }
+ }
+ return info;
+ }
+
+ /**
+ * 删除实例
+ *
+ * @param componentName
+ */
+ public static void deleteExistComponent(WindowInfo componentName) {
+ for (int index = 0; index < getComponentList().size(); index++) {
+ WindowInfo mComponent = getComponentList().get(index);
+ if (mComponent.getClassName().equals(componentName.getClassName())) {
+ getComponentList().remove(index);
+ break;
+ }
+ }
+ }
+}
diff --git a/library/src/main/java/com/dalimao/library/util/DeviceInfoUtil.java b/library/src/main/java/com/dalimao/library/util/DeviceInfoUtil.java
deleted file mode 100644
index 19fbf8d2d5ac5f04e9311c6eae4bac4d569e842f..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/util/DeviceInfoUtil.java
+++ /dev/null
@@ -1,347 +0,0 @@
-package com.dalimao.library.util;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.graphics.Point;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
-import android.os.Build;
-import android.os.Environment;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.WindowManager;
-
-
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import static android.os.Environment.MEDIA_MOUNTED;
-
-
-/**
- * Created by liuguangli on 15/12/17.
- */
-public class DeviceInfoUtil {
- private static final String EXTERNAL_STORAGE_PERMISSION = "android.permission.WRITE_EXTERNAL_STORAGE";
-
- public static final int PORTRAIT = 1;
- public static final int LANDSCAPE = 2;
- private static final String TAG = "DeviceInfoUtil";
- private static DisplayMetrics displayMetrics;
- private static String sExternalSdCardPath = null;
- private static String imei = "";
-
- private static String imsi = "";
- private static String exSdCardPath = "";
- public static DisplayMetrics getScreenSize(Context context){
- if (displayMetrics == null){
- try {
-
- displayMetrics = new DisplayMetrics();
- displayMetrics.widthPixels = 1280;
- displayMetrics.heightPixels = 720;
- WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getMetrics(displayMetrics);
- } catch (Exception e){
- Log.e(TAG,e.getMessage());
- }
-
- }
- return displayMetrics;
- }
-
- public static float getDesity(Context context){
- getScreenSize(context);
- return displayMetrics.density;
- }
-
- public static int getScreenLongSize(Context context){
- getScreenSize(context);
- return Math.max(displayMetrics.widthPixels, displayMetrics.heightPixels);
- }
- public static int getScreenShortSize(Context context){
- getScreenSize(context);
- return Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels);
- }
- public static int getOrientation(Context context){
- DisplayMetrics displayMetrics = new DisplayMetrics();
- displayMetrics.widthPixels = 1280;
- displayMetrics.heightPixels = 720;
- try {
- WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getMetrics(displayMetrics);
- } catch (Exception e){
- //do nothing
- }
-
- if (displayMetrics.heightPixels>displayMetrics.widthPixels){
- return PORTRAIT;
- } else {
- return LANDSCAPE;
- }
- }
- /**
- * @return
- */
- public static int getSystemVersion(){
-
- return Build.VERSION.SDK_INT;
- }
- /**
- */
- public static String getBuildModel(){
-
- return Build.MANUFACTURER+Build.MODEL;
- }
-
- /**
- * @param context 获取sd卡路径
- * @return
- */
- public static String getExternalSDCardPath(Context context) {
- // ArrayList paths = (ArrayList) getExtSDCardPaths();
- // if (paths.size() != 0)
- // return paths.get(0) + "/";
- if (sExternalSdCardPath != null)
- return sExternalSdCardPath;
- String externalStorageState;
- File externalDir = null;// 获取手机根目录
- try {
- externalStorageState = Environment.getExternalStorageState();
- } catch (NullPointerException e) { // (sh)it happens (Issue #660)
- externalStorageState = "";
- }
- if (MEDIA_MOUNTED.equals(externalStorageState) && hasExternalStoragePermission(context)) {
- externalDir = Environment.getExternalStorageDirectory();
- }
- String path = null;
- if (externalDir == null || !externalDir.exists() || !externalDir.canWrite()) {
- externalDir = context.getCacheDir();
- if (externalDir != null) {
- path = externalDir.getPath();
- path = path.endsWith("/") ? path : path + "/";
- sExternalSdCardPath = path;
- }
- } else {
- path = externalDir.getPath();
- path = path.endsWith("/") ? path : path + "/";
- sExternalSdCardPath = path;
- }
- // 如果还为空
-// fix 静态代码扫描 zhengyx 2016.03.15
- if (TextUtils.isEmpty(sExternalSdCardPath)) {
- String cacheDirPath = "/data/data/" + context.getPackageName() + "/cache/";
- sExternalSdCardPath = cacheDirPath;
- }
- Log.d(TAG, "sExternalSdCardPath=" + sExternalSdCardPath);
- return sExternalSdCardPath;
- }
- private static boolean hasExternalStoragePermission(Context context) {
- int perm = context.checkCallingOrSelfPermission(EXTERNAL_STORAGE_PERMISSION);
- return perm == PackageManager.PERMISSION_GRANTED;
- }
-
- public static String getDeviceType(Context context) {
- String phoneString = Build.MODEL;
- return phoneString;
- }
-
- public static String getSystemVersionRelease() {
- String systemVersion = Build.VERSION.RELEASE;
- return systemVersion;
- }
-
- public static String getLocalMacAddress(Context context) {
- if (context == null) {
- return null;
- }
- //1.9.2 bigfix NullPointerException 防止由于某些系统getSystemService不稳定导致activityManager为null情况
- try {
- WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- WifiInfo info = wifi.getConnectionInfo();
- return info.getMacAddress();
- }catch (RuntimeException e) {
- Log.e(TAG, e.getMessage());
- }
- return null;
- }
-
- public static String getIMSI(Context context) {
- if(context == null){
- return null;
- }
- if(TextUtils.isEmpty(imsi)) {
- TelephonyManager mTelephonyMgr = (TelephonyManager) context
- .getSystemService(Context.TELEPHONY_SERVICE);
- try { //Android 6.0异常捕获
- imsi = mTelephonyMgr.getSubscriberId();
- }catch (SecurityException e){
- Log.e(TAG,e.getMessage());
- }
- }
- return imsi;
- }
-
-
-
- public static String getIMEI(Context context) {
- if (context == null) {
- return null;
- }
- if(TextUtils.isEmpty(imei)) {
- TelephonyManager tm = (TelephonyManager) context
- .getSystemService(Context.TELEPHONY_SERVICE);
- try { //Android 6.0异常捕获
- imei = tm.getDeviceId();
- }catch (SecurityException e){
- Log.e(TAG,e.getMessage());
- }
- }
- return imei;
- }
- /**
- * 获得外部sdcard存储位置
- *
- * @return
- * @author tiandp 2015-5-28
- */
- public static List getExtSDCardPaths() {
- List paths = new ArrayList();
- String extFileStatus = Environment.getExternalStorageState();
- File extFile = Environment.getExternalStorageDirectory();
- if (extFileStatus.endsWith(Environment.MEDIA_UNMOUNTED) && extFile.exists()
- && extFile.isDirectory() && extFile.canWrite()) {
- paths.add(extFile.getAbsolutePath());
- }
- try {
- // obtain executed result of command line code of 'mount', to judge
- // whether tfCard exists by the result
- Runtime runtime = Runtime.getRuntime();
- Process process = runtime.exec("mount");
- InputStream is = process.getInputStream();
- InputStreamReader isr = new InputStreamReader(is);
- BufferedReader br = new BufferedReader(isr);
- String line = null;
- int mountPathIndex = 1;
- while ((line = br.readLine()) != null) {
- // format of sdcard file system: vfat/fuse
- if ((!line.contains("fat") && !line.contains("fuse") && !line.contains("storage"))
- || line.contains("secure") || line.contains("asec")
- || line.contains("firmware") || line.contains("shell")
- || line.contains("obb") || line.contains("legacy") || line.contains("data")) {
- continue;
- }
- String[] parts = line.split(" ");
- int length = parts.length;
- if (mountPathIndex >= length) {
- continue;
- }
- String mountPath = parts[mountPathIndex];
- if (!mountPath.contains("/") || mountPath.contains("data")
- || mountPath.contains("Data")) {
- continue;
- }
- File mountRoot = new File(mountPath);
- if (!mountRoot.exists() || !mountRoot.isDirectory() || !mountRoot.canWrite()) {
- continue;
- }
- boolean equalsToPrimarySD = mountPath.equals(extFile.getAbsolutePath());
- if (equalsToPrimarySD) {
- continue;
- }
- paths.add(mountPath);
- }
- } catch (IOException e) {
- Log.e(TAG, "IOException:" + e.getMessage());
- }
- return paths;
- }
- public static String getExSdCardPath() {
- if("".equals(exSdCardPath)){
- ArrayList paths = (ArrayList) getExtSDCardPaths();
- if (paths.size() != 0) {
- exSdCardPath = paths.get(0) + "/";
- }else{
- exSdCardPath = null;
- }
- }
-
- return exSdCardPath;
- }
- /****************************** pushconfig *********************************************/
- /**
- * 分辨率
- *
- * @param
- * @param
- * @return
- * @exception/throws
- * @see
- */
- public static Point getScreenPixed(Context context) {
- if (context == null) return null;
- if (displayMetrics == null){
- displayMetrics = context.getResources().getDisplayMetrics();
- }
- Point point = new Point();
-
- point.x = displayMetrics.widthPixels;
- point.y = displayMetrics.heightPixels;
- return point;
- }
-
- public static String getCpuInfno() {
- String arch = "";// cpu类型
- try {
- Class> clazz = Class.forName("android.os.SystemProperties");
- Method get = clazz.getDeclaredMethod("get", new Class[]{
- String.class
- });
- arch = (String) get.invoke(clazz, new Object[]{
- "ro.product.cpu.abi"
- });
- } catch (Exception e) {
- Log.e(TAG,e.getMessage());
- }
- return arch;
- }
-
- public static long getFreeMemory(Context context) {
-
- // 获取android当前可用内存大小
- long fm = 0;
- try {
- ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
- am.getMemoryInfo(mi);
- fm = mi.availMem/(1024*1024);
- } catch (Exception e) {
-
- }
-
- return fm;
- }
-
- public static String getSmsNo(Context context) {
- //获取手机号码
-
- String tel = null;
- try {
- TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
- tel = tm.getLine1Number();//获取本机号码
- } catch (Exception e) {
-
- }
- return tel;
- }
-}
diff --git a/library/src/main/java/com/dalimao/library/util/FloatUtil.java b/library/src/main/java/com/dalimao/library/util/FloatUtil.java
deleted file mode 100644
index cce58a132cefa08dfb77299e26a6defd5f9ad3d9..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/util/FloatUtil.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.dalimao.library.util;
-
-import android.content.Context;
-import android.graphics.Point;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.View;
-import android.view.WindowManager;
-
-import com.dalimao.library.CommonWindowWrapper;
-import com.dalimao.library.StandOutLayoutParams;
-import com.dalimao.library.StandOutWindowManager;
-import com.dalimao.library.Window;
-import com.dalimao.library.WindowWrapper;
-
-/**
- * Created by liuguangli on 16/10/21.
- */
-public class FloatUtil {
-
- private static final String TAG = "FloatUtil";
-
- /**
- * 显示浮窗,默认对齐方式:左上,默认浮窗层级:TYPE_PHONE,需要权限:SYSTEM_ALERT_WINDOW。
- * @param view
- * @param args 传递的参数,可以为 null
- */
-
- public static void showFloatView(View view, Bundle args){
-
- StandOutWindowManager.getInstance(view.getContext()).showView(view, args);
- }
-
-
-
- /**
- * 显示浮窗,默认浮窗层级:TYPE_PHONE,需要权限:SYSTEM_ALERT_WINDOW。
- * @param view
- * @param gravity 对齐方式
- * @param args 传递的参数,可以为 null
- */
-
- public static void showFloatView(View view, int gravity, Bundle args){
-
- StandOutWindowManager.getInstance(view.getContext()).showView(view, args , gravity);
- }
-
- /**
- * 显示浮窗。
- * @param view
- * @param gravity 对齐方式
- * @param type 浮窗层级
- * @param args 传递的参数,可以为 null
- */
-
- public static void showFloatView(View view,int gravity, int type, Bundle args) {
- StandOutWindowManager.getInstance(view.getContext()).showView(view, args , gravity , type);
- }
-
- /**
- * 显示浮窗,对齐方式
- * @param view
- * @param type 浮窗层级
- * @param point 坐标点
- * @param args
- */
-
- public static void showFloatView(View view, int gravity, int type, Point point, Bundle args) {
- showFloatView(view, gravity, type, point, args, false);
- }
-
- /**
- *
- * @param view
- * @param gravity
- * @param type
- * @param point
- * @param args
- * @param drag 是否可拖动
- */
-
- public static void showFloatView(View view, int gravity,int type, Point point, Bundle args , boolean drag) {
- StandOutWindowManager.getInstance(view.getContext()).showView(view, args , gravity , type, point , drag);
- }
- /**
- * 智能浮窗:更加系统版本、机型自动选择浮窗类型(type),绕过权限的限制
- * @param view
- * @param gravity
- * @param point
- * @param args
- */
-
- public static void showSmartFloat(View view, int gravity, Point point, Bundle args) {
-
-
- showSmartFloat(view, gravity, point, args, false);
- }
-
- /**
- *
- * @param view
- * @param gravity
- * @param point
- * @param args
- * @param drag
- */
-
- public static void showSmartFloat(View view, int gravity, Point point, Bundle args, boolean drag) {
- int type = SmartFloatUtil.askType(view.getContext());
- Log.d(TAG, "showSmartFloat:type=" + type);
- StandOutWindowManager.getInstance(view.getContext()).showView(view, args , gravity , type, point, drag);
- }
- /**
- *
- * @param context
- * @param cls
- * @param cache 是否缓存
- */
-
-
-
- public static void hideFloatView(Context context , Class extends View> cls, boolean cache) {
- StandOutWindowManager.getInstance(context).hideView(cls, cache);
- }
-
-
-}
diff --git a/library/src/main/java/com/dalimao/library/util/LogUtil.java b/library/src/main/java/com/dalimao/library/util/LogUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..a03fe6bbca1a4a845e0061933080e872e7bb8ac6
--- /dev/null
+++ b/library/src/main/java/com/dalimao/library/util/LogUtil.java
@@ -0,0 +1,87 @@
+/*
+ * 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 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.dalimao.library.util;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * LogUtil工具类
+ *
+ * @author xjh
+ * @since 2021-03-24
+ */
+public final class LogUtil {
+ private static final int DOMAIN = 0x001;
+
+ private LogUtil() {
+ }
+
+ /** 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/library/src/main/java/com/dalimao/library/util/NumberUtil.java b/library/src/main/java/com/dalimao/library/util/NumberUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..d611c5dc78c1fbbadbeefeefaad507cf00926c57
--- /dev/null
+++ b/library/src/main/java/com/dalimao/library/util/NumberUtil.java
@@ -0,0 +1,173 @@
+/*
+ * 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 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.dalimao.library.util;
+
+/**
+ * 算法工具类
+ *
+ * @since 2021-04-08
+ */
+public class NumberUtil {
+ /**
+ * 默认除法运算精度
+ */
+ private static final int DEF_DIV_SCALE = 16;
+
+ private NumberUtil() {
+ }
+
+ /**
+ * 提供精确的加法运算。
+ *
+ * @param v1 被加数
+ * @param v2 加数
+ * @return 两个参数的和
+ */
+ public static double add(double v1, double v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.add(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的加法运算。
+ *
+ * @param v1 被加数
+ * @param v2 加数
+ * @return 两个参数的和
+ */
+ public static double add(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.add(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的减法运算。
+ *
+ * @param v1 被减数
+ * @param v2 减数
+ * @return 两个参数的差
+ */
+ public static double sub(double v1, double v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.subtract(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的减法运算。
+ *
+ * @param v1 被减数
+ * @param v2 减数
+ * @return 两个参数的差
+ */
+ public static double sub(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.subtract(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的乘法运算。
+ *
+ * @param v1 被乘数
+ * @param v2 乘数
+ * @return 两个参数的积
+ */
+ public static double mul(double v1, double v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.multiply(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的乘法运算。
+ *
+ * @param v1 被乘数
+ * @param v2 乘数
+ * @return 两个参数的积
+ */
+ public static double mul(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.multiply(b2).doubleValue();
+ }
+
+ /**
+ * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
+ *
+ * @param v1 被除数
+ * @param v2 除数
+ * @return 两个参数的商
+ */
+ public static double div(double v1, double v2) {
+ return div(v1, v2, DEF_DIV_SCALE);
+ }
+
+ /**
+ * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
+ *
+ * @param v1 被除数
+ * @param v2 除数
+ * @return 两个参数的商
+ */
+ public static double div(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.divide(b2, DEF_DIV_SCALE, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ /**
+ * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
+ *
+ * @param v1 被除数
+ * @param v2 除数
+ * @param scale 表示表示需要精确到小数点以后几位。
+ * @return 两个参数的商
+ */
+ public static double div(double v1, double v2, int scale) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.divide(b2, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ /**
+ * 提供精确的小数位四舍五入处理。
+ *
+ * @param value 需要四舍五入的数字
+ * @param scale 小数点后保留几位
+ * @return 四舍五入后的结果
+ */
+ public static double round(double value, int scale) {
+ java.math.BigDecimal bigDecimal = new java.math.BigDecimal(Double.toString(value));
+ java.math.BigDecimal one = new java.math.BigDecimal("1");
+ return bigDecimal.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ /**
+ * 提供精确的小数位四舍五入处理。
+ *
+ * @param value 需要四舍五入的数字
+ * @param scale 小数点后保留几位
+ * @return 四舍五入后的结果
+ */
+ public static double round(String value, int scale) {
+ java.math.BigDecimal bigDecimal = new java.math.BigDecimal(value);
+ java.math.BigDecimal one = new java.math.BigDecimal("1");
+ return bigDecimal.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+}
diff --git a/library/src/main/java/com/dalimao/library/util/SmartFloatUtil.java b/library/src/main/java/com/dalimao/library/util/SmartFloatUtil.java
deleted file mode 100644
index a549343cf260a77d4491d1963cedf283578b8bb0..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/util/SmartFloatUtil.java
+++ /dev/null
@@ -1,166 +0,0 @@
-
-package com.dalimao.library.util;
-
-
-import android.app.AppOpsManager;
-
-import android.content.Context;
-
-import android.os.Binder;
-
-
-import android.util.Log;
-import android.view.WindowManager;
-
-
-
-
-import java.lang.reflect.Method;
-
-/**
- * 浮窗入口判断相关逻辑
- * Created by liuguangli on 16/3/2.
- */
-public class SmartFloatUtil {
- private static final String TAG = "FloatWinEnter";
- public static final int HAS_AUTHOR= 1;
- private static final int NOT_AUTHOR = 2;
- private static final int NOT_SUPPORT_AUTHOR = 3;
- private static final String[] INPUT_METHOD_SPECIAL_MODELS = {"SAMSUNG"};;
- private static Integer[] specialVersions;
- public static final String SPECIAL_MODELS[] = {
- "MI",
- "XIAOMI",
- "HUAWEI",
- "OPPO",
- };
- /**
- * 判断当前是否特殊机型
- * @return
- */
- public static boolean isSpecialDevice(){
- String specialDevices[] = getSpecialDevices();
- String currentDevice = DeviceInfoUtil.getBuildModel();
- if (currentDevice == null){
- return false;
- }
- currentDevice = currentDevice.toUpperCase();
- for (String d:specialDevices){
- if (currentDevice.contains(d)){
- return true;
- }
- }
- return false;
- }
-
- private static String[] getSpecialDevices() {
- return SPECIAL_MODELS;
- }
-
- /**
- * 判断是否是特殊版本(14~17)
- * @return
- */
- public static boolean isSpecialVersion() {
- int systemVersion = DeviceInfoUtil.getSystemVersion();
-
- return systemVersion >= 14 && systemVersion <= 18;
- }
-
- /**
- * 判断是否开启浮窗权限
- * @return
- */
- public static int hasAuthorFloatWin(Context context){
-
- if (DeviceInfoUtil.getSystemVersion() < 19){
- return NOT_SUPPORT_AUTHOR;
- }
- try {
- AppOpsManager appOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
- Class c = appOps.getClass();
- Class[] cArg = new Class[3];
- cArg[0] = int.class;
- cArg[1] = int.class;
- cArg[2] = String.class;
- Method lMethod = c.getDeclaredMethod("checkOp", cArg);
- if (AppOpsManager.MODE_ALLOWED == (Integer) lMethod.invoke(appOps, 24, Binder.getCallingUid(), context.getPackageName())){
- return HAS_AUTHOR;
- } else {
- return NOT_AUTHOR;
- }
-
- } catch(Exception e) {
- return NOT_SUPPORT_AUTHOR;
- }
-
- }
-
-
-
-
- /**
- * 交易猫启动游戏浮窗启动(包含探测流程)
- * @param context
- *
- */
- public static int askType(final Context context){
- Log.d(TAG, "SharedStaticField.HOST_VISIBLE = false;");
- int winType = WindowManager.LayoutParams.TYPE_TOAST;
- if (isSpecialVersion()){
- //Android 4.4 以下,google api 来看这个时候还没有对SYSTEM_PHONE类型的浮窗进行权限管理,使用 TYPE_PHONE
- winType = WindowManager.LayoutParams.TYPE_PHONE;
-
- } else {
-
- /**
- * Android 4.4 以上,有的厂商开始对SYSTEM_PHONE进行权限控制.
- * 好在Android 4.4 可以使用TOAST类型浮窗实现绕过权限,但是TOAST类型浮窗无法定位输入法,只能全屏幕显示输入法.
- * 方案:对特殊机型进行SYSTEM_PHONE权限检查,若已经授权使用SYSTEM_PHONE,若未授权使用TOAST类型浮窗
- */
-
- if ((isSpecialDevice() && hasAuthorFloatWin(context) == HAS_AUTHOR)){
- winType = WindowManager.LayoutParams.TYPE_PHONE;
-
- } else if (isSpecialDevice() && hasAuthorFloatWin(context) != HAS_AUTHOR){
- //特殊继续未授权
- winType = WindowManager.LayoutParams.TYPE_TOAST;
- } else if (isInputMethodSpecialDevice()) {
- //这种机型的Toast压根不支持输入法了,必须使用TYPE_PHONE
- Log.e(TAG, "注意浮窗对输入法支持不友好");
- winType = WindowManager.LayoutParams.TYPE_TOAST;
-
- }
- Log.d(TAG, "启动"+winType+"方式的浮窗");
-
- }
- return winType;
- }
-
-
-
-
-
-
- private static boolean isInputMethodSpecialDevice() {
- String specials[] = INPUT_METHOD_SPECIAL_MODELS;
- String currentDevice = DeviceInfoUtil.getBuildModel();
- if (currentDevice != null){
- currentDevice = currentDevice.toUpperCase();
- }
- for (String dev: specials){
- if (currentDevice.contains(dev)){
- return true;
- }
- }
- return false;
- }
-
-
-
-
-
-
-
-
-}
diff --git a/library/src/main/java/com/dalimao/library/util/TypeFlag.java b/library/src/main/java/com/dalimao/library/util/TypeFlag.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2d3ae60af3ab72e87b1c6ec29945ec8f60173f9
--- /dev/null
+++ b/library/src/main/java/com/dalimao/library/util/TypeFlag.java
@@ -0,0 +1,32 @@
+/*
+ * 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 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.dalimao.library.util;
+
+/**
+ * window显示的层级
+ *
+ * @since 2021-06-30
+ */
+public enum TypeFlag {
+ /**
+ * 应用内窗体
+ */
+ MOD_APPLICATION_MEDIA,
+ /**
+ * 应用外窗体
+ */
+ MOD_APP_OVERLAY
+}
diff --git a/library/src/main/java/com/dalimao/library/util/Utils.java b/library/src/main/java/com/dalimao/library/util/Utils.java
deleted file mode 100644
index e30bb3019aa81daaf23942c74356789919761d5e..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/dalimao/library/util/Utils.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.dalimao.library.util;
-
-import android.content.Context;
-
-public class Utils {
- private static float mDensity = -1;
-
- public static boolean isSet(int flags, int flag) {
- return (flags & flag) == flag;
- }
-
- public static int dp2px(Context context, float dpValue) {
- float scale = getScreenDensity(context);
- return (int) (dpValue * scale + 0.5f);
- }
-
- public static float getScreenDensity(Context context) {
- if (mDensity == -1) {
- mDensity = context.getResources().getDisplayMetrics().density;
- }
- return mDensity;
- }
-}
diff --git a/library/src/main/java/com/dalimao/library/util/WindowInfo.java b/library/src/main/java/com/dalimao/library/util/WindowInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..85f48709cf1ba323c3c1c7a96238b0e6d8c135e7
--- /dev/null
+++ b/library/src/main/java/com/dalimao/library/util/WindowInfo.java
@@ -0,0 +1,45 @@
+/*
+ * 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 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.dalimao.library.util;
+
+import ohos.agp.window.service.Window;
+
+/**
+ * WindowInfo
+ *
+ * @since 2021-06-30
+ */
+public class WindowInfo {
+ private String className;
+
+ private Window window;
+
+ public Window getWindow() {
+ return window;
+ }
+
+ public void setWindow(Window window) {
+ this.window = window;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+}
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
deleted file mode 100644
index 6d5185635a623090a0a12f580fa101b4acbfbc92..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Library
-
diff --git a/library/src/main/resources/base/element/string.json b/library/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..211a936b6a562815c346636393376e8f1a72a08e
--- /dev/null
+++ b/library/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "library_library",
+ "value": "library_library"
+ }
+ ]
+}
diff --git a/library/src/test/java/com/dalimao/floateutil/ExampleTest.java b/library/src/test/java/com/dalimao/floateutil/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..fb673fb1228dd38cac0041d59c8ef60776a57a54
--- /dev/null
+++ b/library/src/test/java/com/dalimao/floateutil/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.dalimao.floateutil;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/library/src/test/java/com/dalimao/library/ExampleUnitTest.java b/library/src/test/java/com/dalimao/library/ExampleUnitTest.java
deleted file mode 100644
index 37711a130bb15c83f4b2b0c56044fd8151721ae2..0000000000000000000000000000000000000000
--- a/library/src/test/java/com/dalimao/library/ExampleUnitTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.dalimao.library;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 303092a2b7bf6a22cb460944c16b9d93827f7444..87cd12d9bee6039db8942628c8cf21ed46c91bd6 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':simple', ':library'
+include ':entry',':library'
diff --git a/simple/build.gradle b/simple/build.gradle
deleted file mode 100644
index b98a1f6fc860506eed5faca0a75b0c0cb02f37a0..0000000000000000000000000000000000000000
--- a/simple/build.gradle
+++ /dev/null
@@ -1,28 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
-
- defaultConfig {
- applicationId "com.dalimao.floateutil"
- minSdkVersion 15
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.2.1'
- //compile project(":library");
- compile 'com.github.liuguangli:FloatUtil:-SNAPSHOT'
-}
diff --git a/simple/proguard-rules.pro b/simple/proguard-rules.pro
deleted file mode 100644
index cddfa279f7a5baf52a5295e890af94855594baf4..0000000000000000000000000000000000000000
--- a/simple/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/liuguangli/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/simple/src/androidTest/java/com/dalimao/floateutil/ApplicationTest.java b/simple/src/androidTest/java/com/dalimao/floateutil/ApplicationTest.java
deleted file mode 100644
index 18efbfa3da27a7d71abc66ca604268500828e6c1..0000000000000000000000000000000000000000
--- a/simple/src/androidTest/java/com/dalimao/floateutil/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.dalimao.floateutil;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/simple/src/main/AndroidManifest.xml b/simple/src/main/AndroidManifest.xml
deleted file mode 100644
index ce09ec66baf70e9df7ec54c26228fb8e6012cebd..0000000000000000000000000000000000000000
--- a/simple/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/simple/src/main/java/com/dalimao/floateutil/FloatBallView.java b/simple/src/main/java/com/dalimao/floateutil/FloatBallView.java
deleted file mode 100644
index 8a03b21c383e0730d03b5bc86af37fc7cfbcf45b..0000000000000000000000000000000000000000
--- a/simple/src/main/java/com/dalimao/floateutil/FloatBallView.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.dalimao.floateutil;
-import android.content.Context;
-import android.view.LayoutInflater;
-import com.dalimao.library.DragView;
-
-
-
-public class FloatBallView extends DragView {
-
-
-
-
- public FloatBallView(Context context) {
-
- super(context);
-
- LayoutInflater.from(context).inflate(R.layout.float_small_drag_ball, this);
- }
-
-
-}
diff --git a/simple/src/main/java/com/dalimao/floateutil/MainActivity.java b/simple/src/main/java/com/dalimao/floateutil/MainActivity.java
deleted file mode 100644
index 189698033737f4dc3679e43205f16a3bd7c48633..0000000000000000000000000000000000000000
--- a/simple/src/main/java/com/dalimao/floateutil/MainActivity.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package com.dalimao.floateutil;
-
-import android.graphics.Point;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.View;
-import android.view.WindowManager;
-
-import com.dalimao.library.util.FloatUtil;
-
-public class MainActivity extends AppCompatActivity {
-
- private static final String TAG = "MainActivity";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_main);
-
- }
-
- /**
- * 添加一个浮窗
- * @param view
- */
- public void addSimpleView(View view) {
-
- SimpleView floatView = new SimpleView(this);
- FloatUtil.showFloatView(floatView, null);
- floatView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, SimpleView.class, false);
- Log.d(TAG, "close");
- }
- });
- }
-
- /**
- * 添加一个浮窗并向浮窗传参
- * @param view
- */
-
- public void addSimpleViewWithParam(View view) {
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- Bundle bundle = new Bundle();
- bundle.putString(SimpleViewWitchParam.PARAM, "我是传过来的参数");
- FloatUtil.showFloatView(floatView, bundle);
- floatView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, SimpleViewWitchParam.class, false);
- Log.d(TAG, "close");
- }
- });
- }
-
-
- /**
- * 添加一个浮窗并向浮窗传参, 指定浮窗齐方式
- * @param view
- */
-
- public void addSimpleViewWithGravity(View view) {
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- Bundle bundle = new Bundle();
- bundle.putString(SimpleViewWitchParam.PARAM, "我是传过来的参数");
- bundle.putString(SimpleViewWitchParam.CONTENT,getString(R.string.add_simple_view_with_gravity));
- FloatUtil.showFloatView(floatView, Gravity.CENTER, bundle);
- floatView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, SimpleViewWitchParam.class, false);
- Log.d(TAG, "close");
- }
- });
- }
- /**
- * 添加一个浮窗并向浮窗传参, 指定浮窗齐方式, 指定显示层级
- * @param view
- */
-
- public void addSimpleViewWithType(View view) {
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- Bundle bundle = new Bundle();
- bundle.putString(SimpleViewWitchParam.PARAM, "我是传过来的参数");
- bundle.putString(SimpleViewWitchParam.CONTENT,getString(R.string.add_simple_view_with_type));
- FloatUtil.showFloatView(floatView, Gravity.CENTER,WindowManager.LayoutParams.TYPE_TOAST , bundle);
- floatView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, SimpleViewWitchParam.class, false);
- Log.d(TAG, "close");
- }
- });
- }
-
- /**
- * 添加一个浮窗并向浮窗传参, 指定浮窗齐方式, 指定显示层级, 指定坐标
- * @param view
- */
-
- public void addSimpleViewWithPoint(View view) {
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- Bundle bundle = new Bundle();
- bundle.putString(SimpleViewWitchParam.PARAM, "我是传过来的参数");
- bundle.putString(SimpleViewWitchParam.CONTENT,getString(R.string.add_simple_view_with_point));
- Point point = new Point();
- point.x = 100;
- point.y = 300;
- FloatUtil.showFloatView(floatView, Gravity.TOP, WindowManager.LayoutParams.TYPE_TOAST, point, bundle);
- floatView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, SimpleViewWitchParam.class, false);
- Log.d(TAG, "close");
- }
- });
- }
-
- /**
- * 添加智能浮窗,智能的意思是自动根据当前系统版本和机型选择何时的 type ,绕过系统权限限制使用浮窗
- * @param view
- */
-
- public void addSimpleSmartFloatView(View view) {
- SimpleViewWitchParam floatView = new SimpleViewWitchParam(this);
- Bundle bundle = new Bundle();
- bundle.putString(SimpleViewWitchParam.PARAM, "智能浮窗");
- bundle.putString(SimpleViewWitchParam.CONTENT,getString(R.string.add_simple_view_with_smart));
- Point point = new Point();
- point.x = 0;
- point.y = 0;
- FloatUtil.showSmartFloat(floatView, Gravity.CENTER, point, bundle);
- floatView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, SimpleViewWitchParam.class, false);
- Log.d(TAG, "close");
- }
- });
- }
-
- /**
- * 添加一个可以拖动的View
- *
- * @param view
- */
-
- public void addDragView(View view) {
- FloatBallView floatBallView = new FloatBallView(this);
- FloatUtil.showFloatView(floatBallView, Gravity.LEFT | Gravity.TOP, WindowManager.LayoutParams.TYPE_TOAST,new Point(0,0), null, true);
-
- SimpleViewWitchParam simpleView = new SimpleViewWitchParam(this);
- FloatUtil.showSmartFloat(simpleView, Gravity.LEFT | Gravity.TOP, new Point(0,0), null, true);
- floatBallView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, FloatBallView.class, false);
- Log.d(TAG, "onClick");
- }
- });
- simpleView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FloatUtil.hideFloatView(MainActivity.this, SimpleViewWitchParam.class, false);
- Log.d(TAG, "close");
- }
- });
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- FloatUtil.hideFloatView(this, FloatBallView.class, false);
- }
-}
diff --git a/simple/src/main/java/com/dalimao/floateutil/SimpleView.java b/simple/src/main/java/com/dalimao/floateutil/SimpleView.java
deleted file mode 100644
index fed39dfe6a9b264f94862ef8a23a6ad53b9eb403..0000000000000000000000000000000000000000
--- a/simple/src/main/java/com/dalimao/floateutil/SimpleView.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.dalimao.floateutil;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.widget.FrameLayout;
-
-import com.dalimao.library.DragView;
-
-/**
- * Created by liuguangli on 16/10/25.
- */
-
-public class SimpleView extends DragView {
- public SimpleView(Context context) {
- super(context);
- LayoutInflater.from(context).inflate(R.layout.float_simple, this);
- }
-
-}
diff --git a/simple/src/main/java/com/dalimao/floateutil/SimpleViewWitchParam.java b/simple/src/main/java/com/dalimao/floateutil/SimpleViewWitchParam.java
deleted file mode 100644
index 8d83b944719988cdf6aa88eb93585715649eb07b..0000000000000000000000000000000000000000
--- a/simple/src/main/java/com/dalimao/floateutil/SimpleViewWitchParam.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.dalimao.floateutil;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import com.dalimao.library.ParamReceiver;
-
-/**
- * Created by liuguangli on 16/10/25.
- */
-
-public class SimpleViewWitchParam extends FrameLayout implements ParamReceiver {
- public static final java.lang.String PARAM = "PARAM";
- public static final String CONTENT = "content";
-
- public SimpleViewWitchParam(Context context) {
- super(context);
- LayoutInflater.from(context).inflate(R.layout.float_simple_witch_param, this);
- }
-
- @Override
- public void onParamReceive(Bundle bundle) {
- if (bundle != null) {
- String param = bundle.getString(PARAM);
- TextView textView = (TextView) findViewById(R.id.tv_param);
- textView.setText(param);
-
- String content = bundle.getString(CONTENT);
- if (!TextUtils.isEmpty(content)) {
- TextView tvContent = (TextView) findViewById(R.id.tv_content);
- tvContent.setText(content);
- }
- }
- }
-}
diff --git a/simple/src/main/res/drawable/shape_ball.xml b/simple/src/main/res/drawable/shape_ball.xml
deleted file mode 100644
index 30d623518ad390f7b08b195acb49a00a3a03e9fc..0000000000000000000000000000000000000000
--- a/simple/src/main/res/drawable/shape_ball.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/simple/src/main/res/layout/activity_main.xml b/simple/src/main/res/layout/activity_main.xml
deleted file mode 100644
index 0446b730b0a46bc08ade730200b9b112011c8fdc..0000000000000000000000000000000000000000
--- a/simple/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/simple/src/main/res/layout/float_simple.xml b/simple/src/main/res/layout/float_simple.xml
deleted file mode 100644
index d287ac05bfbd6c2e16eaf3d712552564cc64ce67..0000000000000000000000000000000000000000
--- a/simple/src/main/res/layout/float_simple.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/simple/src/main/res/layout/float_simple_witch_param.xml b/simple/src/main/res/layout/float_simple_witch_param.xml
deleted file mode 100644
index b7380ac0bdb2e5aa37208e9a9f8ebfefc6ee936d..0000000000000000000000000000000000000000
--- a/simple/src/main/res/layout/float_simple_witch_param.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/simple/src/main/res/layout/float_small_drag_ball.xml b/simple/src/main/res/layout/float_small_drag_ball.xml
deleted file mode 100644
index a349a7bde08d5b21ff35b299eecd6132d2816e6e..0000000000000000000000000000000000000000
--- a/simple/src/main/res/layout/float_small_drag_ball.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/simple/src/main/res/mipmap-hdpi/ic_launcher.png b/simple/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/simple/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/simple/src/main/res/mipmap-mdpi/ic_launcher.png b/simple/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/simple/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/simple/src/main/res/mipmap-xhdpi/ic_launcher.png b/simple/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/simple/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/simple/src/main/res/mipmap-xxhdpi/ic_launcher.png b/simple/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/simple/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/simple/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/simple/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000
Binary files a/simple/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/simple/src/main/res/values-w820dp/dimens.xml b/simple/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/simple/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/simple/src/main/res/values/colors.xml b/simple/src/main/res/values/colors.xml
deleted file mode 100644
index 90781a8edd537ce972382abeb78d2e3247d13796..0000000000000000000000000000000000000000
--- a/simple/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
- #ffffff
-
diff --git a/simple/src/main/res/values/dimens.xml b/simple/src/main/res/values/dimens.xml
deleted file mode 100644
index 47c82246738c4d056e8030d3a259206f42e8e15d..0000000000000000000000000000000000000000
--- a/simple/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 16dp
- 16dp
-
diff --git a/simple/src/main/res/values/strings.xml b/simple/src/main/res/values/strings.xml
deleted file mode 100644
index 575cea4bb3218332866e11eec439c7077c09e03b..0000000000000000000000000000000000000000
--- a/simple/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
- FloateUtil
- 显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,showFloatView(View view, null)。
- 显示
- 标题
-
-
- 显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,showFloatView(View view,Bundle bundle)。
-
-
-
- 显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,指定对齐方式为居中对齐,
- FloatUtil.showFloatView(floatView, Gravity.CENTER, bundle);。
-
-
-
- 显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,指定对齐方式为居中对齐,指定浮窗层级为 WindowManager.LayoutParams.TYPE_TOAST,
- FloatUtil.showFloatView(floatView, Gravity.CENTER, WindowManager.LayoutParams.TYPE_PHONE, bundle);。
-
- 参数:
-
- 显示一个简单的浮窗,默认使用 TYPE_PHONE 类型浮窗,传递一个 Bundle 参数 ,指定对齐方式为居中对齐,指定浮窗层级为 WindowManager.LayoutParams.TYPE_TOAST,
- 指定坐标 point(x,y)
- FloatUtil.showFloatView(floatView, Gravity.CENTER, WindowManager.LayoutParams.TYPE_TOAST, point, bundle);。
- 添加智能浮窗,智能的意思是自动根据当前系统版本和机型选择何时的 type ,绕过系统权限限制使用浮窗
- 添加一个可拖动的浮窗,拖动的方法在自定义的 View 中实现
-
diff --git a/simple/src/main/res/values/styles.xml b/simple/src/main/res/values/styles.xml
deleted file mode 100644
index 5885930df6d10edf3d6df40d6556297d11f953da..0000000000000000000000000000000000000000
--- a/simple/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
diff --git a/simple/src/test/java/com/dalimao/floateutil/ExampleUnitTest.java b/simple/src/test/java/com/dalimao/floateutil/ExampleUnitTest.java
deleted file mode 100644
index 6a452557f33641b9263a9c6b749a2a7a1d43c86a..0000000000000000000000000000000000000000
--- a/simple/src/test/java/com/dalimao/floateutil/ExampleUnitTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.dalimao.floateutil;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file