diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..10da1cdc43c49b72303537b9f8650741956bb096
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,6 @@
+## 0.0.1-SHAOSHOT
+
+ohos第一个版本
+
+* 实现了原库基本功能
+* 与原库调用无差异
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..3aef99b7761b19fc672432e5d44bbcac4ad97f93
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2017 scwang90
+
+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.OPENRESOURCE b/README.OPENRESOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..ae671c5a22c764bfb1f0a25eddb1847599537792
--- /dev/null
+++ b/README.OPENRESOURCE
@@ -0,0 +1,37 @@
+[
+
+
+
+{
+
+
+
+"Name":"MultiWaveHeader"
+
+
+
+"License":"Apache License"
+
+
+
+"License File":"LICENSE"
+
+
+
+"Version Number":"1.0.0"
+
+
+
+"Upstream URL":"https://github.com/scwang90/MultiWaveHeader"
+
+
+
+"Description":"MultiWaveHeader 是一个可以高度定制每个波形的Android水波控件。"
+
+
+
+}
+
+
+
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index c7386aab6c8d777236d0cc2caef2602e8fde3129..12a3539f9dc0d13729663e0ca383afe48ee4f83f 100644
--- a/README.md
+++ b/README.md
@@ -1,168 +1,122 @@
-# 多重水波纹 - MultiWaveHeader
+# MultiWaveHeader
-[](https://www.apache.org/licenses/LICENSE-2.0)
-[](https://bintray.com/scwang90/maven/MultiWaveHeader/_latestVersion)
-[](https://android-arsenal.com/api?level=9)
-[](https://www.android.com)
-[](https://github.com/scwang90)
+#### 项目介绍
-## [English](https://github.com/scwang90/MultiWaveHeader/blob/master/README.md) | 中文
+* 项目名称:MultiWaveHeader
+* 所属系列:openharmony
+* 功能:MultiWaveHeader是一个可以高度定制每个波形的ohos水波控件
+* 项目移植状态:完成
+* 调用差异:无
+* 开发版本:sdk6,DevEco Studio 2.2 Beat1
+* 基线版本:Relesase 1.0.0
-MultiWaveHeader 是一个可以高度定制每个波形的Android水波控件。
+#### 效果演示
-## 功能特点
+
- - 支持调节进度.
- - 支持调节速度.
- - 支持设置方向(上下).
- - 支持设置水波的数量(无上限).
- - 支持精确定义水波的参数(偏移、拉伸、原始速度).
- - 支持设置颜色渐变和改变渐变方向.
+#### 安装教程
-## 演示
+1.在项目根目录下的build.gradle文件中
-[Download APK-Demo](https://github.com/scwang90/MultiWaveHeader/blob/master/art/app-debug.apk?raw=true)
-
-
-
-## 每天领红包
-
-最近开通了支付宝商家,生成了个红包二维码,经常用支付宝的童鞋可有扫码领优惠红包,扫码只会拿红包,不会有任何损失,每天都可以扫码哦!
-
-
-
-### 实战
-
-
+```txt
+allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ }
+}
+```
+2.在entry模块下的build.gradle文件中
-## 控制台
+```txt
+dependencies {
+ implementation('com.gitee.chinasoft_ohos:MultiWaveHeader:0.0.1-SNAPSHOT')
+ ......
+ }
+```
-### 方向
+在sdk6,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
-|顶部|底部|
-|:---:|:---:|
-||
+#### 使用说明
-|一对|单一|
-|:---:|:---:|
-||
+在布局中引入对应的自定义控件用于绘制波纹
-## 简单用例
-#### 1.在 build.gradle 中添加依赖
+```txt
+
```
- implementation 'com.scwang.wave:MultiWaveHeader:1.0.0'
- //androidx
- implementation 'com.scwang.wave:MultiWaveHeader:1.0.0-andx'
+可以配置一些基本的属性
-```
-
-#### 2.在XML布局文件中添加 MultiWaveHeader
-```xml
-
-```
+```txt
+multiWaveHeader.start();
+multiWaveHeader.stop();
-## 属性
+multiWaveHeader.setShape(ShapeType.Rect);
-#### 可以配置一些基本的属性.
+multiWaveHeader.setStartColor(colorValue);
+multiWaveHeader.setCloseColor(colorValue);
-###### java
-```java
- MultiWaveHeader waveHeader = findViewById(R.id.waveHeader);
+multiWaveHeader.setProgress(1f * i / 100);
- waveHeader.setStartColor(R.color.colorPrimary);
- waveHeader.setCloseColor(R.color.colorPrimaryDark);
- waveHeader.setColorAlpha(.5f);
+multiWaveHeader.setWaveHeight(seekBar.getProgress());
- waveHeader.setWaveHeight(50);
- waveHeader.setGradientAngle(360);
- waveHeader.setProgress(.8f);
- waveHeader.setVelocity(1f);
- waveHeader.setScaleY(-1f);
+multiWaveHeader.setWaves("0,0,1,1,25" +System.lineSeparator() + "90,0,1,1,25");
+```
- waveHeader.setWaves("PairWave");
+且内部配置一个颜色块seekbar,可直接引用ColorSeekBar,设置接口回调可实时获得当前的颜色
- waveHeader.start();
- waveHeader.stop();
- waveHeader.isRunning();
+```txt
+startSeekBar.setSeekBarColorChange(new SeekBarColorChange() {
+ @Override
+ public void colorChange(Color color, int colorValue) {
+ // color Color对象的颜色
+ // colorValue int类型的颜色
+ }
+ });
```
-###### xml
-```xml
-
-```
+#### 测试信息
-## 自定义
+CodeCheck代码测试无异常
-#### 可以高度定制每一条水波.
+CloudTest代码测试无异常
-###### java
-```java
- MultiWaveHeader waveHeader = findViewById(R.id.waveHeader);
+病毒安全检测通过
- String[] waves = new String[]{
- "70,25,1.4,1.4,-26",//wave-1:offsetX(dp),offsetY(dp),scaleX,scaleY,velocity(dp/s)
- "100,5,1.4,1.2,15",
- "420,0,1.15,1,-10",//wave-3:水平偏移(dp),竖直偏移(dp),水平拉伸,竖直拉伸,速度(dp/s)
- "520,10,1.7,1.5,20",
- "220,0,1,1,-15",
- };
- waveHeader.setWaves(TextUtils.join(" ", Arrays.asList(waves)));// custom
- waveHeader.setWaves("PairWave");// default two waves
- waveHeader.setWaves("MultiWave");// default five waves
+当前版本demo功能与原组件基本无差异
-```
+#### 版本迭代
-###### xml
-```xml
-
-```
+* 0.0.1-SHAPSHOT
-## 其他作品
-[SmartRefreshLayout](https://github.com/scwang90/SmartRefreshLayout)
-[SmartRefreshHorizontal](https://github.com/scwang90/SmartRefreshHorizontal)
+#### 版权和许可信息
-License
--------
+```txt
+Copyright 2017 scwang90
- Copyright 2017 scwang90
+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
- 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
- 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.
+```
- 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.
diff --git a/README_EN.md b/README_EN.md
deleted file mode 100644
index f7d3ace3cb81843b1d713270c45d6a8e88ab3311..0000000000000000000000000000000000000000
--- a/README_EN.md
+++ /dev/null
@@ -1,159 +0,0 @@
-# MultiWaveHeader
-
-[](https://www.apache.org/licenses/LICENSE-2.0)
-[](https://bintray.com/scwang90/maven/MultiWaveHeader/_latestVersion)
-[](https://android-arsenal.com/api?level=9)
-[](https://www.android.com)
-[](https://github.com/scwang90)
-
-
-## English | [中文](https://github.com/scwang90/MultiWaveHeader/blob/master/README.md)
-
-MultiWaveHeader is an android wave view that can be highly customized for each wave.
-
-## Features
-
- - Support adjust progress.
- - Support adjust velocity.
- - Support adjust direction.
- - Support adjust waves number.
- - Support precise customization waves.
- - Support color gradient and adjust angle.
-
-## Demo
-
-[Download APK-Demo](https://github.com/scwang90/MultiWaveHeader/blob/master/art/app-debug.apk?raw=true)
-
-
-
-### Practical
-
-
-
-
-## Console
-
-### direction
-
-|top|bottom|
-|:---:|:---:|
-||
-
-|pair|single|
-|:---:|:---:|
-||
-
-## Usage
-#### 1.Add a gradle dependency.
-```
- implementation 'com.scwang.wave:MultiWaveHeader:1.0.0'
-
- //androidx
- implementation 'com.scwang.wave:MultiWaveHeader:1.0.0-andx'
-```
-
-#### 2.Add MultiWaveHeader in the layout xml.
-```xml
-
-```
-
-## Property
-
-#### you can config basic attribute of waves.
-
-###### java
-```java
- MultiWaveHeader waveHeader = findViewById(R.id.waveHeader);
-
- waveHeader.setStartColor(R.color.colorPrimary);
- waveHeader.setCloseColor(R.color.colorPrimaryDark);
- waveHeader.setColorAlpha(.5f);
-
- waveHeader.setWaveHeight(50);
- waveHeader.setGradientAngle(360);
- waveHeader.setProgress(.8f);
- waveHeader.setVelocity(1f);
- waveHeader.setScaleY(-1f);
-
- waveHeader.setWaves("PairWave");
-
- waveHeader.start();
- waveHeader.stop();
- waveHeader.isRunning();
-
-```
-
-###### xml
-```xml
-
-```
-
-## Custom
-
-#### You can customize each wave with precision.
-
-###### java
-```java
- MultiWaveHeader waveHeader = findViewById(R.id.waveHeader);
-
- String[] waves = new String[]{
- "70,25,1.4,1.4,-26",//wave-1:offsetX(dp),offsetY(dp),scaleX,scaleY,velocity(dp/s)
- "100,5,1.4,1.2,15",
- "420,0,1.15,1,-10",//wave-3:offsetX(dp),offsetY(dp),scaleX,scaleY,velocity(dp/s)
- "520,10,1.7,1.5,20",
- "220,0,1,1,-15",
- };
- waveHeader.setWaves(TextUtils.join(" ", Arrays.asList(waves)));// custom
- waveHeader.setWaves("PairWave");// default two waves
- waveHeader.setWaves("MultiWave");// default five waves
-
-```
-
-###### xml
-```xml
-
-```
-
-License
--------
-
- Copyright 2017 scwang90
-
- 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.
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index b1744cda50547d9b1ff1005bc7b7a15aac781a5e..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,41 +0,0 @@
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
-apply plugin: 'kotlin-android-extensions'
-
-android {
- compileSdkVersion 28
- defaultConfig {
- applicationId "com.scwang.wave.app"
- minSdkVersion 14
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- vectorDrawables.useSupportLibrary = true
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation 'com.android.support:appcompat-v7:28.0.0'
- implementation 'com.android.support:design:28.0.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
- implementation 'com.android.support:support-vector-drawable:28.0.0'
- implementation 'com.android.support:support-v4:28.0.0'
- implementation 'com.larswerkman:lobsterpicker:1.0.1'
- implementation 'org.adw.library:discrete-seekbar:1.0.0'
-
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
- testImplementation 'junit:junit:4.12'
-
-// implementation project(':library')
- implementation 'com.scwang.wave:MultiWaveHeader:1.0.0'
-}
diff --git a/app/debug.keystore b/app/debug.keystore
deleted file mode 100644
index e9a18800718b1494e3adf6bd1fef593575652afa..0000000000000000000000000000000000000000
Binary files a/app/debug.keystore and /dev/null differ
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index f1b424510da51fd82143bc74a0a801ae5a1e2fcd..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# 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 *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/app/src/androidTest/java/com/scwang/wave/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/scwang/wave/ExampleInstrumentedTest.kt
deleted file mode 100644
index 2d3174ba1cef997d0235592f30c7934408f3a396..0000000000000000000000000000000000000000
--- a/app/src/androidTest/java/com/scwang/wave/ExampleInstrumentedTest.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.wave
-
-import android.support.test.InstrumentationRegistry
-import android.support.test.runner.AndroidJUnit4
-
-import org.junit.Test
-import org.junit.runner.RunWith
-
-import org.junit.Assert.*
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getTargetContext()
- assertEquals("com.scwang.wave", appContext.packageName)
- }
-}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 8c65188f32e85c37d8e905d735fa02417f188b57..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/com/scwang/wave/app/activity/FragmentActivity.kt b/app/src/main/java/com/scwang/wave/app/activity/FragmentActivity.kt
deleted file mode 100644
index ce65f3199c1c3d2e227d8e10f7218f0ba318e13e..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/scwang/wave/app/activity/FragmentActivity.kt
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.scwang.wave.app.activity
-
-import android.R.id.widget_frame
-import android.app.Activity
-import android.content.Context
-import android.content.Intent
-import android.os.Bundle
-import android.support.v4.app.Fragment
-import android.support.v7.app.AppCompatActivity
-import android.widget.FrameLayout
-import java.util.*
-
-/**
- * Fragment 容器页面
- * Created by SCWANG on 2017/10/10.
- */
-
-class FragmentActivity : AppCompatActivity() {
- //
-
- var fragment: Fragment? = null
- private set
- //
-
- //
-
- //@InjectExtra(value = EXTRA_FRAGMENT,remark = "Fragment类名")
- lateinit var mFragmentClazz: String
- private val fragmentClass: Class<*>
- @Throws(ClassNotFoundException::class)
- get() {
- var type: Class<*>? = typeCache[mFragmentClazz]
- if (type != null) {
- return type
- }
- type = Class.forName(mFragmentClazz)
- typeCache[mFragmentClazz] = type
- return type
- }
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- mFragmentClazz = intent.getStringExtra(EXTRA_FRAGMENT)
- val frameLayout = FrameLayout(this)
- frameLayout.id = widget_frame
- setContentView(frameLayout)
- replaceFragment()
- }
-
- private fun replaceFragment() {
- try {
- val fragment = fragmentClass.newInstance() as Fragment
- val manager = supportFragmentManager
- val transaction = manager.beginTransaction()
- transaction.replace(widget_frame, fragment)
- transaction.commit()
- this.fragment = fragment
- } catch (e: Exception) {
- e.printStackTrace()
- // AfExceptionHandler.handle(e, "AfFragmentActivity Fragment 类型错误:" + mFragmentClazz);
- }
-
- }
-
- companion object {
-
- private const val EXTRA_FRAGMENT = "EXTRA_FRAGMENT"
-
- //
- private fun start(context: Context?, clazz: Class<*>, vararg params: Any) {
- if (context != null && Fragment::class.java.isAssignableFrom(clazz)) {
- context.startActivity(newIntent(clazz, context, *params))
- }
- }
-
- fun start(activity: Activity, clazz: Class<*>, vararg params: Any) {
- start(activity as Context, clazz, *params)
- }
-
- fun start(fragment: Fragment?, clazz: Class<*>, vararg params: Any) {
- if (fragment != null) {
- start(fragment.activity as Context, clazz, *params)
- }
- }
-
- private fun newIntent(clazz: Class<*>, context: Context, vararg params: Any): Intent {
- val intent = Intent(context, FragmentActivity::class.java)
- intent.putExtra(EXTRA_FRAGMENT, clazz.name)
- return intent
- }
-
- //
- private val typeCache = HashMap>()
- }
-
- //
-
-
-}
diff --git a/app/src/main/java/com/scwang/wave/app/activity/MainActivity.kt b/app/src/main/java/com/scwang/wave/app/activity/MainActivity.kt
deleted file mode 100644
index 8b18dcadc777dd952715aa97d7b695cdc3320a29..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/scwang/wave/app/activity/MainActivity.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.scwang.wave.app.activity
-
-import android.os.Bundle
-import android.support.design.widget.BottomNavigationView.OnNavigationItemSelectedListener
-import android.support.v4.app.Fragment
-import android.support.v4.app.FragmentTransaction
-import android.support.v7.app.AppCompatActivity
-import android.view.MenuItem
-import com.scwang.wave.app.R
-import com.scwang.wave.app.fragment.WaveConsoleFragment
-import kotlinx.android.synthetic.main.activity_main.*
-import kotlin.reflect.KClass
-
-class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener {
-
- enum class Tabs(val menuId: Int, val clazz: KClass) {
- WavePair(R.id.navigation_home, WaveConsoleFragment::class),
- Wave(R.id.navigation_dashboard, WaveConsoleFragment::class),
- Wave2(R.id.navigation_notifications, WaveConsoleFragment::class),
- }
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main)
-
- navigation.setOnNavigationItemSelectedListener(this)
- navigation.selectedItemId = R.id.navigation_home
- }
-
- override fun onNavigationItemSelected(item: MenuItem): Boolean {
- supportFragmentManager
- .beginTransaction()
- .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
- .replace(R.id.content, Tabs.values().first { it.menuId==item.itemId }.clazz.java.newInstance())
- .commit()
- return true
- }
-
-}
diff --git a/app/src/main/java/com/scwang/wave/app/activity/UserLoginActivity.kt b/app/src/main/java/com/scwang/wave/app/activity/UserLoginActivity.kt
deleted file mode 100644
index b24c9e75915d1b4ef8d22452707a19bdf66412f7..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/scwang/wave/app/activity/UserLoginActivity.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.scwang.wave.app.activity
-
-import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
-import com.scwang.wave.app.R
-import com.scwang.wave.app.fragment.WaveConsoleFragment
-import com.scwang.wave.app.util.StatusBarUtil
-import kotlinx.android.synthetic.main.activity_user_login.*
-
-
-class UserLoginActivity : AppCompatActivity() {
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_user_login)
- //状态栏透明和间距处理
- StatusBarUtil.immersive(this)
-
- login.setOnClickListener {
-// startActivity(Intent(this, MainActivity::class.java))
- FragmentActivity.start(this, WaveConsoleFragment::class.java)
- }
-
- }
-}
diff --git a/app/src/main/java/com/scwang/wave/app/fragment/WaveConsoleFragment.kt b/app/src/main/java/com/scwang/wave/app/fragment/WaveConsoleFragment.kt
deleted file mode 100644
index f6aeae98d40c90689b95459357811a8612ffbe6b..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/scwang/wave/app/fragment/WaveConsoleFragment.kt
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.scwang.wave.app.fragment
-
-
-import android.content.res.Resources
-import android.os.Bundle
-import android.support.v4.app.Fragment
-import android.support.v4.content.ContextCompat
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import com.larswerkman.lobsterpicker.OnColorListener
-import com.scwang.wave.ShapeType
-import com.scwang.wave.app.R
-import com.scwang.wave.app.util.StatusBarUtil
-import kotlinx.android.synthetic.main.fragment_wave_console.*
-import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
-
-/**
- * A simple [Fragment] subclass.
- */
-class WaveConsoleFragment : Fragment(), DiscreteSeekBar.OnProgressChangeListener {
-
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_wave_console, container, false)
- }
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- StatusBarUtil.immersive(activity)
- StatusBarUtil.setPaddingSmart(context, toolbar)
- toolbar.setNavigationOnClickListener {
- activity?.finish()
- }
-
- seekAngle.progress = multiWaveHeader.gradientAngle
- seekVelocity.progress = (multiWaveHeader.velocity * 10).toInt()
- seekAlpha.progress = (multiWaveHeader.colorAlpha * 100).toInt()
- seekProgress.progress = (multiWaveHeader.progress * 100).toInt()
- seekWave.progress = (multiWaveHeader.waveHeight / Resources.getSystem().displayMetrics.density).toInt()
- checkBoxRunning.isChecked = multiWaveHeader.isRunning
- checkBoxDirection.isChecked = multiWaveHeader.scaleY == -1f
-
- seekWave.setOnProgressChangeListener(this)
- seekAngle.setOnProgressChangeListener(this)
- seekVelocity.setOnProgressChangeListener(this)
- seekProgress.setOnProgressChangeListener(this)
- seekAlpha.setOnProgressChangeListener(this)
- seekNumber.setOnProgressChangeListener(this)
- checkBoxRunning.setOnCheckedChangeListener {_,value->
- if (value) {
- multiWaveHeader.start()
- } else {
- multiWaveHeader.stop()
- }
- }
- checkBoxDirection.setOnCheckedChangeListener{_,value->
- multiWaveHeader.scaleY = if (value) -1f else 1f
- context?.also {
- toolbar.setBackgroundColor(if (value) ContextCompat.getColor(it, R.color.colorPrimary) else 0)
- }
- }
-
- sliderStartColor.addOnColorListener(object : OnColorListener{
- override fun onColorChanged(color: Int) {
- onColorSelected(color)
- }
- override fun onColorSelected(color: Int) {
- multiWaveHeader.startColor = color
- }
- })
- sliderCloseColor.addOnColorListener(object : OnColorListener{
- override fun onColorChanged(color: Int) {
- onColorSelected(color)
- }
- override fun onColorSelected(color: Int) {
- multiWaveHeader.closeColor = color
- }
- })
-
- radioGroup.setOnCheckedChangeListener { _, checkedId ->
- when (checkedId) {
- R.id.radioRect -> multiWaveHeader.shape = ShapeType.Rect
- R.id.radioOval -> multiWaveHeader.shape = ShapeType.Oval
- R.id.radioRoundRect -> multiWaveHeader.shape = ShapeType.RoundRect
- }
- }
-
- }
-
- override fun onProgressChanged(seekBar: DiscreteSeekBar, value: Int, fromUser: Boolean) {
- when (seekBar) {
- seekProgress -> multiWaveHeader.progress = 1f * value / 100
- seekVelocity -> multiWaveHeader.velocity = 1f * value / 10
- seekAlpha -> multiWaveHeader.colorAlpha = 1f * value / 100
- seekAngle -> multiWaveHeader.gradientAngle = value
- }
- }
-
- override fun onStartTrackingTouch(seekBar: DiscreteSeekBar) {
- }
-
- override fun onStopTrackingTouch(seekBar: DiscreteSeekBar) {
- if (seekWave == seekBar) {
- multiWaveHeader.waveHeight = seekBar.progress
- } else if (seekNumber == seekBar) {
- if (seekBar.progress == 2) {
- /**
- * 格式-format
- * offsetX offsetY scaleX scaleY velocity(dp/s)
- * 水平偏移量 竖直偏移量 水平拉伸比例 竖直拉伸比例 速度
- */
- multiWaveHeader.setWaves("0,0,1,1,25\n90,0,1,1,25")
- } else {
- val waves = "70,25,1.4,1.4,-26\n100,5,1.4,1.2,15\n420,0,1.15,1,-10\n520,10,1.7,1.5,20\n220,0,1,1,-15".split("\n")
- multiWaveHeader.setWaves(waves.subList(0, seekBar.progress).joinToString("\n"))
- }
- }
- }
-}
diff --git a/app/src/main/java/com/scwang/wave/app/util/StatusBarUtil.java b/app/src/main/java/com/scwang/wave/app/util/StatusBarUtil.java
deleted file mode 100644
index 507d2147bbd039214ea0963828f4abd17dda3537..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/scwang/wave/app/util/StatusBarUtil.java
+++ /dev/null
@@ -1,291 +0,0 @@
-package com.scwang.wave.app.util;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Build;
-import android.support.annotation.FloatRange;
-import android.support.annotation.RequiresApi;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.regex.Pattern;
-
-/**
- * 状态栏透明
- * Created by SCWANG on 2016/10/26.
- */
-
-@SuppressWarnings({"unused", "WeakerAccess"})
-public class StatusBarUtil {
-
- public static int DEFAULT_COLOR = 0;
- public static float DEFAULT_ALPHA = 0;//Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? 0.2f : 0.3f;
- public static final int MIN_API = 19;
-
- //
- public static void immersive(Activity activity) {
- immersive(activity, DEFAULT_COLOR, DEFAULT_ALPHA);
- }
-
- public static void immersive(Activity activity, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
- immersive(activity.getWindow(), color, alpha);
- }
-
- public static void immersive(Activity activity, int color) {
- immersive(activity.getWindow(), color, 1f);
- }
-
- public static void immersive(Window window) {
- immersive(window, DEFAULT_COLOR, DEFAULT_ALPHA);
- }
-
- public static void immersive(Window window, int color) {
- immersive(window, color, 1f);
- }
-
- public static void immersive(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
- if (Build.VERSION.SDK_INT >= 21) {
- window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- window.setStatusBarColor(mixtureColor(color, alpha));
-
- int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
- systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
- systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
- window.getDecorView().setSystemUiVisibility(systemUiVisibility);
- } else if (Build.VERSION.SDK_INT >= 19) {
- window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- setTranslucentView((ViewGroup) window.getDecorView(), color, alpha);
- } else if (Build.VERSION.SDK_INT >= MIN_API && Build.VERSION.SDK_INT > 16) {
- int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
- systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
- systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
- window.getDecorView().setSystemUiVisibility(systemUiVisibility);
- }
- }
- //
-
- //
- public static void darkMode(Activity activity, boolean dark) {
- if (isFlyme4Later()) {
- darkModeForFlyme4(activity.getWindow(), dark);
- } else if (isMIUI6Later()) {
- darkModeForMIUI6(activity.getWindow(), dark);
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- darkModeForM(activity.getWindow(), dark);
- }
- }
-
- /** 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上) */
- public static void darkMode(Activity activity) {
- darkMode(activity.getWindow(), DEFAULT_COLOR, DEFAULT_ALPHA);
- }
-
- public static void darkMode(Activity activity, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
- darkMode(activity.getWindow(), color, alpha);
- }
-
- /** 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上) */
- public static void darkMode(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
- if (isFlyme4Later()) {
- darkModeForFlyme4(window, true);
- immersive(window,color,alpha);
- } else if (isMIUI6Later()) {
- darkModeForMIUI6(window, true);
- immersive(window,color,alpha);
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- darkModeForM(window, true);
- immersive(window, color, alpha);
- } else if (Build.VERSION.SDK_INT >= 19) {
- window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- setTranslucentView((ViewGroup) window.getDecorView(), color, alpha);
- } else {
- immersive(window, color, alpha);
- }
-// if (Build.VERSION.SDK_INT >= 21) {
-// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
-// window.setStatusBarColor(Color.TRANSPARENT);
-// } else if (Build.VERSION.SDK_INT >= 19) {
-// window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-// }
-
-// setTranslucentView((ViewGroup) window.getDecorView(), color, alpha);
- }
-
- //------------------------->
-
- /** android 6.0设置字体颜色 */
- @RequiresApi(Build.VERSION_CODES.M)
- private static void darkModeForM(Window window, boolean dark) {
-// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
-// window.setStatusBarColor(Color.TRANSPARENT);
-
- int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
- if (dark) {
- systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
- } else {
- systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
- }
- window.getDecorView().setSystemUiVisibility(systemUiVisibility);
- }
-
- /**
- * 设置Flyme4+的darkMode,darkMode时候字体颜色及icon变黑
- * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
- */
- public static boolean darkModeForFlyme4(Window window, boolean dark) {
- boolean result = false;
- if (window != null) {
- try {
- WindowManager.LayoutParams e = window.getAttributes();
- Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
- Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
- darkFlag.setAccessible(true);
- meizuFlags.setAccessible(true);
- int bit = darkFlag.getInt(null);
- int value = meizuFlags.getInt(e);
- if (dark) {
- value |= bit;
- } else {
- value &= ~bit;
- }
-
- meizuFlags.setInt(e, value);
- window.setAttributes(e);
- result = true;
- } catch (Exception var8) {
- Log.e("StatusBar", "darkIcon: failed");
- }
- }
-
- return result;
- }
-
- /**
- * 设置MIUI6+的状态栏是否为darkMode,darkMode时候字体颜色及icon变黑
- * http://dev.xiaomi.com/doc/p=4769/
- */
- public static boolean darkModeForMIUI6(Window window, boolean darkmode) {
- Class extends Window> clazz = window.getClass();
- try {
- int darkModeFlag = 0;
- Class> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
- Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
- darkModeFlag = field.getInt(layoutParams);
- Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
- extraFlagField.invoke(window, darkmode ? darkModeFlag : 0, darkModeFlag);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- /** 判断是否Flyme4以上 */
- public static boolean isFlyme4Later() {
- return Build.FINGERPRINT.contains("Flyme_OS_4")
- || Build.VERSION.INCREMENTAL.contains("Flyme_OS_4")
- || Pattern.compile("Flyme OS [4|5]", Pattern.CASE_INSENSITIVE).matcher(Build.DISPLAY).find();
- }
-
- /** 判断是否为MIUI6以上 */
- public static boolean isMIUI6Later() {
- try {
- Class> clz = Class.forName("android.os.SystemProperties");
- Method mtd = clz.getMethod("get", String.class);
- String val = (String) mtd.invoke(null, "ro.miui.ui.version.name");
- val = val.replaceAll("[vV]", "");
- int version = Integer.parseInt(val);
- return version >= 6;
- } catch (Exception e) {
- return false;
- }
- }
- //
-
-
- /** 增加View的paddingTop,增加的值为状态栏高度 */
- public static void setPadding(Context context, View view) {
- if (Build.VERSION.SDK_INT >= MIN_API) {
- view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context),
- view.getPaddingRight(), view.getPaddingBottom());
- }
- }
- /** 增加View的paddingTop,增加的值为状态栏高度 (智能判断,并设置高度)*/
- public static void setPaddingSmart(Context context, View view) {
- if (Build.VERSION.SDK_INT >= MIN_API) {
- ViewGroup.LayoutParams lp = view.getLayoutParams();
- if (lp != null && lp.height > 0) {
- lp.height += getStatusBarHeight(context);//增高
- }
- view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context),
- view.getPaddingRight(), view.getPaddingBottom());
- }
- }
-
- /** 增加View的高度以及paddingTop,增加的值为状态栏高度.一般是在沉浸式全屏给ToolBar用的 */
- public static void setHeightAndPadding(Context context, View view) {
- if (Build.VERSION.SDK_INT >= MIN_API) {
- ViewGroup.LayoutParams lp = view.getLayoutParams();
- lp.height += getStatusBarHeight(context);//增高
- view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context),
- view.getPaddingRight(), view.getPaddingBottom());
- }
- }
- /** 增加View上边距(MarginTop)一般是给高度为 WARP_CONTENT 的小控件用的*/
- public static void setMargin(Context context, View view) {
- if (Build.VERSION.SDK_INT >= MIN_API) {
- ViewGroup.LayoutParams lp = view.getLayoutParams();
- if (lp instanceof ViewGroup.MarginLayoutParams) {
- ((ViewGroup.MarginLayoutParams) lp).topMargin += getStatusBarHeight(context);//增高
- }
- view.setLayoutParams(lp);
- }
- }
- /**
- * 创建假的透明栏
- */
- public static void setTranslucentView(ViewGroup container, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
- if (Build.VERSION.SDK_INT >= 19) {
- int mixtureColor = mixtureColor(color, alpha);
- View translucentView = container.findViewById(android.R.id.custom);
- if (translucentView == null && mixtureColor != 0) {
- translucentView = new View(container.getContext());
- translucentView.setId(android.R.id.custom);
- ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(container.getContext()));
- container.addView(translucentView, lp);
- }
- if (translucentView != null) {
- translucentView.setBackgroundColor(mixtureColor);
- }
- }
- }
-
- public static int mixtureColor(int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
- int a = (color & 0xff000000) == 0 ? 0xff : color >>> 24;
- return (color & 0x00ffffff) | (((int) (a * alpha)) << 24);
- }
-
- /** 获取状态栏高度 */
- public static int getStatusBarHeight(Context context) {
- int result = 24;
- int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
- if (resId > 0) {
- result = context.getResources().getDimensionPixelSize(resId);
- } else {
- result = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
- result, Resources.getSystem().getDisplayMetrics());
- }
- return result;
- }
-}
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
deleted file mode 100644
index c7bd21dbd86990cde81fea8abd3bf904b4546749..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml
deleted file mode 100644
index ae6a44683c24c10c770bda4f5dc6fe8040d55e9c..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml
deleted file mode 100644
index 0c36320fd1e7faeb01085d2d193b82086469de0f..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/ic_home_black_24dp.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
deleted file mode 100644
index d5fccc538c179838bfdce779c26eebb4fa0b5ce9..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/ic_launcher_background.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml
deleted file mode 100644
index 02623821ced621af6ccb29e2cf579d967e8cf147..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/ic_notifications_black_24dp.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/app/src/main/res/drawable/primary_button.xml b/app/src/main/res/drawable/primary_button.xml
deleted file mode 100644
index d0e7daf319dc077d59e6599ec0562296f761f882..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/primary_button.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
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 901008d1bb5fe5f1a7568aa63152683db012888f..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_user_login.xml b/app/src/main/res/layout/activity_user_login.xml
deleted file mode 100644
index 95d8a75aedc828de480d5d4a360a58ecfb6789e4..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_user_login.xml
+++ /dev/null
@@ -1,204 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/fragment_wave_console.xml b/app/src/main/res/layout/fragment_wave_console.xml
deleted file mode 100644
index 24acc4673768cb70ac73cb4c892d6453d8fd83d7..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/fragment_wave_console.xml
+++ /dev/null
@@ -1,207 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/menu/navigation.xml b/app/src/main/res/menu/navigation.xml
deleted file mode 100644
index f4de4f8c2327046fa2b6145051425d6c70ecafcc..0000000000000000000000000000000000000000
--- a/app/src/main/res/menu/navigation.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
deleted file mode 100644
index eca70cfe52eac1ba66ba280a68ca7be8fcf88a16..0000000000000000000000000000000000000000
--- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
deleted file mode 100644
index eca70cfe52eac1ba66ba280a68ca7be8fcf88a16..0000000000000000000000000000000000000000
--- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
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 a2f5908281d070150700378b64a84c7db1f97aa1..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-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 1b523998081149a985cef0cdf89045b9ed29964a..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.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 ff10afd6e182edb2b1a63c8f984e9070d9f950ba..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-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index 115a4c768a20c9e13185c17043f4c4d12dd4632a..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index dcd3cd8083358269d6ed7894726283bb9bcbbfea..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 459ca609d3ae0d3943ab44cdc27feef9256dc6d7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.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 8ca12fe024be86e868d14e91120a6902f8e88ac6..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/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index 8e19b410a1b15ff180f3dacac19395fe3046cdec..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.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 b824ebdd48db917eea2e67a82260a100371f8a24..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index 4c19a13c239cb67b8a2134ddd5f325db1d2d5bee..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 8a66230b16ea415b4ba6ffa937646e9c7bc10012..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
- #056CD0
- #95ABBF
- #025BC0
- #167DE1
- #FF4081
-
- #FFFFFF
- #000000
- #00000000
-
- #FF0000
- #00FF00
- #0000FF
-
- #FFFF00
- #ff6200
- #FF87EF
- #AA00EF
-
- #444444
- #666666
- #7c7c7c
- #acacac
- #ebebeb
-
- #FFFFFF
- #f2f2f2
- #dedede
-
- #333333
- #444444
- #777777
- #999999
-
- #FFFFFF
- #444444
- #FFFFFF
-
- #EE4444
- #CC3333
- #FF5555
-
-
-
-
- #3198F2
- #2187E1
- #42A9FF
-
- #1bc98e
- #18ab79
- #5fd9b0
-
- #e4d836
- #c6bc31
- #ece472
-
- #EE8822
- #DD7711
- #FF9933
-
- #EE7777
- #DD6666
- #FF8888
-
- #8A6DE9
- #795CD8
- #9B7EFA
-
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 56121eed874d5b9acbb3585a1b8446e9802ca1e9..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- 16dp
- 16dp
-
- 10dp
- 16dp
- 10dp
- 5dp
- 25dp
-
- 45dp
-
- 0.5dp
- 20dp
-
- 14sp
- 16sp
-
-
-
-
-
-
-
-
- 10sp
- 12sp
- 14sp
- 15sp
- 17sp
- 19sp
- 18sp
-
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index ae04e2321e38a59a407f5118bde788b611aa30eb..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
- MultiWaveHeader
- Home
- Dashboard
- Notifications
-
-
- 忘记密码?
- 登 录
- 游客模式
- 验证码模式
- 请输入密码
- 密码模式
- 获取验证码
- 输入手机号码
-
-
- Hello blank fragment
- Wave Console
- Toggle:
- up side down
- running
- Shape:
- rect
- roundRect
- oval
- Number:
- Wave:
- Angle:
- Alpha:
- Velocity:
- Progress:
- StartColor:
- CloseColor:
-
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index bdae43e4337b192ae1d695447af2a9c2440b5eaf..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/test/java/com/scwang/wave/ExampleUnitTest.kt b/app/src/test/java/com/scwang/wave/ExampleUnitTest.kt
deleted file mode 100644
index 5e853b71b5db7dfee88d17163ba44f6481d94178..0000000000000000000000000000000000000000
--- a/app/src/test/java/com/scwang/wave/ExampleUnitTest.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.scwang.wave
-
-import org.junit.Test
-
-import org.junit.Assert.*
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-class ExampleUnitTest {
- @Test
- fun addition_isCorrect() {
- assertEquals(4, 2 + 2)
- }
-}
diff --git a/bintrayUpload.bat b/bintrayUpload.bat
deleted file mode 100644
index 375c8f6fd65d41def14c3398c80f3881a3c025ff..0000000000000000000000000000000000000000
--- a/bintrayUpload.bat
+++ /dev/null
@@ -1 +0,0 @@
-gradlew clean build bintrayUpload -PdryRun=false
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 35cec7f6cfe12e05692b5ef4ea9abf83350dc465..8ad5f91713db2573b3471ca814476b290374188b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,63 +1,37 @@
// 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 {
- ext.kotlin_version = '1.3.41'
repositories {
- google()
- jcenter()
+ 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 "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- classpath 'com.novoda:bintray-release:0.9.1'
+ classpath 'com.huawei.ohos:hap:2.4.5.0'
+ classpath 'com.huawei.ohos:decctest:1.2.4.1'
}
}
allprojects {
repositories {
- google()
- jcenter()
- }
- tasks.withType(Javadoc) {
- options {
- encoding "UTF-8"
- charSet 'UTF-8'
- links "http://docs.oracle.com/javase/7/docs/api"
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
}
}
}
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
-
-
-def file = 'local.properties'
-if (new File(file).exists()) {
- Properties properties = new Properties()
- properties.load(new FileInputStream(file))
- if ('true' == properties['bintray.enable']) {
- subprojects {
- if (name == ("library")) {
- afterEvaluate {
- publish {
- groupId = group
- desc = description
- publishVersion = version
- artifactId = SMART_ARTIFACT
- userOrg = properties['bintray.user']
- bintrayKey = properties['bintray.key']
- bintrayUser = properties['bintray.user']
- dryRun = properties['bintray.dryRun'] ?: 'false'
- website = "https://github.com/scwang90/${rootProject.name}"
- }
- }
- apply plugin: 'com.novoda.bintray-release'
- }
- }
-
- }
-}
\ No newline at end of file
diff --git a/app/.gitignore b/entry/.gitignore
similarity index 53%
rename from app/.gitignore
rename to entry/.gitignore
index 4877b1290d404e9f074b1c40b18d17d1425d93e1..796b96d1c402326528b4ba3c12ee9d92d0e212e9 100644
--- a/app/.gitignore
+++ b/entry/.gitignore
@@ -1,2 +1 @@
/build
-/*.iml
\ No newline at end of file
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..37ada361216dca0ebbfbdfa428a27b6fd3a9841b
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,29 @@
+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'
+ implementation project(':library')
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200'
+ implementation 'io.openharmony.tpc.thirdlib:discreteSeekBar:1.0.1'
+}
+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..53f61caa19c3e7eda70840dd097b0b65bd1bae52
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,64 @@
+{
+ "app": {
+ "bundleName": "com.scwang.wave.app",
+ "vendor": "scwang",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.scwang.wave.app",
+ "name": ".MyApplication",
+ "mainAbility": "com.scwang.wave.app.MainAbility",
+ "metaData": {
+ "customizeData": [
+ {
+ "name": "hwc-theme",
+ "value": "androidhwext:style/Theme.Emui.NoTitleBar",
+ "extra": ""
+ }
+ ]
+ },
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.scwang.wave.app.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:entry_MainAbility",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.scwang.wave.app.FractionAbility",
+ "icon": "$media:icon",
+ "description": "$string:fractionability_description",
+ "label": "$string:entry_FractionAbility",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/scwang/wave/app/FractionAbility.java b/entry/src/main/java/com/scwang/wave/app/FractionAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..b93787e21d2b723b47ec93c7b22c78a1d51c010c
--- /dev/null
+++ b/entry/src/main/java/com/scwang/wave/app/FractionAbility.java
@@ -0,0 +1,179 @@
+package com.scwang.wave.app;
+
+import com.scwang.wave.*;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.*;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.utils.Color;
+import ohos.agp.window.service.WindowManager;
+
+import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class FractionAbility extends Ability implements DiscreteSeekBar.OnProgressChangeListener {
+ private MultiWaveHeader multiWaveHeader;
+ private DiscreteSeekBar seekAngle;
+ private DiscreteSeekBar seekVelocity;
+ private DiscreteSeekBar seekAlpha;
+ private DiscreteSeekBar seekProgress;
+ private DiscreteSeekBar seekWave;
+ private DiscreteSeekBar seekNumber;
+ private Checkbox checkBoxRunning;
+ private Checkbox checkBoxDirection;
+ private RadioContainer radioContainer;
+ private RadioButton radioButton;
+ private ColorSeekBar startSeekBar;
+ private ColorSeekBar closeSeekBar;
+ private Component headerLayout;
+ private ShapeElement element = new ShapeElement();
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ setUIContent(ResourceTable.Layout_ability_fraction);
+
+ getWindow().addFlags(WindowManager.LayoutConfig.MARK_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ getWindow().clearFlags(WindowManager.LayoutConfig.MARK_TRANSLUCENT_STATUS);
+ getWindow().addFlags(WindowManager.LayoutConfig.MARK_TRANSLUCENT_NAVIGATION);
+ getWindow().setStatusBarColor(Color.TRANSPARENT.getValue());
+
+ initComponent();
+
+ radioButton.setChecked(true);
+ checkBoxRunning.setChecked(true);
+ seekWave.setOnProgressChangeListener(this);
+ seekAngle.setOnProgressChangeListener(this);
+ seekVelocity.setOnProgressChangeListener(this);
+ seekProgress.setOnProgressChangeListener(this);
+ seekAlpha.setOnProgressChangeListener(this);
+ seekNumber.setOnProgressChangeListener(this);
+
+ findComponentById(ResourceTable.Id_back).setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ onBackPressed();
+ }
+ });
+ checkBoxRunning.setCheckedStateChangedListener(new AbsButton.CheckedStateChangedListener() {
+ @Override
+ public void onCheckedChanged(AbsButton absButton, boolean isCheck) {
+ if (isCheck) {
+ multiWaveHeader.start();
+ } else {
+ multiWaveHeader.stop();
+ }
+ }
+ });
+
+ checkBoxDirection.setCheckedStateChangedListener(new AbsButton.CheckedStateChangedListener() {
+ @Override
+ public void onCheckedChanged(AbsButton absButton, boolean b) {
+ if (b) {
+ element.setRgbColor(new RgbColor(0,109,208));
+ headerLayout.setBackground(element);
+ multiWaveHeader.setRotation(180);
+ } else {
+ element.setRgbColor(new RgbColor(0,0,0,0));
+ headerLayout.setBackground(element);
+ multiWaveHeader.setRotation(0);
+ }
+ }
+ });
+
+ radioContainer.setMarkChangedListener(new RadioContainer.CheckedStateChangedListener() {
+ @Override
+ public void onCheckedChanged(RadioContainer radio, int i) {
+ switch (i) {
+ case 1:
+ multiWaveHeader.setShape(ShapeType.Rect);
+ break;
+ case 2:
+ multiWaveHeader.setShape(ShapeType.RoundRect);
+ break;
+ case 3:
+ multiWaveHeader.setShape(ShapeType.Oval);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ startSeekBar.setSeekBarColorChange(new SeekBarColorChange() {
+ @Override
+ public void colorChange(Color color, int colorValue) {
+ multiWaveHeader.setStartColor(colorValue);
+ }
+ });
+
+ closeSeekBar.setSeekBarColorChange(new SeekBarColorChange() {
+ @Override
+ public void colorChange(Color color, int colorValue) {
+ multiWaveHeader.setCloseColor(colorValue);
+ }
+ });
+ }
+
+ private void initComponent() {
+ seekAngle = (DiscreteSeekBar) findComponentById(ResourceTable.Id_seekAngle);
+ seekNumber = (DiscreteSeekBar) findComponentById(ResourceTable.Id_seekNumber);
+ seekVelocity = (DiscreteSeekBar) findComponentById(ResourceTable.Id_seekVelocity);
+ seekAlpha = (DiscreteSeekBar) findComponentById(ResourceTable.Id_seekAlpha);
+ seekProgress = (DiscreteSeekBar) findComponentById(ResourceTable.Id_seekProgress);
+ seekWave = (DiscreteSeekBar) findComponentById(ResourceTable.Id_seekWave);
+ checkBoxRunning = (Checkbox) findComponentById(ResourceTable.Id_checkBoxRunning);
+ checkBoxDirection = (Checkbox) findComponentById(ResourceTable.Id_checkBoxDirection);
+ multiWaveHeader = (MultiWaveHeader) findComponentById(ResourceTable.Id_multiWaveHeader);
+ radioContainer = (RadioContainer) findComponentById(ResourceTable.Id_radioGroup);
+ startSeekBar = (ColorSeekBar) findComponentById(ResourceTable.Id_sliderStartColor);
+ closeSeekBar = (ColorSeekBar) findComponentById(ResourceTable.Id_sliderCloseColor);
+ radioButton = (RadioButton) findComponentById(ResourceTable.Id_radioRect);
+ headerLayout = findComponentById(ResourceTable.Id_header_layout);
+ }
+
+ @Override
+ public void onProgressChanged(DiscreteSeekBar discreteSeekBar, int i, boolean b) {
+ if (discreteSeekBar.getId() == seekProgress.getId()) {
+ multiWaveHeader.setProgress(1f * i / 100);
+ } else if (discreteSeekBar.getId() == seekVelocity.getId()) {
+ multiWaveHeader.setVelocity(1f * i / 10);
+ } else if (discreteSeekBar.getId() == seekAlpha.getId()) {
+ multiWaveHeader.setColorAlpha(1f * i / 100);
+ } else if (discreteSeekBar.getId() == seekAngle.getId()) {
+ multiWaveHeader.setGradientAngle(i);
+ }
+ }
+
+ @Override
+ public void onStartTrackingTouch(DiscreteSeekBar discreteSeekBar) {
+ }
+
+ @Override
+ public void onStopTrackingTouch(DiscreteSeekBar seekBar) {
+ if (seekWave.getId() == seekBar.getId()) {
+ multiWaveHeader.setWaveHeight(seekBar.getProgress());
+ } else if (seekNumber.getId() == seekBar.getId()) {
+ if (seekBar.getProgress() == 2) {
+ multiWaveHeader.setWaves("0,0,1,1,25" + System.lineSeparator() + "90,0,1,1,25");
+ } else {
+ List waves = Arrays.asList(("70,25,1.4,1.4,-26" + System.lineSeparator()
+ + "100,5,1.4,1.2,15" + System.lineSeparator()
+ + "420,0,1.15,1,-10" + System.lineSeparator()
+ + "520,10,1.7,1.5,20" + System.lineSeparator()
+ + "220,0,1,1,-15").split(System.lineSeparator()));
+ List strings = waves.subList(0, seekBar.getProgress());
+ StringBuffer stringBuffer = new StringBuffer();
+ for (int i = 0; i < strings.size(); i++) {
+ stringBuffer.append(strings.get(i) + System.lineSeparator());
+ }
+ multiWaveHeader.setWaves(stringBuffer.toString());
+ }
+ }
+ }
+}
diff --git a/entry/src/main/java/com/scwang/wave/app/MainAbility.java b/entry/src/main/java/com/scwang/wave/app/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..5bc0641a73cabb5b10667afa18b9f21439056a5c
--- /dev/null
+++ b/entry/src/main/java/com/scwang/wave/app/MainAbility.java
@@ -0,0 +1,40 @@
+package com.scwang.wave.app;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.Operation;
+import ohos.agp.components.Component;
+import ohos.agp.components.Text;
+import ohos.agp.utils.Color;
+import ohos.agp.window.service.WindowManager;
+
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ setUIContent(ResourceTable.Layout_ability_main);
+ getWindow().addFlags(WindowManager.LayoutConfig.MARK_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ getWindow().clearFlags(WindowManager.LayoutConfig.MARK_TRANSLUCENT_STATUS);
+ getWindow().addFlags(WindowManager.LayoutConfig.MARK_TRANSLUCENT_NAVIGATION);
+ getWindow().setStatusBarColor(Color.TRANSPARENT.getValue());
+
+ Text login = (Text) findComponentById(ResourceTable.Id_login);
+ login.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ start();
+ }
+ });
+ }
+
+ private void start() {
+ Intent intent = new Intent();
+ Operation operation = new Intent.OperationBuilder()
+ .withDeviceId("")
+ .withBundleName(getBundleName())
+ .withAbilityName("com.scwang.wave.app.FractionAbility")
+ .build();
+ intent.setOperation(operation);
+ startAbility(intent);
+ }
+}
diff --git a/entry/src/main/java/com/scwang/wave/app/MyApplication.java b/entry/src/main/java/com/scwang/wave/app/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..cd60d28759eae2c96081f884331b9fedc31793a2
--- /dev/null
+++ b/entry/src/main/java/com/scwang/wave/app/MyApplication.java
@@ -0,0 +1,10 @@
+package com.scwang.wave.app;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
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..da7ca48aff3447dbf13ff0acdf11a36f25cca444
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,40 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "fractionability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "fractionability_HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "entry_FractionAbility",
+ "value": "entry_FractionAbility"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_fraction.xml b/entry/src/main/resources/base/graphic/background_ability_fraction.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a002c2353e78af3a15235e00738328ff566bc085
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_fraction.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ 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_ability_main2.xml b/entry/src/main/resources/base/graphic/background_ability_main2.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a002c2353e78af3a15235e00738328ff566bc085
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main2.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/checkbox_check_element.xml b/entry/src/main/resources/base/graphic/checkbox_check_element.xml
new file mode 100644
index 0000000000000000000000000000000000000000..48fb95d811fc68974f5ab03919d6d3fec8e38163
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/checkbox_check_element.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/primary_button.xml b/entry/src/main/resources/base/graphic/primary_button.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f732ae6a78901ee69acb1d1f05f9f5a15b756900
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/primary_button.xml
@@ -0,0 +1,37 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/radio_check_element.xml b/entry/src/main/resources/base/graphic/radio_check_element.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e62d2abd9ccdd5179df5565271101398bd16538f
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/radio_check_element.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_fraction.xml b/entry/src/main/resources/base/layout/ability_fraction.xml
new file mode 100644
index 0000000000000000000000000000000000000000..bfd0fddeeec27a900f04fc3044e6fead82151c65
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_fraction.xml
@@ -0,0 +1,344 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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..f4b579490b9a7cd72eec6e8eae9a49fbb5c50caa
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/media/back.png b/entry/src/main/resources/base/media/back.png
new file mode 100644
index 0000000000000000000000000000000000000000..0d2f58b3d4fb5813d740da1e2609126fb8ff1330
Binary files /dev/null and b/entry/src/main/resources/base/media/back.png differ
diff --git a/entry/src/main/resources/base/media/checkbox_false.png b/entry/src/main/resources/base/media/checkbox_false.png
new file mode 100644
index 0000000000000000000000000000000000000000..6a4de2f698ab3a5769b5af3dfbb0a7eb601b16b0
Binary files /dev/null and b/entry/src/main/resources/base/media/checkbox_false.png differ
diff --git a/entry/src/main/resources/base/media/checkbox_true.png b/entry/src/main/resources/base/media/checkbox_true.png
new file mode 100644
index 0000000000000000000000000000000000000000..f34e15e201c6f3fafe7bd70084aaa32271fe4fab
Binary files /dev/null and b/entry/src/main/resources/base/media/checkbox_true.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_account.png b/entry/src/main/resources/base/media/ic_login_account.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_account.png
rename to entry/src/main/resources/base/media/ic_login_account.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_delete.png b/entry/src/main/resources/base/media/ic_login_delete.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_delete.png
rename to entry/src/main/resources/base/media/ic_login_delete.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_logo.png b/entry/src/main/resources/base/media/ic_login_logo.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_logo.png
rename to entry/src/main/resources/base/media/ic_login_logo.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_password.png b/entry/src/main/resources/base/media/ic_login_password.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_password.png
rename to entry/src/main/resources/base/media/ic_login_password.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_passwordpattern.png b/entry/src/main/resources/base/media/ic_login_passwordpattern.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_passwordpattern.png
rename to entry/src/main/resources/base/media/ic_login_passwordpattern.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_phone.png b/entry/src/main/resources/base/media/ic_login_phone.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_phone.png
rename to entry/src/main/resources/base/media/ic_login_phone.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_tourist.png b/entry/src/main/resources/base/media/ic_login_tourist.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_tourist.png
rename to entry/src/main/resources/base/media/ic_login_tourist.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_login_verification.png b/entry/src/main/resources/base/media/ic_login_verification.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_login_verification.png
rename to entry/src/main/resources/base/media/ic_login_verification.png
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/entry/src/main/resources/base/media/radio_false.png b/entry/src/main/resources/base/media/radio_false.png
new file mode 100644
index 0000000000000000000000000000000000000000..33ee593912ebfa449026c74a02b50d561b325c79
Binary files /dev/null and b/entry/src/main/resources/base/media/radio_false.png differ
diff --git a/entry/src/main/resources/base/media/radio_true.png b/entry/src/main/resources/base/media/radio_true.png
new file mode 100644
index 0000000000000000000000000000000000000000..0d987275a6aa987aa10c27a6f088d402124d6a92
Binary files /dev/null and b/entry/src/main/resources/base/media/radio_true.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..09c71e859d717cd6a3868a23a85aa43b5de1f38d
--- /dev/null
+++ b/entry/src/main/resources/en/element/string.json
@@ -0,0 +1,40 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "entry_FractionAbility",
+ "value": "entry_FractionAbility"
+ },
+ {
+ "name": "fractionability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "fractionability_HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
\ No newline at end of file
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..39311b0d24db957ac5d910306890b9dae4a5c86f
--- /dev/null
+++ b/entry/src/main/resources/zh/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "MultiWaveHeader"
+ },
+ {
+ "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/scwang/wave/app/ExampleOhosTest.java b/entry/src/ohosTest/java/com/scwang/wave/app/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..82db85efb6b8e7d9ffaef2b49e3361ce83ce99bf
--- /dev/null
+++ b/entry/src/ohosTest/java/com/scwang/wave/app/ExampleOhosTest.java
@@ -0,0 +1,15 @@
+package com.scwang.wave.app;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ // entry下需要context,无法进行单元测试
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.scwang.wave.app", actualBundleName);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/scwang/wave/app/ExampleTest.java b/entry/src/test/java/com/scwang/wave/app/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..17224df72a42f5525a13f72d7313ddfb49483adc
--- /dev/null
+++ b/entry/src/test/java/com/scwang/wave/app/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.scwang.wave.app;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index 67c4ebba7c0a890e82d570a77dfb84f68fab8268..0000000000000000000000000000000000000000
--- a/gradle.properties
+++ /dev/null
@@ -1,21 +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.
-org.gradle.jvmargs=-Xmx1536m
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-
-SMART_GROUP=com.scwang.wave
-SMART_ARTIFACT=MultiWaveHeader
-SMART_VERSION=1.0.0
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372aef5e24af05341d49695ee84e5f9b594659..0000000000000000000000000000000000000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index ef3e366867bf2d78e331584d6670ffa6be045e6f..0000000000000000000000000000000000000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Sun Apr 15 02:38:53 CST 2018
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-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/MultiWaveHeader.gif b/img/MultiWaveHeader.gif
new file mode 100644
index 0000000000000000000000000000000000000000..8c6794d7e046a709a4b258e451a707588b036661
Binary files /dev/null and b/img/MultiWaveHeader.gif differ
diff --git a/library/build.gradle b/library/build.gradle
index 976ae869954392b918266b122c06c341f6330ad7..b295dedf89429c60e5a3c99f29b0f62476526c36 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,23 +1,16 @@
-apply plugin: 'com.android.library'
-apply plugin: 'maven'
-
-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 12
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
-
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
+ compatibleSdkVersion 5
}
-
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
@@ -25,23 +18,5 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
-
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
-
- compileOnly 'com.android.support:appcompat-v7:28.0.0'
+ testImplementation 'junit:junit:4.13'
}
-
-
-group = SMART_GROUP
-version = SMART_VERSION
-description = 'A wave view of android'
-
-uploadArchives {
- repositories.mavenDeployer {
- repository(url: uri('../repo'))
- pom.artifactId = SMART_ARTIFACT
- }
-}
-
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 f1b424510da51fd82143bc74a0a801ae5a1e2fcd..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/library/proguard-rules.pro
+++ b/library/proguard-rules.pro
@@ -1,21 +1 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# 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 *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/library/src/main/config.json b/library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..6db74c78598f858843c10bd1f7c919e7b9771508
--- /dev/null
+++ b/library/src/main/config.json
@@ -0,0 +1,23 @@
+{
+ "app": {
+ "bundleName": "com.scwang.wave.app",
+ "vendor": "scwang",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.scwang.wave",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/scwang/wave/ColorRes.java b/library/src/main/java/com/scwang/wave/ColorRes.java
new file mode 100644
index 0000000000000000000000000000000000000000..3da7db60fd7f970aff22a089ec8174d604283897
--- /dev/null
+++ b/library/src/main/java/com/scwang/wave/ColorRes.java
@@ -0,0 +1,14 @@
+package com.scwang.wave;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义注解
+ *
+ * @since 2021-07-05
+ */
+@Documented
+@Retention(RetentionPolicy.CLASS)
+@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.LOCAL_VARIABLE})
+public @interface ColorRes {
+}
diff --git a/library/src/main/java/com/scwang/wave/ColorSeekBar.java b/library/src/main/java/com/scwang/wave/ColorSeekBar.java
new file mode 100644
index 0000000000000000000000000000000000000000..5e847617b425d031a99fc5f54f72850708287d1c
--- /dev/null
+++ b/library/src/main/java/com/scwang/wave/ColorSeekBar.java
@@ -0,0 +1,195 @@
+/*
+ * 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.scwang.wave;
+
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Circle;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
+import ohos.multimodalinput.event.MmiPoint;
+import ohos.multimodalinput.event.TouchEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 自定义滑动分色块seekbar
+ *
+ * @since 2021-07-05
+ */
+public class ColorSeekBar extends Component implements Component.TouchEventListener, Component.DrawTask {
+ private TypedArray typedArray;
+ private List colorList = new ArrayList<>();
+ private float progress;
+ private int progressHeight;
+ private Paint paint = new Paint();
+ private boolean isNeedCenter = true;
+ private SeekBarColorChange seekBarColorChange;
+ private int inwardCircle;
+ private int externalCircle;
+ private Circle circle = new Circle(0, 0, 0);
+ private boolean isTouch = false;
+ private float itemWidth;
+ protected float leftPadding;
+ protected float rightPadding;
+
+ /**
+ * Java代码实例化调用
+ *
+ * @param context
+ */
+ public ColorSeekBar(Context context) {
+ super(context);
+ }
+
+ /**
+ * xml代码实例化调用
+ *
+ * @param context
+ * @param attrSet
+ */
+ public ColorSeekBar(Context context, AttrSet attrSet) {
+ super(context, attrSet);
+ initView(context, attrSet);
+ }
+
+ public void setSeekBarColorChange(SeekBarColorChange seekBarColorChange) {
+ this.seekBarColorChange = seekBarColorChange;
+ }
+
+ private void initView(Context context, AttrSet attrSet) {
+ typedArray = new TypedArray(attrSet);
+
+ // 初始进度值 1-100
+ progress = typedArray.getFloat("zf_progress", 10f);
+
+ // 横向颜色块的高度
+ progressHeight = typedArray.getDimensionValue("zf_progressHeight", 10);
+
+ // 内部纯色园的半径
+ inwardCircle = typedArray.getDimensionValue("zf_inwardCircle", 30);
+
+ // 外部透明色园的半径
+ externalCircle = typedArray.getDimensionValue("zf_externalCircle", 40);
+ isNeedCenter = typedArray.getBoolean("zf_isNeedCenter", false);
+
+ // 右侧内间距
+ rightPadding = typedArray.getDimensionValue("zf_padding_right", 0);
+
+ // 左侧内间距
+ leftPadding = typedArray.getDimensionValue("zf_padding_left", 0);
+
+ // 颜色字符串 使用,拼接 例如"#111111,#F00F00,#FFFFFF"
+ String colors = typedArray.getString("zf_colors");
+ if (colors == null) {
+ colors = "#111111,#F00F00";
+ }
+ String[] strings = colors.split(",");
+ for (int i = 0; i < strings.length; i++) {
+ colorList.add(new Color(Color.getIntColor(strings[i])));
+ }
+
+ paint.setAntiAlias(true);
+ paint.setStyle(Paint.Style.FILL_STYLE);
+ paint.setStrokeWidth(progressHeight);
+ setTouchEventListener(this::onTouchEvent);
+ addDrawTask(this::onDraw);
+ }
+
+ @Override
+ public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
+ isTouch = true;
+ MmiPoint point = touchEvent.getPointerPosition(touchEvent.getIndex());
+
+ // 1080/100=10.8
+ int width = getWidth();
+ float eachWidth = (getWidth() - rightPadding - leftPadding) / 100;
+ switch (touchEvent.getAction()) {
+ case TouchEvent.PRIMARY_POINT_DOWN:
+ isNeedCenter = false;
+ float downX = point.getX();
+
+ // 540/10.8 = 50
+ float v = downX / eachWidth;
+ progress = (int) v;
+ invalidate();
+ return true;
+ case TouchEvent.POINT_MOVE:
+ float moveX = point.getX();
+ if (moveX < inwardCircle) {
+ moveX = inwardCircle;
+ } else if (moveX > getWidth() - rightPadding - leftPadding) {
+ moveX = getWidth() - rightPadding - leftPadding - 5;
+ }
+ float v1 = moveX / eachWidth;
+ progress = (int) v1;
+ invalidate();
+ break;
+ case TouchEvent.PRIMARY_POINT_UP:
+ isNeedCenter = true;
+ invalidate();
+ break;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ canvas.translate(leftPadding, 0);
+ float width = getWidth() - rightPadding - leftPadding;
+ int height = getHeight();
+ // 每个色块的长度
+ itemWidth = width / colorList.size();
+
+ for (int i1 = 0; i1 < colorList.size(); i1++) {
+ paint.setColor(colorList.get(i1));
+ canvas.drawRect(new RectFloat(i1 * itemWidth, (height - progressHeight) / 2, (i1 + 1) * itemWidth, (height - progressHeight) / 2 + progressHeight), paint);
+ }
+
+ float eachWidth = width / 100;
+ float nowProgress = eachWidth * progress;
+ float i = nowProgress / itemWidth;
+ if (i > 0 && i < colorList.size()) {
+ paint.setColor(colorList.get((int) Math.floor(i)));
+ if (isNeedCenter) {
+ float v = (float) (Math.floor(i) * itemWidth + itemWidth / 2);
+ circle.set(v, height / 2, inwardCircle);
+ canvas.drawCircle(circle, paint);
+ paint.setAlpha(0.3f);
+ circle.set(v, height / 2, externalCircle);
+ canvas.drawCircle(circle, paint);
+ } else {
+ float v = (float) (Math.floor(i) * itemWidth + (i - Math.floor(i)) * itemWidth);
+ circle.set(v, height / 2, inwardCircle);
+ canvas.drawCircle(circle, paint);
+ paint.setAlpha(0.3f);
+ circle.set(v, height / 2, externalCircle);
+ canvas.drawCircle(circle, paint);
+ }
+ if (seekBarColorChange != null && isTouch) {
+ int floor = (int) Math.floor(i);
+ Color color = colorList.get(floor);
+ seekBarColorChange.colorChange(color, color.getValue());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/scwang/wave/IntRange.java b/library/src/main/java/com/scwang/wave/IntRange.java
new file mode 100644
index 0000000000000000000000000000000000000000..208ef813e32e023e17b7070a69d32c641bcc86fb
--- /dev/null
+++ b/library/src/main/java/com/scwang/wave/IntRange.java
@@ -0,0 +1,30 @@
+package com.scwang.wave;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 自定义注解
+ *
+ * @since 2021-07-05
+ */
+@Retention(RetentionPolicy.CLASS)
+@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD,
+ ElementType.LOCAL_VARIABLE, ElementType.ANNOTATION_TYPE})
+public @interface IntRange {
+ /**
+ * 自定义注解
+ *
+ * @return 返回long类型
+ */
+ long from() default -9223372036854775808L;
+
+ /**
+ * 自定义注解
+ *
+ * @return 返回long类型
+ */
+ long to() default 9223372036854775807L;
+}
diff --git a/library/src/main/java/com/scwang/wave/MultiWaveHeader.java b/library/src/main/java/com/scwang/wave/MultiWaveHeader.java
index 7d2e2e621adc722adc11ffee3ad1b07991be14a8..51d5a1f7b01ef0901b4acad95b5a42d50eb9bfb3 100644
--- a/library/src/main/java/com/scwang/wave/MultiWaveHeader.java
+++ b/library/src/main/java/com/scwang/wave/MultiWaveHeader.java
@@ -1,38 +1,27 @@
package com.scwang.wave;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.LinearGradient;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.RectF;
-import android.graphics.Shader;
-import android.support.annotation.ColorRes;
-import android.support.annotation.Nullable;
-import android.support.v4.graphics.ColorUtils;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.render.*;
+import ohos.agp.utils.*;
+import ohos.app.Context;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import static java.lang.Float.parseFloat;
/**
- * 多重水波纹
- * Created by SCWANG on 2017/12/11.
+ * 自定义波形控件
+ *
+ * @since 2021-07-05
*/
-@SuppressWarnings("unused")
-public class MultiWaveHeader extends ViewGroup {
-
+public class MultiWaveHeader extends ComponentContainer implements ComponentContainer.ArrangeListener,
+ Component.EstimateSizeListener, Component.DrawTask {
protected Path mPath;
protected ShapeType mShape = ShapeType.Rect;
protected Paint mPaint = new Paint();
@@ -49,115 +38,136 @@ public class MultiWaveHeader extends ViewGroup {
protected float mColorAlpha;
protected float mProgress;
protected float mCurProgress;
- protected long mLastTime = 0;
- protected ValueAnimator reboundAnimator;
+ protected long mLastTime = 0L;
+ protected AnimatorValue reboundAnimator;
+ private boolean isNeedEstimateSize = true;
+ private boolean isNeedArrange = true;
+ private Point startPoint = new Point();
+ private Point endPoint = new Point();
+ /**
+ * Java代码实例化调用
+ *
+ * @param context
+ */
public MultiWaveHeader(Context context) {
- this(context, null, 0);
+ super(context);
}
- public MultiWaveHeader(Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
+ /**
+ * xml代码实例化调用
+ *
+ * @param context
+ * @param attrSet
+ */
+ public MultiWaveHeader(Context context, AttrSet attrSet) {
+ super(context, attrSet);
+ initView(context, attrSet);
}
- public MultiWaveHeader(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
+ /**
+ * xml添加style调用
+ *
+ * @param context
+ * @param attrSet
+ * @param styleName
+ */
+ public MultiWaveHeader(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ initView(context, attrSet);
+ }
+ private void initView(Context context, AttrSet attrSet) {
mPaint.setAntiAlias(true);
-
- TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MultiWaveHeader);
-
- mWaveHeight = ta.getDimensionPixelOffset(R.styleable.MultiWaveHeader_mwhWaveHeight, Util.dp2px(50));
- mStartColor = ta.getColor(R.styleable.MultiWaveHeader_mwhStartColor, 0xFF056CD0);
- mCloseColor = ta.getColor(R.styleable.MultiWaveHeader_mwhCloseColor, 0xFF31AFFE);
- mColorAlpha = ta.getFloat(R.styleable.MultiWaveHeader_mwhColorAlpha, 0.45f);
- mVelocity = ta.getFloat(R.styleable.MultiWaveHeader_mwhVelocity, 1f);
- mGradientAngle = ta.getInt(R.styleable.MultiWaveHeader_mwhGradientAngle, 45);
- mIsRunning = ta.getBoolean(R.styleable.MultiWaveHeader_mwhIsRunning, true);
- mEnableFullScreen = ta.getBoolean(R.styleable.MultiWaveHeader_mwhEnableFullScreen, false);
- mCornerRadius = ta.getDimensionPixelOffset(R.styleable.MultiWaveHeader_mwhCornerRadius, Util.dp2px(25));
- mShape = ShapeType.values()[ta.getInt(R.styleable.MultiWaveHeader_mwhShape, mShape.ordinal())];
- mProgress = mCurProgress = ta.getFloat(R.styleable.MultiWaveHeader_mwhProgress, 1f);
-
- if (ta.hasValue(R.styleable.MultiWaveHeader_mwhWaves)) {
- setTag(ta.getString(R.styleable.MultiWaveHeader_mwhWaves));
+ TypedArray ta = new TypedArray(attrSet);
+ mWaveHeight = ta.getDimensionValue("mwhWaveHeight", Util.vp2px(50, context));
+ mStartColor = ta.getColor("mwhStartColor", 0xFF056CD0).getValue();
+ mCloseColor = ta.getColor("mwhCloseColor", 0xFF31AFFE).getValue();
+ mColorAlpha = ta.getFloat("mwhColorAlpha", 0.45f);
+ mVelocity = ta.getFloat("mwhVelocity", 1f);
+ mGradientAngle = ta.getInt("mwhGradientAngle", 45);
+ mIsRunning = ta.getBoolean("mwhIsRunning", true);
+ mEnableFullScreen = ta.getBoolean("mwhEnableFullScreen", false);
+ mCornerRadius = ta.getDimensionValue("mwhCornerRadius", Util.vp2px(25, context));
+ mShape = ShapeType.values()[ta.getInt("mwhShape", mShape.ordinal())];
+ mCurProgress = ta.getFloat("mwhProgress", 1f);
+ mProgress = mCurProgress;
+ if (ta.hasValue("mwhWaves")) {
+ setTag(ta.getString("mwhWaves"));
} else if (getTag() == null) {
- setTag("70,25,1.4,1.4,-26\n" +
- "100,5,1.4,1.2,15\n" +
- "420,0,1.15,1,-10\n" +
- "520,10,1.7,1.5,20\n" +
- "220,0,1,1,-15");
+ setTag("70,25,1.4,1.4,-26" + System.lineSeparator()
+ + "100,5,1.4,1.2,15" + System.lineSeparator()
+ + "420,0,1.15,1,-10" + System.lineSeparator()
+ + "520,10,1.7,1.5,20" + System.lineSeparator()
+ + "220,0,1,1,-15");
}
- ta.recycle();
- }
-
-// @Override
-// protected void onFinishInflate() {
-// super.onFinishInflate();
-//
-// int count = getChildCount();
-// if (count > 0) {
-// for (int i = 0; i < count; i++) {
-// View child = getChildAt(i);
-// if (child instanceof Wave) {
-// child.setVisibility(GONE);
-// } else {
-// throw new RuntimeException("只能用Wave作为子视图,You can only use Wave as a subview.");
-// }
-// }
-// }
-// }
+ setArrangeListener(this::onArrange);
+ setEstimateSizeListener(this::onEstimateSize);
+ addDrawTask(this::onDraw);
+ }
@Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- if (mltWave.isEmpty()) {
- updateWavePath();
- updateWavePath(r - l, b - t);
+ public boolean onArrange(int l, int t, int r, int b) {
+ if (isNeedArrange) {
+ if (mltWave.isEmpty()) {
+ updateWavePath();
+ updateWavePath(r - l, b - t);
+ }
+ isNeedArrange = false;
}
+ return false;
}
@Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- updateShapePath();
- updateWavePath(w, h);
- updateLinearGradient(w, h);
+ public void setComponentStateChangedListener(ComponentStateChangedListener listener) {
+ super.setComponentStateChangedListener(listener);
}
@Override
- protected void dispatchDraw(Canvas canvas) {
- super.dispatchDraw(canvas);
- if (mltWave.size() > 0) {
+ public boolean onEstimateSize(int w, int h) {
+ if (isNeedEstimateSize) {
+ int width = EstimateSpec.getSize(w);
+ int height = EstimateSpec.getSize(h);
+ updateShapePath();
+ updateWavePath(width, height);
+ updateLinearGradient(width, height);
+ isNeedEstimateSize = false;
+ }
+ return false;
+ }
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ if (mltWave.size() > 0) {
if (mPath != null) {
canvas.save();
- canvas.clipPath(mPath);
+ canvas.clipPath(mPath, Canvas.ClipOp.INTERSECT);
}
- View thisView = this;
+ Component thisView = this;
int height = thisView.getHeight();
long thisTime = System.currentTimeMillis();
for (Wave wave : mltWave) {
mMatrix.reset();
canvas.save();
if (mIsRunning && mLastTime > 0 && wave.velocity != 0) {
- float offsetX = (wave.offsetX - (wave.velocity * mVelocity * (thisTime - mLastTime) / 1000f));
+ float offsetX = wave.offsetX - wave.velocity * mVelocity * (thisTime - mLastTime) / 1000f;
if (-wave.velocity > 0) {
offsetX %= (float) wave.width / 2;
} else {
while (offsetX < 0) {
- offsetX += ((float)wave.width / 2);
+ offsetX += (float)wave.width / 2;
}
}
wave.offsetX = offsetX;
- mMatrix.setTranslate(offsetX, (1 - mCurProgress) * height);//wave.offsetX =
+ mMatrix.setTranslate(offsetX, (1 - mCurProgress) * height);
canvas.translate(-offsetX, -wave.offsetY - (1 - mCurProgress) * height);
- } else{
+ } else {
mMatrix.setTranslate(wave.offsetX, (1 - mCurProgress) * height);
canvas.translate(-wave.offsetX, -wave.offsetY - (1 - mCurProgress) * height);
}
- mPaint.getShader().setLocalMatrix(mMatrix);
+ mPaint.getShader().setShaderMatrix(mMatrix);
canvas.drawPath(wave.path, mPaint);
canvas.restore();
}
@@ -168,36 +178,53 @@ public class MultiWaveHeader extends ViewGroup {
}
if (mIsRunning) {
- invalidate();
+ getContext().getUITaskDispatcher().asyncDispatch(new Runnable() {
+ @Override
+ public void run() {
+ invalidate();
+ }
+ });
}
}
}
private void updateLinearGradient(int width, int height) {
- int startColor = ColorUtils.setAlphaComponent(mStartColor, (int)(mColorAlpha*255));
- int closeColor = ColorUtils.setAlphaComponent(mCloseColor, (int)(mColorAlpha*255));
- //noinspection UnnecessaryLocalVariable
+ int startColor = setAlphaComponent(mStartColor, (int)(mColorAlpha * 255));
+ int closeColor = setAlphaComponent(mCloseColor, (int)(mColorAlpha * 255));
+
+ // noinspection UnnecessaryLocalVariable
double w = width;
double h = height * mCurProgress;
double r = Math.sqrt(w * w + h * h) / 2;
double y = r * Math.sin(2 * Math.PI * mGradientAngle / 360);
double x = r * Math.cos(2 * Math.PI * mGradientAngle / 360);
- mPaint.setShader(new LinearGradient((int)(w/2-x), (int)(h/2-y), (int)(w/2+x), (int)(h/2+y), startColor, closeColor, Shader.TileMode.CLAMP));
- }
+ // 103,-136
+ startPoint.modify((float) (w / 2 - x), (float) (h / 2 - y));
+ // 976,736
+ endPoint.modify((float) (w / 2 + x), (float) (h / 2 + y));
+ Point[] points = new Point[]{startPoint, endPoint};
+ LinearShader linearShader = new LinearShader(points, new float[]{0}, new Color[]{new Color(startColor), new Color(closeColor)}, Shader.TileMode.CLAMP_TILEMODE);
+ mPaint.setShader(linearShader, Paint.ShaderType.LINEAR_SHADER);
+ }
+ /**
+ * 更新Path路径
+ */
protected void updateShapePath() {
- View thisView = this;
- int w = thisView.getWidth();
- int h = thisView.getHeight();
+ int w = getWidth();
+ int h = getHeight();
if (w > 0 && h > 0 && mShape != null && mShape != ShapeType.Rect) {
mPath = new Path();
switch (mShape) {
case RoundRect:
- mPath.addRoundRect(new RectF(0, 0, w, h), mCornerRadius, mCornerRadius, Path.Direction.CW);
+ mPath.addRoundRect(new RectFloat(0, 0, w, h), mCornerRadius,
+ mCornerRadius, Path.Direction.CLOCK_WISE);
break;
case Oval:
- mPath.addOval(new RectF(0, 0, w, h), Path.Direction.CW);
+ mPath.addOval(new RectFloat(0, 0, w, h), Path.Direction.CLOCK_WISE);
+ break;
+ default:
break;
}
} else {
@@ -205,27 +232,36 @@ public class MultiWaveHeader extends ViewGroup {
}
}
+ /**
+ * 更新波纹路径
+ */
protected void updateWavePath() {
mltWave.clear();
if (getTag() instanceof String) {
String[] waves = getTag().toString().split("\\s+");
if ("-1".equals(getTag())) {
- waves = "70,25,1.4,1.4,-26\n100,5,1.4,1.2,15\n420,0,1.15,1,-10\n520,10,1.7,1.5,20\n220,0,1,1,-15".split("\\s+");
+ String wave = "70,25,1.4,1.4,-26" + System.lineSeparator() + "100,5,1.4,1.2,15" + System.lineSeparator() + "420,0,1.15,1,-10" + System.lineSeparator() + "520,10,1.7,1.5,20" + System.lineSeparator() + "220,0,1,1,-15";
+ waves = wave.split("\\s+");
} else if ("-2".equals(getTag())) {
- waves = "0,0,1,0.5,90\n90,0,1,0.5,90".split("\\s+");
+ waves = "0,0,1,0.5,90\" + System.lineSeparator() + \"90,0,1,0.5,90".split("\\s+");
}
for (String wave : waves) {
- String[] args = wave.split ("\\s*,\\s*");
+ String[] args = wave.split("\\s*,\\s*");
if (args.length == 5) {
- mltWave.add(new Wave(Util.dp2px(parseFloat(args[0])), Util.dp2px(parseFloat(args[1])), Util.dp2px(parseFloat(args[4])), parseFloat(args[2]), parseFloat(args[3]), mWaveHeight/2));
+ mltWave.add(new Wave(getContext(), Util.vp2px(parseFloat(args[0]), getContext()), Util.vp2px(parseFloat(args[1]), getContext()), Util.vp2px(parseFloat(args[4]), getContext()), parseFloat(args[2]), parseFloat(args[3]), mWaveHeight / 2));
}
}
} else {
- mltWave.add(new Wave(Util.dp2px(50), Util.dp2px(0), Util.dp2px(5), 1.7f, 2f, mWaveHeight / 2));
+ mltWave.add(new Wave(getContext(), Util.vp2px(50, getContext()), Util.vp2px(0, getContext()), Util.vp2px(5, getContext()), 1.7f, 2f, mWaveHeight / 2));
}
}
-
+ /**
+ * 更新波纹路径
+ *
+ * @param w
+ * @param h
+ */
protected void updateWavePath(int w, int h) {
for (Wave wave : mltWave) {
wave.updateWavePath(w, h, mWaveHeight / 2, mEnableFullScreen, mCurProgress);
@@ -234,37 +270,63 @@ public class MultiWaveHeader extends ViewGroup {
/**
* 执行回弹动画
+ *
* @param progress 目标值
- * @param interpolator 加速器
+ * @param curveType 加速器
* @param duration 时长
*/
- protected void animProgress(float progress, Interpolator interpolator, int duration) {
+ protected void animProgress(float progress, int curveType, int duration) {
if (mCurProgress != progress) {
if (reboundAnimator != null) {
reboundAnimator.cancel();
}
- reboundAnimator = ValueAnimator.ofFloat(mCurProgress, progress);
+ reboundAnimator = new AnimatorValue(); // 0-1
+
+ reboundAnimator.setCurveType(curveType);
reboundAnimator.setDuration(duration);
- reboundAnimator.setInterpolator(interpolator);
- reboundAnimator.addListener(new AnimatorListenerAdapter() {
+ reboundAnimator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
@Override
- public void onAnimationEnd(Animator animation) {
- reboundAnimator = null;
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ updateProgress(progress);
}
});
- reboundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ reboundAnimator.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 onAnimationUpdate(ValueAnimator animation) {
- updateProgress((float)animation.getAnimatedValue());
+ public void onEnd(Animator animator) {
+ reboundAnimator = null;
+ }
+
+ @Override
+ public void onPause(Animator animator) {
+ }
+
+ @Override
+ public void onResume(Animator animator) {
}
});
reboundAnimator.start();
}
}
-
+ /**
+ * 更新进度值
+ *
+ * @param progress
+ */
protected void updateProgress(float progress) {
- View thisView = this;
+ Component thisView = this;
mCurProgress = progress;
updateLinearGradient(thisView.getWidth(), thisView.getHeight());
if (mEnableFullScreen) {
@@ -277,112 +339,206 @@ public class MultiWaveHeader extends ViewGroup {
}
}
- //
+ /**
+ * 更新波纹
+ *
+ * @param waves
+ */
public void setWaves(String waves) {
setTag(waves);
if (mLastTime > 0) {
- View thisView = this;
+ Component thisView = this;
updateWavePath();
updateWavePath(thisView.getWidth(), thisView.getHeight());
}
}
+ /**
+ * 获取控件高度
+ *
+ * @return 控件高度
+ */
public int getWaveHeight() {
return mWaveHeight;
}
+ /**
+ * 设置控件高度
+ *
+ * @param waveHeight
+ */
public void setWaveHeight(int waveHeight) {
- this.mWaveHeight = Util.dp2px(waveHeight);
+ this.mWaveHeight = Util.vp2px(waveHeight, getContext());
if (!mltWave.isEmpty()) {
- View thisView = this;
+ Component thisView = this;
updateWavePath(thisView.getWidth(), thisView.getHeight());
}
}
+ /**
+ * 获取波纹运动速度
+ *
+ * @return 波纹运动速度
+ */
public float getVelocity() {
return mVelocity;
}
+ /**
+ * 设置波纹运动速度
+ *
+ * @param velocity
+ */
public void setVelocity(float velocity) {
this.mVelocity = velocity;
}
+ /**
+ * 获取波纹进度值
+ *
+ * @return 波纹进度值
+ */
public float getProgress() {
return mProgress;
}
+ /**
+ * 设置波纹进度值
+ *
+ * @param progress
+ */
public void setProgress(float progress) {
this.mProgress = progress;
if (!mIsRunning) {
updateProgress(progress);
} else {
- animProgress(progress, new DecelerateInterpolator(), 300);
+ animProgress(progress, Animator.CurveType.DECELERATE, 300);
}
}
- public void setProgress(float progress, Interpolator interpolator, int duration) {
+ /**
+ * 设置波纹进度值
+ *
+ * @param progress
+ * @param curveType
+ * @param duration
+ */
+ public void setProgress(float progress, int curveType, int duration) {
this.mProgress = progress;
- animProgress(progress, new DecelerateInterpolator(), duration);
+ animProgress(progress, Animator.CurveType.DECELERATE, duration);
}
+ /**
+ * 获取渐变色的旋转度数
+ *
+ * @return 旋转度数
+ */
public int getGradientAngle() {
return mGradientAngle;
}
+ /**
+ * 设置渐变色旋转度数
+ *
+ * @param angle
+ */
public void setGradientAngle(int angle) {
this.mGradientAngle = angle;
if (!mltWave.isEmpty()) {
- View thisView = this;
+ Component thisView = this;
updateLinearGradient(thisView.getWidth(), thisView.getHeight());
}
}
+ /**
+ * 获取渐变色的起始颜色
+ *
+ * @return 起始颜色
+ */
public int getStartColor() {
return mStartColor;
}
+ /**
+ * 设置渐变色的起始颜色
+ *
+ * @param color
+ */
public void setStartColor(int color) {
this.mStartColor = color;
if (!mltWave.isEmpty()) {
- View thisView = this;
+ Component thisView = this;
updateLinearGradient(thisView.getWidth(), thisView.getHeight());
}
}
+ /**
+ * 获取渐变色的起始颜色
+ *
+ * @param colorId
+ */
public void setStartColorId(@ColorRes int colorId) {
- final View thisView = this;
+ final Component thisView = this;
setStartColor(Util.getColor(thisView.getContext(), colorId));
}
+ /**
+ * 获取渐变色的结束颜色
+ *
+ * @return 结束颜色
+ */
public int getCloseColor() {
return mCloseColor;
}
+ /**
+ * 获取渐变色的结束颜色
+ *
+ * @param color 结束颜色
+ */
public void setCloseColor(int color) {
this.mCloseColor = color;
if (!mltWave.isEmpty()) {
- View thisView = this;
+ Component thisView = this;
updateLinearGradient(thisView.getWidth(), thisView.getHeight());
}
}
+ /**
+ * 设置渐变色的结束颜色
+ *
+ * @param colorId
+ */
public void setCloseColorId(@ColorRes int colorId) {
- final View thisView = this;
+ final Component thisView = this;
setCloseColor(Util.getColor(thisView.getContext(), colorId));
}
+ /**
+ * 获取颜色的透明度
+ *
+ * @return float
+ */
public float getColorAlpha() {
return mColorAlpha;
}
+ /**
+ * 设置颜色透明度
+ *
+ * @param alpha
+ */
public void setColorAlpha(float alpha) {
this.mColorAlpha = alpha;
if (!mltWave.isEmpty()) {
- View thisView = this;
+ Component thisView = this;
updateLinearGradient(thisView.getWidth(), thisView.getHeight());
}
}
+ /**
+ * 执行
+ */
public void start() {
if (!mIsRunning) {
mIsRunning = true;
@@ -391,30 +547,72 @@ public class MultiWaveHeader extends ViewGroup {
}
}
+ /**
+ * 结束
+ */
public void stop() {
mIsRunning = false;
}
+ /**
+ * 是否执行
+ *
+ * @return boolean
+ */
public boolean isRunning() {
return mIsRunning;
}
+ /**
+ * 设置属性
+ *
+ * @param fullScreen
+ */
public void setEnableFullScreen(boolean fullScreen) {
this.mEnableFullScreen = fullScreen;
}
+ /**
+ * isEnableFullScreen
+ *
+ * @return boolean
+ */
public boolean isEnableFullScreen() {
return mEnableFullScreen;
}
+ /**
+ * 设置ShapeType
+ *
+ * @param shape
+ */
public void setShape(ShapeType shape) {
this.mShape = shape;
updateShapePath();
}
+ /**
+ * 获取ShapeType
+ *
+ * @return ShapeType
+ */
public ShapeType getShape() {
return mShape;
}
- //
+ /**
+ * 设置透明布局
+ *
+ * @param color
+ * @param alpha
+ * @return int
+ * @throws IllegalArgumentException
+ */
+ public static int setAlphaComponent(int color, @IntRange(from = 0L,to = 255L) int alpha) {
+ if (alpha >= 0 && alpha <= 255) {
+ return color & 16777215 | alpha << 24;
+ } else {
+ throw new IllegalArgumentException("alpha must be between 0 and 255.");
+ }
+ }
}
diff --git a/library/src/main/java/com/scwang/wave/SeekBarColorChange.java b/library/src/main/java/com/scwang/wave/SeekBarColorChange.java
new file mode 100644
index 0000000000000000000000000000000000000000..cbd0c6cb2f5062a4c5b2d312b1ef0863b188412a
--- /dev/null
+++ b/library/src/main/java/com/scwang/wave/SeekBarColorChange.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.scwang.wave;
+
+import ohos.agp.utils.Color;
+
+/**
+ * Seekbar滑动的接口回调
+ *
+ * @since 2021-07-05
+ */
+public interface SeekBarColorChange {
+ /**
+ * Seekbar滑动回调
+ *
+ * @param color
+ * @param colorValue
+ */
+ void colorChange(Color color, int colorValue);
+}
diff --git a/library/src/main/java/com/scwang/wave/TypedArray.java b/library/src/main/java/com/scwang/wave/TypedArray.java
new file mode 100644
index 0000000000000000000000000000000000000000..0064034fb91e22f0247980af395acf60fb8084b1
--- /dev/null
+++ b/library/src/main/java/com/scwang/wave/TypedArray.java
@@ -0,0 +1,135 @@
+/*
+ * 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.scwang.wave;
+
+import ohos.agp.components.AttrSet;
+import ohos.agp.utils.Color;
+
+public class TypedArray {
+ private AttrSet attrSet;
+
+ /**
+ * 构造方法
+ *
+ * @param attrSet
+ */
+ public TypedArray(AttrSet attrSet) {
+ this.attrSet = attrSet;
+ }
+
+ /**
+ * 获取vp fp属性
+ *
+ * @param value
+ * @param defaultValue
+ * @return int
+ */
+ public int getDimensionValue(String value, int defaultValue) {
+ if (attrSet.getAttr(value).isPresent()) {
+ return attrSet.getAttr(value).get().getDimensionValue();
+ } else {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 获取颜色属性
+ *
+ * @param value
+ * @param defaultValue
+ * @return Color
+ */
+ public Color getColor(String value, int defaultValue) {
+ if (attrSet.getAttr(value).isPresent()) {
+ return attrSet.getAttr(value).get().getColorValue();
+ } else {
+ return new Color(defaultValue);
+ }
+ }
+
+ /**
+ * 获取float属性
+ *
+ * @param value
+ * @param defaultValue
+ * @return float
+ */
+ public float getFloat(String value, float defaultValue) {
+ if (attrSet.getAttr(value).isPresent()) {
+ return attrSet.getAttr(value).get().getFloatValue();
+ } else {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 获取int属性
+ *
+ * @param value
+ * @param defaultValue
+ * @return int
+ */
+ public int getInt(String value, int defaultValue) {
+ if (attrSet.getAttr(value).isPresent()) {
+ return attrSet.getAttr(value).get().getIntegerValue();
+ } else {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 获取Boolean属性
+ *
+ * @param value
+ * @param defaultValue
+ * @return boolean
+ */
+ public boolean getBoolean(String value, boolean defaultValue) {
+ if (attrSet.getAttr(value).isPresent()) {
+ return attrSet.getAttr(value).get().getBoolValue();
+ } else {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 获取String属性
+ *
+ * @param value
+ * @return String
+ */
+ public String getString(String value) {
+ if (attrSet.getAttr(value).isPresent()) {
+ return attrSet.getAttr(value).get().getStringValue();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * 判断是否声明当前属性
+ *
+ * @param value
+ * @return boolean
+ */
+ public boolean hasValue(String value) {
+ if (attrSet.getAttr(value).isPresent()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/library/src/main/java/com/scwang/wave/Util.java b/library/src/main/java/com/scwang/wave/Util.java
index ee474d36de85cb61719650f384be2ff8cb937052..489f9c446c9fb7920597c10c26dba57b766381e4 100644
--- a/library/src/main/java/com/scwang/wave/Util.java
+++ b/library/src/main/java/com/scwang/wave/Util.java
@@ -1,37 +1,43 @@
+/*
+ * 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.scwang.wave;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Build;
-import android.support.annotation.ColorInt;
-import android.support.annotation.ColorRes;
-import android.support.annotation.NonNull;
-import android.util.TypedValue;
+import ohos.agp.components.AttrHelper;
+import ohos.app.Context;
public class Util {
-
/**
* 获取颜色
+ *
* @param context 上下文
* @param colorId 颜色ID
* @return 颜色
*/
- @ColorInt
- public static int getColor(@NonNull Context context, @ColorRes int colorId) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- return context.getColor(colorId);
- }
- //noinspection deprecation
- return context.getResources().getColor(colorId);
+ public static int getColor(Context context, int colorId) {
+ return context.getColor(colorId);
}
/**
* dp转px
+ *
* @param dpVal dp 值
+ * @param context
* @return px
*/
- public static int dp2px(float dpVal) {
- return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
- dpVal, Resources.getSystem().getDisplayMetrics());
+ public static int vp2px(float dpVal, Context context) {
+ return AttrHelper.vp2px(dpVal, context);
}
}
diff --git a/library/src/main/java/com/scwang/wave/Wave.java b/library/src/main/java/com/scwang/wave/Wave.java
index 921aef021c4f163a84b580366fae4b7339e6b608..a3e64abc64a15dfff00f556d08b27c0318b9b841 100644
--- a/library/src/main/java/com/scwang/wave/Wave.java
+++ b/library/src/main/java/com/scwang/wave/Wave.java
@@ -1,120 +1,135 @@
package com.scwang.wave;
-import android.graphics.Path;
+import ohos.agp.render.Path;
+import ohos.app.Context;
/**
* 水波对象
* Created by SCWANG on 2017/12/11.
*/
@SuppressWarnings("WeakerAccess")
-class Wave /*extends View*/ {
-
- Path path; //水波路径
- int width; //画布宽度(2倍波长)
- int wave; //波幅(振幅)
- float offsetX; //水波的水平偏移量
- float offsetY; //水波的竖直偏移量
- float velocity; //水波移动速度(像素/秒)
- private float scaleX; //水平拉伸比例
- private float scaleY; //竖直拉伸比例
+public class Wave {
+ // 水波路径
+ Path path;
+
+ // 画布宽度(2倍波长)
+ int width;
+
+ // 波幅(振幅)
+ int wave;
+
+ // 水波的水平偏移量
+ float offsetX;
+
+ // 水波的竖直偏移量
+ float offsetY;
+
+ // 水波移动速度(像素/秒)
+ float velocity;
+
+ // 水平拉伸比例
+ private float scaleX;
+
+ // 竖直拉伸比例
+ private float scaleY;
private int curWave;
-// int startColor; //开始颜色
-// int closeColor; //结束颜色
-// float alpha; //颜色透明度
+ private Context context;
/**
* 通过参数构造一个水波对象
- * @param offsetX 水平偏移量
- * @param offsetY 竖直偏移量
- * @param velocity 移动速度(像素/秒)
- * @param scaleX 水平拉伸量
- * @param scaleY 竖直拉伸量
- * @param wave 波幅(波宽度)
+ *
+ * @param context
+ * @param offsetX 水平偏移量
+ * @param offsetY 竖直偏移量
+ * @param velocity 移动速度(像素/秒)
+ * @param scaleX 水平拉伸量
+ * @param scaleY 竖直拉伸量
+ * @param wave 波幅(波宽度)
*/
-// @SuppressWarnings("PointlessArithmeticExpression")
- Wave(/*Context context, */int offsetX, int offsetY, int velocity, float scaleX, float scaleY, int wave) {
-// super(context);
- this.wave = wave; //波幅(波宽)
- this.scaleX = scaleX; //水平拉伸量
- this.scaleY = scaleY; //竖直拉伸量
- this.offsetX = offsetX; //水平偏移量
- this.offsetY = offsetY; //竖直偏移量
- this.velocity = velocity; //移动速度(像素/秒)
+ public Wave(Context context, int offsetX, int offsetY, int velocity, float scaleX, float scaleY, int wave) {
+ this.context = context;
+ this.wave = wave;
+ this.scaleX = scaleX;
+ this.scaleY = scaleY;
+ this.offsetX = offsetX;
+ this.offsetY = offsetY;
+ this.velocity = velocity;
this.path = new Path();
}
-// /*
-// * 根据 波长度、中轴线高度、波幅 绘制水波路径
-// */
-// public Wave(Context context) {
-// this(context, null, 0);
-// }
-//
-// public Wave(Context context, @Nullable AttributeSet attrs) {
-// this(context, attrs, 0);
-// }
-//
-// public Wave(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
-// super(context, attrs, defStyleAttr);
-//
-// TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Wave);
-//
-//// startColor = ta.getColor(R.styleable.Wave_mwhStartColor, 0);
-//// closeColor = ta.getColor(R.styleable.Wave_mwhCloseColor, 0);
-//// alpha = ta.getFloat(R.styleable.Wave_mwhColorAlpha, 0f);
-// scaleX = ta.getFloat(R.styleable.Wave_mwScaleX, 1);
-// scaleY = ta.getFloat(R.styleable.Wave_mwScaleY, 1);
-// offsetX = ta.getDimensionPixelOffset(R.styleable.Wave_mwOffsetX, 0);
-// offsetY = ta.getDimensionPixelOffset(R.styleable.Wave_mwOffsetY, 0);
-// velocity = ta.getDimensionPixelOffset(R.styleable.Wave_mwVelocity, Util.dp2px(10));
-// wave = ta.getDimensionPixelOffset(R.styleable.Wave_mwWaveHeight, 0) / 2;
-//
-// ta.recycle();
-// }
-
+ /**
+ * 更新path路径
+ *
+ * @param w
+ * @param h
+ * @param waveHeight
+ * @param fullScreen
+ * @param progress
+ */
protected void updateWavePath(int w, int h, int waveHeight, boolean fullScreen, float progress) {
this.wave = waveHeight;
- this.width = (int) (2* scaleX * w); //画布宽度(2倍波长)
+
+ // 画布宽度(2倍波长)
+ this.width = (int) (2 * scaleX * w);
this.path = buildWavePath(width, h, fullScreen, progress);
}
+ /**
+ * 更新path路径
+ *
+ * @param w
+ * @param h
+ * @param progress
+ */
protected void updateWavePath(int w, int h, float progress) {
- int wave = (int) (scaleY * this.wave);//计算拉伸之后的波幅
- float maxWave = h * Math.max(0, (1 - progress));
- if (wave > maxWave) {
- wave = (int)maxWave;
+ // 计算拉伸之后的波幅
+ int mWave = (int) (scaleY * this.wave);
+ float maxWave = h * Math.max(0, 1 - progress);
+ if (mWave > maxWave) {
+ mWave = (int)maxWave;
}
- if (curWave != wave) {
- this.width = (int) (2 * scaleX * w); //画布宽度(2倍波长)
+ if (curWave != mWave) {
+ // 画布宽度(2倍波长)
+ this.width = (int) (2 * scaleX * w);
this.path = buildWavePath(width, h, true, progress);
}
}
+ /**
+ * 构建path路径
+ *
+ * @param width
+ * @param height
+ * @param fullScreen
+ * @param progress
+ * @return Path
+ */
protected Path buildWavePath(int width, int height, boolean fullScreen, float progress) {
- int DP = Util.dp2px(1);//一个dp在当前设备表示的像素量(水波的绘制精度设为一个dp单位)
- if (DP < 1) {
- DP = 1;
+ // DP = 3,一个dp在当前设备表示的像素量(水波的绘制精度设为一个dp单位)
+ int dp = Util.vp2px(1, context);
+ if (dp < 1) {
+ dp = 1;
}
- int wave = (int) (scaleY * this.wave);//计算拉伸之后的波幅
+ // 计算拉伸之后的波幅
+ int wave = (int) (scaleY * this.wave);
if (fullScreen) {
- float maxWave = height * Math.max(0, (1 - progress));
+ float maxWave = height * Math.max(0, 1 - progress);
if (wave > maxWave) {
wave = (int) maxWave;
}
}
this.curWave = wave;
-// Path path = new Path();
path.reset();
path.moveTo(0, 0);
path.lineTo(0, height - wave);
if (wave > 0) {
- for (int x = DP; x < width; x += DP) {
+ for (int x = dp; x < width; x += dp) {
path.lineTo(x, height - wave - wave * (float) Math.sin(4.0 * Math.PI * x / width));
}
}
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/scwang/wave/ExampleTest.java b/library/src/test/java/com/scwang/wave/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ba75db98f84936daaf1e2d1acea9e815e05c8bca
--- /dev/null
+++ b/library/src/test/java/com/scwang/wave/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.scwang.wave;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/settings.gradle b/settings.gradle
index 33069973b21ca48fd9db7889bf3865384837327a..d0c7ee8440156d4a9324ac5357770747425fef57 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':library'
+include ':entry', ':library'