diff --git a/.gitignore b/.gitignore index 2a1e58f39ad0f8fe70636ab3ccafbc9f3f4b3847..37a4eb8b43d978ea05b2c6e3fb934f9b40dddd4d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ /build /captures .externalNativeBuild - +/entry/.preview +.cxx diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml new file mode 100644 index 0000000000000000000000000000000000000000..20791dc4d8bbe175d0c8bfdde766da48a040cf20 --- /dev/null +++ b/.idea/checkstyle-idea.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000000000000000000000000000000000000..61a9130cd9669c3843e6445dfe1fee2d493869bc --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000000000000000000000000000000000000..ec729767304fbf173633c94a92cf236cfb222ecb --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000000000000000000000000000000000000..19e238eaa31f512cfc1e8641964227098d1eb8bb --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..8a14290d011eafeb38e9abc5abac47df163a6d4f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml new file mode 100644 index 0000000000000000000000000000000000000000..92ffb0b6f88b0dfdb74bf38ec1bc95b7abbfcf77 --- /dev/null +++ b/.idea/qaplug_profiles.xml @@ -0,0 +1,465 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..bcd6398ab09eb57ce347dba68de3dd1d172fadb3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1-SNAPSHOT +ohos第一个版本 +*实现了原库的全部功能 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..3670e5117d9aecc0af60013b724d9dc1cc3b8b54 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,14 @@ + + Copyright 2016 Hitomis, Inc. + + 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. \ No newline at end of file diff --git a/README.OPENSOURCE b/README.OPENSOURCE new file mode 100644 index 0000000000000000000000000000000000000000..c595f09fa18f6816c2e495fccb9643f3fdcd551c --- /dev/null +++ b/README.OPENSOURCE @@ -0,0 +1,10 @@ +[ + { + "Name": "circlemenu", + "License": " ", + "License File": " LICENSE ", + "Version Number": "V1.1.0", + "Upstream URL": " https://github.com /Hitomis/CircleMenu", + "Description": "CircleMenu 是一个精美别致支持定制的圆形菜单,可以有 0 到 8 个子菜单按钮,按钮背景色,图标都可以修改。CircleMenu 比较适合放在屏幕中间,以得到完好的展现" + } +] diff --git a/README.md b/README.md index 82143263bf716c7c08eb34c02349091b48239bdb..2a5bdc8c60c60c9b817fcf196c49bd219d586cb2 100644 --- a/README.md +++ b/README.md @@ -1,117 +1,102 @@ -# CircleMenu - -[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CircleMenu-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/4631) -[![](https://jitpack.io/v/Hitomis/CircleMenu.svg)](https://jitpack.io/#Hitomis/CircleMenu) - -CircleMenu 是一个精美别致支持定制的圆形菜单,可以有 0 到 8 个子菜单按钮,按钮背景色,图标都可以修改。CircleMenu 比较适合放在屏幕中间,以得到完好的展现。 - -小记:
- - CircleMenu 是在 dribbble 上看到的一个比较有感觉的设计,并不炫酷,但是 UI 很精致,值得推敲的细节比较多。因为没有比较标准的原型图。在还原设计的时候,来来回回修改好多次。到最后也不知道跟原设计有多少差距。不过自己看着还算满意。 - - 该库在实现的时候碰到了许多困难。比如选中子菜单项绘制圆环轨迹路径的时候,使用 PathMeasure 发现 getSegment 方法并不是可以截取任何两个位置之间的 Path(因为要从选中的子菜单按钮的位置开始绘制圆环轨迹路径),思考良久后,使用旋转画布的方法巧妙解决。 - - 又例如,在圆环绘制完成后,圆环会逐渐放大扩散变透明,然后消失的动画。如果这个动画针对的是一个 View 对象,我想使用 ObjectAnimator 可以很快解决。但是现在是在 onDraw 中绘制这一动画效果。最困难的是绘制圆环扩散变透明直至消失这一动画效果。(ps:期间还问过我 QQ 中所有技术群。都说很简单,就是没人说具体,群中绝大部分都是各种灌水,到最后也得不到答案。那时候的感觉很糟糕,感觉再也不相信技术群了,伤心···)最后实现很简单,也是无意中发现 ColorUtils 这个类, ColorUtils 是 Support.v4 中提供的,封装了对 Color 的各种操作。我使用了 ColorUtils.setAlphaComponent(color, alpha) 来操作圆环的颜色的透明度,从而达到一个圆环逐渐消失的效果。 - - 最后谢谢 [Aige](http://blog.csdn.net/aigestudio?viewmode=contents) 和 [GcsSloop](http://www.gcssloop.com/#blog) 两位大神无私奉献。让我能深入学习自定义 View 范畴的知识。让我有能力去完成这个项目。 - - -# Preview - - - - -# Import - -### Gradle - -Step 1. Add the JitPack repository to your build file - - allprojects { - repositories { - ... - maven { url "https://jitpack.io" } - } - } - -Step 2. Add the dependency - - dependencies { - compile 'com.github.Hitomis:CircleMenu:v1.1.0' - } - -### Maven - -Step 1. Add the JitPack repository to your build file - - - - jitpack.io - https://jitpack.io - - - -Step 2. Add the dependency - - - com.github.Hitomis - CircleMenu - v1.1.0 - - -# Usage - -布局文件中: - - - -Activity 中: - - circleMenu = (CircleMenu) findViewById(R.id.circle_menu); - - circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.mipmap.icon_menu, R.mipmap.icon_cancel) - .addSubMenu(Color.parseColor("#258CFF"), R.mipmap.icon_home) - .addSubMenu(Color.parseColor("#30A400"), R.mipmap.icon_search) - .addSubMenu(Color.parseColor("#FF4B32"), R.mipmap.icon_notify) - .addSubMenu(Color.parseColor("#8A39FF"), R.mipmap.icon_setting) - .addSubMenu(Color.parseColor("#FF6A00"), R.mipmap.icon_gps) - .setOnMenuSelectedListener(new OnMenuSelectedListener() { - - @Override - public void onMenuSelected(int index) {} - - }).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() { - - @Override - public void onMenuOpened() {} - - @Override - public void onMenuClosed() {} - - }); - -# Method - -| 方法 | 说明 | -| :--: | :--: | -| setMainMenu | 设置主按钮(打开/关闭)的背景色,以及打开/关闭的图标。图标支持 Resource、Bitmap、Drawable 形式 | -| addSubMenu | 添加一个子菜单项,包括子菜单的背景色以及图标 。图标支持 Resource、Bitmap、Drawable 形式| -| openMenu | 打开菜单 | -| closeMenu | 关闭菜单 | -| isOpened | 菜单是否打开,返回 boolean 值 | -| setOnMenuSelectedListener | 设置选中子菜单项的监听器,回调方法会传递当前点击子菜单项的下标值,从 0 开始计算 | -| setOnMenuStatusChangeListener | 设置 CircleMenu 行为状态监听器,onMenuOpened 为菜单打开后的回调方法,onMenuClosed 为菜单关闭后的回调方法 | - - -# Thanks - - 原型设计来源于 [dribbble](https://dribbble.com/shots/2534780-Circle-Menu-Swift-Open-Source)
- IOS 版本 [Ramotion](https://github.com/Ramotion/circle-menu) - -# Licence +# circlemenu + +#### 项目介绍 +- 项目名称:圆形菜单 +- 所属系列:openharmony的第三方组件适配移植 +- 功能:CircleMenu 是一个精美别致支持定制的圆形菜单,可以有 0 到 8 个子菜单按钮,按钮背景色,图标都可以修改。CircleMenu 比较适合放在屏幕中间,以得到完好的展现 +- 项目移植状态:主功能完成 +- 调用差异:无 +- 开发版本:sdk6,DevEco Studio2.2 Bate1 +- 基线版本:V1.1.0 + +#### 效果演示 + + +#### 安装教程 + +1.在项目根目录下的build.gradle文件中, + ```gradle +allprojects { + repositories { + maven { + url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' + } + } +} + ``` +2.在entry模块的build.gradle文件中, + ```gradle + dependencies { + implementation('com.gitee.chinasoft_ohos:circlemenu:0.0.1-SNAPSHOT') + ...... + } +``` + +在sdk6,DevEco Studio2.2 Bate1下项目可直接运行 +如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, +并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 + +#### 使用说明 + +使用该库非常简单,只需查看提供的示例的源代码。 +```示例XML + +``` + +```java + circleMenu = (CircleMenu) findComponentById(ResourceTable.Id_circle_menu); + circleMenu.setMainMenu(Color.getIntColor("#CDCDCD"), ResourceTable.Graphic_icon_menu, ResourceTable.Graphic_icon_cancel) + .addSubMenu(Color.getIntColor("#258CFF"), ResourceTable.Graphic_icon_home) + .addSubMenu(Color.getIntColor("#30A400"), ResourceTable.Graphic_icon_search) + .addSubMenu(Color.getIntColor("#FF4B32"), ResourceTable.Graphic_icon_notify) + .addSubMenu(Color.getIntColor("#8A39FF"), ResourceTable.Graphic_icon_setting) + .addSubMenu(Color.getIntColor("#FF6A00"),ResourceTable.Graphic_icon_gps) + .setOnMenuSelectedListener(new OnMenuSelectedListener() { + + @Override + public void onMenuSelected(int index) {} + + }).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() { + + @Override + public void onMenuOpened() {} + + @Override + public void onMenuClosed() {} + + }); +``` +```Method + + | 方法 | 说明 | + | :--: | :--: | + | setMainMenu | 设置主按钮(打开/关闭)的背景色,以及打开/关闭的图标。图标支持 Resource、Bitmap、Drawable 形式 | + | addSubMenu | 添加一个子菜单项,包括子菜单的背景色以及图标 。图标支持 Resource、Bitmap、Drawable 形式| + | openMenu | 打开菜单 | + | closeMenu | 关闭菜单 | + | isOpened | 菜单是否打开,返回 boolean 值 | + | setOnMenuSelectedListener | 设置选中子菜单项的监听器,回调方法会传递当前点击子菜单项的下标值,从 0 开始计算 | + | setOnMenuStatusChangeListener | 设置 CircleMenu 行为状态监听器,onMenuOpened 为菜单打开后的回调方法,onMenuClosed 为菜单关闭后的回调方法 | +``` +#### 测试信息 + +CodeCheck代码测试无异常 + +CloudTest代码测试无异常 + +病毒安全检测通过 + +当前版本demo功能与原组件基本无差异 + +#### 版本迭代 + +- 0.0.1-SNAPSHOT + +#### 版权和许可信息 Copyright 2016 Hitomis, Inc. @@ -126,6 +111,3 @@ Activity 中: 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. - - - diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index a0443b7907cad5c5453edf809b6a5203bbe191fc..0000000000000000000000000000000000000000 --- a/app/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 28 - - defaultConfig { - applicationId "com.hitomi.circlemenu" - minSdkVersion 19 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation project(':cmlibrary') -} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index f4e510a7dc97548cf4a41b0a0f0275c147098cf9..0000000000000000000000000000000000000000 --- a/app/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 E:\androidstuido_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/app/src/androidTest/java/com/hitomi/circlemenu/ApplicationTest.java b/app/src/androidTest/java/com/hitomi/circlemenu/ApplicationTest.java deleted file mode 100644 index ce6affda0b6c7b051c7e5f5052afbcedd7ce5966..0000000000000000000000000000000000000000 --- a/app/src/androidTest/java/com/hitomi/circlemenu/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hitomi.circlemenu; - -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/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index d1028eddebaa19ae8851c0c4a73e1a2a34d2c8f9..0000000000000000000000000000000000000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/hitomi/circlemenu/MainActivity.java b/app/src/main/java/com/hitomi/circlemenu/MainActivity.java deleted file mode 100644 index 0d1242563d1f1cf670380d0186c12a485728ab12..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/hitomi/circlemenu/MainActivity.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.hitomi.circlemenu; - -import android.graphics.Color; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.Menu; - -import com.hitomi.cmlibrary.CircleMenu; -import com.hitomi.cmlibrary.OnMenuSelectedListener; -import com.hitomi.cmlibrary.OnMenuStatusChangeListener; - -public class MainActivity extends AppCompatActivity { - - private CircleMenu circleMenu; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - circleMenu = (CircleMenu) findViewById(R.id.circle_menu); - - circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.mipmap.icon_menu, R.mipmap.icon_cancel) - .addSubMenu(Color.parseColor("#258CFF"), R.mipmap.icon_home) - .addSubMenu(Color.parseColor("#30A400"), R.mipmap.icon_search) - .addSubMenu(Color.parseColor("#FF4B32"), R.mipmap.icon_notify) - .addSubMenu(Color.parseColor("#8A39FF"), R.mipmap.icon_setting) - .addSubMenu(Color.parseColor("#FF6A00"), R.mipmap.icon_gps) - .setOnMenuSelectedListener(new OnMenuSelectedListener() { - - @Override - public void onMenuSelected(int index) {} - - }).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() { - - @Override - public void onMenuOpened() {} - - @Override - public void onMenuClosed() {} - - }); - } - - @Override - public boolean onMenuOpened(int featureId, Menu menu) { - circleMenu.openMenu(); - return super.onMenuOpened(featureId, menu); - } - - @Override - public void onBackPressed() { - circleMenu.closeMenu(); - } -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 968e549d5d984cf6632071aac7d38097204c3e67..0000000000000000000000000000000000000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_cancel.png b/app/src/main/res/mipmap-xxhdpi/icon_cancel.png deleted file mode 100644 index c7408069c183126d62719a5c14ba9c82ecc9ae8d..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_cancel.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_gps.png b/app/src/main/res/mipmap-xxhdpi/icon_gps.png deleted file mode 100644 index 7f26d3f1bf8761fa73eb39820e5bde3c85736d6d..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_gps.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_home.png b/app/src/main/res/mipmap-xxhdpi/icon_home.png deleted file mode 100644 index 028e69e508d2752998f882018bed5577666306e4..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_home.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_menu.png b/app/src/main/res/mipmap-xxhdpi/icon_menu.png deleted file mode 100644 index 1a6ca9b4b51a8fef56cdabacae05c1ebd9e6cc03..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_menu.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_notify.png b/app/src/main/res/mipmap-xxhdpi/icon_notify.png deleted file mode 100644 index 38b82e5d6838ad55163e61fc84f060f98beb19b5..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_notify.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_search.png b/app/src/main/res/mipmap-xxhdpi/icon_search.png deleted file mode 100644 index b8a398746de1333ff1bb2479f1ea5934b499d137..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_search.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_setting.png b/app/src/main/res/mipmap-xxhdpi/icon_setting.png deleted file mode 100644 index e3f6651edb8b6f2c7746c5213241acd2e84a8843..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_setting.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml deleted file mode 100644 index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000 --- a/app/src/main/res/values-w820dp/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 64dp - diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml deleted file mode 100644 index 3ab3e9cbce07f7cdc941fc8ba424c05e83ed80f0..0000000000000000000000000000000000000000 --- a/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - #3F51B5 - #303F9F - #FF4081 - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 47c82246738c4d056e8030d3a259206f42e8e15d..0000000000000000000000000000000000000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 16dp - 16dp - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index f8e5ed3a57b2c832e1979355a65fd94fa972539e..0000000000000000000000000000000000000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - CircleMenu - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml deleted file mode 100644 index 5885930df6d10edf3d6df40d6556297d11f953da..0000000000000000000000000000000000000000 --- a/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/app/src/test/java/com/hitomi/circlemenu/ExampleUnitTest.java b/app/src/test/java/com/hitomi/circlemenu/ExampleUnitTest.java deleted file mode 100644 index f43a19f3293202dce2f3782a64c9ea39bc9f601c..0000000000000000000000000000000000000000 --- a/app/src/test/java/com/hitomi/circlemenu/ExampleUnitTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hitomi.circlemenu; - -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/build.gradle b/build.gradle index 62f391e28a093715405dc90038e078e2a49f8be6..053b598314427762ef9ed02bced2d2b234093d42 100644 --- a/build.gradle +++ b/build.gradle @@ -1,26 +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 5 + defaultConfig { + compatibleSdkVersion 4 + } +} + buildscript { repositories { - jcenter() - google() + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' - - // 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() - google() + 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/cmlibrary/build.gradle b/cmlibrary/build.gradle index d4a6921e66a7e0c8af6a2868e7f7e2e97d2973fb..f7ea3bd45c0b32d79061a37223dd31d1ca834345 100644 --- a/cmlibrary/build.gradle +++ b/cmlibrary/build.gradle @@ -1,27 +1,22 @@ -apply plugin: 'com.android.library' -// JitPack Maven -apply plugin: 'com.github.dcendents.android-maven' -// Group -group='com.github.Hitomi' - -android { - compileSdkVersion 28 - +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#section1112183053510 +ohos { + compileSdkVersion 5 defaultConfig { - minSdkVersion 19 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" + compatibleSdkVersion 4 } buildTypes { release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } } } + } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:28.0.0' + testImplementation 'junit:junit:4.13' } diff --git a/cmlibrary/consumer-rules.pro b/cmlibrary/consumer-rules.pro new file mode 100644 index 0000000000000000000000000000000000000000..9dccc613bc71b04b83531f550bdab2fb667ecfc9 --- /dev/null +++ b/cmlibrary/consumer-rules.pro @@ -0,0 +1 @@ +# Add har specific ProGuard rules for consumer here. \ No newline at end of file diff --git a/cmlibrary/proguard-rules.pro b/cmlibrary/proguard-rules.pro index f4e510a7dc97548cf4a41b0a0f0275c147098cf9..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644 --- a/cmlibrary/proguard-rules.pro +++ b/cmlibrary/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 E:\androidstuido_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/cmlibrary/src/main/AndroidManifest.xml b/cmlibrary/src/main/AndroidManifest.xml deleted file mode 100644 index abc4bc06c6b7714e0c13ccc4b522f06cd27c3330..0000000000000000000000000000000000000000 --- a/cmlibrary/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/cmlibrary/src/main/config.json b/cmlibrary/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..e3bb37aaf378f459088796886ebaa1792373b603 --- /dev/null +++ b/cmlibrary/src/main/config.json @@ -0,0 +1,23 @@ +{ + "app": { + "bundleName": "com.hitomi.circlemenu", + "vendor": "hitomi", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": { + }, + "module": { + "package": "com.hitomi.cmlibrary", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "cmlibrary", + "moduleType": "har" + } + } +} \ No newline at end of file diff --git a/cmlibrary/src/main/java/com/hitomi/cmlibrary/CircleMenu.java b/cmlibrary/src/main/java/com/hitomi/cmlibrary/CircleMenu.java index 5a803b48490c3163d9689fd4db2337ba3546e136..6b1e84e69d89fd17bd02d711280e2f9df2a52680 100644 --- a/cmlibrary/src/main/java/com/hitomi/cmlibrary/CircleMenu.java +++ b/cmlibrary/src/main/java/com/hitomi/cmlibrary/CircleMenu.java @@ -1,34 +1,31 @@ package com.hitomi.cmlibrary; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.AnimatorSet; -import android.animation.ValueAnimator; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.PathMeasure; -import android.graphics.RadialGradient; -import android.graphics.RectF; -import android.graphics.Shader; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.support.v4.graphics.ColorUtils; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.view.animation.AnticipateInterpolator; -import android.view.animation.LinearInterpolator; -import android.view.animation.OvershootInterpolator; - +import com.hitomi.cmlibrary.util.ColorConverUtils; +import com.hitomi.cmlibrary.util.Constant; +import ohos.agp.animation.Animator; +import ohos.agp.animation.AnimatorGroup; +import ohos.agp.animation.AnimatorValue; +import ohos.agp.components.AttrSet; +import ohos.agp.components.Component; +import ohos.agp.components.ComponentContainer; +import ohos.agp.components.element.PixelMapElement; +import ohos.agp.components.element.ShapeElement; +import ohos.agp.render.*; +import ohos.agp.utils.Color; +import ohos.agp.utils.Point; +import ohos.agp.utils.RectFloat; +import ohos.agp.window.service.DisplayManager; +import ohos.app.Context; +import ohos.media.image.PixelMap; +import ohos.multimodalinput.event.MmiPoint; +import ohos.multimodalinput.event.TouchEvent; + +import javax.net.ssl.SSLSocket; import java.util.ArrayList; import java.util.List; +import static com.hitomi.cmlibrary.util.Constant.SECOND; + /** * Created by hitomi on 2016/9/28. *

@@ -36,7 +33,7 @@ import java.util.List; *

* email : 196425254@qq.com */ -public class CircleMenu extends View { +public class CircleMenu extends ComponentContainer implements Component.DrawTask, Component.EstimateSizeListener, Component.TouchEventListener { private static final int STATUS_MENU_OPEN = 1; @@ -70,13 +67,13 @@ public class CircleMenu extends View { private int mainMenuColor; - private Drawable openMenuIcon, closeMenuIcon; + private PixelMapElement openMenuIcon, closeMenuIcon; private List subMenuColorList; - private List subMenuDrawableList; + private List subMenuDrawableList; - private List menuRectFList; + private List menuRectFList; private int centerX, centerY; @@ -106,11 +103,11 @@ public class CircleMenu extends View { this(context, null); } - public CircleMenu(Context context, AttributeSet attrs) { - this(context, attrs, 0); + public CircleMenu(Context context, AttrSet attrs) { + this(context, attrs, "0"); } - public CircleMenu(Context context, AttributeSet attrs, int defStyleAttr) { + public CircleMenu(Context context, AttrSet attrs, String defStyleAttr) { super(context, attrs, defStyleAttr); status = STATUS_MENU_CLOSED; init(); @@ -118,79 +115,93 @@ public class CircleMenu extends View { private void init() { initTool(); - - mainMenuColor = Color.parseColor("#CDCDCD"); - - openMenuIcon = new GradientDrawable(); - closeMenuIcon = new GradientDrawable(); - + mainMenuColor = Color.getIntColor("#CDCDCD"); +// openMenuIcon = new PixelMapElement(); +// closeMenuIcon = new PixelMapElement(); subMenuColorList = new ArrayList<>(); subMenuDrawableList = new ArrayList<>(); menuRectFList = new ArrayList<>(); + addDrawTask(this); + setEstimateSizeListener(this::onEstimateSize); + System.out.println("zzm->" + "init"); + setTouchEventListener(this::onTouchEvent); } private void initTool() { - oPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - oPaint.setStyle(Paint.Style.FILL_AND_STROKE); + oPaint = new Paint(); + oPaint.setAntiAlias(true); + oPaint.setStyle(Paint.Style.FILLANDSTROKE_STYLE); + cPaint = new Paint(); + cPaint.setAntiAlias(true); + cPaint.setStyle(Paint.Style.STROKE_STYLE); + cPaint.setStrokeCap(Paint.StrokeCap.ROUND_CAP); - cPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - cPaint.setStyle(Paint.Style.STROKE); - cPaint.setStrokeCap(Paint.Cap.ROUND); + sPaint = new Paint(); + sPaint.setAntiAlias(true); - sPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - sPaint.setStyle(Paint.Style.FILL); + sPaint.setStyle(Paint.Style.FILL_STYLE); path = new Path(); dstPath = new Path(); - pathMeasure = new PathMeasure(); + pathMeasure = new PathMeasure(path, false); } @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - int heightMode = MeasureSpec.getMode(heightMeasureSpec); + public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) { + System.out.println("zzm->" + "onEstimateSize"); - int width = MeasureSpec.getSize(widthMeasureSpec); - int height = MeasureSpec.getSize(heightMeasureSpec); + int widthMode = EstimateSpec.getMode(widthMeasureSpec); + int heightMode = EstimateSpec.getMode(heightMeasureSpec); + + int width = EstimateSpec.getSize(widthMeasureSpec); + int height = EstimateSpec.getSize(heightMeasureSpec); int measureWidthSize = width, measureHeightSize = height; - if (widthMode == MeasureSpec.AT_MOST) { + if (widthMode == EstimateSpec.NOT_EXCEED) { measureWidthSize = dip2px(20) * 10; } - if (heightMode == MeasureSpec.AT_MOST) { + if (heightMode == EstimateSpec.NOT_EXCEED) { measureHeightSize = dip2px(20) * 10; } - setMeasuredDimension(measureWidthSize, measureHeightSize); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); + setEstimatedSize(measureWidthSize, measureHeightSize); - int minSize = Math.min(getMeasuredWidth(), getMeasuredHeight()); + if (measureWidthSize != measureHeightSize || menuRectFList.size() > 0) { + return true; + } + int minSize = Math.min(getEstimatedWidth(), getEstimatedHeight()); + System.out.println("minSizeminSize->"+minSize); partSize = minSize / 10; iconSize = partSize * 4 / 5; circleMenuRadius = partSize * 3; - - centerX = getMeasuredWidth() / 2; - centerY = getMeasuredHeight() / 2; + System.out.println("clickclick-centerY--getEstimatedHeight->"+getEstimatedHeight()/2); + centerX = getEstimatedWidth() / 2; + centerY = getEstimatedHeight() / 2; resetMainDrawableBounds(); - path.addCircle(centerX, centerY, circleMenuRadius, Path.Direction.CW); + path.addCircle(centerX, centerY, circleMenuRadius, Path.Direction.CLOCK_WISE); pathMeasure.setPath(path, true); pathLength = pathMeasure.getLength(); + System.out.println("clickclick-centerY->"+centerX+"------>"+centerY+"--->"+partSize+"----->"+pathLength); + + RectFloat mainMenuRectF = new RectFloat(centerX - partSize, centerY - partSize, centerX + partSize, centerY + partSize); + System.out.println("clickclick-->"+"mainMenuRectF"); - RectF mainMenuRectF = new RectF(centerX - partSize, centerY - partSize, centerX + partSize, centerY + partSize); menuRectFList.add(mainMenuRectF); + return true; } + @Override - protected void onDraw(Canvas canvas) { + public void onDraw(Component component, Canvas canvas) { + System.out.println("zzmzzm->" + "onDraw--->"+status); + switch (status) { case STATUS_MENU_CLOSED: + System.out.println("zzmzzm->" + "onDraw--->STATUS_MENU_CLOSED"); + drawMainMenu(canvas); break; case STATUS_MENU_OPEN: @@ -204,10 +215,14 @@ public class CircleMenu extends View { case STATUS_MENU_CLOSE: drawMainMenu(canvas); drawSubMenu(canvas); + System.out.println("drawCircleMenu->"+"STATUS_MENU_CLOSE"); + drawCircleMenu(canvas); break; case STATUS_MENU_CLOSE_CLEAR: drawMainMenu(canvas); + System.out.println("drawCircleMenu->"+"STATUS_MENU_CLOSE_CLEAR"); + drawCircleMenu(canvas); break; case STATUS_MENU_CANCEL: @@ -223,20 +238,25 @@ public class CircleMenu extends View { * @param canvas */ private void drawCircleMenu(Canvas canvas) { + System.out.println("drawCircleMenu->"+"drawCircleMenu"); if (status == STATUS_MENU_CLOSE) { drawCirclePath(canvas); drawCircleIcon(canvas); } else { cPaint.setStrokeWidth(partSize * 2 + partSize * .5f * fraction); - cPaint.setColor(calcAlphaColor(getClickMenuColor(), true)); + cPaint.setColor(calcAlphaColor(getIntClickMenuColor(), true)); canvas.drawCircle(centerX, centerY, circleMenuRadius + partSize * .5f * fraction, cPaint); } } - private int getClickMenuColor() { + private int getIntClickMenuColor() { return clickIndex == 0 ? mainMenuColor : subMenuColorList.get(clickIndex - 1); } + private Color getClickMenuColor() { + return new Color(clickIndex == 0 ? mainMenuColor : subMenuColorList.get(clickIndex - 1)); + } + /** * 绘制子菜单转动时的图标 * @@ -244,7 +264,7 @@ public class CircleMenu extends View { */ private void drawCircleIcon(Canvas canvas) { canvas.save(); - Drawable selDrawable = subMenuDrawableList.get(clickIndex - 1); + PixelMapElement selDrawable = subMenuDrawableList.get(clickIndex - 1); if (selDrawable == null) return; int startAngle = (clickIndex - 1) * (360 / itemNum); int endAngle = 360 + startAngle; @@ -252,7 +272,7 @@ public class CircleMenu extends View { int itemY = (int) (centerY - Math.cos(Math.toRadians((endAngle - startAngle) * fraction + startAngle)) * circleMenuRadius); canvas.rotate(360 * fraction, itemX, itemY); selDrawable.setBounds(itemX - iconSize / 2, itemY - iconSize / 2, itemX + iconSize / 2, itemY + iconSize / 2); - selDrawable.draw(canvas); + selDrawable.drawToCanvas(canvas); canvas.restore(); } @@ -266,6 +286,8 @@ public class CircleMenu extends View { canvas.rotate(rotateAngle, centerX, centerY); dstPath.reset(); dstPath.lineTo(0, 0); + System.out.println("drawerCircle--->"+rotateAngle+"----"+centerX+"----"+centerY+"----"+pathLength +"----"+ fraction+"----->"+dstPath); +// pathMeasure.getPosTan(1000,null,null); pathMeasure.getSegment(0, pathLength * fraction, dstPath, true); cPaint.setStrokeWidth(partSize * 2); cPaint.setColor(getClickMenuColor()); @@ -281,7 +303,7 @@ public class CircleMenu extends View { private void drawSubMenu(Canvas canvas) { int itemX, itemY, angle; final float offsetRadius = 1.5f; - RectF menuRectF; + RectFloat menuRectF; for (int i = 0; i < itemNum; i++) { angle = i * (360 / itemNum); if (status == STATUS_MENU_OPEN) { @@ -297,19 +319,20 @@ public class CircleMenu extends View { } else { itemX = (int) (centerX + Math.sin(Math.toRadians(angle)) * circleMenuRadius); itemY = (int) (centerY - Math.cos(Math.toRadians(angle)) * circleMenuRadius); - oPaint.setColor(subMenuColorList.get(i)); - sPaint.setColor(subMenuColorList.get(i)); + oPaint.setColor(new Color(subMenuColorList.get(i))); + sPaint.setColor(new Color(subMenuColorList.get(i))); } if (pressed && clickIndex - 1 == i) { - oPaint.setColor(pressedColor); + oPaint.setColor(new Color(pressedColor)); } drawMenuShadow(canvas, itemX, itemY, itemMenuRadius); canvas.drawCircle(itemX, itemY, itemMenuRadius, oPaint); drawSubMenuIcon(canvas, itemX, itemY, i); - menuRectF = new RectF(itemX - partSize, itemY - partSize, itemX + partSize, itemY + partSize); + menuRectF = new RectFloat(itemX - partSize, itemY - partSize, itemX + partSize, itemY + partSize); if (menuRectFList.size() - 1 > i) { menuRectFList.remove(i + 1); } + System.out.println("clickclick-->"+"times"); menuRectFList.add(i + 1, menuRectF); } } @@ -332,10 +355,10 @@ public class CircleMenu extends View { resetBoundsAndDrawIcon(canvas, subMenuDrawableList.get(index), centerX, centerY, diff); } - private void resetBoundsAndDrawIcon(Canvas canvas, Drawable drawable, int centerX, int centerY, int diff) { + private void resetBoundsAndDrawIcon(Canvas canvas, PixelMapElement drawable, int centerX, int centerY, int diff) { if (drawable == null) return; drawable.setBounds(centerX - diff, centerY - diff, centerX + diff, centerY + diff); - drawable.draw(canvas); + drawable.drawToCanvas(canvas); } /** @@ -345,6 +368,7 @@ public class CircleMenu extends View { */ private void drawMainMenu(Canvas canvas) { float centerMenuRadius, realFraction; + System.out.println("drawr-drawMainMenu->"+status); if (status == STATUS_MENU_CLOSE) { // 中心主菜单按钮以两倍速度缩小 realFraction = (1 - fraction * 2) == 0 ? 0 : (1 - fraction * 2); @@ -354,17 +378,19 @@ public class CircleMenu extends View { realFraction = fraction * 4 >= 1 ? 1 : fraction * 4; centerMenuRadius = partSize * realFraction; } else if (status == STATUS_MENU_CLOSED || status == STATUS_MENU_CANCEL) { + System.out.println("drawr-drawMainMenuSTATUS_MENU_CLOSED->"+status); + centerMenuRadius = partSize; } else { centerMenuRadius = partSize; } if (status == STATUS_MENU_OPEN || status == STATUS_MENU_OPENED || status == STATUS_MENU_CLOSE) { - oPaint.setColor(calcPressedEffectColor(0, .5f)); + oPaint.setColor(new Color(calcPressedEffectColor(0, .5f))); } else if (pressed && clickIndex == 0) { - oPaint.setColor(pressedColor); + oPaint.setColor(new Color(pressedColor)); } else { - oPaint.setColor(mainMenuColor); - sPaint.setColor(mainMenuColor); + oPaint.setColor(new Color(mainMenuColor)); + sPaint.setColor(new Color(mainMenuColor)); } drawMenuShadow(canvas, centerX, centerY, centerMenuRadius); canvas.drawCircle(centerX, centerY, centerMenuRadius, oPaint); @@ -375,8 +401,16 @@ public class CircleMenu extends View { canvas.save(); switch (status) { case STATUS_MENU_CLOSED: + if (openMenuIcon != null){ + System.out.println("drawr-openMenuIcon != null->"+status); + + } + System.out.println("drawr-STATUS_MENU_CLOSED->"+status); + if (openMenuIcon != null) - openMenuIcon.draw(canvas); +// openMenuIcon.drawToCanvas(canvas); +// openMenuIcon.getPixelMap() + canvas.drawPixelMapHolder(new PixelMapHolder(openMenuIcon.getPixelMap()),centerX - iconSize / 2 , centerY - iconSize / 2,oPaint); break; case STATUS_MENU_OPEN: canvas.rotate(45 * (fraction - 1), centerX, centerY); @@ -395,7 +429,7 @@ public class CircleMenu extends View { case STATUS_MENU_CANCEL: canvas.rotate(-45 * fraction, centerX, centerY); if (closeMenuIcon != null) - closeMenuIcon.draw(canvas); + closeMenuIcon.drawToCanvas(canvas); break; } canvas.restore(); @@ -410,37 +444,49 @@ public class CircleMenu extends View { */ private void drawMenuShadow(Canvas canvas, int centerX, int centerY, float radius) { if (radius + shadowRadius > 0) { - sPaint.setShader(new RadialGradient(centerX, centerY, radius + shadowRadius, - Color.BLACK, Color.TRANSPARENT, Shader.TileMode.CLAMP)); +// sPaint.setShader(new RadialShader(centerX, centerY, radius + shadowRadius, +// Color.BLACK, Color.TRANSPARENT, Shader.TileMode.CLAMP_TILEMODE)); + Color[] colors = new Color[]{Color.BLACK, Color.TRANSPARENT}; + sPaint.setShader(new RadialShader(new Point((float) centerX, (float) centerY), radius + shadowRadius, + null, colors, Shader.TileMode.CLAMP_TILEMODE), Paint.ShaderType.RADIAL_SHADER); canvas.drawCircle(centerX, centerY, radius + shadowRadius, sPaint); } } @Override - public boolean onTouchEvent(MotionEvent event) { + public boolean onTouchEvent(Component component, TouchEvent event) { + System.out.println("zzm->" + "onTouchEvent--->"+status); + if (status == STATUS_MENU_CLOSE || status == STATUS_MENU_CLOSE_CLEAR) return true; - int index = clickWhichRectF(event.getX(), event.getY()); + MmiPoint point = event.getPointerPosition(event.getIndex()); + System.out.println("clickclick->"+point.getX()+"--->"+point.getY()); + int index = clickWhichRectF(point.getX(), point.getY()); switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: + case TouchEvent.PRIMARY_POINT_DOWN: pressed = true; if (index != -1) { clickIndex = index; updatePressEffect(index, pressed); } break; - case MotionEvent.ACTION_MOVE: + case TouchEvent.OTHER_POINT_DOWN: + break; + case TouchEvent.OTHER_POINT_UP: + break; + case TouchEvent.POINT_MOVE: if (index == -1) { pressed = false; invalidate(); } break; - case MotionEvent.ACTION_UP: + case TouchEvent.PRIMARY_POINT_UP: pressed = false; if (index != -1) { clickIndex = index; updatePressEffect(index, pressed); } - if (index == 0) { // 点击的是中间的按钮 + System.out.println("indexindex->"+index); + if (index == 0 ) { // 点击的是中间的按钮 if (status == STATUS_MENU_CLOSED) { status = STATUS_MENU_OPEN; startOpenMenuAnima(); @@ -462,6 +508,7 @@ public class CircleMenu extends View { return true; } + /** * 更新按钮的状态 * @@ -485,11 +532,21 @@ public class CircleMenu extends View { private int calcPressedEffectColor(int menuIndex, float depth) { int color = menuIndex == 0 ? mainMenuColor : subMenuColorList.get(menuIndex - 1); float[] hsv = new float[3]; - Color.colorToHSV(color, hsv); + float[] hsvInfo = new float[Constant.THIRD]; + // color id 转RGB + int red = (color & Constant.DEFAULT) >> Constant.ONESIX; + int green = (color & Constant.DEFAULT2) >> Constant.EAT; + int blue = color & Constant.DEFAULT3; +// double[] hsvColor = ColorConverUtils.rgbToHsv(red, green, blue); + ColorConverUtils.rgbToHsv(red, green, blue); +// Color.colorToHSV(color, hsv); hsv[2] *= (1.f - depth); - return Color.HSVToColor(hsv); + float[] rgb = ColorConverUtils.hsb2rgb(hsvInfo); + int hsvColor = Color.rgb((int) rgb[0], (int) rgb[1], (int) rgb[SECOND]); + return hsvColor; } + /** * 用于完成在 View 中的圆环逐渐扩散消失的动画效果
*

@@ -497,9 +554,9 @@ public class CircleMenu extends View { * * @param color 被调整 Alpha 值的颜色 * @param reverse true : 由不透明到透明的顺序调整,否则就逆序 - * @return + * @return Color Color */ - private int calcAlphaColor(int color, boolean reverse) { + private Color calcAlphaColor(int color, boolean reverse) { int alpha; if (reverse) { // 由不透明到透明 alpha = (int) (255 * (1.f - fraction)); @@ -508,32 +565,57 @@ public class CircleMenu extends View { } if (alpha >= 255) alpha = 255; if (alpha <= 0) alpha = 0; - return ColorUtils.setAlphaComponent(color, alpha); + if (alpha >= 0 && alpha <= 255) { + return new Color(color & 16777215 | alpha << 24); + } else { + throw new IllegalArgumentException("alpha must be between 0 and 255."); + } } /** * 启动打开菜单动画 */ private void startOpenMenuAnima() { - ValueAnimator openAnima = ValueAnimator.ofFloat(1.f, 100.f); +// ofFloat(1.f, 100.f) + AnimatorValue openAnima = new AnimatorValue(); openAnima.setDuration(500); - openAnima.setInterpolator(new OvershootInterpolator()); - openAnima.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + openAnima.setCurveType(Animator.CurveType.OVERSHOOT); + openAnima.setStateChangedListener(new Animator.StateChangedListener() { @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - fraction = valueAnimator.getAnimatedFraction(); - itemMenuRadius = fraction * partSize; - itemIconSize = (int) (fraction * iconSize); - invalidate(); + public void onStart(Animator animator) { } - }); - openAnima.addListener(new AnimatorListenerAdapter() { + + @Override + public void onStop(Animator animator) { + } + + @Override + public void onCancel(Animator animator) { + } + @Override - public void onAnimationEnd(Animator animation) { + public void onEnd(Animator animator) { status = STATUS_MENU_OPENED; if (onMenuStatusChangeListener != null) onMenuStatusChangeListener.onMenuOpened(); } + + @Override + public void onPause(Animator animator) { + } + + @Override + public void onResume(Animator animator) { + } + }); + openAnima.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() { + @Override + public void onUpdate(AnimatorValue animatorValue, float interpolatedTime) { + fraction = interpolatedTime; + itemMenuRadius = fraction * partSize; + itemIconSize = (int) (fraction * iconSize); + invalidate(); + } }); openAnima.start(); } @@ -542,25 +624,46 @@ public class CircleMenu extends View { * 启动取消动画 */ private void startCancelMenuAnima() { - ValueAnimator cancelAnima = ValueAnimator.ofFloat(1.f, 100.f); + // ofFloat(1.f, 100.f) + AnimatorValue cancelAnima = new AnimatorValue(); cancelAnima.setDuration(500); - cancelAnima.setInterpolator(new AnticipateInterpolator()); - cancelAnima.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + cancelAnima.setCurveType(Animator.CurveType.ANTICIPATE); + cancelAnima.setStateChangedListener(new Animator.StateChangedListener() { @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - fraction = valueAnimator.getAnimatedFraction(); - itemMenuRadius = (1 - fraction) * partSize; - itemIconSize = (int) ((1 - fraction) * iconSize); - invalidate(); + public void onStart(Animator animator) { } - }); - cancelAnima.addListener(new AnimatorListenerAdapter() { + @Override - public void onAnimationEnd(Animator animation) { + public void onStop(Animator animator) { + } + + @Override + public void onCancel(Animator animator) { + } + + @Override + public void onEnd(Animator animator) { status = STATUS_MENU_CLOSED; if (onMenuStatusChangeListener != null) onMenuStatusChangeListener.onMenuClosed(); } + + @Override + public void onPause(Animator animator) { + } + + @Override + public void onResume(Animator animator) { + } + }); + cancelAnima.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() { + @Override + public void onUpdate(AnimatorValue animatorValue, float interpolatedTime) { + fraction = interpolatedTime; + itemMenuRadius = (1 - fraction) * partSize; + itemIconSize = (int) ((1 - fraction) * iconSize); + invalidate(); + } }); cancelAnima.start(); } @@ -576,62 +679,131 @@ public class CircleMenu extends View { */ private void startCloseMeunAnima() { // 选中菜单项转动一周动画驱动 - ValueAnimator aroundAnima = ValueAnimator.ofFloat(1.f, 100.f); + // ofFloat(1.f, 100.f) + AnimatorValue aroundAnima = new AnimatorValue(); aroundAnima.setDuration(600); - aroundAnima.setInterpolator(new AccelerateDecelerateInterpolator()); - aroundAnima.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + aroundAnima.setCurveType(Animator.CurveType.ACCELERATE_DECELERATE); + aroundAnima.setStateChangedListener(new Animator.StateChangedListener() { + @Override + public void onStart(Animator animator) { + } + + @Override + public void onStop(Animator animator) { + } + + @Override + public void onCancel(Animator animator) { + } + + @Override + public void onEnd(Animator animator) { + status = STATUS_MENU_CLOSE_CLEAR; + } + + @Override + public void onPause(Animator animator) { + } + @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - fraction = valueAnimator.getAnimatedFraction(); + public void onResume(Animator animator) { + } + }); + aroundAnima.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() { + @Override + public void onUpdate(AnimatorValue animatorValue, float interpolatedTime) { + fraction = interpolatedTime; // 中心主菜单图标以两倍速度缩小 float animaFraction = fraction * 2 >= 1 ? 1 : fraction * 2; itemIconSize = (int) ((1 - animaFraction) * iconSize); invalidate(); } }); - aroundAnima.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - status = STATUS_MENU_CLOSE_CLEAR; - } - }); + aroundAnima.start(); // 环状轨迹扩散消失动画驱动 - ValueAnimator spreadAnima = ValueAnimator.ofFloat(1.f, 100.f); - spreadAnima.setInterpolator(new LinearInterpolator()); - spreadAnima.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + // ofFloat(1.f, 100.f) + AnimatorValue spreadAnima = new AnimatorValue(); + spreadAnima.setDuration(600); + spreadAnima.setCurveType(Animator.CurveType.LINEAR); + spreadAnima.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() { @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - fraction = valueAnimator.getAnimatedFraction(); + public void onUpdate(AnimatorValue animatorValue, float interpolatedTime) { + fraction = interpolatedTime; } }); + // 主菜单转动动画驱动 - ValueAnimator rotateAnima = ValueAnimator.ofFloat(1.f, 100.f); - rotateAnima.setInterpolator(new OvershootInterpolator()); - rotateAnima.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + // ofFloat(1.f, 100.f) + AnimatorValue rotateAnima = new AnimatorValue(); + rotateAnima.setCurveType(Animator.CurveType.OVERSHOOT); + rotateAnima.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() { @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - rFraction = valueAnimator.getAnimatedFraction(); + public void onUpdate(AnimatorValue animatorValue, float interpolatedTime) { + fraction = interpolatedTime; itemIconSize = (int) (rFraction * iconSize); invalidate(); } }); - AnimatorSet closeAnimaSet = new AnimatorSet(); + + AnimatorGroup closeAnimaSet = new AnimatorGroup(); closeAnimaSet.setDuration(500); - closeAnimaSet.play(spreadAnima).with(rotateAnima); - closeAnimaSet.addListener(new AnimatorListenerAdapter() { + AnimatorGroup.Builder animatorGroupBuilder = closeAnimaSet.build(); + // 4个动画的顺序为: am1 -> am2/am3 -> am4 + animatorGroupBuilder.addAnimators(spreadAnima, rotateAnima); + closeAnimaSet.setStateChangedListener(new Animator.StateChangedListener() { @Override - public void onAnimationEnd(Animator animation) { + public void onStart(Animator animator) { + System.out.println("zzmzzm-"+"closeanimal"); + } + + @Override + public void onStop(Animator animator) { + + } + + @Override + public void onCancel(Animator animator) { + + } + + @Override + public void onEnd(Animator animator) { status = STATUS_MENU_CLOSED; + System.out.println("zzmzzm-onEnd"+"closeanimalstatus+=="+status); + if (onMenuStatusChangeListener != null) onMenuStatusChangeListener.onMenuClosed(); + invalidate(); } - }); - AnimatorSet animatorSet = new AnimatorSet(); - animatorSet.play(aroundAnima).before(closeAnimaSet); + @Override + public void onPause(Animator animator) { + + } + + @Override + public void onResume(Animator animator) { + + } + }); +// AnimatorSet closeAnimaSet = new AnimatorSet(); +// closeAnimaSet.setDuration(500); +// closeAnimaSet.play(spreadAnima).with(rotateAnima); +// closeAnimaSet.addListener(new AnimatorListenerAdapter() { +// @Override +// public void onAnimationEnd(Animator animation) { +// status = STATUS_MENU_CLOSED; +// if (onMenuStatusChangeListener != null) +// onMenuStatusChangeListener.onMenuClosed(); +// } +// }); + AnimatorGroup animatorSet = new AnimatorGroup(); + AnimatorGroup.Builder animatorSetGroupBuilder = animatorSet.build(); + // 4个动画的顺序为: am1 -> am2/am3 -> am4 + animatorSetGroupBuilder.addAnimators(aroundAnima).addAnimators(closeAnimaSet); animatorSet.start(); } @@ -639,14 +811,14 @@ public class CircleMenu extends View { * 获取当前点击的是哪一个菜单按钮
* 中心菜单下标为0,周围菜单从正上方顺时针计数1~5 * - * @param x - * @param y - * @return + * @param x x + * @param y y + * @return int int */ private int clickWhichRectF(float x, float y) { int which = -1; - for (RectF rectF : menuRectFList) { - if (rectF.contains(x, y)) { + for (RectFloat rectF : menuRectFList) { + if (rectF.isInclude(x, y)) { which = menuRectFList.indexOf(rectF); break; } @@ -654,12 +826,13 @@ public class CircleMenu extends View { return which; } - private Drawable convertDrawable(int iconRes) { - return getResources().getDrawable(iconRes); + private PixelMapElement convertDrawable(int iconRes) { + PixelMapElement pixelMapElement = new PixelMapElement(ColorConverUtils.getPixelMap(getContext(), iconRes)); + return pixelMapElement; } - private Drawable convertBitmap(Bitmap bitmap) { - return new BitmapDrawable(getResources(), bitmap); + private PixelMapElement convertBitmap(PixelMap bitmap) { + return new PixelMapElement(bitmap); } private void resetMainDrawableBounds() { @@ -675,7 +848,7 @@ public class CircleMenu extends View { * @param mainMenuColor 主菜单背景色 * @param openMenuRes 菜单打开图标,Resource 格式 * @param closeMenuRes 菜单关闭图标,Resource 格式 - * @return + * @return CircleMenu CircleMenu */ public CircleMenu setMainMenu(int mainMenuColor, int openMenuRes, int closeMenuRes) { openMenuIcon = convertDrawable(openMenuRes); @@ -690,9 +863,9 @@ public class CircleMenu extends View { * @param mainMenuColor 主菜单背景色 * @param openMenuBitmap 菜单打开图标,Bitmap 格式 * @param closeMenuBitmap 菜单关闭图标,Bitmap 格式 - * @return + * @return CircleMenu CircleMenu */ - public CircleMenu setMainMenu(int mainMenuColor, Bitmap openMenuBitmap, Bitmap closeMenuBitmap) { + public CircleMenu setMainMenu(int mainMenuColor, PixelMap openMenuBitmap, PixelMap closeMenuBitmap) { openMenuIcon = convertBitmap(openMenuBitmap); closeMenuIcon = convertBitmap(closeMenuBitmap); this.mainMenuColor = mainMenuColor; @@ -705,9 +878,9 @@ public class CircleMenu extends View { * @param mainMenuColor 主菜单背景色 * @param openMenuDrawable 菜单打开图标,Drawable 格式 * @param closeMenuDrawable 菜单关闭图标,Drawable 格式 - * @return + * @return CircleMenu CircleMenu */ - public CircleMenu setMainMenu(int mainMenuColor, Drawable openMenuDrawable, Drawable closeMenuDrawable) { + public CircleMenu setMainMenu(int mainMenuColor, PixelMapElement openMenuDrawable, PixelMapElement closeMenuDrawable) { openMenuIcon = openMenuDrawable; closeMenuIcon = closeMenuDrawable; this.mainMenuColor = mainMenuColor; @@ -719,7 +892,7 @@ public class CircleMenu extends View { * * @param menuColor 子菜单的背景色 * @param menuRes 子菜单图标,Resource 格式 - * @return + * @return CircleMenu CircleMenu */ public CircleMenu addSubMenu(int menuColor, int menuRes) { if (subMenuColorList.size() < MAX_SUBMENU_NUM && subMenuDrawableList.size() < MAX_SUBMENU_NUM) { @@ -735,9 +908,9 @@ public class CircleMenu extends View { * * @param menuColor 子菜单的背景色 * @param menuBitmap 子菜单图标,Bitmap 格式 - * @return + * @return CircleMenu CircleMenu */ - public CircleMenu addSubMenu(int menuColor, Bitmap menuBitmap) { + public CircleMenu addSubMenu(int menuColor, PixelMap menuBitmap) { if (subMenuColorList.size() < MAX_SUBMENU_NUM && subMenuDrawableList.size() < MAX_SUBMENU_NUM) { subMenuColorList.add(menuColor); subMenuDrawableList.add(convertBitmap(menuBitmap)); @@ -751,9 +924,9 @@ public class CircleMenu extends View { * * @param menuColor 子菜单的背景色 * @param menuDrawable 子菜单图标,Drawable 格式 - * @return + * @return CircleMenu CircleMenu */ - public CircleMenu addSubMenu(int menuColor, Drawable menuDrawable) { + public CircleMenu addSubMenu(int menuColor, PixelMapElement menuDrawable) { if (subMenuColorList.size() < MAX_SUBMENU_NUM && subMenuDrawableList.size() < MAX_SUBMENU_NUM) { subMenuColorList.add(menuColor); subMenuDrawableList.add(menuDrawable); @@ -788,7 +961,7 @@ public class CircleMenu extends View { * 菜单是否关闭 * Returns whether the menu is alread open * - * @return + * @return boolean boolean */ public boolean isOpened() { return status == STATUS_MENU_OPENED; @@ -805,7 +978,9 @@ public class CircleMenu extends View { } private int dip2px(float dpValue) { - final float scale = getContext().getResources().getDisplayMetrics().density; + final float scale = DisplayManager.getInstance().getDefaultDisplay(getContext()).get().getRealAttributes().densityPixels; return (int) (dpValue * scale + 0.5f); } + + } diff --git a/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/ColorConverUtils.java b/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/ColorConverUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..3a3b258848ffbe2a483a2b115c09ca6618a29445 --- /dev/null +++ b/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/ColorConverUtils.java @@ -0,0 +1,227 @@ +/* + * 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.hitomi.cmlibrary.util; + +import ohos.app.Context; +import ohos.global.resource.NotExistException; +import ohos.media.image.ImageSource; +import ohos.media.image.PixelMap; +import ohos.media.image.common.PixelFormat; +import ohos.media.image.common.Rect; +import ohos.media.image.common.Size; + +import java.io.IOException; +import java.io.InputStream; + +/** + * 颜色转换工具类 + * + * @since 2021-04-16 + */ +public final class ColorConverUtils { + private static final int ADJUSTCOLOR = 0x00ffffff; + private static final int ONE = -1; + private static final int SECOND = 2; + private static final int THIRD = 3; + private static final int FOUR = 4; + private static final int NUMBER8 = 8; + private static final int NUMBER16 = 16; + private static final int ADJUST = 24; + private static final int SIXTEN = 60; + private static final int ONWSECOND = 120; + private static final int SECONDFOUR = 240; + private static final int ALPHAINT = 255; + private static final int THIRDSIX = 360; + + /** + * 构造函数 + */ + protected ColorConverUtils() { + } + + /** + * 透明度数值 + * + * @param alpha alpha + * @return 透明度数值 + */ + public static int alphaValueAsInt(float alpha) { + return Math.round(alpha * ALPHAINT); + } + + /** + * 透明度调整 + * + * @param alpha alpha + * @param color color + * @return 透明度数值 + */ + public static int adjustAlpha(float alpha, int color) { + return alphaValueAsInt(alpha) << ADJUST | (ADJUSTCOLOR & color); + } + + + + /** + * rgb转hsv + * + * @param rr rr + * @param gg gg + * @param bb bb + * @return rgb转hsv + */ + public static double[] rgbToHsv(double rr, double gg, double bb) { + double hh; + double ss; + double vv; + double min; + double max; + min = Math.min(Math.min(rr, gg), bb); + max = Math.max(Math.max(rr, gg), bb); + double delta; + vv = max; + delta = max - min; + if (max != 0) { + ss = delta / max; + } else { + ss = 0; + hh = ONE; + return new double[]{hh, ss, vv}; + } + + // H + if (rr == max) { + hh = (gg - bb) / delta; // between yellow & magenta + } else if (gg == max) { + hh = SECOND + (bb - rr) / delta; // between cyan & yellow + } else { + hh = FOUR + (rr - gg) / delta; // between magenta & cyan + } + hh *= SIXTEN; // degrees + if (hh < 0) { + hh += THIRDSIX; + } + return new double[]{hh, ss, vv}; + } + + /** + * 颜色id转rgb + * + * @param color color + * @return 颜色id转rgb + */ + public static int[] colorToRgb(int color) { + // color id 转RGB + int red = (color & Constant.DEFAULT) >> NUMBER16; + int green = (color & Constant.DEFAULT2) >> NUMBER8; + int blue = color & Constant.DEFAULT3; + return new int[]{red, green, blue}; + } + + /** + * hsv格式颜色转rgb格式 + * + * @param hsb hsb + * @return hsv格式颜色转rgb格式 + */ + public static float[] hsb2rgb(float[] hsb) { + float[] rgb = new float[THIRD]; + + // 先令饱和度和亮度为100%,调节色相h + for (int offset = SECONDFOUR, inum = 0; inum < THIRD; inum++, offset -= ONWSECOND) { + // 算出色相h的值和三个区域中心点(即0°,120°和240°)相差多少,然后根据坐标图按分段函数算出rgb。 + // 但因为色环展开后,红色区域的中心点是0°同时也是360°,不好算,索性将三个区域的中心点都向右平移到240°再计算比较方便 + float diff = Math.abs(((int)hsb[0] + offset) % THIRDSIX - SECONDFOUR); + + // 如果相差小于60°则为255 + if (diff <= SIXTEN) { + rgb[inum] = ALPHAINT; + } + + // 如果相差在60°和120°之间, + else if (diff > SIXTEN && diff < ONWSECOND) { + rgb[inum] = NumCalcUtil.multiply((NumCalcUtil.subtract(1f , (NumCalcUtil.subtract(diff , SIXTEN)) / SIXTEN)), ALPHAINT); + } + + // 如果相差大于120°则为0 + else { + rgb[inum] = 0; + } + } + + // 在调节饱和度s + for (int ii = 0; ii < THIRD; ii++) { + rgb[ii] = NumCalcUtil.add(rgb[ii] , NumCalcUtil.multiply((NumCalcUtil.subtract(ALPHAINT , rgb[ii])) + , (NumCalcUtil.subtract(1f , hsb[1])))); + } + + // 最后调节亮度b + for (int ii = 0; ii < THIRD; ii++) { + rgb[ii] *= hsb[SECOND]; + } + return rgb; + } + + + + /** + * 通过资源ID获取位图对象 + * + * @param context + * @param resId + * @return PixelMap + */ + public static PixelMap getPixelMap(Context context, int resId) { + return getPixelMap(context, resId, 0, 0); + } + + /** + * 通过资源ID获取位图对象 + * + * @param context + * @param resId + * @param width + * @param height + * @return PixelMap + */ + public static PixelMap getPixelMap(Context context, int resId, int width, int height) { + InputStream drawableInputStream = null; + try { + drawableInputStream = context.getResourceManager().getResource(resId); + ImageSource.SourceOptions sourceOptions = new ImageSource.SourceOptions(); + sourceOptions.formatHint = "image/png"; + ImageSource imageSource = ImageSource.create(drawableInputStream, null); + ImageSource.DecodingOptions decodingOptions = new ImageSource.DecodingOptions(); + decodingOptions.desiredSize = new Size(width, height); + decodingOptions.desiredRegion = new Rect(0, 0, 0, 0); + decodingOptions.desiredPixelFormat = PixelFormat.ARGB_8888; + PixelMap pixelMap = imageSource.createPixelmap(decodingOptions); + return pixelMap; + } catch (IOException | NotExistException e) { + e.fillInStackTrace(); + } finally { + try { + if (drawableInputStream != null) { + drawableInputStream.close(); + } + } catch (IOException e) { + e.fillInStackTrace(); + } + } + return null; + } + +} diff --git a/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/Constant.java b/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/Constant.java new file mode 100644 index 0000000000000000000000000000000000000000..f045c5b891b349be2b2e620b40664bf43c9d44aa --- /dev/null +++ b/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/Constant.java @@ -0,0 +1,123 @@ +/* + * 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.hitomi.cmlibrary.util; + +/** + * 常量工具类 + * + * @since 2021-04-16 + */ +public final class Constant { + /** + * SECOND + */ + public static final int SECOND = 2; + /** + * THIRD + */ + public static final int THIRD = 3; + /** + * STROKE_RATIO + */ + public static final float STROKE_RATIO = 1.5f; + /** + * SECONDF + */ + public static final float SECONDF = 2f; + /** + * SECONDFIVERF + */ + public static final float SECONDFIVERF = 2.3f; + /** + * SECONDFIVERF + */ + public static final float SECONDFIVERF1080 = 2.1f; + /** + * SECONDNORMAL + */ + public static final float SECONDNORMAL = 2.45f; + /** + * SECONDNORMAL + */ + public static final float SECONDNORMAL1080 = 2.25f; + /** + * ONESECONDF + */ + public static final float ONESECONDF = 1.2f; + /** + * ONEEAT + */ + public static final int ONEEAT = 180; + /** + * numner 1080 + */ + public static final int ONEZOREEATER = 1080; + /** + * FIVEZORE + */ + public static final int FIVEZORE = 50; + /** + * EAT + */ + public static final int EAT = 8; + /** + * TEN + */ + public static final int TEN = 10; + /** + * NUMBER255F + */ + public static final float NUMBER255F = 255.0f; + /** + * NUMBER65536 + */ + public static final int NUMBER65536 = -65536; + /** + * TENF + */ + public static final float TENF = 10.0f; + /** + * ONESIX + */ + public static final int ONESIX = 16; + /** + * DEFAULT + */ + public static final int DEFAULT = 0xff0000; + /** + * DEFAULT2 + */ + public static final int DEFAULT2 = 0x00ff00; + /** + * DEFAULT3 + */ + public static final int DEFAULT3 = 0x0000ff; + /** + * red + */ + public static final int DEFAULTRED = 0xFFFF0000; + /** + * GROSE + */ + public static final int DEFAULTGRESS = 0xFF00FF00; + /** + * blue + */ + public static final int DEFAULTBLUE = 0xFF0000FF; + + private Constant() { + } +} diff --git a/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/NumCalcUtil.java b/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/NumCalcUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..886f8a9c2b9954228f2f1de0c67fb14344bd1e67 --- /dev/null +++ b/cmlibrary/src/main/java/com/hitomi/cmlibrary/util/NumCalcUtil.java @@ -0,0 +1,71 @@ +/* + * 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.hitomi.cmlibrary.util; + +import java.math.BigDecimal; + +/** + * 浮点数计算工具类 + * + * @since 2021-05-17 + */ +public class NumCalcUtil { + private NumCalcUtil() { + } + /** + * 加法 + * + * @param num1 + * @param num2 + * @return 结果 + */ + public static float add(float num1, float num2) { + return new BigDecimal(num1).add(new BigDecimal(num2)).floatValue(); + } + + /** + * 减法 + * + * @param num1 + * @param num2 + * @return 结果 + */ + public static float subtract(float num1, float num2) { + return new BigDecimal(num1).subtract(new BigDecimal(num2)).floatValue(); + } + + /** + * 除法 + * + * @param num1 + * @param num2 + * @return 结果 + */ + public static float divide(float num1, float num2) { + return new BigDecimal(num1).divide(new BigDecimal(num2)).floatValue(); + } + + /** + * 乘法 + * + * @param num1 + * @param num2 + * @return 结果 + */ + public static float multiply(float num1, float num2) { + return new BigDecimal(num1).multiply(new BigDecimal(num2)).floatValue(); + } +} diff --git a/cmlibrary/src/main/res/values/strings.xml b/cmlibrary/src/main/res/values/strings.xml deleted file mode 100644 index d7dda5264d1b44700813e44c7a680dc0884465fa..0000000000000000000000000000000000000000 --- a/cmlibrary/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - cmlibrary - diff --git a/cmlibrary/src/main/resources/base/element/string.json b/cmlibrary/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..132f6ffb9a7c9f5bdb23124745a4148cb3137541 --- /dev/null +++ b/cmlibrary/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "cmlibrary_library", + "value": "cmlibrary_library" + } + ] +} diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/cmlibrary/src/main/resources/base/graphic/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to cmlibrary/src/main/resources/base/graphic/ic_launcher.png diff --git a/app/src/main/res/mipmap-xhdpi/icon_cancel.png b/cmlibrary/src/main/resources/base/graphic/icon_cancel.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/icon_cancel.png rename to cmlibrary/src/main/resources/base/graphic/icon_cancel.png diff --git a/app/src/main/res/mipmap-xhdpi/icon_gps.png b/cmlibrary/src/main/resources/base/graphic/icon_gps.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/icon_gps.png rename to cmlibrary/src/main/resources/base/graphic/icon_gps.png diff --git a/app/src/main/res/mipmap-xhdpi/icon_home.png b/cmlibrary/src/main/resources/base/graphic/icon_home.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/icon_home.png rename to cmlibrary/src/main/resources/base/graphic/icon_home.png diff --git a/app/src/main/res/mipmap-xhdpi/icon_menu.png b/cmlibrary/src/main/resources/base/graphic/icon_menu.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/icon_menu.png rename to cmlibrary/src/main/resources/base/graphic/icon_menu.png diff --git a/app/src/main/res/mipmap-xhdpi/icon_notify.png b/cmlibrary/src/main/resources/base/graphic/icon_notify.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/icon_notify.png rename to cmlibrary/src/main/resources/base/graphic/icon_notify.png diff --git a/app/src/main/res/mipmap-xhdpi/icon_search.png b/cmlibrary/src/main/resources/base/graphic/icon_search.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/icon_search.png rename to cmlibrary/src/main/resources/base/graphic/icon_search.png diff --git a/app/src/main/res/mipmap-xhdpi/icon_setting.png b/cmlibrary/src/main/resources/base/graphic/icon_setting.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/icon_setting.png rename to cmlibrary/src/main/resources/base/graphic/icon_setting.png diff --git a/cmlibrary/src/test/java/com/hitomi/cmlibrary/ExampleTest.java b/cmlibrary/src/test/java/com/hitomi/cmlibrary/ExampleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3fac74f0291fd1d513babd553b3d26a8ccc79375 --- /dev/null +++ b/cmlibrary/src/test/java/com/hitomi/cmlibrary/ExampleTest.java @@ -0,0 +1,9 @@ +package com.hitomi.cmlibrary; + +import org.junit.Test; + +public class ExampleTest { + @Test + public void onStart() { + } +} diff --git a/app/.gitignore b/entry/.gitignore similarity index 100% rename from app/.gitignore rename to entry/.gitignore diff --git a/entry/build.gradle b/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..42e9841e07b4c502b271746191fee94e50de28f5 --- /dev/null +++ b/entry/build.gradle @@ -0,0 +1,28 @@ +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 5 + defaultConfig { + compatibleSdkVersion 4 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13' + compile project(":cmlibrary") + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200' +} +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..86482728f08d9fd416c75f179bc818deb8e42f64 --- /dev/null +++ b/entry/src/main/config.json @@ -0,0 +1,55 @@ +{ + "app": { + "bundleName": "com.hitomi.circlemenu", + "vendor": "hitomi", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.hitomi.circlemenu", + "name": ".MyApplication", + "mainAbility": "com.hitomi.circlemenu.MainAbility", + "deviceType": [ + "phone" + ], + "metaData": { + "customizeData": [ + { + "name": "hwc-theme", + "value": "androidhwext:style/Theme.Emui.NoTitleBar", + "extra": "" + } + ] + }, + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "name": "com.hitomi.circlemenu.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/java/com/hitomi/circlemenu/MainAbility.java b/entry/src/main/java/com/hitomi/circlemenu/MainAbility.java new file mode 100644 index 0000000000000000000000000000000000000000..e7d61b114f7d7f40f9d7ce01327c405e65ecb057 --- /dev/null +++ b/entry/src/main/java/com/hitomi/circlemenu/MainAbility.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. + *

+ * 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.hitomi.circlemenu; + +import com.hitomi.circlemenu.slice.MainAbilitySlice; +import ohos.aafwk.ability.Ability; +import ohos.aafwk.content.Intent; + +public class MainAbility extends Ability { + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setMainRoute(MainAbilitySlice.class.getName()); + } +} diff --git a/entry/src/main/java/com/hitomi/circlemenu/MyApplication.java b/entry/src/main/java/com/hitomi/circlemenu/MyApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..74a924aa1cae6472c5827b0fd98d52e5b7e4701a --- /dev/null +++ b/entry/src/main/java/com/hitomi/circlemenu/MyApplication.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. + *

+ * 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.hitomi.circlemenu; + +import ohos.aafwk.ability.AbilityPackage; + +public class MyApplication extends AbilityPackage { + @Override + public void onInitialize() { + super.onInitialize(); + } +} diff --git a/entry/src/main/java/com/hitomi/circlemenu/slice/MainAbilitySlice.java b/entry/src/main/java/com/hitomi/circlemenu/slice/MainAbilitySlice.java new file mode 100644 index 0000000000000000000000000000000000000000..fd0fd91644e85fc0d83ce9f43bffe9240fcd785e --- /dev/null +++ b/entry/src/main/java/com/hitomi/circlemenu/slice/MainAbilitySlice.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. + *

+ * 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.hitomi.circlemenu.slice; + +import com.hitomi.circlemenu.ResourceTable; +import com.hitomi.cmlibrary.CircleMenu; +import com.hitomi.cmlibrary.OnMenuSelectedListener; +import com.hitomi.cmlibrary.OnMenuStatusChangeListener; +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.agp.utils.Color; + +public class MainAbilitySlice extends AbilitySlice { + private CircleMenu circleMenu; + + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setUIContent(ResourceTable.Layout_ability_main); + getWindow().setStatusBarColor(Color.getIntColor("#2828FF")); + circleMenu = (CircleMenu) findComponentById(ResourceTable.Id_circle_menu); + circleMenu.setMainMenu(Color.getIntColor("#CDCDCD"), ResourceTable.Graphic_icon_menu, ResourceTable.Graphic_icon_cancel) + .addSubMenu(Color.getIntColor("#258CFF"), ResourceTable.Graphic_icon_home) + .addSubMenu(Color.getIntColor("#30A400"), ResourceTable.Graphic_icon_search) + .addSubMenu(Color.getIntColor("#FF4B32"), ResourceTable.Graphic_icon_notify) + .addSubMenu(Color.getIntColor("#8A39FF"), ResourceTable.Graphic_icon_setting) + .addSubMenu(Color.getIntColor("#FF6A00"),ResourceTable.Graphic_icon_gps) + .setOnMenuSelectedListener(new OnMenuSelectedListener() { + + @Override + public void onMenuSelected(int index) {} + + }).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() { + + @Override + public void onMenuOpened() {} + + @Override + public void onMenuClosed() {} + + }); + } + + @Override + public void onActive() { + super.onActive(); + } + + @Override + public void onForeground(Intent intent) { + super.onForeground(intent); + } +} 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..c2a6b66cf9bbe3634a9332007717dfd5f2db38bf --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "Java_Empty Ability" + }, + { + "name": "mainability_HelloWorld", + "value": "Hello World" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0 --- /dev/null +++ b/entry/src/main/resources/base/graphic/background_ability_main.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..64560f368d312494e13e7b06372b21144db91850 --- /dev/null +++ b/entry/src/main/resources/base/layout/ability_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file 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..bcf9f99db439d496a88899a967191af5e7407e15 --- /dev/null +++ b/entry/src/main/resources/en/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "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..fdc4bd140b689dfcb287ba35be2d478105f47f72 --- /dev/null +++ b/entry/src/main/resources/zh/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "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/hitomi/circlemenu/ExampleOhosTest.java b/entry/src/ohosTest/java/com/hitomi/circlemenu/ExampleOhosTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dfcaa79488fa31590911d22f7e3025c4cd3d2ed4 --- /dev/null +++ b/entry/src/ohosTest/java/com/hitomi/circlemenu/ExampleOhosTest.java @@ -0,0 +1,14 @@ +package com.hitomi.circlemenu; + +import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class ExampleOhosTest { + @Test + public void testBundleName() { + final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); + assertEquals("com.hitomi.circlemenu", actualBundleName); + } +} \ No newline at end of file diff --git a/entry/src/test/java/com/hitomi/circlemenu/ExampleTest.java b/entry/src/test/java/com/hitomi/circlemenu/ExampleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..646ef54bbad765b320553ad26ff7f53b3b94855d --- /dev/null +++ b/entry/src/test/java/com/hitomi/circlemenu/ExampleTest.java @@ -0,0 +1,9 @@ +package com.hitomi.circlemenu; + +import org.junit.Test; + +public class ExampleTest { + @Test + public void onStart() { + } +} diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..0000000000000000000000000000000000000000 --- a/gradle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android 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 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 1c121ad27c21bc1783fc67e9e8c2492717df6460..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Sep 23 20:39:01 CST 2019 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-5.1.1-all.zip diff --git a/gradlew b/gradlew deleted file mode 100644 index 9d82f78915133e1c35a6ea51252590fb38efac2f..0000000000000000000000000000000000000000 --- a/gradlew +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=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. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -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 - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((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" ;; - 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=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..0000000000000000000000000000000000000000 --- a/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@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 Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz 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. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -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 - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/img/demo.gif b/img/demo.gif new file mode 100644 index 0000000000000000000000000000000000000000..3fad83ba4c721e0003fc812d6f98e1f9e657612b Binary files /dev/null and b/img/demo.gif differ diff --git a/preview/circle_menu.gif b/preview/circle_menu.gif deleted file mode 100644 index b043b05b9ab7c110b88c0ed9be7c41f4a2dcfcd2..0000000000000000000000000000000000000000 Binary files a/preview/circle_menu.gif and /dev/null differ diff --git a/settings.gradle b/settings.gradle index 047bb386c2581fa7f5feba2de6b4bd67d99d66ea..f53fadf4f826a6fa890386da3163ab37e6623ad6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':cmlibrary' +include ':entry', ':cmlibrary'