add fancynew finished

This commit is contained in:
2022-03-06 19:33:37 +08:00
commit 2ab2d85738
75 changed files with 2751 additions and 0 deletions

2
Demo/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/build
/node_modules

33
Demo/build.gradle Normal file
View File

@@ -0,0 +1,33 @@
apply plugin: 'com.huawei.ohos.hap'
apply plugin: 'com.huawei.ohos.decctest'
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
ohos {
compileSdkVersion 6
defaultConfig {
compatibleSdkVersion 5
}
buildTypes {
release {
proguardOpt {
proguardEnabled true
rulesFiles 'proguard-rules.pro'
}
}
debug {
proguardOpt {
proguardEnabled true
rulesFiles 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
testImplementation 'junit:junit:4.13.1'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200'
implementation project(':fancynew')
}
decc {
supportType = ['html','xml']
}

66
Demo/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,66 @@
-dontwarn
# 代码混淆压缩比在0~7之间
-optimizationpasses 5
# 混合时不使用大小写混合,混合后的类名为小写
-dontusemixedcaseclassnames
# 在读取依赖的库文件时不要略过那些非public类成员
-dontskipnonpubliclibraryclassmembers
# 指定不去忽略非公共库的类
-dontskipnonpubliclibraryclasses
# 不做预校验preverify是proguard的四个步骤之一去掉这一步能够加快混淆速度
-dontpreverify
-verbose
# google推荐算法
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
# 保留注解、内部类、泛型、匿名类
-keepattributes *Annotation*,Exceptions,InnerClasses,Signature,EnclosingMethod
# 重命名抛出异常时的文件名称
-renamesourcefileattribute SourceFile
# 抛出异常时保留代码行号
-keepattributes SourceFile,LineNumberTable
-dontwarn javax.annotation.**
# 保留本地native方法不被混淆
-keepclasseswithmembernames,allowshrinking class * {
native <methods>;
}
# 保留枚举类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# 忽略继承
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# 保留HMS相关接入[AnalyticsKit SDK和依赖SDK的混淆配置]
-ignorewarnings
-repackageclasses
-keep class com.huawei.agconnect.**{*;}
-keep class com.huawei.hms.analytics.**{*;}
-keep class com.huawei.hms.push.**{*;}
-keep class com.huawei.hms.**{*;}
# HMS接口服务
-keepattributes Exceptions
-keep interface com.huawei.hms.analytics.type.HAEventType{*;}
-keep interface com.huawei.hms.analytics.type.HAParamType{*;}
-keep class com.huawei.hms.analytics.HiAnalyticsInstance{*;}
-keep class com.huawei.hms.analytics.HiAnalytics{*;}
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.harmony.**{*;}
-keep class com.huawei.mylibrary.**{*;}
# 保留HarmonyOS应用/服务入口类
-keep public class * extends *.aafwk.ability.Ability
-keep public class * extends *.ace.ability.AceAbility
-keep public class * extends *.aafwk.ability.AbilitySlice
-keep public class * extends *.aafwk.ability.AbilityPackage
-dontwarn java.lang.invoke.**
-dontwarn javax.naming.**
-keepattributes Signature, InnerClasses, EnclosingMethod, Exceptions
# 保留配置文件
-printmapping mapping.txt

49
Demo/src/main/config.json Normal file
View File

@@ -0,0 +1,49 @@
{
"app": {
"bundleName":"com.xcl.demo",
"vendor": "tzx",
"version": {
"code": 1932,
"name": "1.0.1"
}
},
"deviceConfig": {},
"module": {
"package": "com.xcl.demo",
"name": ".MyApplication",
"mainAbility": "com.xcl.demo.MainAbility",
"deviceType": [
"phone",
"tablet",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "Demo",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"name": "com.xcl.demo.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:Demo_MainAbility",
"type": "page",
"launchType": "standard"
}
]
}
}

View File

@@ -0,0 +1,97 @@
package com.xcl.demo;
import com.xcl.fancynew.*;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.utils.Color;
import ohos.global.resource.NotExistException;
import ohos.media.image.ImageSource;
import ohos.media.image.PixelMap;
import java.io.IOException;
import java.io.InputStream;
/**
* The type Main ability.
*
* @author Xcl
* @version 1.2
* @package com.xcl.fancynew
*/
public class MainAbility extends Ability implements Component.ClickedListener {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setUIContent(ResourceTable.Layout_ability_main);
Button button1, button2, button3, button4;
button1 = (Button) findComponentById(ResourceTable.Id_button_normal);
button2 = (Button) findComponentById(ResourceTable.Id_button_ryb);
button3 = (Button) findComponentById(ResourceTable.Id_button_line);
button4 = (Button) findComponentById(ResourceTable.Id_button_rotation);
button1.setClickedListener(this);
button2.setClickedListener(this);
button3.setClickedListener(this);
button4.setClickedListener(this);
}
private PixelMap getPixelMapFromResource(int resourceId) {
InputStream inputStream = null;
try {
// 创建图像数据源ImageSource对象
inputStream = getContext().getResourceManager().getResource(resourceId);
ImageSource.SourceOptions srcOpts = new ImageSource.SourceOptions();
srcOpts.formatHint = "image/png";
ImageSource imageSource = ImageSource.create(inputStream, srcOpts);
// 设置图片参数
ImageSource.DecodingOptions decodingOptions = new ImageSource.DecodingOptions();
return imageSource.createPixelmap(decodingOptions);
} catch (IOException | NotExistException e) {
e.printStackTrace();
}
return null;
}
@Override
public void onClick(Component component) {
switch (component.getId()) {
case ResourceTable.Id_button_normal:
OpeningStartAnimation openingStartAnimation = new OpeningStartAnimation.Builder(this, ResourceTable.Media_icon, 1)
.setDrawStategy(new NormalDrawStrategy())
.setAppIcon(getPixelMapFromResource(ResourceTable.Media_icon))
.setAppName("测试APP")
.setColorOfBackground(Color.rgb(255, 0, 0))
.setColorOfAppIcon(Color.rgb(255, 0, 0))
.setColorOfAppName(Color.rgb(0, 237, 255))
.setColorOfAppStatement(Color.rgb(68, 255, 0))
.create();
openingStartAnimation.show(this);
break;
case ResourceTable.Id_button_ryb:
OpeningStartAnimation openingStartAnimation1 = new OpeningStartAnimation.Builder(this, ResourceTable.Media_icon, 2)
.setDrawStategy(new RedYellowBlueDrawStrategy())
.setColorOfBackground(Color.BLACK.getValue())
.create();
openingStartAnimation1.show(this);
break;
case ResourceTable.Id_button_line:
OpeningStartAnimation openingStartAnimation2 = new OpeningStartAnimation.Builder(this, ResourceTable.Media_icon, 3)
.setDrawStategy(new LineDrawStrategy())
.setAppIcon(getPixelMapFromResource(ResourceTable.Media_icon))
.create();
openingStartAnimation2.show(this);
break;
case ResourceTable.Id_button_rotation:
OpeningStartAnimation openingStartAnimation3 = new OpeningStartAnimation.Builder(this, ResourceTable.Media_icon)
.setDrawStategy(new RotationDrawStrategy())
.create();
openingStartAnimation3.show(this);
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,17 @@
package com.xcl.demo;
import ohos.aafwk.ability.AbilityPackage;
/**
* The type My application.
*
* @author Xcl
* @version 1.2
* @package com.xcl.fancynew
*/
public class MyApplication extends AbilityPackage {
@Override
public void onInitialize() {
super.onInitialize();
}
}

View File

@@ -0,0 +1,16 @@
{
"string": [
{
"name": "Demo_MainAbility",
"value": "FancyNew示例"
},
{
"name": "mainability_description",
"value": "Java_Empty Ability"
},
{
"name": "mainability_HelloWorld",
"value": "Hello World"
}
]
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<shape
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:shape="rectangle">
<solid
ohos:color="#FFFFFF"/>
</shape>

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:orientation="vertical">
<Button
ohos:id="$+id:button_normal"
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="#30000000"
ohos:bottom_margin="10vp"
ohos:padding="10vp"
ohos:text="NormalDraw"
ohos:text_size="16fp"/>
<Button
ohos:id="$+id:button_ryb"
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="#30000000"
ohos:bottom_margin="10vp"
ohos:padding="10vp"
ohos:text="RYBDraw"
ohos:text_size="16fp"/>
<Button
ohos:id="$+id:button_line"
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="#30000000"
ohos:bottom_margin="10vp"
ohos:padding="10vp"
ohos:text="LineDraw"
ohos:text_size="16fp"/>
<Button
ohos:id="$+id:button_rotation"
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="#30000000"
ohos:bottom_margin="10vp"
ohos:padding="10vp"
ohos:text="RotationDraw"
ohos:text_size="16fp"/>
</DirectionalLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@@ -0,0 +1,14 @@
package com.xcl.demo;
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("", actualBundleName);
}
}

View File

@@ -0,0 +1,9 @@
package com.xcl.demo;
import org.junit.Test;
public class ExampleTest {
@Test
public void onStart() {
}
}