diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..c846c5b6d46c7c53a03b41c5cbb65053c7528c80
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,4 @@
+0.0.1-SNAPSHOT
+--------------
+
+ohos 第一个版本,完整实现了原库的全部 api
\ No newline at end of file
diff --git a/README.OPENSOURCE b/README.OPENSOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..9408b52c125cfdb400ad4b79f0b2d54d9ea7cdf5
--- /dev/null
+++ b/README.OPENSOURCE
@@ -0,0 +1,19 @@
+[
+
+ {
+
+ "Name": "RadarView",
+
+ "License": "",
+
+ "License File": "",
+
+ "Version Number": "master",
+
+ "Upstream URL": "https://github.com/Blowing/RadarView",
+
+ "Description": "这是一款高仿360清理功能的动画view"
+
+ }
+
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index 9152d7081c3e7e02b16dc1313b6abe4e24d3b752..64912252d8b166d8ca1d8fbddd91e8d8e18182e9 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,87 @@
-# RadarView
-高仿360检测评分动画
-
+# RadarView
+
+#### 项目介绍
+- 项目名称:RadarView
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:实现360清理动画
+- 项目移植状态:主功能完成
+- 调用差异:无
+- 基线版本 master
+- 开发版本:sdk5,DevEco Studio2.1 beta4
+
+#### 效果演示
+
+
+
+#### 安装教程
+
+1.在项目根目录下的build.gradle文件中,
+ ```
+ allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ }
+ }
+```
+2.在entry模块的build.gradle文件中,
+ ```
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:radarvie:0.0.1-SNAPSHOT')
+ ......
+ }
+```
+
+在sdk5,DevEco Studio2.1 beta4下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
+
+#### 使用说明
+
+此效果主要是通过自定义view,设置属性动画形成的效果。
+
+1、XML中引用控件:
+
+```xml
+
+
+```
+
+2、启动动画:
+
+```java
+ CHANNEL_ID 目前demo中设置的是12
+ RadarCommpent radarCommpent = (RadarCommpent) findComponentById(ResourceTable.Id_radarview);
+ radarCommpent.showCheckProcess(CHANNEL_ID);
+```
+
+自定义MaterialSpinner控件,可以添加自定义属性,具体可用属性如下:
+
+| name | type | info |
+|-------------------------|-----------|--------------------------------------------------------|
+| topColor | int | 检测值是90%-100%的颜色 |
+| middColor | int | 检测值是75%-90%的颜色 |
+| lowColor | int | 设置值低于75%的颜色 |
+
+#### 测试信息
+
+CodeCheck代码测试无异常
+
+CloudTest代码测试无异常
+
+火绒安全病毒安全检测通过
+
+当前版本demo功能与原组件基本无差异
+
+#### 版本迭代
+
+- 0.0.1-SNAPSHOT
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index 06d913d435f50ac6f6e7ce9837ca02171104fbeb..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,36 +0,0 @@
-apply plugin: 'com.android.application'
-apply plugin: 'com.neenbedankt.android-apt'
-apply plugin: 'me.tatarka.retrolambda'
-
-
-android {
- compileSdkVersion 25
- buildToolsVersion "25.0.2"
-
- defaultConfig {
- applicationId "com.wujie.radarview"
- minSdkVersion 14
- targetSdkVersion 25
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:25.1.1'
- compile 'com.jakewharton:butterknife:8.5.1'
- apt 'com.jakewharton:butterknife-compiler:8.5.1'
- compile 'io.reactivex:rxandroid:1.2.1'
-}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index 24d63f714d4d4ef265833cfd4984c4feb6f57261..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in E:\android\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/app/src/androidTest/java/com/wujie/radarview/ApplicationTest.java b/app/src/androidTest/java/com/wujie/radarview/ApplicationTest.java
deleted file mode 100644
index 40555d6c7baf24856303becec0a03120a7c5dc43..0000000000000000000000000000000000000000
--- a/app/src/androidTest/java/com/wujie/radarview/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.wujie.radarview;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 07ec33db3d0b8a52a4a58fce389ec3f883e7680b..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/com/wujie/radarview/Main2Activity.java b/app/src/main/java/com/wujie/radarview/Main2Activity.java
deleted file mode 100644
index 5eee08318fcdfa309794b4de1152eae4aca5339c..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/wujie/radarview/Main2Activity.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.wujie.radarview;
-
-import android.animation.ObjectAnimator;
-import android.os.Bundle;
-import android.os.Looper;
-import android.support.v7.app.AppCompatActivity;
-import android.view.animation.LinearInterpolator;
-import android.widget.ImageView;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-public class Main2Activity extends AppCompatActivity {
-
- private ObjectAnimator animator1,animator2, animator3;
- private ImageView imageView1, imageView2, imageView3;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main2);
- initView();
- animator1 = new ObjectAnimator();
- animator2 = new ObjectAnimator();
- animator3 = new ObjectAnimator();
- initAnimator(animator1, imageView1, 90.0f, 450.0f);
-
- initAnimator(animator3, imageView3, 0.0f, 360.0f);
-
-
-
- final Timer timer = new Timer();
- timer.schedule(new TimerTask() {
- @Override
- public void run() {
- Looper.prepare();
-
- animator1.cancel();
- animator2.cancel();
- animator3.cancel();
- timer.cancel();
- Looper.loop();
-
-
- }
- }, 6000);
-
- }
- private void initView() {
- imageView1 = (ImageView) findViewById(R.id.image1);
- imageView2 = (ImageView) findViewById(R.id.image2);
- imageView3 = (ImageView) findViewById(R.id.image3);
-
-
- }
-
- private void initAnimator (ObjectAnimator animator, ImageView imageView , float f1, float f2) {
- animator = ObjectAnimator.ofFloat(imageView, "rotation", f1, f2);
- animator.setDuration(1000);
- animator.setInterpolator(new LinearInterpolator());//不停顿
- animator.setRepeatCount(-1);//设置动画重复次数
- //animator.setRepeatMode(ValueAnimator.RESTART);//动画重复模式
- animator.start();
- }
-}
diff --git a/app/src/main/java/com/wujie/radarview/MainActivity.java b/app/src/main/java/com/wujie/radarview/MainActivity.java
deleted file mode 100644
index 7171e6af90227041614b6b932420a38a1f94b90d..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/wujie/radarview/MainActivity.java
+++ /dev/null
@@ -1,334 +0,0 @@
-package com.wujie.radarview;
-
-import android.animation.ObjectAnimator;
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
-import android.view.View;
-import android.view.animation.LinearInterpolator;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.wujie.radarview.view.RaderWheelView;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import butterknife.OnClick;
-import rx.Observable;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
-
-public class MainActivity extends AppCompatActivity {
-
-
- @BindView(R.id.check_layout_top_1)
- View top1Layout;
- @BindView(R.id.check_layout_top_2)
- View top2Layout;
- @BindView(R.id.check_radar_view)
- com.wujie.radarview.view.RadarView mRadarView;
- @BindView(R.id.check_radar_wheel_view)
- RaderWheelView mRaderWheelView;
- @BindView(R.id.wifi_acclerate_btn)
- Button acclerateBtn;
- @BindView(R.id.check_layout_animator)
- RelativeLayout checkLayoutAnimator;
- @BindView(R.id.wifi_acclerate_tv_tip)
- TextView wifiAcclerateTvTip;
- @BindView(R.id.wifi_acclerate_tv_check)
- TextView mCheckTips;
- @BindView(R.id.check_layout_acclerate)
- RelativeLayout checkLayoutAcclerate;
- @BindView(R.id.image3)
- ImageView image3;
- @BindView(R.id.image2)
- ImageView image2;
- @BindView(R.id.image1)
- ImageView image1;
- @BindView(R.id.wifi_acclerate_tv_optimze_core)
- TextView wifiAcclerateTvOptimzeCore;
- @BindView(R.id.checkd_layout_animator)
- RelativeLayout checkdLayoutAnimator;
- @BindView(R.id.wifi_optimize_tv_tip)
- TextView optimzeCore;
- @BindView(R.id.check_layout_optimize)
- RelativeLayout checkLayoutOptimize;
- @BindView(R.id.check_layout_top)
- RelativeLayout checkLayoutTop;
- @BindView(R.id.check_tv_score)
- TextView scoreTv;
-
- private ObjectAnimator animator1 = new ObjectAnimator(), animator2 = new ObjectAnimator(), animator3 = new ObjectAnimator();
-
-
- int progress = 100;
- private int core;
- private int position = 0;
- private int count = 0;
- private int position1 = 0;
- private int hasShowCheckImageViewCount = 0;
-
- private int during = 300;//检测时间间隔
-
- private int mChannelID;
- private String optimzeNames[];
- private String[] checkTips;
-
- private Subscription checkProcessSub, checkViewDoneSub;
-
- private Random mRandom = new Random();
-
- private String result = "";
-
- private boolean isToNext = false;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- ButterKnife.bind(this);
- mRadarView.start();
- showCheckProcess(11);
-
- }
-
-
- public void showCheckProcess(int chan_2g_sta) {
- int time = 0;
- chan_2g_sta = 11;
- switch (chan_2g_sta) {
- case -1:
- case 0:
- core = 50;
- chan_2g_sta = 11;
- break;
- case 1:
- core = 75;
- chan_2g_sta = 15;
- break;
- case 2:
- core = 100;
- chan_2g_sta = 20;
- break;
- case 3:
- core = 100;
- chan_2g_sta = 20;
- break;
- case 11:
- core = 50;
- break;
- case 12:
- core = 60;
- break;
- case 13:
- core = 65;
- break;
- case 14:
- core = 70;
- break;
- case 15:
- core = 75;
- break;
- case 16:
- core = 80;
- break;
- case 17:
- core = 85;
- break;
- case 18:
- core = 90;
- break;
- case 19:
- core = 95;
- break;
- case 20:
- core = 100;
- break;
- default:
- core = 50;
- chan_2g_sta = 11;
- break;
- }
- mChannelID = chan_2g_sta;
- if (chan_2g_sta < 4) {
- time = 34 - (4 - chan_2g_sta);
- } else {
- time = 34 - (21 - chan_2g_sta);
- }
- final int finalCore = core;
-
-
- final int finalTime = time;
- Observable.interval(during, TimeUnit.MILLISECONDS)
- .observeOn(AndroidSchedulers.mainThread())
- .take(34)
- .subscribe(new Action1() {
- @Override
- public void call(Long aLong) {
- int id = aLong.intValue();
-
- //if (mCheckTips != null) {
- // mCheckTips.setText(checkTips[id]);
- //mProgressbar.setProgress(id+1);
- if (id >= finalTime) {
-// if (finalCore == 100) {
-// toNextActivity(WifiAcclerateFullMarkActivity.class);
-// }
- if (progress > finalCore) {
- if (progress > 60) {
- progress = progress - (mRandom.nextInt(5) + 1);
-
- showBackground(progress);
- scoreTv.setText(String.valueOf(progress));
- progress = (progress + 5) / 5 * 5 - 5;
- } else {
- progress = progress - (mRandom.nextInt(10) + 1);
-
- showBackground(progress);
- scoreTv.setText(String.valueOf(progress));
- progress = progress / 10 * 10;
- }
-
- } else {
-
- if (core <= 70) {
- showBackground(50);
- } else if (core > 70 && core <= 90) {
- showBackground(75);
- } else {
- showBackground(100);
- }
- mRadarView.stop();
- mRadarView.setStart(0);
- mRadarView.setStopRoate(true);
- mRaderWheelView.stop();
- scoreTv.setText(String.valueOf(finalCore));
- mRadarView.setCodeangel(finalCore * 360 / 100);
-
-
- // mProgressbar.setVisibility(View.INVISIBLE);
- mCheckTips.setVisibility(View.INVISIBLE);
- if (finalCore != 100) {
- mRadarView.start();
- acclerateBtn.setVisibility(View.VISIBLE);
- // tipTv.setVisibility(View.VISIBLE);
- } else {
- mRadarView.stop();
- }
- }
- }
- //}
-
-
- }
- }, throwable -> {
- Log.e("raderview", throwable.getMessage()+"error");
- });
-
- }
-
- private void initAnimator(ObjectAnimator animator, ImageView imageView, float f1, float f2, int duration) {
- animator = ObjectAnimator.ofFloat(imageView, "rotation", f1, f2);
- animator.setDuration(duration);
- animator.setInterpolator(new LinearInterpolator());//不停顿
- // animator.setRepeatMode(ValueAnimator.INFINITE);
- animator.setRepeatCount(-1);//设置动画重复次数
-// //animator.setRepeatMode(ValueAnimator.RESTART);//动画重复模式
- animator.start();
- }
-
-
- public void showBackground(int core) {
- if (core > 90 && core <= 100) {
- top1Layout.setAlpha(1);
- top2Layout.setAlpha(1);
- top2Layout.setBackgroundColor(getResources().getColor(R.color.wifi_acclerate_green));
- top1Layout.setBackgroundColor(getResources().getColor(R.color.transparent));
- } else if (core >= 75 && core <= 90) {
- float topAlpha = (float) ((core - 75) * 0.04);
- top2Layout.setAlpha(topAlpha);
- top1Layout.setAlpha(1 - topAlpha);
- top1Layout.setBackgroundColor(getResources().getColor(R.color.wifi_acclerate_orange));
-
- } else {
- float topAlpha = (float) ((core - 50) * 0.04);
- top2Layout.setAlpha(topAlpha);
- top1Layout.setAlpha(1 - topAlpha);
- top2Layout.setBackgroundColor(getResources().getColor(R.color.wifi_acclerate_orange));
- top1Layout.setBackgroundColor(getResources().getColor(R.color.wifi_acclerate_red));
-
- }
- }
-
-
- public void showOptimzeAnimator(int channelID) {
-
- /**
- * 初始化优化的动画
- */
- animator1 = new ObjectAnimator();
- animator2 = new ObjectAnimator();
- animator3 = new ObjectAnimator();
- initAnimator(animator1, image1, 90.0f, 450.0f, 500);
- initAnimator(animator3, image3, 360.0f, 0.0f, 1000);
- optimzeCore.setText(String.valueOf(core));
-
-
- /**
- * 这里是优化以后的自动加分
- */
- progress = core;
- Observable.interval(500, 500, TimeUnit.MILLISECONDS)
- .observeOn(AndroidSchedulers.mainThread())
- .take(20 - channelID + 1)
- .subscribe(aLong -> {
- if (progress < 100) {
- if (progress == 50) {
- int score = progress + mRandom.nextInt(10) + 1;
- showBackground(score);
- wifiAcclerateTvOptimzeCore.setText(String.valueOf(score));
- progress = progress + 10;
- } else if (progress >= 60 && progress < 100) {
- int score = progress + mRandom.nextInt(5) + 1;
- showBackground(score);
- wifiAcclerateTvOptimzeCore.setText(String.valueOf(score));
- progress = progress + 5;
- } else {
- showBackground(99);
- wifiAcclerateTvOptimzeCore.setText(String.valueOf(99));
- progress = progress + 5;
- }
- } else {
- showBackground(100);
- wifiAcclerateTvOptimzeCore.setText(String.valueOf(100));
- animator1.cancel();
- animator2.cancel();
- animator3.cancel();
- image1.setVisibility(View.GONE);
- image3.setVisibility(View.GONE);
-
- //timer.cancel();
-
- }
- }, throwable -> {
- Log.e("throwablecore", throwable.getMessage());
- // LogUtil.e("throwablecore", throwable.getMessage());
- });
-
- }
-
-
- @OnClick(R.id.wifi_acclerate_btn)
- public void onClick() {
- checkLayoutAcclerate.setVisibility(View.GONE);
- checkLayoutOptimize.setVisibility(View.VISIBLE);
- showOptimzeAnimator(mChannelID);
- showOptimzeAnimator(11);
- }
-}
diff --git a/app/src/main/java/com/wujie/radarview/MyProgressDrawable.java b/app/src/main/java/com/wujie/radarview/MyProgressDrawable.java
deleted file mode 100644
index a31821bdb1c6f13c2bd2bfdff48c51ae36dab92d..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/wujie/radarview/MyProgressDrawable.java
+++ /dev/null
@@ -1,191 +0,0 @@
-package com.wujie.radarview;
-
-import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.ColorFilter;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.drawable.Animatable;
-import android.graphics.drawable.Drawable;
-import android.util.Property;
-import android.view.animation.LinearInterpolator;
-
-/**
- * Created by wujie on 2016/10/31.
- */
-public class MyProgressDrawable extends Drawable implements Animatable {
- private static final int SCAN_DURATION = 800; /* 扫描频率,旋转一周时间 */
-
- public static final int SCANNING = 0;
- public static final int SCAN_SUCCESS = 1;
- public static final int SCAN_ERROR = 2;
- private int mState = SCANNING;
-
- private static final String COLOR_SUCCESS = "#2CBE1B"; /* 绿色 */
- private static final String COLOR_ERROR = "#FF9400"; /* 橙色 */
-
- private Context context;
-
- private boolean mRunning;
-
- private ObjectAnimator mObjectAnimatorAngle; /* 旋转动画 */
- private float mCurrAngle; /* 旋转偏移角度 */
-
- private Paint paint;
- private int width, height;
-
- public MyProgressDrawable(Context context) {
- this.context = context;
- paint = new Paint();
- paint.setAntiAlias(true); /* 消除锯齿 */
- setupAnimations();
- }
-
- @Override
- public void draw(Canvas canvas) {
- switch (mState) {
- case SCANNING:
- paint.setColor(Color.parseColor(COLOR_SUCCESS));
- paint.setStyle(Paint.Style.FILL); /* 设置实心 */
- /* 扫描框 */
- Bitmap pb_scan = BitmapFactory.decodeResource(context.getResources(),
- R.drawable.pb_scan);
- pb_scan = Bitmap.createScaledBitmap(pb_scan, width, height, true);
- Matrix matrix = new Matrix();
- matrix.postRotate(mCurrAngle % 360f, pb_scan.getWidth() / 2,
- pb_scan.getHeight() / 2);
- canvas.drawBitmap(pb_scan, matrix, paint);
- break;
- case SCAN_SUCCESS:
- paint.setColor(Color.parseColor(COLOR_SUCCESS));
- paint.setStyle(Paint.Style.FILL); /* 设置实心 */
- break;
- case SCAN_ERROR:
- paint.setColor(Color.parseColor(COLOR_ERROR));
- paint.setStyle(Paint.Style.FILL); /* 设置实心 */
- break;
- default:
- break;
- }
-
- /* 中心圆 */
- int centre = width / 2; /* 获取圆心的x坐标 */
- int radius = (int) (centre * 4 / 5); /* 圆环的半径 */
- canvas.drawCircle(centre, centre, radius, paint); /* 画出圆 */
-
- /* 中心图标 */
- Rect rect = new Rect(centre - radius, centre - radius, centre + radius,
- centre + radius);
- Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),
- R.drawable.pb_icon1);
- canvas.drawBitmap(bitmap, null, rect, paint);
-
- }
-
- private Property mAngleProperty = new Property(
- Float.class, "angle") {
- @Override
- public Float get(MyProgressDrawable object) {
- return object.getCurrentGlobalAngle();
- }
-
- @Override
- public void set(MyProgressDrawable object, Float value) {
- object.setCurrentGlobalAngle(value);
- }
- };
-
- private void setupAnimations() {
- mObjectAnimatorAngle = ObjectAnimator.ofFloat(this, mAngleProperty,
- 360f);
- mObjectAnimatorAngle.setInterpolator(new LinearInterpolator());
- mObjectAnimatorAngle.setDuration(SCAN_DURATION);
- mObjectAnimatorAngle.setRepeatMode(ValueAnimator.RESTART);
- mObjectAnimatorAngle.setRepeatCount(ValueAnimator.INFINITE);
- }
-
- public void setCurrentGlobalAngle(float currentGlobalAngle) {
- mCurrAngle = currentGlobalAngle;
- invalidateSelf();
- }
-
- public float getCurrentGlobalAngle() {
- return mCurrAngle;
- }
-
- @Override
- public void setAlpha(int alpha) {
- }
-
- @Override
- public void setColorFilter(ColorFilter cf) {
-
- }
-
- @Override
- public int getOpacity() {
- return 0;
- }
-
- @Override
- protected void onBoundsChange(Rect bounds) {
- super.onBoundsChange(bounds);
- width = bounds.right - bounds.left;
- height = bounds.bottom - bounds.top;
- }
-
- @Override
- public boolean isRunning() {
- return mRunning;
- }
-
- @Override
- public void start() {
- if (isRunning()) {
- return;
- }
- mRunning = true;
- mObjectAnimatorAngle.start();
- invalidateSelf();
- }
-
- @Override
- public void stop() {
- if (!isRunning()) {
- return;
- }
- mRunning = false;
- mObjectAnimatorAngle.cancel();
- invalidateSelf();
- }
-
- public void testStart() {
- mRunning = true;
- invalidateSelf();
- }
-
- public int getmState() {
- return mState;
- }
-
- public void setmState(int mState) {
- this.mState = mState;
- switch (mState) {
- case SCANNING:
- start();
- break;
- case SCAN_SUCCESS:
- stop();
- break;
- default:
- break;
- }
- invalidateSelf();
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/wujie/radarview/Utils.java b/app/src/main/java/com/wujie/radarview/Utils.java
deleted file mode 100644
index 186da6d119da2b0b87d3644b96a80aaa2e6449ef..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/wujie/radarview/Utils.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.wujie.radarview;
-
-import android.content.Context;
-
-/**
- * Created by wujie on 2017/2/22.
- */
-public class Utils {
-
- public static int dip2px (Context context, float dipValue) {
- float density = context.getResources().getDisplayMetrics().density;
- return (int) (density*dipValue + 0.5f);
- }
-
- public static int px2dip(Context context, float pixValue) {
- final float density = context.getResources().getDisplayMetrics().density;
- return (int) (pixValue / density + 0.5f);
- }
-}
diff --git a/app/src/main/res/drawable/pb_icon1.png b/app/src/main/res/drawable/pb_icon1.png
deleted file mode 100644
index 2d45219863c49db93fa2be694d5398588652550c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/drawable/pb_icon1.png and /dev/null differ
diff --git a/app/src/main/res/drawable/pb_scan.png b/app/src/main/res/drawable/pb_scan.png
deleted file mode 100644
index d338a1adb3a1d5fc892d95b50b93adc57cdf1013..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/drawable/pb_scan.png and /dev/null differ
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 f302535e99c03280c248c824974ae07b32c4b1a8..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,223 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_main2.xml b/app/src/main/res/layout/activity_main2.xml
deleted file mode 100644
index d69216b81e9cf8b7469eb4ca0f0e0a66ac074b2e..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main2.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..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-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 523655371f7e42eb32c15c565694d4dbbffc3fdb..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,202 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
-
-
- #ffffff
- #cbffffff
- #ff8a01
- #666666
- #888888
- #b3b3b3
- #fbb477
- #c87000
- #cc000000
- #33FFFFFF
- #cccccc
- #454545
- #333333
- #c8c8ca
- #000
- #4A4A4A
-
- #B8B8B8
- #F5F5F5
-
- #D00000FF
- #777
-
-
- #757575
- #b1b1b1
- #cccccc
- #797979
- #6a6a6a
- #7a7a7a
- #a0a0a0
- #cbcbcb
- #000000
-
-
- #e6e6e6
- #ed6d00
- #ee0000
- #e6e6e6
-
- #d16000
- #b35200
-
- #e95701
- #818181
- #707070
- #cccccc
-
- #c9c9c9
- #e9c7ac
-
- #959595
- #818181
- #e54900
-
- #eaeaea
-
- #e61c1c
- #c01213
-
- #d2d2d2
- #F2F2F2
-
- #a2a2a2
- #02a0ea
-
- #FF8822
-
- #0aa74b
-
- #c8c8ca
-
- #33000000
- #00000000
- #00000001
- #4db0ec
-
-
-
- #bebebe
- #009CFF
- #009CFF
-
-
- #990000
-
-
- #88cfcfcf
-
- - 0.30
- #f3c12e
- #bace2f
- #83d1dd
- #ecececff
-
-
- #ffdedede
- #ff0099cc
- #ff00719b
- #ffff4444
- #ffcd3a3a
- #ff99cc00
- #ff6d9b00
- @android:color/white
-
-
- #FF642B
- #4EFF642B
- #FF7644
-
- #FBFAF9
- #FFFF642B
- #F7F6F6
- #222222
- #444444
- #555555
- #666666
- #777777
- #999999
- #CCCCCC
- #FFF3EE
- #FFFF642B
- #679FDD
- #eeeeee
- #F7F7F7
-
- #444444
- #666666
- #B5B5B5
- #999999
- #59ffffff
- #F5F5F5
- #CCFFFFFF
-
- #FF642B
- #CCCCCC
- #C8C8C8
-
-
- #FFCCCCCC
- #FFF7F7F7
- #0076FF
- #80FFFFFF
- #77FFFFFF
- #53FFFFFF
- #CCFCFCFC
- #8fFCFCFC
- #4D4D4D
- #C74D4D4D
- #CCCCCC
- #99CCCCCC
- #c64D4D4D
- #FE3824
- #15B96B
-
- #612C9E
- #855BB5
- #B59BD4
- #F9F4FE
- #EE6E74
- #439DD1
-
- #99FFFFFF
-
-
- #79FFFFFF
- #FFF6EF
- #9CFFFFFF
- #15B96B
- #F29336
- #EC6066
- #DCFFFFFF
- #37FFFFFF
- #99FFFFFF
- #999999
- #FFFF5151
- #F9F9F9
- #b8313131
- #80000000
-
- #15B96B
- #F29336
- #EC6066
- #FFF4F4
- #B2FFFFFF
-
- #008747
- #CC008747
- #88008747
- #77FFFFFF
- #030303
-
-
-
-
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 489bcf15d06c7e8de648682197af4fddf93a22f6..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,171 +0,0 @@
-
-
-
- 16dp
- 16dp
-
-
- 20sp
-
-
-
- 24dp
-
-
- 10dp
-
-
- 300dp
-
-
- 64dp
-
-
- 30dp
-
-
- 3dp
-
-
-
- 10dp
- 12dp
- 4dp
- 24dp
- 12dp
-
-
-
-
- 4dp
-
- 16dp
- 15dp
- 16sp
- 16sp
-
- 54dp
- 30dp
-
- 56dp
- 25dp
-
-
-
- 15sp
- 18sp
- 16sp
- 16sp
- 15sp
- 15sp
- 11sp
- 12sp
- 13sp
- 14sp
- 17sp
- 15sp
- 14sp
- 24sp
- 14sp
-
-
- 14dp
- 14dp
- 12dp
- 84dp
- 24dp
- 30dp
- 46dp
- 56dp
- 22dp
- 17dp
- 15dp
- 10dp
- 15dp
- 17dp
- 21dp
- 16dp
- 50dp
- 18dp
- 17dp
- 30dp
-
-
- 48dp
-
-
- 0.5dp
-
- 64dp
- 60dp
- 17dp
-
- 46dp
- 50dp
- 60dp
- 70dp
- 73dp
- 75dp
- 50dp
- 50dp
-
-
- 8dp
- 13dp
- 12dp
- 155dp
- 49dp
- 33dp
- 85dp
- 34dp
- 36dp
- 44dp
-
- 46dp
- 32dp
-
- 47dp
- 43dp
-
- 50dp
- 39dp
- 85dp
-
- 18dp
- 18dp
-
- 14dp
- 19dp
- 26dp
-
- 9dp
- 11dp
- 29dp
-
- 68dp
- 128dp
- 40dp
-
- 36dp
- 19dp
-
- 34dp
- 150dp
- 18dp
- 20dp
-
- 35dp
- 43dp
- 145dp
- 128dp
- 100dp
- 100dp
- 26dp
- 10dp
- 8dp
- 15dp
- 14sp
- 12sp
-
-
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index b6254df555961db130eab3ccbe265422987830ee..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- RadarView
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 5885930df6d10edf3d6df40d6556297d11f953da..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
diff --git a/app/src/test/java/com/wujie/radarview/ExampleUnitTest.java b/app/src/test/java/com/wujie/radarview/ExampleUnitTest.java
deleted file mode 100644
index d7a219a5b2f24dfe5ccfcd8a720e40bc7ca40699..0000000000000000000000000000000000000000
--- a/app/src/test/java/com/wujie/radarview/ExampleUnitTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.wujie.radarview;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 630ed86223c337addea82f349bc63142edcfd5d8..5a48948cec269b71e3a5fca0fe88f636b0e79929 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,24 +1,40 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
buildscript {
repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.3'
- classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
- classpath 'me.tatarka:gradle-retrolambda:3.2.0'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:hap:2.4.2.7'
+ classpath 'com.huawei.ohos:decctest:1.0.0.6'
}
}
allprojects {
repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/app/.gitignore b/entry/.gitignore
similarity index 100%
rename from app/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..774e20306b3b9de671e76cc1e27fabd9b2820061
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,29 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+ implementation 'io.reactivex.rxjava3:rxjava:3.0.3'
+ implementation group: 'io.reactivex', name: 'rxjava', version: '1.1.6'
+ implementation('com.gitee.chinasoft_ohos:radarvie:0.0.1-SNAPSHOT')
+}
+decc {
+ supportType = ['html', 'xml']
+}
diff --git a/entry/libs/rxohos-release.har b/entry/libs/rxohos-release.har
new file mode 100644
index 0000000000000000000000000000000000000000..33f552733e449b8c189f5a8c9f9580da72546feb
Binary files /dev/null and b/entry/libs/rxohos-release.har differ
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..abdf6a994557f1b1a25c4a445abf02f090351079
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,49 @@
+{
+ "app": {
+ "bundleName": "com.wujie.radarview",
+ "vendor": "wujie",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Release"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.wujie.radarview",
+ "name": "com.wujie.radarview.MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.wujie.radarview.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/wujie/radarview/MainAbility.java b/entry/src/main/java/com/wujie/radarview/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..bb543b434b509ab308247e43c9aa2102e11ec2dd
--- /dev/null
+++ b/entry/src/main/java/com/wujie/radarview/MainAbility.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.wujie.radarview;
+
+import com.wujie.radarview.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * 主入口
+ *
+ * @author jjy
+ * @since 2021-04-23
+ */
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/wujie/radarview/MyApplication.java b/entry/src/main/java/com/wujie/radarview/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..1661398f8f60b5e73b8f3840815c37bf37932f1c
--- /dev/null
+++ b/entry/src/main/java/com/wujie/radarview/MyApplication.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.wujie.radarview;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/**
+ * MyApplication
+ *
+ * @author jjy
+ * @since 2021-04-23
+ */
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/wujie/radarview/slice/MainAbilitySlice.java b/entry/src/main/java/com/wujie/radarview/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d1fd989965e8c7ac06242d59cc064cd6be58460
--- /dev/null
+++ b/entry/src/main/java/com/wujie/radarview/slice/MainAbilitySlice.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.wujie.radarview.slice;
+
+import com.huawei.radarviewlib.RadarCommpent;
+import com.wujie.radarview.ResourceTable;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+
+/**
+ * MainAbilitySlice
+ *
+ * @author jjy
+ * @since 2021-04-23
+ */
+public class MainAbilitySlice extends AbilitySlice {
+ private static final int CHANNEL_ID = 11;
+ private RadarCommpent radarCommpent;
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ initView();
+ }
+
+ private void initView() {
+ radarCommpent = (RadarCommpent) findComponentById(ResourceTable.Id_radarview);
+ radarCommpent.showCheckProcess(CHANNEL_ID);
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..19acb4e876d6b1ec228c802b0a37b49e41073a3a
--- /dev/null
+++ b/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,172 @@
+{
+ "color": [
+ {
+ "name": "z_transparent",
+ "value": "#00000000"
+ },
+ {
+ "name": "z_dialog_bg_color",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "z_ztransparent",
+ "value": "#e0000000"
+ },
+ {
+ "name": "white",
+ "value": "#ffffff"
+ },
+ {
+ "name": "light_x_white",
+ "value": "#cbffffff"
+ },
+ {
+ "name": "orange",
+ "value": "#ff8a01"
+ },
+ {
+ "name": "deep_gray",
+ "value": "#666666"
+ },
+ {
+ "name": "gray",
+ "value": "#888888"
+ },
+ {
+ "name": "light_gray",
+ "value": "#b3b3b3"
+ },
+ {
+ "name": "light_orange",
+ "value": "#fbb477"
+ },
+ {
+ "name": "dark_orange",
+ "value": "#c87000"
+ },
+ {
+ "name": "translucent_80_dark",
+ "value": "#cc000000"
+ },
+ {
+ "name": "translucent_light",
+ "value": "#33FFFFFF"
+ },
+ {
+ "name": "light_s_gray",
+ "value": "#cccccc"
+ },
+ {
+ "name": "deep_s_gray",
+ "value": "#454545"
+ },
+ {
+ "name": "deep_ss_gray",
+ "value": "#333333"
+ },
+ {
+ "name": "list_line",
+ "value": "#c8c8ca"
+ },
+ {
+ "name": "shape_view",
+ "value": "#000"
+ },
+ {
+ "name": "light_black",
+ "value": "#4A4A4A"
+ },
+ {
+ "name": "split_line_gray",
+ "value": "#B8B8B8"
+ },
+ {
+ "name": "picker_bar_bg",
+ "value": "#F5F5F5"
+ },
+ {
+ "name": "limited",
+ "value": "#D00000FF"
+ },
+ {
+ "name": "unlimited",
+ "value": "#777"
+ },
+ {
+ "name": "main_tips_gray",
+ "value": "#757575"
+ },
+ {
+ "name": "secondary_tips_gray",
+ "value": "#b1b1b1"
+ },
+ {
+ "name": "hint_gray",
+ "value": "#cccccc"
+ },
+ {
+ "name": "speed_limited_gray",
+ "value": "#797979"
+ },
+ {
+ "name": "text_deep_gray",
+ "value": "#7a7a7a"
+ },
+ {
+ "name": "version_number",
+ "value": "#a0a0a0"
+ },
+ {
+ "name": "offline_gray",
+ "value": "#cbcbcb"
+ },
+ {
+ "name": "black",
+ "value": "#000000"
+ },
+ {
+ "name": "bg_gray",
+ "value": "#e6e6e6"
+ },
+ {
+ "name": "tenda_orange",
+ "value": "#ed6d00"
+ },
+ {
+ "name": "err_info_red",
+ "value": "#ee0000"
+ },
+ {
+ "name": "bg_light_orange",
+ "value": "#e6e6e6"
+ },
+ {
+ "name": "title_btn",
+ "value": "#d16000"
+ },
+ {
+ "name": "title_btn_pressed",
+ "value": "#b35200"
+ },
+ {
+ "name": "tenda_orange_pressed",
+ "value": "#e95701"
+ },
+ {
+ "name": "wifi_acclerate_green",
+ "value": "#15B96B"
+ },
+ {
+ "name": "wifi_acclerate_orange",
+ "value": "#F29336"
+ },
+ {
+ "name": "wifi_acclerate_red",
+ "value": "#EC6066"
+ }
+ ]
+}
+
+
+
+
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..1c2612e8b7b0c15557f5b3a9aaea47afa0862631
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "RadarView"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f64e844ab7b8a9ad76bfaa81e39b273c9c1e30aa
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-xxhdpi/circle2.png b/entry/src/main/resources/base/media/circle2.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/circle2.png
rename to entry/src/main/resources/base/media/circle2.png
diff --git a/app/src/main/res/mipmap-xxhdpi/circle3.png b/entry/src/main/resources/base/media/circle3.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/circle3.png
rename to entry/src/main/resources/base/media/circle3.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/ohosTest/config.json b/entry/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..4c171c14d1d852e1c35be05fb1e8061376e5a6aa
--- /dev/null
+++ b/entry/src/ohosTest/config.json
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "bundleName": "com.wujie.radarview",
+ "vendor": "wujie",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Release"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.wujie.radarview",
+ "name": "testModule",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": true
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/wujie/radarview/ExampleOhosTest.java b/entry/src/ohosTest/java/com/wujie/radarview/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5e8458270e4d624c13bc4a3080615b306df83147
--- /dev/null
+++ b/entry/src/ohosTest/java/com/wujie/radarview/ExampleOhosTest.java
@@ -0,0 +1,14 @@
+package com.wujie.radarview;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.wujie.radarview", actualBundleName);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/wujie/radarview/slice/MainAbilitySliceTest.java b/entry/src/ohosTest/java/com/wujie/radarview/slice/MainAbilitySliceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..eadcc1049d2841e2948b66abc6c81f1e9ac10305
--- /dev/null
+++ b/entry/src/ohosTest/java/com/wujie/radarview/slice/MainAbilitySliceTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.wujie.radarview.slice;
+
+import org.junit.Test;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * MainAbilitySlice单元测试
+ *
+ * @author jjy
+ * @since 2021-04-23
+ */
+public class MainAbilitySliceTest {
+ private Class unitClass;
+ private Object obj;
+ private void initClass() {
+ try {
+ unitClass = Class.forName("com.wujie.radarview.slice.MainAbilitySlice");
+ obj = unitClass.getConstructor().newInstance(); //实例化一个对象
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 初始化view
+ */
+ @Test
+ public void initView() {
+ initClass();
+ try {
+ Method method = unitClass.getMethod("initView", int.class);
+ method.invoke(obj, null);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/huawei/radarview/ExampleTest.java b/entry/src/test/java/com/huawei/radarview/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1c3b11fdf33ca2ed60c549235074175beb6f6b4c
--- /dev/null
+++ b/entry/src/test/java/com/huawei/radarview/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.huawei.radarview;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gif/screen.gif b/gif/screen.gif
new file mode 100644
index 0000000000000000000000000000000000000000..d75101e2b3959d4d1b61cb2cfb1658bcfcd86397
Binary files /dev/null and b/gif/screen.gif differ
diff --git a/gradle.properties b/gradle.properties
index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e24af05341d49695ee84e5f9b594659..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3d86dcf00e6b81380e33cebe578f607911dd4e07..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Mon Oct 31 08:52:23 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 100644
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,26 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/radarviewlib/.gitignore b/radarviewlib/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..a7747886cf71beda9b7dd8306ca43551329d5332
--- /dev/null
+++ b/radarviewlib/.gitignore
@@ -0,0 +1,2 @@
+/build
+
diff --git a/radarviewlib/build.gradle b/radarviewlib/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..048ea07d8e6208cf7e653cd89f595c0082f6223a
--- /dev/null
+++ b/radarviewlib/build.gradle
@@ -0,0 +1,24 @@
+apply plugin: 'com.huawei.ohos.library'
+
+
+ohos {
+ compileSdkVersion 5
+ 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 'io.reactivex.rxjava3:rxjava:3.0.3'
+}
diff --git a/radarviewlib/libs/rxohos-release.har b/radarviewlib/libs/rxohos-release.har
new file mode 100644
index 0000000000000000000000000000000000000000..33f552733e449b8c189f5a8c9f9580da72546feb
Binary files /dev/null and b/radarviewlib/libs/rxohos-release.har differ
diff --git a/radarviewlib/proguard-rules.pro b/radarviewlib/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/radarviewlib/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/radarviewlib/src/main/config.json b/radarviewlib/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..93fb2e9bf5b20b25943573ae30ac6f88c655642d
--- /dev/null
+++ b/radarviewlib/src/main/config.json
@@ -0,0 +1,28 @@
+{
+ "app": {
+ "bundleName": "com.huawei.radarview",
+ "vendor": "huawei",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.huawei.radarviewlib",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "radarviewlib",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/radarviewlib/src/main/java/com/huawei/radarviewlib/IntDef.java b/radarviewlib/src/main/java/com/huawei/radarviewlib/IntDef.java
new file mode 100644
index 0000000000000000000000000000000000000000..30fe41391b2feb1b8b3b21149fbc82c736e1174c
--- /dev/null
+++ b/radarviewlib/src/main/java/com/huawei/radarviewlib/IntDef.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.huawei.radarviewlib;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * RadarCommpent
+ *
+ * @author jjy
+ * @since 2021-04-23
+ */
+@Retention(SOURCE)
+@Target({ANNOTATION_TYPE})
+public @interface IntDef {
+ /**
+ * 获取value
+ *
+ * @return long[]
+ */
+ long[] value() default {};
+
+ /**
+ * 获取flag
+ *
+ * @return flag
+ */
+ boolean flag() default false;
+}
diff --git a/radarviewlib/src/main/java/com/huawei/radarviewlib/RadarCommpent.java b/radarviewlib/src/main/java/com/huawei/radarviewlib/RadarCommpent.java
new file mode 100644
index 0000000000000000000000000000000000000000..adfe576ac571dc5935bb0dbb70449c153782f623
--- /dev/null
+++ b/radarviewlib/src/main/java/com/huawei/radarviewlib/RadarCommpent.java
@@ -0,0 +1,375 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.huawei.radarviewlib;
+
+import io.reactivex.rxjava3.core.Observable;
+import io.reactivex.rxjava3.disposables.CompositeDisposable;
+import io.reactivex.rxjava3.functions.Consumer;
+import io.reactivex.rxjava3.openharmony.schedulers.OpenHarmonySchedulers;
+import io.reactivex.rxjava3.schedulers.Schedulers;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorProperty;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.*;
+import ohos.agp.components.element.ShapeElement;
+import ohos.app.Context;
+
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * RadarCommpent
+ *
+ * @author jjy
+ * @since 2021-04-23
+ */
+public class RadarCommpent extends DependentLayout implements Component.ClickedListener {
+ private static final int DURING = 300;
+ private final CompositeDisposable disposables = new CompositeDisposable();
+ private Context mContext;
+ private RadarView mRadarView;
+ private Component top1Layout;
+ private Component top2Layout;
+ private RaderWheelView mRaderWheelView;
+ private Button acclerateBtn;
+ private DependentLayout checkLayoutAnimator;
+ private Text wifiAcclerateTvTip;
+ private Text mCheckTips;
+ private DependentLayout checkLayoutAcclerate;
+ private Image image3;
+ private Image image2;
+ private Image image1;
+ private Text wifiAcclerateTvOptimzeCore;
+ private DependentLayout checkdLayoutAnimator;
+ private Text optimzeCore;
+ private DependentLayout checkLayoutOptimize;
+ private DependentLayout checkLayoutTop;
+ private Text scoreTv;
+ private AnimatorValue animator1;
+ private AnimatorValue animator2;
+ private AnimatorValue animator3;
+ private int core;
+ private int mChannelId;
+ int progress = 100;
+ private Random mRandom = new Random();
+ private int topColor = 0xff15B96B;
+ private int middColor = 0xffF29336;
+ private int lowColor = 0xffEC6066;
+
+ /**
+ * 构造函数
+ *
+ * @param context context对象
+ */
+ public RadarCommpent(Context context) {
+ super(context);
+ }
+
+ /**
+ * 构造函数
+ *
+ * @param context context对象
+ * @param attrSet 属性值
+ */
+ public RadarCommpent(Context context, AttrSet attrSet) {
+ super(context, attrSet);
+ topColor = attrSet.getAttr("topColor").get().getIntegerValue();
+ middColor = attrSet.getAttr("middColor").get().getIntegerValue();
+ lowColor = attrSet.getAttr("lowColor").get().getIntegerValue();
+ this.mContext = context;
+ initView();
+ }
+
+ private void initView() {
+ Component layoutScatter = LayoutScatter.getInstance(mContext).parse(ResourceTable.Layout_radarview, this, true);
+ mRadarView = (RadarView) layoutScatter.findComponentById(ResourceTable.Id_check_radar_view);
+ top1Layout = (Component) layoutScatter.findComponentById(ResourceTable.Id_check_layout_top_1);
+ top2Layout = (Component) layoutScatter.findComponentById(ResourceTable.Id_check_layout_top_2);
+ mRaderWheelView = (RaderWheelView) layoutScatter.findComponentById(ResourceTable.Id_check_radar_wheel_view);
+ acclerateBtn = (Button) layoutScatter.findComponentById(ResourceTable.Id_wifi_acclerate_btn);
+ acclerateBtn.setTag(1);
+ checkLayoutAnimator = (DependentLayout) layoutScatter.findComponentById(ResourceTable.Id_check_layout_animator);
+ wifiAcclerateTvTip = (Text) layoutScatter.findComponentById(ResourceTable.Id_wifi_acclerate_tv_tip);
+ mCheckTips = (Text) layoutScatter.findComponentById(ResourceTable.Id_wifi_acclerate_tv_check);
+ checkLayoutAcclerate = (DependentLayout) layoutScatter.findComponentById(ResourceTable.Id_check_layout_acclerate);
+ image3 = (Image) layoutScatter.findComponentById(ResourceTable.Id_image3);
+ image2 = (Image) layoutScatter.findComponentById(ResourceTable.Id_image2);
+ image1 = (Image) layoutScatter.findComponentById(ResourceTable.Id_image1);
+ wifiAcclerateTvOptimzeCore = (Text) layoutScatter.findComponentById(ResourceTable.Id_wifi_acclerate_tv_optimze_core);
+ checkdLayoutAnimator = (DependentLayout) layoutScatter.findComponentById(ResourceTable.Id_checkd_layout_animator);
+ optimzeCore = (Text) layoutScatter.findComponentById(ResourceTable.Id_wifi_optimize_tv_tip);
+ checkLayoutOptimize = (DependentLayout) layoutScatter.findComponentById(ResourceTable.Id_check_layout_optimize);
+ checkLayoutTop = (DependentLayout) layoutScatter.findComponentById(ResourceTable.Id_check_layout_top);
+ scoreTv = (Text) layoutScatter.findComponentById(ResourceTable.Id_check_tv_score);
+ mRadarView.start();
+ acclerateBtn.setClickedListener(this::onClick);
+ }
+
+ @Override
+ public void onClick(Component component) {
+ int Tag = Integer.parseInt(component.getTag().toString());
+ switch (Tag) {
+ case 1:
+ checkLayoutAcclerate.setVisibility(Component.INVISIBLE);
+ checkLayoutOptimize.setVisibility(Component.VISIBLE);
+ showOptimzeAnimator(mChannelId);
+ showOptimzeAnimator(mChannelId);
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void stopAnimator() {
+ animator1.setLoopedCount(0);
+ animator1.setDuration(0);
+ animator1.end();
+ animator1.stop();
+ animator3.setLoopedCount(0);
+ animator3.setDuration(0);
+ animator3.end();
+ animator3.stop();
+ }
+
+ private void initAnimator() {
+ animator1 = new AnimatorValue();
+ animator1.setDuration(500);
+ animator1.setCurveType(Animator.CurveType.LINEAR);
+ animator1.setLoopedCount(AnimatorProperty.INFINITE);
+ animator1.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ float value = (v * 360) + 90;
+ image1.setRotation(value);
+ }
+ });
+ animator1.start();
+ animator2 = new AnimatorValue();
+ animator2.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+
+ }
+ });
+ animator3 = new AnimatorValue();
+ animator3.setDuration(1000);
+ animator3.setLoopedCount(AnimatorProperty.INFINITE);
+ animator3.setCurveType(Animator.CurveType.LINEAR);
+ animator3.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ float value = 360 * (1 - v);
+ image3.setRotation(value);
+ }
+ });
+ animator3.start();
+ }
+
+ public void showCheckProcess(int channelId) {
+ this.mChannelId = channelId;
+ int time = 0;
+ switch (channelId) {
+ case -1:
+ case 0:
+ core = 50;
+ channelId = 11;
+ break;
+ case 1:
+ core = 75;
+ channelId = 15;
+ break;
+ case 2:
+ core = 100;
+ channelId = 20;
+ break;
+ case 3:
+ core = 100;
+ channelId = 20;
+ break;
+ case 11:
+ core = 50;
+ break;
+ case 12:
+ core = 60;
+ break;
+ case 13:
+ core = 65;
+ break;
+ case 14:
+ core = 70;
+ break;
+ case 15:
+ core = 75;
+ break;
+ case 16:
+ core = 80;
+ break;
+ case 17:
+ core = 85;
+ break;
+ case 18:
+ core = 90;
+ break;
+ case 19:
+ core = 95;
+ break;
+ case 20:
+ core = 100;
+ break;
+ default:
+ core = 50;
+ channelId = 11;
+ break;
+ }
+ if (channelId < 4) {
+ time = 34 - (4 - channelId);
+ } else {
+ time = 34 - (21 - channelId);
+ }
+ final int finalCore = core;
+ final int finalTime = time;
+ rxOpenHarmonyTestCase1(DURING, finalCore, finalTime);
+ }
+ public void rxOpenHarmonyTestCase1(int during, int finalCore, int finalTime) {
+ disposables.add(sampleObservable(during)
+ .subscribeOn(Schedulers.io())
+ .observeOn(OpenHarmonySchedulers.mainThread()).take(34).subscribe(new Consumer() {
+ @Override
+ public void accept(Long longTime) throws Throwable {
+ int id = longTime.intValue();
+ if (id >= finalTime) {
+ if (progress > finalCore) {
+ if (progress > 60) {
+ progress = progress - (mRandom.nextInt(5) + 1);
+ showBackground(progress);
+ scoreTv.setText(String.valueOf(progress));
+ progress = (progress + 5) / 5 * 5 - 5;
+ } else {
+ progress = progress - (mRandom.nextInt(10) + 1);
+
+ showBackground(progress);
+ scoreTv.setText(String.valueOf(progress));
+ progress = progress / 10 * 10;
+ }
+
+ } else {
+ if (core <= 70) {
+ showBackground(50);
+ } else if (core > 70 && core <= 90) {
+ showBackground(75);
+ } else {
+ showBackground(100);
+ }
+ mRadarView.stop();
+ mRadarView.setStopRoate(true);
+ mRaderWheelView.stop();
+ scoreTv.setText(String.valueOf(finalCore));
+ mRadarView.setCodeangel(finalCore * 360 / 100);
+ mCheckTips.setVisibility(Component.INVISIBLE);
+ if (finalCore != 100) {
+ mRadarView.start();
+ acclerateBtn.setVisibility(Component.VISIBLE);
+ } else {
+ mRadarView.stop();
+ }
+ }
+ }
+ }
+ }, throwable -> {
+ }));
+ }
+
+ public void showBackground(int core) {
+ System.out.println("showBackgroundcore : " + core);
+ if (core > 90 && core <= 100) {
+ top1Layout.setAlpha(1);
+ top2Layout.setAlpha(1);
+ ShapeElement element = new ShapeElement();
+ element.setRgbColor(RgbColor.fromRgbaInt(ResourceTable.Color_wifi_acclerate_green));
+ top2Layout.setBackground(element);
+ element.setRgbColor(RgbColor.fromArgbInt(topColor));
+ top1Layout.setBackground(element);
+ } else if (core >= 75 && core <= 90) {
+ float topAlpha = (float) ((core - 75) * 0.04);
+ top2Layout.setAlpha(topAlpha);
+ top1Layout.setAlpha(1 - topAlpha);
+ ShapeElement element = new ShapeElement();
+ element.setRgbColor(RgbColor.fromArgbInt(middColor));
+ top1Layout.setBackground(element);
+ } else {
+ float topAlpha = (float) ((core - 50) * 0.04);
+ top2Layout.setAlpha(topAlpha);
+ top1Layout.setAlpha(1 - topAlpha);
+ ShapeElement element = new ShapeElement();
+ element.setRgbColor(RgbColor.fromArgbInt(middColor));
+ top2Layout.setBackground(element);
+ element.setRgbColor(RgbColor.fromArgbInt(lowColor));
+ top1Layout.setBackground(element);
+ }
+ }
+
+ static Observable sampleObservable(int during) {
+ return Observable.interval(during, TimeUnit.MILLISECONDS);
+ }
+
+ static Observable longObservable() {
+ return Observable.interval(500, 500, TimeUnit.MILLISECONDS);
+ }
+
+ public void showOptimzeAnimator(int channelId) {
+ /**
+ * 初始化优化的动画
+ */
+ initAnimator();
+ optimzeCore.setText(String.valueOf(core));
+ /**
+ * 这里是优化以后的自动加分
+ */
+ progress = core;
+ disposables.add(longObservable()
+ .subscribeOn(Schedulers.io())
+ .observeOn(OpenHarmonySchedulers.mainThread())
+ .take(20 - channelId + 1)
+ .subscribe(aLong -> {
+ if (progress < 100) {
+ if (progress == 50) {
+ int score = progress + mRandom.nextInt(10) + 1;
+ showBackground(score);
+ wifiAcclerateTvOptimzeCore.setText(String.valueOf(score));
+ progress = progress + 10;
+ } else if (progress >= 60 && progress < 100) {
+ int score = progress + mRandom.nextInt(5) + 1;
+ showBackground(score);
+ wifiAcclerateTvOptimzeCore.setText(String.valueOf(score));
+ progress = progress + 5;
+ } else {
+ showBackground(99);
+ wifiAcclerateTvOptimzeCore.setText(String.valueOf(99));
+ progress = progress + 5;
+ }
+ } else {
+ showBackground(100);
+ wifiAcclerateTvOptimzeCore.setText(String.valueOf(100));
+ stopAnimator();
+ image1.setVisibility(Component.INVISIBLE);
+ image3.setVisibility(Component.INVISIBLE);
+ }
+ }, throwable -> {
+ System.out.println("throwablecore" + throwable.getMessage());
+ }));
+ }
+}
diff --git a/app/src/main/java/com/wujie/radarview/view/RadarView.java b/radarviewlib/src/main/java/com/huawei/radarviewlib/RadarView.java
similarity index 45%
rename from app/src/main/java/com/wujie/radarview/view/RadarView.java
rename to radarviewlib/src/main/java/com/huawei/radarviewlib/RadarView.java
index 0b27fc46ee16c1174baed7f042fac853f19328f4..3c503f124982f1679efac50f95eb5d7747e30e6d 100644
--- a/app/src/main/java/com/wujie/radarview/view/RadarView.java
+++ b/radarviewlib/src/main/java/com/huawei/radarviewlib/RadarView.java
@@ -1,27 +1,49 @@
-package com.wujie.radarview.view;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.RadialGradient;
-import android.graphics.RectF;
-import android.graphics.Shader;
-import android.support.annotation.IntDef;
-import android.util.AttributeSet;
-import android.widget.FrameLayout;
-
-import com.wujie.radarview.Utils;
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.huawei.radarviewlib;
+
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.StackLayout;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.render.*;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.Matrix;
+import ohos.agp.utils.Point;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
+import ohos.app.dispatcher.TaskDispatcher;
/**
- * Created by wujie on 2016/11/1.
+ * RadarView
+ *
+ * @author jjy
+ * @since 2021-04-23
*/
-public class RadarView extends FrameLayout {
+public class RadarView extends StackLayout implements Component.DrawTask {
+ public final static int CLOCK_WISE = 1;
+ public final static int ANTI_CLOCK_WISE = -1;
+ // 默认为顺时针呢
+ private final static int DEFAULT_DIERCTION = CLOCK_WISE;
+ // 设定雷达扫描方向
+ private int direction = DEFAULT_DIERCTION;
+ private boolean threadRunning = true;
private Context mContext;
- // private int viewSize = 800;
private int mWidth;
private int mHeight;
private Paint mPaintLine;
@@ -29,6 +51,7 @@ public class RadarView extends FrameLayout {
private Paint mPaintArc;
private Paint mPaintArcLine;
public boolean isstart = false;
+ private boolean isStop = false;
private ScanThread mThread;
private Paint mPaintPoint;
//旋转效果起始角度
@@ -40,6 +63,8 @@ public class RadarView extends FrameLayout {
private int lineWidth = 1;
private int[] point_x;
+ private TaskDispatcher globalTaskDispatcher;
+ private Runnable runnable;
public void stopThread() {
stop();
@@ -50,6 +75,7 @@ public class RadarView extends FrameLayout {
public void setStart(int start) {
this.Istart = start;
+ System.out.println("start: " + start);
}
private int[] point_y;
@@ -59,12 +85,10 @@ public class RadarView extends FrameLayout {
private int codeangel = 0;
- public final static int CLOCK_WISE = 1;
- public final static int ANTI_CLOCK_WISE = -1;
- RectF rectF;
-
+ RectFloat rectF;
public void setStopRoate(boolean stopRoate) {
+ System.out.println("stopRoate : " + stopRoate);
this.stopRoate = stopRoate;
}
@@ -72,33 +96,24 @@ public class RadarView extends FrameLayout {
this.codeangel = codeangel;
}
-
@IntDef({CLOCK_WISE, ANTI_CLOCK_WISE})
public @interface RADAR_DIRECTION {
}
- //默认为顺时针呢
- private final static int DEFAULT_DIERCTION = CLOCK_WISE;
-
- //设定雷达扫描方向
- private int direction = DEFAULT_DIERCTION;
-
- private boolean threadRunning = true;
- public RadarView(Context context, AttributeSet attrs) {
+ public RadarView(Context context, AttrSet attrs) {
super(context, attrs);
- // TODO Auto-generated constructor stub
- mContext = context.getApplicationContext();
+ this.mContext = context;
initPaint();
+ this.addDrawTask(this::onDraw);
}
public RadarView(Context context) {
super(context);
// TODO Auto-generated constructor stub
- mContext = context.getApplicationContext();
+ mContext = context;
initPaint();
-
}
private void initRadius() {
@@ -106,73 +121,43 @@ public class RadarView extends FrameLayout {
smallR = Utils.dip2px(mContext, smallR);
stoke = Utils.dip2px(mContext, stoke);
lineWidth = Utils.px2dip(mContext, lineWidth);
-
-
}
private void initPaint() {
// TODO Auto-generated method stub
- setBackgroundColor(Color.TRANSPARENT);
+ ShapeElement element = new ShapeElement();
+ element.setRgbColor(RgbColor.fromArgbInt(Color.TRANSPARENT.getValue()));
+ setBackground(element);
initRadius();
- //宽度=1,抗锯齿,描边效果的白色画笔
+ // 宽度=1,抗锯齿,描边效果的白色画笔
mPaintLine = new Paint();
mPaintLine.setStrokeWidth(lineWidth);
mPaintLine.setAntiAlias(true);
- mPaintLine.setStyle(Paint.Style.STROKE);
- mPaintLine.setColor(0x40FFFFFF);
+ mPaintLine.setStyle(Paint.Style.STROKE_STYLE);
+ mPaintLine.setColor(new Color(0x40FFFFFF));
- //画扇形的画笔
+ // 画扇形的画笔
mPaintSector = new Paint();
mPaintSector.setAntiAlias(true);
- RadialGradient radialGradient = new RadialGradient(getWidth() / 2, getHeight() / 2, bigR,
- new int[]{Color.TRANSPARENT, 0x1eFFFFFF}, new float[]{0.0f, 1f}
- , Shader.TileMode.CLAMP);
- mPaintSector.setShader(radialGradient);
-
+ RadialShader radialGradient = new RadialShader(new Point(getWidth() / 2, getHeight() / 2), bigR
+ , new float[]{0.0f, 1f},new Color[]{Color.TRANSPARENT,
+ new Color(0x1eFFFFFF)}, Shader.TileMode.CLAMP_TILEMODE);
+ mPaintSector.setShader(radialGradient, Paint.ShaderType.GROUP_SHADER);
- //画白色打分宽圆弧
+ // 画白色打分宽圆弧
mPaintArc = new Paint();
mPaintArc.setAntiAlias(true);
mPaintArc.setStrokeWidth(stoke);
- mPaintArc.setStyle(Paint.Style.STROKE);
+ mPaintArc.setStyle(Paint.Style.STROKE_STYLE);
- //绘制旋转圆弧上的亮线
+ // 绘制旋转圆弧上的亮线
mPaintArcLine = new Paint();
mPaintArcLine.setAntiAlias(true);
- mPaintArcLine.setColor(0x7affffff);
- mPaintArcLine.setStyle(Paint.Style.STROKE);
+ mPaintArcLine.setColor(new Color(0x7affffff));
+ mPaintArcLine.setStyle(Paint.Style.STROKE_STYLE);
mPaintArcLine.setStrokeWidth(lineWidth);
- //随机生成的点,模拟雷达扫描结果
-
- //白色实心画笔
- /* mPaintPoint = new Paint();
- mPaintPoint.setColor(Color.WHITE);
- mPaintPoint.setStyle(Paint.Style.FILL);*/
-// point_x = UtilTools.Getrandomarray(15, 300);
-// point_y = UtilTools.Getrandomarray(15, 300);
-
- }
-
-// public void setViewSize(int size) {
-// this.viewSize = size;
-// setMeasuredDimension(viewSize, viewSize);
-// }
-
-// @Override
-// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-// // TODO Auto-generated method stub
-// setMeasuredDimension(viewSize, viewSize);
-// }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- mWidth = w;
- mHeight = h;
- rectF = new RectF(mWidth / 2 - bigR + 20, mHeight / 2 - bigR + 20, mWidth / 2 + bigR - 20, mHeight / 2 + bigR - 20);
-
}
public void start() {
@@ -184,50 +169,62 @@ public class RadarView extends FrameLayout {
}
public void stop() {
- if (isstart) {
+ if (isstart && !isStop) {
+ System.out.println("threadRunning stop");
threadRunning = false;
isstart = false;
mContext = null;
+ isStop = true;
}
}
- @Override
- protected void onDraw(Canvas canvas) {
- // TODO Auto-generated method stub
-
-
+ @Override
+ public void invalidate() {
+ super.invalidate();
+ }
- if (stopRoate) { //停止转圈的时候,开始绘制打分进度先绘制一个浅色的圆,然后再绘制一个进度的圆弧
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ mWidth = component.getWidth();
+ mHeight = component.getHeight();
+ if (stopRoate) { // 停止转圈的时候,开始绘制打分进度先绘制一个浅色的圆,然后再绘制一个进度的圆弧
+ rectF = new RectFloat(mWidth / 2 - bigR + 20, mHeight / 2 - bigR + 20, mWidth / 2 + bigR - 20, mHeight / 2 + bigR - 20);
+ System.out.println("threadRunning Istart : " + Istart);
if (Istart <= 360) {
- mPaintArc.setColor(0x7aFFFFFF);
- canvas.drawArc(rectF, -90, Istart, false, mPaintArc);
+ mPaintArc.setColor(new Color(0x7aFFFFFF));
+ Arc arc = new Arc( -90, Istart, false);
+ canvas.drawArc(rectF, arc, mPaintArc);
} else if (Istart > 360 && Istart <= 360 + codeangel) {
- mPaintArc.setColor(0x7aFFFFFF);
- canvas.drawArc(rectF, -90, 360, false, mPaintArc);
- mPaintArc.setColor(0xc1FFFFFF);
- canvas.drawArc(rectF, -90, Istart - 360, false, mPaintArc);
+ mPaintArc.setColor(new Color(0x7aFFFFFF));
+ Arc arc = new Arc( -90, 360, false);
+ canvas.drawArc(rectF, arc, mPaintArc);
+ mPaintArc.setColor(new Color(0xc1FFFFFF));
+ Arc arcTwo = new Arc( -90, Istart - 360, false);
+ canvas.drawArc(rectF, arcTwo, mPaintArc);
} else {
- mPaintArc.setColor(0x7aFFFFFF);
- canvas.drawArc(rectF, -90, 360, false, mPaintArc);
- mPaintArc.setColor(0xc1FFFFFF);
- canvas.drawArc(rectF, -90, codeangel, false, mPaintArc);
+ mPaintArc.setColor(new Color(0x7aFFFFFF));
+ Arc arc = new Arc( -90, 360, false);
+ canvas.drawArc(rectF, arc, mPaintArc);
+ mPaintArc.setColor(new Color(0xc1FFFFFF));
+ Arc arcTwo = new Arc( -90, codeangel, false);
+ canvas.drawArc(rectF, arcTwo, mPaintArc);
}
}
-
if (!stopRoate) {
- //根据matrix中设定角度,不断绘制shader,呈现出一种扇形扫描效果
+ // 根据matrix中设定角度,不断绘制shader,呈现出一种扇形扫描效果
canvas.save();
int sweep = 1;
canvas.rotate(start, mWidth / 2, mHeight / 2);
- RectF rect = new RectF(mWidth / 2 - bigR, mHeight / 2 - bigR, mWidth / 2 + bigR, mHeight / 2 + bigR);
- canvas.drawArc(rect, 0, 90, true, mPaintSector);
- canvas.drawArc(rect, 0, 90, false, mPaintArcLine);
+ RectFloat rect = new RectFloat(mWidth / 2 - bigR, mHeight / 2 - bigR, mWidth / 2 + bigR, mHeight / 2 + bigR);
+ Arc arc = new Arc( 0, 90, true);
+ canvas.drawArc(rect, arc, mPaintSector);
+ Arc arcTwo = new Arc( 0, 90, false);
+ canvas.drawArc(rect, arcTwo, mPaintArcLine);
canvas.restore();
canvas.setMatrix(matrix);
}
- super.onDraw(canvas);
}
public void setDirection(@RADAR_DIRECTION int direction) {
@@ -238,33 +235,16 @@ public class RadarView extends FrameLayout {
}
protected class ScanThread extends Thread {
-
-// private RadarView view;
-//
-// public ScanThread(RadarView view) {
-// // TODO Auto-generated constructor stub
-// this.view = view;
-// }
-
@Override
public void run() {
// TODO Auto-generated method stub
while (threadRunning) {
if (isstart) {
-// view.post(new Runnable() {
-// public void run() {
start = start + 5;
Istart= Istart + 5;
matrix = new Matrix();
- //设定旋转角度,制定进行转转操作的圆心
-// matrix.postRotate(start, viewSize / 2, viewSize / 2);
-// matrix.setRotate(start,viewSize/2,viewSize/2);
matrix.preRotate(direction * start, mWidth / 2, mHeight / 2);
- //invalidate();
- postInvalidate();
-
-// }
-// });
+ reInvalidate();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
@@ -275,4 +255,16 @@ public class RadarView extends FrameLayout {
}
}
}
+
+ private void reInvalidate() {
+ if (mContext == null)return;
+ globalTaskDispatcher = mContext.getMainTaskDispatcher();
+ runnable = new Runnable() {
+ @Override
+ public void run() {
+ invalidate();
+ }
+ };
+ globalTaskDispatcher.asyncDispatch(runnable);
+ }
}
diff --git a/app/src/main/java/com/wujie/radarview/view/RaderWheelView.java b/radarviewlib/src/main/java/com/huawei/radarviewlib/RaderWheelView.java
similarity index 32%
rename from app/src/main/java/com/wujie/radarview/view/RaderWheelView.java
rename to radarviewlib/src/main/java/com/huawei/radarviewlib/RaderWheelView.java
index a10bbc32d7fe1870c1c681e0f3e0c9f66feaa994..5a82a0c14457e2e0ff91a8e5ce511c4c19d75114 100644
--- a/app/src/main/java/com/wujie/radarview/view/RaderWheelView.java
+++ b/radarviewlib/src/main/java/com/huawei/radarviewlib/RaderWheelView.java
@@ -1,25 +1,39 @@
-package com.wujie.radarview.view;
-
-/**
- * Created by wujie on 2017/2/22.
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-import android.widget.FrameLayout;
-
-import com.wujie.radarview.Utils;
+package com.huawei.radarviewlib;
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.StackLayout;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
+import ohos.app.dispatcher.TaskDispatcher;
/**
- * Created by wujie on 2016/12/16.
+ * RaderWheelView
+ *
+ * @author jjy
+ * @since 2021-04-23
*/
-public class RaderWheelView extends FrameLayout {
-
+public class RaderWheelView extends StackLayout implements Component.DrawTask {
private Context mContext;
private int mWidth;
private int mHeight;
@@ -27,69 +41,92 @@ public class RaderWheelView extends FrameLayout {
private int bigR = 100;
private int smallR = 60;
private int stoke = 7;
- private int lineWidth = 1;
+ private int lineWidth = 3;
private boolean stopRoate = false;
- RectF rectF;
-
+ private RectFloat rectF;
+ private TaskDispatcher globalTaskDispatcher;
+ private Runnable runnable;
+
+ /**
+ * 构造函数
+ *
+ * @param context context
+ */
public RaderWheelView(Context context) {
super(context);
mContext = context.getApplicationContext();
initPaint();
}
- public RaderWheelView(Context context, AttributeSet attrs) {
+ /**
+ * 构造函数
+ *
+ * @param context context对象
+ * @param attrs 属性参数
+ */
+ public RaderWheelView(Context context, AttrSet attrs) {
super(context, attrs);
mContext = context.getApplicationContext();
initPaint();
+ this.addDrawTask(this::onDraw);
}
-
private void initRadius() {
bigR = Utils.dip2px(mContext, bigR);
smallR = Utils.dip2px(mContext, smallR);
stoke = Utils.dip2px(mContext, stoke);
lineWidth = Utils.px2dip(mContext, lineWidth);
-
}
private void initPaint() {
- // TODO Auto-generated method stub
- setBackgroundColor(Color.TRANSPARENT);
+ ShapeElement element = new ShapeElement();
+ element.setRgbColor(RgbColor.fromArgbInt(Color.TRANSPARENT.getValue()));
+ setBackground(element);
initRadius();
- //宽度=1,抗锯齿,描边效果的白色画笔
mPaintLine = new Paint();
mPaintLine.setStrokeWidth(lineWidth);
mPaintLine.setAntiAlias(true);
- mPaintLine.setStyle(Paint.Style.STROKE);
- mPaintLine.setColor(0x60FFFFFF);
-
+ mPaintLine.setStyle(Paint.Style.STROKE_STYLE);
+ mPaintLine.setColor(new Color(0x60FFFFFF));
+ }
+ /**
+ * 停止线程
+ */
+ public void stop() {
+ stopRoate = true;
+ invalidate();
}
@Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- mWidth = w;
- mHeight = h;
- rectF = new RectF(mWidth / 2 - bigR + 20, mHeight / 2 - bigR + 20, mWidth / 2 + bigR - 20, mHeight / 2 + bigR - 20);
+ public void invalidate() {
+ super.invalidate();
}
@Override
- protected void onDraw(Canvas canvas) {
- // TODO Auto-generated method stub
-
- if (!stopRoate) {//停止转圈的时候,隐藏掉中间的小圈
+ public void onDraw(Component component, Canvas canvas) {
+ mWidth = component.getWidth();
+ mHeight = component.getHeight();
+ if (!stopRoate) { // 停止转圈的时候,隐藏掉中间的小圈
canvas.drawCircle(mWidth / 2, mHeight / 2, smallR, mPaintLine);
- canvas.drawLine(mWidth / 2 - smallR, mHeight / 2, mWidth /2 + smallR, mHeight / 2 , mPaintLine);
- canvas.drawLine(mWidth / 2 , mHeight / 2 - smallR, mWidth /2 , mHeight / 2+ smallR , mPaintLine);
+ canvas.drawLine(mWidth / 2 - smallR, mHeight / 2, mWidth / 2 + smallR, mHeight / 2, mPaintLine);
+ canvas.drawLine(mWidth / 2, mHeight / 2 - smallR, mWidth / 2, mHeight / 2 + smallR, mPaintLine);
}
canvas.drawCircle(mWidth / 2, mHeight / 2, bigR, mPaintLine);
- super.onDraw(canvas);
}
- public void stop() {
- stopRoate = true;
- invalidate();
+ private void reInvalidate() {
+ if (mContext == null) {
+ return;
+ }
+ globalTaskDispatcher = mContext.getMainTaskDispatcher();
+ runnable = new Runnable() {
+ @Override
+ public void run() {
+ invalidate();
+ }
+ };
+ globalTaskDispatcher.asyncDispatch(runnable);
}
}
diff --git a/radarviewlib/src/main/java/com/huawei/radarviewlib/Utils.java b/radarviewlib/src/main/java/com/huawei/radarviewlib/Utils.java
new file mode 100644
index 0000000000000000000000000000000000000000..3c02246d005659cb5f21e7c8c770f266663cd5b4
--- /dev/null
+++ b/radarviewlib/src/main/java/com/huawei/radarviewlib/Utils.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain an copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.huawei.radarviewlib;
+
+import ohos.agp.window.service.Display;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.app.Context;
+
+import java.util.Optional;
+
+/**
+ * Utils
+ *
+ * @author jjy
+ * @since 2021-04-23
+ */
+public class Utils {
+ private static final float HARF_VALUE = 0.5f;
+
+ private Utils() {
+ }
+
+ /**
+ * 获取屏幕密度
+ *
+ * @param context context对象
+ * @return 屏幕密度
+ */
+ public static DisplayAttributes getScreenPiex(Context context) {
+ Optional display = DisplayManager.getInstance().getDefaultDisplay(context);
+ DisplayAttributes displayAttributes = display.get().getAttributes();
+ return displayAttributes;
+ }
+
+ /**
+ * vp转px
+ *
+ * @param context context对象
+ * @param dipValue dip值
+ * @return px像素
+ */
+ public static int dip2px(Context context, float dipValue) {
+ DisplayAttributes displayAttributes = getScreenPiex(context);
+ return (int) (dipValue * displayAttributes.scalDensity);
+ }
+
+ /**
+ * px转vp
+ *
+ * @param context context对象
+ * @param pixValue px值
+ * @return vp值
+ */
+ public static int px2dip(Context context, float pixValue) {
+ DisplayAttributes displayAttributes = getScreenPiex(context);
+ return (int) (pixValue / displayAttributes.scalDensity + HARF_VALUE);
+ }
+}
diff --git a/radarviewlib/src/main/resources/base/element/color.json b/radarviewlib/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..19acb4e876d6b1ec228c802b0a37b49e41073a3a
--- /dev/null
+++ b/radarviewlib/src/main/resources/base/element/color.json
@@ -0,0 +1,172 @@
+{
+ "color": [
+ {
+ "name": "z_transparent",
+ "value": "#00000000"
+ },
+ {
+ "name": "z_dialog_bg_color",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "z_ztransparent",
+ "value": "#e0000000"
+ },
+ {
+ "name": "white",
+ "value": "#ffffff"
+ },
+ {
+ "name": "light_x_white",
+ "value": "#cbffffff"
+ },
+ {
+ "name": "orange",
+ "value": "#ff8a01"
+ },
+ {
+ "name": "deep_gray",
+ "value": "#666666"
+ },
+ {
+ "name": "gray",
+ "value": "#888888"
+ },
+ {
+ "name": "light_gray",
+ "value": "#b3b3b3"
+ },
+ {
+ "name": "light_orange",
+ "value": "#fbb477"
+ },
+ {
+ "name": "dark_orange",
+ "value": "#c87000"
+ },
+ {
+ "name": "translucent_80_dark",
+ "value": "#cc000000"
+ },
+ {
+ "name": "translucent_light",
+ "value": "#33FFFFFF"
+ },
+ {
+ "name": "light_s_gray",
+ "value": "#cccccc"
+ },
+ {
+ "name": "deep_s_gray",
+ "value": "#454545"
+ },
+ {
+ "name": "deep_ss_gray",
+ "value": "#333333"
+ },
+ {
+ "name": "list_line",
+ "value": "#c8c8ca"
+ },
+ {
+ "name": "shape_view",
+ "value": "#000"
+ },
+ {
+ "name": "light_black",
+ "value": "#4A4A4A"
+ },
+ {
+ "name": "split_line_gray",
+ "value": "#B8B8B8"
+ },
+ {
+ "name": "picker_bar_bg",
+ "value": "#F5F5F5"
+ },
+ {
+ "name": "limited",
+ "value": "#D00000FF"
+ },
+ {
+ "name": "unlimited",
+ "value": "#777"
+ },
+ {
+ "name": "main_tips_gray",
+ "value": "#757575"
+ },
+ {
+ "name": "secondary_tips_gray",
+ "value": "#b1b1b1"
+ },
+ {
+ "name": "hint_gray",
+ "value": "#cccccc"
+ },
+ {
+ "name": "speed_limited_gray",
+ "value": "#797979"
+ },
+ {
+ "name": "text_deep_gray",
+ "value": "#7a7a7a"
+ },
+ {
+ "name": "version_number",
+ "value": "#a0a0a0"
+ },
+ {
+ "name": "offline_gray",
+ "value": "#cbcbcb"
+ },
+ {
+ "name": "black",
+ "value": "#000000"
+ },
+ {
+ "name": "bg_gray",
+ "value": "#e6e6e6"
+ },
+ {
+ "name": "tenda_orange",
+ "value": "#ed6d00"
+ },
+ {
+ "name": "err_info_red",
+ "value": "#ee0000"
+ },
+ {
+ "name": "bg_light_orange",
+ "value": "#e6e6e6"
+ },
+ {
+ "name": "title_btn",
+ "value": "#d16000"
+ },
+ {
+ "name": "title_btn_pressed",
+ "value": "#b35200"
+ },
+ {
+ "name": "tenda_orange_pressed",
+ "value": "#e95701"
+ },
+ {
+ "name": "wifi_acclerate_green",
+ "value": "#15B96B"
+ },
+ {
+ "name": "wifi_acclerate_orange",
+ "value": "#F29336"
+ },
+ {
+ "name": "wifi_acclerate_red",
+ "value": "#EC6066"
+ }
+ ]
+}
+
+
+
+
diff --git a/radarviewlib/src/main/resources/base/element/string.json b/radarviewlib/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..1acd7489471d7ea0dee13b62cc6008841188d613
--- /dev/null
+++ b/radarviewlib/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "RadarviewLib"
+ }
+ ]
+}
diff --git a/radarviewlib/src/main/resources/base/layout/radarview.xml b/radarviewlib/src/main/resources/base/layout/radarview.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f8e73b57e1cf4d2001ade3374712345ef00d795f
--- /dev/null
+++ b/radarviewlib/src/main/resources/base/layout/radarview.xml
@@ -0,0 +1,192 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-xxhdpi/circle1.png b/radarviewlib/src/main/resources/base/media/circle1.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/circle1.png
rename to radarviewlib/src/main/resources/base/media/circle1.png
diff --git a/radarviewlib/src/main/resources/base/media/circle2.png b/radarviewlib/src/main/resources/base/media/circle2.png
new file mode 100644
index 0000000000000000000000000000000000000000..7ee64cd99cca16c28358bf6c3d7b0f6823fd7e94
Binary files /dev/null and b/radarviewlib/src/main/resources/base/media/circle2.png differ
diff --git a/radarviewlib/src/main/resources/base/media/circle3.png b/radarviewlib/src/main/resources/base/media/circle3.png
new file mode 100644
index 0000000000000000000000000000000000000000..49027e7fb966777328c97c84fdbc86a3d25816a4
Binary files /dev/null and b/radarviewlib/src/main/resources/base/media/circle3.png differ
diff --git a/radarviewlib/src/main/resources/base/media/icon.png b/radarviewlib/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/radarviewlib/src/main/resources/base/media/icon.png differ
diff --git a/radarviewlib/src/test/java/com/huawei/radarviewlib/ExampleTest.java b/radarviewlib/src/test/java/com/huawei/radarviewlib/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3198b0da197753239a24fbc217bfd968f197cd34
--- /dev/null
+++ b/radarviewlib/src/test/java/com/huawei/radarviewlib/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.huawei.radarviewlib;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/raderView.gif b/raderView.gif
deleted file mode 100644
index b4d5b1b1fad555c6e2d9422ef9f131241155033f..0000000000000000000000000000000000000000
Binary files a/raderView.gif and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index e7b4def49cb53d9aa04228dd3edb14c9e635e003..45a2c122a753d6f763a9b3cd5ceab7ffbc2ffda1 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app'
+include ':entry', ':radarviewlib'