diff --git a/.gitignore b/.gitignore
index 067b13c7284cf578fd89843d2677f5fc7bedc27f..603b14077394cd2294ac6922fe619669630ef3ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,14 @@
*.iml
.gradle
/local.properties
-/.idea/workspace.xml
+/.idea/caches
/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
-.idea/
\ No newline at end of file
+.cxx
diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$
new file mode 100644
index 0000000000000000000000000000000000000000..96ce66b7bad790e3375595de9557ef041961420d
--- /dev/null
+++ b/.idea/$PRODUCT_WORKSPACE_FILE$
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e2f9acb6094bc3e295ccda1557c24967eb5dd072
--- /dev/null
+++ b/.idea/checkstyle-idea.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/checkstyleidea-libs/readme.txt b/.idea/checkstyleidea-libs/readme.txt
new file mode 100644
index 0000000000000000000000000000000000000000..18e341d93314706c7d585f81be2b2781284182da
--- /dev/null
+++ b/.idea/checkstyleidea-libs/readme.txt
@@ -0,0 +1,6 @@
+This folder contains libraries copied from the "branches" project.
+It is managed by the CheckStyle-IDEA IDE plugin.
+Do not modify this folder while the IDE is running.
+When the IDE is stopped, you may delete this folder at any time. It will be recreated as needed.
+In order to prevent the CheckStyle-IDEA IDE plugin from creating this folder,
+uncheck the "Copy libraries from project directory" option in the CheckStyle-IDEA settings dialog.
diff --git a/.idea/code-check/java/codemars.log b/.idea/code-check/java/codemars.log
new file mode 100644
index 0000000000000000000000000000000000000000..b229e2aae388cfe12a1597295b3f9cf23c41c330
--- /dev/null
+++ b/.idea/code-check/java/codemars.log
@@ -0,0 +1,50 @@
+2021-03-15 14:41:47.930 [main] INFO . - user input: E:\Program Files\Huawei\DevEco Studio\jbr\bin\java,-j,-source,@E:/WorkSpace/HM_ShadowLayout_master/branches/.idea/code-check/java/detect.txt,-output,E:/WorkSpace/HM_ShadowLayout_master/branches/.idea/code-check/java/output.xml
+2021-03-15 14:41:47.932 [main] INFO . - CodeMars Version:2.1.2.sp4
+2021-03-15 14:41:47.986 [main] INFO . - starting analyzing.
+2021-03-15 14:41:47.997 [main] INFO . - start collecting report.
+2021-03-15 14:41:48.000 [CodeMars1] INFO . - Command: "E:\Program Files\Huawei\DevEco Studio\plugins\codecheck\lib\CodeMars\engines\SecFinder-J\bin\run_SecFinder-J.bat",-filelist,E:\WorkSpace\HM_ShadowLayout_master\branches\.idea\code-check\java\filelist_2021_03_15_14_41_47_998_13.txt,-f,xml,-default,-progress,-r,E:\WorkSpace\HM_ShadowLayout_master\branches\.idea\code-check\java\\errorreport_2021_03_15_14_41_47_874_85.xml,-ruleclasspath,file:///E:\WorkSpace\HM_ShadowLayout_master\branches\.idea\code-check\java\ruleclasspath.txt
+2021-03-15 14:41:48.233 [Thread-2] INFO . - 15, 2021 2:41:48 com.huawei.secfinderj.SecFinderJ needScan
+2021-03-15 14:41:48.233 [Thread-2] INFO . - Ϣ: SecFinder-J Version: 2.1.3
+2021-03-15 14:41:48.320 [Thread-1] INFO . - 2021-03-15 14:41:48.281: SecFinder-J Output: Inspect start...
+2021-03-15 14:41:49.111 [Thread-1] INFO . - 2021-03-15 14:41:49.111: SecFinder-J Output: Load checkers...
+2021-03-15 14:41:49.254 [Thread-1] INFO . - 2021-03-15 14:41:49.253: SecFinder-J Output: Load config...
+2021-03-15 14:41:49.282 [Thread-1] INFO . - 2021-03-15 14:41:49.282: SecFinder-J Output: step 1/4: Find files
+2021-03-15 14:41:49.320 [Thread-1] INFO . - 2021-03-15 14:41:49.320: SecFinder-J Output: step 2/4: Process files
+2021-03-15 14:41:49.360 [Thread-1] INFO . - 2021-03-15 14:41:49.360: SecFinder-J Output: step 3/4: Run analysis...
+2021-03-15 14:41:49.361 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--3] - during processing of [ResourceTable.java]
+2021-03-15 14:41:49.361 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--2] - during processing of [ResourceTable.java]
+2021-03-15 14:41:49.361 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--8] - during processing of [MyApplication.java]
+2021-03-15 14:41:49.362 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--1] - during processing of [BuildConfig.java]
+2021-03-15 14:41:49.362 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--4] - during processing of [R.java]
+2021-03-15 14:41:49.362 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--6] - during processing of [ShellMyApplication.java]
+2021-03-15 14:41:49.364 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--5] - during processing of [MainAbilityShellActivity.java]
+2021-03-15 14:41:49.365 [Thread-1] INFO . - 2021-03-15 14:41:49.361: SecFinder-J Output: [SecFinder-J--Thread--7] - during processing of [MainAbility.java]
+2021-03-15 14:41:49.762 [Thread-1] INFO . - 2021-03-15 14:41:49.762: SecFinder-J Output: [SecFinder-J--Thread--2] - during processing of [SampleItemProvider.java]
+2021-03-15 14:41:49.763 [Thread-1] INFO . - 2021-03-15 14:41:49.763: SecFinder-J Output: [SecFinder-J--Thread--6] - during processing of [DynamicChangeAbilitySlice.java]
+2021-03-15 14:41:49.765 [Thread-1] INFO . - 2021-03-15 14:41:49.765: SecFinder-J Output: [SecFinder-J--Thread--8] - during processing of [ListAbilitySlice.java]
+2021-03-15 14:41:49.770 [Thread-1] INFO . - 2021-03-15 14:41:49.770: SecFinder-J Output: [SecFinder-J--Thread--3] - during processing of [MainAbilitySlice.java]
+2021-03-15 14:41:49.786 [Thread-1] INFO . - 2021-03-15 14:41:49.786: SecFinder-J Output: [SecFinder-J--Thread--7] - during processing of [ShowAbilitySlice.java]
+2021-03-15 14:41:49.792 [Thread-1] INFO . - 2021-03-15 14:41:49.792: SecFinder-J Output: [SecFinder-J--Thread--4] - during processing of [BuildConfig.java]
+2021-03-15 14:41:49.793 [Thread-1] INFO . - 2021-03-15 14:41:49.793: SecFinder-J Output: [SecFinder-J--Thread--1] - during processing of [ResourceTable.java]
+2021-03-15 14:41:49.813 [Thread-1] INFO . - 2021-03-15 14:41:49.813: SecFinder-J Output: [SecFinder-J--Thread--5] - during processing of [AttrUtil.java]
+2021-03-15 14:41:49.914 [Thread-1] INFO . - 2021-03-15 14:41:49.914: SecFinder-J Output: [SecFinder-J--Thread--6] - during processing of [ShadowLayout.java]
+2021-03-15 14:41:49.927 [Thread-1] INFO . - 2021-03-15 14:41:49.927: SecFinder-J Output: [SecFinder-J--Thread--4] - during processing of [ShadowComponent.java]
+2021-03-15 14:41:49.929 [Thread-1] INFO . - 2021-03-15 14:41:49.929: SecFinder-J Output: [SecFinder-J--Thread--3] - during processing of [ShadowDrawable.java]
+2021-03-15 14:41:49.938 [Thread-1] INFO . - 2021-03-15 14:41:49.938: SecFinder-J Output: [SecFinder-J--Thread--1] - during processing of [ShadowLayout1.java]
+2021-03-15 14:41:49.938 [Thread-1] INFO . - 2021-03-15 14:41:49.937: SecFinder-J Output: [SecFinder-J--Thread--8] - during processing of [ShadowLayout.java]
+2021-03-15 14:41:50.130 [Thread-1] INFO . - 2021-03-15 14:41:50.130: SecFinder-J Output: step 4/4: Result output...
+2021-03-15 14:41:50.130 [Thread-1] INFO . - 2021-03-15 14:41:50.130: SecFinder-J Output: Inspect finish...
+2021-03-15 14:41:50.130 [Thread-1] INFO . - Analysis result:
+2021-03-15 14:41:50.130 [Thread-1] INFO . - files analyzed : 21
+2021-03-15 14:41:50.130 [Thread-1] INFO . - lines analyzed : 1663
+2021-03-15 14:41:50.130 [Thread-1] INFO . - rules used : 59
+2021-03-15 14:41:50.130 [Thread-1] INFO . - issues detected : 0
+2021-03-15 14:41:50.130 [Thread-1] INFO . - time cost(sec) : 1
+2021-03-15 14:41:50.130 [Thread-1] INFO . -
+2021-03-15 14:41:50.131 [Thread-2] INFO . - 15, 2021 2:41:50 com.huawei.secfinderj.override.HwPmd end
+2021-03-15 14:41:50.131 [Thread-2] INFO . - Ϣ: SecFinder-J run successed!
+2021-03-15 14:41:50.194 [CodeMars1] INFO . - start parse errorreport xml
+2021-03-15 14:41:50.196 [CodeMars1] INFO . - parse xml time : 4
+2021-03-15 14:41:50.196 [CodeMars1] INFO . - end parse errorreport xml
+2021-03-15 14:41:50.197 [main] INFO . - end collecting report.
+2021-03-15 14:41:50.197 [main] INFO . - end analyzing.
diff --git a/.idea/code-check/java/detect.txt b/.idea/code-check/java/detect.txt
new file mode 100644
index 0000000000000000000000000000000000000000..a388f0e0318af5e9ea76b131730d21c60671cb6c
--- /dev/null
+++ b/.idea/code-check/java/detect.txt
@@ -0,0 +1,22 @@
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/build/intermediates/shell/debug/src/main/java/com/example/hm_shadowlayout_master/MainAbilityShellActivity.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/build/generated/source/r/com/lijiankun24/shadowlayout/ResourceTable.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/AttrUtil.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ListAbilitySlice.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowComponent.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout1.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ShowAbilitySlice.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/main/java/com/example/hm_shadowlayout_master/slice/DynamicChangeAbilitySlice.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/ShadowLayout.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/test/java/com/example/hm_shadowlayout_master/ExampleTest.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/main/java/com/example/hm_shadowlayout_master/MyApplication.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/build/generated/source/r/com/example/hm_shadowlayout_master/ResourceTable.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/build/generated/source/buildConfig/debug/com/example/hm_shadowlayout_master/BuildConfig.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/main/java/com/example/hm_shadowlayout_master/slice/MainAbilitySlice.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/build/generated/source/r/com/lijiankun24/shadowlayout/ResourceTable.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/main/java/com/example/hm_shadowlayout_master/MainAbility.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/build/intermediates/shell/debug/src/main/java/com/example/hm_shadowlayout_master/ShellMyApplication.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/build/intermediates/shell/debug/build/res/r/com/example/hm_shadowlayout_master/R.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowDrawable.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/shadowlayout/build/generated/source/buildConfig/debug/com/lijiankun24/shadowlayout/BuildConfig.java
+E:/WorkSpace/HM_ShadowLayout_master/branches/entry/src/main/java/com/example/hm_shadowlayout_master/provider/SampleItemProvider.java
diff --git a/.idea/code-check/java/output.xml b/.idea/code-check/java/output.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a69ad2080b18150720d3843d443abe112c5c2ca4
--- /dev/null
+++ b/.idea/code-check/java/output.xml
@@ -0,0 +1,9 @@
+
+
+
+
+21
+1663
+1
+0
+
diff --git a/.idea/code-check/java/ruleclasspath.txt b/.idea/code-check/java/ruleclasspath.txt
new file mode 100644
index 0000000000000000000000000000000000000000..f2523a2d78555dacdf4c585b4e4942aebe380c5d
--- /dev/null
+++ b/.idea/code-check/java/ruleclasspath.txt
@@ -0,0 +1 @@
+E:\Program Files\Huawei\DevEco Studio\plugins\codecheck\lib\CodeMars\engines\SecFinder-J\rule\
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000000000000000000000000000000000000..61a9130cd9669c3843e6445dfe1fee2d493869bc
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/chinasoft.xml b/.idea/copyright/chinasoft.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cfdf6c2c5aaca3c3b722eed8bba3e45f0697310a
--- /dev/null
+++ b/.idea/copyright/chinasoft.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..43bda82febb5eea40d96ef7468a1f6048407f5cf
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000000000000000000000000000000000000..588286e5ec9df23f553b8213a8169d4fe84056da
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000000000000000000000000000000000000..21770a1c363c17b3e5ad31dbc6182acf2bce4251
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ba2e7443424bc5abb3b2c16dd9751cfceb69faed
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..890e81047a4348566b46172a4cacb16ac3e6aec4
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/previewer/phone/phoneSettingConfig_-979570527.json b/.idea/previewer/phone/phoneSettingConfig_-979570527.json
new file mode 100644
index 0000000000000000000000000000000000000000..f505e6b9ca3d41faf1f0a39a496db58b117fbd60
--- /dev/null
+++ b/.idea/previewer/phone/phoneSettingConfig_-979570527.json
@@ -0,0 +1,25 @@
+{
+ "setting": {
+ "1.0.1": {
+ "Language": {
+ "args": {
+ "Language": "zh-CN"
+ }
+ }
+ }
+ },
+ "frontend": {
+ "1.0.0": {
+ "Resolution": {
+ "args": {
+ "Resolution": "360*780"
+ }
+ },
+ "DeviceType": {
+ "args": {
+ "DeviceType": "phone"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/.idea/previewer/phone/phoneSettingConfig_341013527.json b/.idea/previewer/phone/phoneSettingConfig_341013527.json
new file mode 100644
index 0000000000000000000000000000000000000000..f505e6b9ca3d41faf1f0a39a496db58b117fbd60
--- /dev/null
+++ b/.idea/previewer/phone/phoneSettingConfig_341013527.json
@@ -0,0 +1,25 @@
+{
+ "setting": {
+ "1.0.1": {
+ "Language": {
+ "args": {
+ "Language": "zh-CN"
+ }
+ }
+ }
+ },
+ "frontend": {
+ "1.0.0": {
+ "Resolution": {
+ "args": {
+ "Resolution": "360*780"
+ }
+ },
+ "DeviceType": {
+ "args": {
+ "DeviceType": "phone"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/.idea/previewer/previewConfig.json b/.idea/previewer/previewConfig.json
new file mode 100644
index 0000000000000000000000000000000000000000..f44f54c3b14252108bf8095dd14fbdde5e7acbed
--- /dev/null
+++ b/.idea/previewer/previewConfig.json
@@ -0,0 +1,12 @@
+{
+ "1.0.0": {
+ "LastPreviewDevice": {
+ "E:\\WorkSpace\\HM_ShadowLayout_master\\entry": [
+ "phone"
+ ],
+ "E:\\WorkSpace\\HM_ShadowLayout_master\\branches\\entry": [
+ "phone"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/.idea/previewer/tv/tvSettingConfig_341013527.json b/.idea/previewer/tv/tvSettingConfig_341013527.json
new file mode 100644
index 0000000000000000000000000000000000000000..735b7846e511202d22504a70bf2c92d8f7aba460
--- /dev/null
+++ b/.idea/previewer/tv/tvSettingConfig_341013527.json
@@ -0,0 +1,25 @@
+{
+ "setting": {
+ "1.0.1": {
+ "Language": {
+ "args": {
+ "Language": "zh-CN"
+ }
+ }
+ }
+ },
+ "frontend": {
+ "1.0.0": {
+ "Resolution": {
+ "args": {
+ "Resolution": "960*540"
+ }
+ },
+ "DeviceType": {
+ "args": {
+ "DeviceType": "tv"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d7636d1caa65fc25304f1069f02ae5f3cd2c159e
--- /dev/null
+++ b/.idea/qaplug_profiles.xml
@@ -0,0 +1,467 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.ch.md b/README.ch.md
deleted file mode 100644
index a24e40fbe0cce487110b0cf1a87040b924137e85..0000000000000000000000000000000000000000
--- a/README.ch.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# ShadowLayout
-
- [  ](https://bintray.com/lijiankun/maven/shadowlayout/_latestVersion)
-
-*Read this in other languages: [中文](README.ch.md), [English](README.md)*
-
-## 简介
-
-看一张使用 `ShadowLayout` 库实现的各种阴影的效果图,如下图所示:
-
-The result of using `ShadowLayout` is as follows:
-
-
-
+## 项目介绍
-By using `ShadowLayout`, you can set the color、shape、radius、display boundary (all|left|right|top|bottom), the offset of the x-axis and the y-axis of shadow.
+- 编程语言:Java
-You can change the color and radius of shadow dynamically, as follows:
-
-
-
+## 安装教程
-## How to use ShadowLayout
+1. 下载ShadowLayout的har包ShadowLayout-ohos.har(位于:https://gitee.com/chinasoft_ohos/ShadowLayout/releases/shadowLayout)。
+2. 启动 DevEco Studio,将下载的har包,导入工程目录“entry->libs”下。
+3. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下har包的引用。
+```
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ compile(name:'ShadowLayout-ohos', ext:'har')
+}
+```
-### Setting up the dependency
-Gradle:
-``` groovy
- implementation 'com.lijiankun24:shadowlayout:x.y.z'
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
+
+## 使用说明
+
+ShadowLayout
+
+1. 布局文件定义,提供控件:ShadowLayout
+
+```xml
+
+
+
```
+2. 在 AbilitySlice 中,这样配置
+
+```java
+//改变阴影颜色
+ShadowLayout slOval = (ShadowLayout) findComponentById(ResourceTable.Id_sl_oval);
+slOval.setShadowColor(Color.getIntColor("#FEFFD700"));
-Maven:
-``` groovy
-
- com.lijiankun24
- shadowlayout
- x.y.z
- pom
-
```
->Please replace x and y and z with the latest version numbers:[](https://bintray.com/lijiankun/maven/shadowlayout/_latestVersion)
-
-### Show Shadow
-config in xml:
-``` xml
-
-
-
-
+
+3.阴影的动态改变
+
+```java
+//改变阴影颜色
+ShadowLayout slOval = (ShadowLayout) findComponentById(ResourceTable.Id_sl_oval);
+slOval.setShadowColor(Color.getIntColor("#FEFFD700"));
+
+//改变阴影颜色
+ShadowLayout slRectangle = (ShadowLayout)findComponentById(ResourceTable.Id_sl_rectangle);
+slRectangle.setShadowColor(Color.getIntColor("#EE00FF7F"));
+
+// 改变阴影范围
+ShadowLayout slRadius = (ShadowLayout) findComponentById(ResourceTable.Id_sl_radius);
+slRadius.setShadowRadius(10f);
```
-The result of above xml is as follows:
-
-
-
-
-There are 6 properties in xml:
-* `app:shadowColor="#66000000"` set the color of shadow,**notice:Color must have a alpha value**
-* `app:shadowShape="rectangle|oval"` set the shape of shadow:rectangle|oval
-* `app:shadowDx="0dp"` set the shadow x-axis offset
-* `app:shadowDy="3dp"` set the shadow y-axis offset
-* `app:shadowRadius="10dp"` set the radius of shadow
-* `app:shadowSide="all|left|right|top|bottom"` set the display boundary (all|left|right|top|bottom) of shadow
-
-### Change shadow dynamically
-``` java
-// change the color of shadow
-ShadowLayout slOval = findViewById(R.id.sl_oval);
-slOval.setShadowColor(ContextCompat.getColor(this, R.color.drak_yellow))
-
-// change the color of shadow
-ShadowLayout slRectangle = findViewById(R.id.sl_rectangle)
-slRectangle.setShadowColor(Color.parseColor("#EE00FF7F"));
-
-// change the radius of shadow
-ShadowLayout slRadius = findViewById(R.id.sl_radius);
-slRadius.setShadowRadius(dip2px(12))
+
+6.其他说明
+```java
+无
```
-the result is as follows:
-
-
-
-
-Welcome to star and fork, and welcome to download the [ShadowLayoutExample.apk](https://github.com/lijiankun24/ShadowLayout/blob/master/ShadowLayoutExample.apk) to experience. if any questions are welcome. My work email: jiankunli24@gmail.com
-
-
-## License
-
-> ```
-> Copyright 2018 lijiankun24
->
-> Licensed under the Apache License, Version 2.0 (the "License");
-> you may not use this file except in compliance with the License.
-> You may obtain a copy of the License at
->
-> http://www.apache.org/licenses/LICENSE-2.0
->
-> Unless required by applicable law or agreed to in writing, software
-> distributed under the License is distributed on an "AS IS" BASIS,
-> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-> See the License for the specific language governing permissions and
-> limitations under the License.
-> ```
+
+自定义属性
+**ShadowLayout**
+
+
+| 名称 | 类型 |说明 |
+|---|---|---|
+|shadowRadius|float|阴影半径范围|
+|shadowColor|integer|阴影颜色|
+|shadowDx|float|控制x轴阴影偏移量|
+|shadowDy|float|控制y轴阴影偏移量|
+|shadowSide|integer|阴影方向: 0x1111 全部、0x0001 左侧、0x0010 上方、0x0100 右侧、0x1000 下方 |
+|shadowShape|integer|阴影形状展示: 0x0001 矩形、0x0010 圆形|
+
+
+## 效果图
+
+
+
+
+
+## 测试信息
+CodeCheck代码测试无异常
+
+CloudTest代码测试无异常
+
+火绒安全病毒安全检测通过
+
+当前版本demo功能与安卓原组件基本无差异
+
+测试员:李姗姗
+
+
+## 版本迭代
+- v0.0.1_alpha
+
+## 版权和许可信息
+- Copyright 2021 alpbak
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/ShadowLayoutExample.apk b/ShadowLayoutExample.apk
deleted file mode 100644
index 7f90487511a4988834329bf94f811979102edd3a..0000000000000000000000000000000000000000
Binary files a/ShadowLayoutExample.apk and /dev/null differ
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index 183ee29f9ac7dcf4a4c6a2e1e0b7668ebec7e4fd..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,33 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion rootProject.ext.compileSdkVersion
-
- defaultConfig {
- applicationId "com.lijiankun24.shadowlayout"
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(include: ['*.jar'], dir: 'libs')
- testImplementation 'junit:junit:4.12'
- androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
- implementation "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
- // implementation 'com.lijiankun24:shadowlayout:1.1.0'
- compile project(':library')
-}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index a542474a4648d6197e9940d5026bc82fd4dd31fe..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/lijiankun/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/app/src/androidTest/java/com/lijiankun24/shadowlayoutexample/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/lijiankun24/shadowlayoutexample/ExampleInstrumentedTest.java
deleted file mode 100644
index b7e96059b0ab476aa3012624b47f5e0165ab1c60..0000000000000000000000000000000000000000
--- a/app/src/androidTest/java/com/lijiankun24/shadowlayoutexample/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.lijiankun24.shadowlayoutexample;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.lijiankun24.shadowlayout", appContext.getPackageName());
- }
-}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index adb0f5e57d8be5143c936707dcf34a6da33adfd0..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/com/lijiankun24/shadowlayoutexample/DynamicChangeActivity.java b/app/src/main/java/com/lijiankun24/shadowlayoutexample/DynamicChangeActivity.java
deleted file mode 100644
index 770c3817dc09f94a46ba5dbbd1ec2154fea24f72..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lijiankun24/shadowlayoutexample/DynamicChangeActivity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.lijiankun24.shadowlayoutexample;
-
-import android.graphics.Color;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.util.DisplayMetrics;
-import android.view.View;
-
-import com.lijiankun24.shadowlayout.ShadowLayout;
-
-public class DynamicChangeActivity extends AppCompatActivity implements View.OnClickListener {
-
- private ShadowLayout SlOval = null;
-
- private ShadowLayout SlRectangle = null;
-
- private ShadowLayout SlRadius = null;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_dynamic_change);
- initView();
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.tv_change_oval:
- SlOval.setShadowColor(ContextCompat.getColor(this, R.color.drak_yellow));
- break;
- case R.id.tv_change_rectangle:
- SlRectangle.setShadowColor(Color.parseColor("#EE00FF7F"));
- break;
- case R.id.tv_change_radius:
- SlRadius.setShadowRadius(dip2px(12));
- break;
- }
- }
-
- private void initView() {
- findViewById(R.id.tv_change_oval).setOnClickListener(this);
- findViewById(R.id.tv_change_rectangle).setOnClickListener(this);
- findViewById(R.id.tv_change_radius).setOnClickListener(this);
- SlOval = findViewById(R.id.sl_oval);
- SlRectangle = findViewById(R.id.sl_rectangle);
- SlRadius = findViewById(R.id.sl_radius);
- }
-
-
- /**
- * dip2px dp 值转 px 值
- *
- * @param dpValue dp 值
- * @return px 值
- */
- private float dip2px(float dpValue) {
- DisplayMetrics dm = DynamicChangeActivity.this.getResources().getDisplayMetrics();
- float scale = dm.density;
- return (dpValue * scale + 0.5F);
- }
-}
diff --git a/app/src/main/java/com/lijiankun24/shadowlayoutexample/MainActivity.java b/app/src/main/java/com/lijiankun24/shadowlayoutexample/MainActivity.java
deleted file mode 100644
index 93375cb9cd04d57d06367a17374487af1957b257..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lijiankun24/shadowlayoutexample/MainActivity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.lijiankun24.shadowlayoutexample;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-
-import com.lijiankun24.shadowlayoutexample.about.AboutActivity;
-import com.lijiankun24.shadowlayoutexample.list.ListActivity;
-
-public class MainActivity extends AppCompatActivity implements Toolbar.OnMenuItemClickListener,
- View.OnClickListener {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- initView();
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.tv_to_show:
- startActivity(new Intent(MainActivity.this, ShowActivity.class));
- break;
- case R.id.tv_to_dynamic_change:
- startActivity(new Intent(MainActivity.this, DynamicChangeActivity.class));
- break;
- case R.id.tv_to_list:
- startActivity(new Intent(MainActivity.this, ListActivity.class));
- break;
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_main, menu);
- return true;
- }
-
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.menu_main_about:
- startActivity(new Intent(MainActivity.this, AboutActivity.class));
- break;
- }
- return true;
- }
-
- private void initView() {
- Toolbar toolbar = findViewById(R.id.tool_bar);
- setSupportActionBar(toolbar);
- toolbar.setOnMenuItemClickListener(this);
- findViewById(R.id.tv_to_show).setOnClickListener(this);
- findViewById(R.id.tv_to_dynamic_change).setOnClickListener(this);
- findViewById(R.id.tv_to_list).setOnClickListener(this);
- }
-}
diff --git a/app/src/main/java/com/lijiankun24/shadowlayoutexample/ShowActivity.java b/app/src/main/java/com/lijiankun24/shadowlayoutexample/ShowActivity.java
deleted file mode 100644
index 4320979394798bbd683dd42af95ebbd8e678408e..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lijiankun24/shadowlayoutexample/ShowActivity.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.lijiankun24.shadowlayoutexample;
-
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-
-public class ShowActivity extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_show);
- }
-}
diff --git a/app/src/main/java/com/lijiankun24/shadowlayoutexample/about/AboutActivity.java b/app/src/main/java/com/lijiankun24/shadowlayoutexample/about/AboutActivity.java
deleted file mode 100644
index 9f42f12b0ab1185ce6babe15a5aa2fed3a525e97..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lijiankun24/shadowlayoutexample/about/AboutActivity.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.lijiankun24.shadowlayoutexample.about;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.text.Html;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.TextView;
-
-import com.lijiankun24.shadowlayoutexample.R;
-
-public class AboutActivity extends AppCompatActivity implements View.OnClickListener {
-
- private Author mAuthor = new Author();
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_about);
- initView();
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.tv_github:
- toBrower(mAuthor.getGithub());
- break;
- case R.id.tv_weibo:
- toBrower(mAuthor.getWeibo());
- break;
- case R.id.tv_blog:
- toBrower(mAuthor.getBlog());
- break;
- case R.id.tv_jianshu:
- toBrower(mAuthor.getJianshu());
- break;
- case R.id.tv_mail:
- sendMail(mAuthor.getMail());
- break;
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- AboutActivity.this.finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
-
- private void initView() {
- TextView tvGithub = (TextView) findViewById(R.id.tv_github);
- tvGithub.setText(Html.fromHtml(getString(R.string.about_github, mAuthor.getGithub())));
- tvGithub.setOnClickListener(this);
-
- TextView tvWeibo = (TextView) findViewById(R.id.tv_weibo);
- tvWeibo.setText(Html.fromHtml(getString(R.string.about_weibo, mAuthor.getWeibo())));
- tvWeibo.setOnClickListener(this);
-
- TextView tvBlog = (TextView) findViewById(R.id.tv_blog);
- tvBlog.setText(Html.fromHtml(getString(R.string.about_blog, mAuthor.getBlog())));
- tvBlog.setOnClickListener(this);
-
- TextView tvJianshu = (TextView) findViewById(R.id.tv_jianshu);
- tvJianshu.setText(Html.fromHtml(getString(R.string.about_jianshu, mAuthor.getJianshu())));
- tvJianshu.setOnClickListener(this);
-
- TextView tvMail = (TextView) findViewById(R.id.tv_mail);
- tvMail.setText(Html.fromHtml(getString(R.string.about_mail, mAuthor.getMail())));
- tvMail.setOnClickListener(this);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- initToolbar(toolbar, true, AboutActivity.this.getString(R.string.about_activity_title));
- }
-
- private void sendMail(String mailUrl) {
- Intent data = new Intent(Intent.ACTION_SENDTO);
- data.setData(Uri.parse("mailto:" + mailUrl));
- startActivity(data);
- }
-
- private void toBrower(String url) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(url));
- startActivity(intent);
- }
-
- /**
- * 初始化 Toolbar
- *
- * @param toolbar 要初始化的 Toolbar 对象
- * @param setDisplayHomeAsUpEnabled 是否显示返回键
- * @param title 标题 Title
- */
- protected void initToolbar(Toolbar toolbar, boolean setDisplayHomeAsUpEnabled, String title) {
- setSupportActionBar(toolbar);
- if (getSupportActionBar() != null) {
- getSupportActionBar().setDisplayHomeAsUpEnabled(setDisplayHomeAsUpEnabled);
- getSupportActionBar().setTitle(title);
- }
- }
-}
diff --git a/app/src/main/java/com/lijiankun24/shadowlayoutexample/about/Author.java b/app/src/main/java/com/lijiankun24/shadowlayoutexample/about/Author.java
deleted file mode 100644
index a449f6463ebe9924cce539ac46287b98faed713a..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lijiankun24/shadowlayoutexample/about/Author.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.lijiankun24.shadowlayoutexample.about;
-
-/**
- * Author.java
- *
- * Created by lijiankun on 17/8/11.
- */
-
-public class Author {
-
- private String github = null;
-
- private String weibo = null;
-
- private String blog = null;
-
- private String mail = null;
-
- private String jianshu = null;
-
- Author() {
- github = "https://github.com/lijiankun24";
- weibo = "http://weibo.com/lijiankun24";
- blog = "http://lijiankun24.com";
- mail = "jiankunli24@gmail.com";
- jianshu = "http://www.jianshu.com/u/1abe21b7ff5f";
- }
-
- String getGithub() {
- return github;
- }
-
- String getWeibo() {
- return weibo;
- }
-
- String getBlog() {
- return blog;
- }
-
- String getMail() {
- return mail;
- }
-
- String getJianshu() {
- return jianshu;
- }
-}
diff --git a/app/src/main/java/com/lijiankun24/shadowlayoutexample/list/ListActivity.java b/app/src/main/java/com/lijiankun24/shadowlayoutexample/list/ListActivity.java
deleted file mode 100644
index 35cc028945e445b8c8984a37b2d8a77c38ff3c08..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lijiankun24/shadowlayoutexample/list/ListActivity.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.lijiankun24.shadowlayoutexample.list;
-
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-
-import com.lijiankun24.shadowlayoutexample.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ListActivity extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_list);
- RecyclerView recyclerView = findViewById(R.id.list);
- recyclerView.setLayoutManager(new LinearLayoutManager(ListActivity.this));
- recyclerView.setAdapter(new TestAdapter(getData(), ListActivity.this));
- }
-
- List getData() {
- List list = new ArrayList<>();
- for (int i = 0; i < 20; i++) {
- list.add("Test " + i);
- }
- return list;
- }
-}
diff --git a/app/src/main/java/com/lijiankun24/shadowlayoutexample/list/TestAdapter.java b/app/src/main/java/com/lijiankun24/shadowlayoutexample/list/TestAdapter.java
deleted file mode 100644
index ab78394f4813268ee528bdee4037c3d28b5f2db4..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lijiankun24/shadowlayoutexample/list/TestAdapter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.lijiankun24.shadowlayoutexample.list;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.lijiankun24.shadowlayoutexample.R;
-
-import java.util.List;
-
-/**
- * TestAdapter
- *
- * Created by lijiankun on 2018/10/11
- * Email: lijiankun03@meituan.com
- */
-class TestAdapter extends RecyclerView.Adapter {
-
- private List mDataList;
-
- private Context mContext;
-
- TestAdapter(List dataList, Context context) {
- this.mDataList = dataList;
- this.mContext = context;
- }
-
- @NonNull
- @Override
- public TestViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
- View view = LayoutInflater.from(mContext).inflate(R.layout.activity_list_item,
- viewGroup, false);
- return new TestViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(@NonNull TestViewHolder testViewHolder, int i) {
- String msg = null;
- if (i >= 0 && i < mDataList.size()) {
- msg = mDataList.get(i);
- }
- testViewHolder.onBind(msg);
- }
-
- @Override
- public int getItemCount() {
- return mDataList == null ? 0 : mDataList.size();
- }
-
- static class TestViewHolder extends RecyclerView.ViewHolder {
-
- private TextView mTV;
-
- TestViewHolder(@NonNull View itemView) {
- super(itemView);
- mTV = itemView.findViewById(R.id.tv_item);
- }
-
- void onBind(String msg) {
- mTV.setText(msg);
- }
- }
-}
diff --git a/app/src/main/res/drawable/circle_bg.xml b/app/src/main/res/drawable/circle_bg.xml
deleted file mode 100644
index c23f82f5031a41bf89ce790ef895979c83f133ab..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/circle_bg.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
deleted file mode 100644
index 5e718b43a5603067bd1133132e6a7f04356b7108..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_about.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_dynamic_change.xml b/app/src/main/res/layout/activity_dynamic_change.xml
deleted file mode 100644
index 5b13d250f7d06f5edfc0aff0e986eeff90edcbb4..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_dynamic_change.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_list.xml b/app/src/main/res/layout/activity_list.xml
deleted file mode 100644
index 5bc0d1fc5013b1baaedfd542b03e258c3e5211e8..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_list.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_list_item.xml b/app/src/main/res/layout/activity_list_item.xml
deleted file mode 100644
index 66805d7027c9cd75651cb0c982743bef09dbbcdd..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_list_item.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index c620b95cf876e039657da4245e76ee7ba069af63..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_show.xml b/app/src/main/res/layout/activity_show.xml
deleted file mode 100644
index e014ea847ad727cd750a36b0a95b55488037cf16..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_show.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
deleted file mode 100644
index f40afb5a5b4894d0fd69eda31e996b1daa86c9f5..0000000000000000000000000000000000000000
--- a/app/src/main/res/menu/menu_main.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index 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-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 9a078e3e1a42d474c78470a73c7987cf7ac5d9a0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index 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-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index efc028a636dd690a51db5a525cf781a5a7daba68..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 3af2608a4492ef9ae63a77ec3305aedda89594cb..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index 9bec2e623103ac9713b00cad8502a057c1efda61..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 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/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index 34947cd6bbf9c729be83edc96ad08a1d42b82bc9..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 14960fa666ae34fe6772a66213086d109ce49b7e..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- #2196F3
- #1976D2
- #448AFF
-
- #FEFFD700
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index 361e95ee1840a59339b11d8e3bf91dd07f06c748..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
- ShadowLayout
-
-
- Click to ShowActivity.
- Click to DynamicChangeActivity.
- Click to ListActivity.
-
-
-
- DynamicChangeActivity
- Click to change the color of oval shadow
- Click to change the color of rectangle shadow
- Click to change the radius of shadow
-
-
-
- Show Shadow
-
-
-
- about
- About
- Contact Me
- %s]]>
- %s(lijiankun24)]]>
- %s]]>
- %s]]>
- %s]]>
-
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 9585911a1f37aad8e3fb7a2c561c642c4e19e11b..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/app/src/test/java/com/lijiankun24/shadowlayoutexample/ExampleUnitTest.java b/app/src/test/java/com/lijiankun24/shadowlayoutexample/ExampleUnitTest.java
deleted file mode 100644
index f112ad87b84643fe40246de5a9d806a8cd41169c..0000000000000000000000000000000000000000
--- a/app/src/test/java/com/lijiankun24/shadowlayoutexample/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.lijiankun24.shadowlayoutexample;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-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 17a2efe4588a970cfb296bd3553b77a3942219b0..b83f1bc32d3ed4d4a953fe453ac4ed860f1d4352 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,33 +1,37 @@
// 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 4
+ }
+}
buildscript {
repositories {
- google()
+ maven {
+ url 'https://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.4'
- classpath 'com.novoda:bintray-release:0.8.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.5'
+ classpath 'com.huawei.ohos:decctest:1.0.0.6'
}
}
allprojects {
repositories {
- google()
+ maven {
+ url 'https://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
-
-ext {
- compileSdkVersion = 28
- buildToolsVersion = '27.0.3'
- minSdkVersion = 15
- targetSdkVersion = 28
- supportLibraryVersion = "28.0.0"
-}
\ No newline at end of file
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..ab57fbf36a63e6375429ac01d3cfaa341ab190c3
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,13 @@
+apply plugin: 'com.huawei.ohos.hap'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testCompile 'junit:junit:4.12'
+ compile project(path: ':shadowlayout')
+}
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..c741a520afcfd47425c8234a39294b8663fd54ed
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,50 @@
+{
+ "app": {
+ "bundleName": "com.example.hm_shadowlayout_master",
+ "vendor": "example",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.hm_shadowlayout_master",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone",
+ "tv"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.example.hm_shadowlayout_master.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "HM_ShadowLayout_master",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/example/hm_shadowlayout_master/MainAbility.java b/entry/src/main/java/com/example/hm_shadowlayout_master/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..83c05532b8983c1bc11bf2b400b7434079bc18f0
--- /dev/null
+++ b/entry/src/main/java/com/example/hm_shadowlayout_master/MainAbility.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.example.hm_shadowlayout_master;
+
+import com.example.hm_shadowlayout_master.slice.MainAbilitySlice;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * 主页
+ *
+ * @author renpengfei
+ * @since 2021-03-08
+ */
+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/example/hm_shadowlayout_master/MyApplication.java b/entry/src/main/java/com/example/hm_shadowlayout_master/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..3cb8dcb46a2d9ea14b616deb70254c5adfdb89aa
--- /dev/null
+++ b/entry/src/main/java/com/example/hm_shadowlayout_master/MyApplication.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.example.hm_shadowlayout_master;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/**
+ * 主程序
+ *
+ * @author renpengfei
+ * @since 2021-03-08
+ */
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/example/hm_shadowlayout_master/provider/SampleItemProvider.java b/entry/src/main/java/com/example/hm_shadowlayout_master/provider/SampleItemProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..2727830d621bdc390b8007a0de82ba10926429bb
--- /dev/null
+++ b/entry/src/main/java/com/example/hm_shadowlayout_master/provider/SampleItemProvider.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.example.hm_shadowlayout_master.provider;
+
+import com.example.hm_shadowlayout_master.ResourceTable;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.agp.components.BaseItemProvider;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.Text;
+
+import java.util.List;
+
+/**
+ * 列表适配器
+ *
+ * @author lijiankun
+ * @since 2021-03-11
+ */
+public class SampleItemProvider extends BaseItemProvider {
+ private List list;
+ private AbilitySlice abilitySlice;
+
+ /**
+ * 构造方法
+ *
+ * @param list
+ * @param abilitySlice
+ */
+ public SampleItemProvider(List list, AbilitySlice abilitySlice) {
+ this.list = list;
+ this.abilitySlice = abilitySlice;
+ }
+
+ @Override
+ public int getCount() {
+ return list == null ? 0 : list.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ if (list != null && position >= 0 && position < list.size()) {
+ return list.get(position);
+ }
+ return new Object();
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public Component getComponent(int position, Component component, ComponentContainer componentContainer) {
+ Component component1 = LayoutScatter.getInstance(abilitySlice).parse(ResourceTable.Layout_item_sample,
+ null, false);
+
+ String string = list.get(position);
+ Text text = (Text) component1.findComponentById(ResourceTable.Id_text_item);
+ text.setText(string);
+
+ text.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ }
+ });
+
+ return component1;
+ }
+}
diff --git a/entry/src/main/java/com/example/hm_shadowlayout_master/slice/DynamicChangeAbilitySlice.java b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/DynamicChangeAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..56af2d706be43170a38cc8212f1a5e611245bd69
--- /dev/null
+++ b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/DynamicChangeAbilitySlice.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.example.hm_shadowlayout_master.slice;
+
+import com.example.hm_shadowlayout_master.ResourceTable;
+import com.lijiankun24.shadowlayout.ShadowLayout;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.Text;
+import ohos.agp.utils.Color;
+
+/**
+ * 更改阴影效果展示类
+ *
+ * @author lijiankun
+ * @since 2021-03-08
+ */
+public class DynamicChangeAbilitySlice extends AbilitySlice {
+ private static final float RADIUS = 10f;
+ private static final float DEFAULT_RADIUS = 20f;
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_dynamic_change);
+
+ initComponent();
+ }
+
+ private void initComponent() {
+ ShadowLayout slOval = (ShadowLayout) findComponentById(ResourceTable.Id_sl_oval);
+ ShadowLayout slRectangle = (ShadowLayout) findComponentById(ResourceTable.Id_sl_rectangle);
+ ShadowLayout slRadius = (ShadowLayout) findComponentById(ResourceTable.Id_sl_radius);
+ slOval.setShadowColor(Color.getIntColor("#FE3311F3"));
+ slRectangle.setShadowColor(Color.getIntColor("#EE000000"));
+ slRadius.setShadowRadius(DEFAULT_RADIUS);
+ Text textOval = (Text) findComponentById(ResourceTable.Id_text_oval);
+ Text textRectangle = (Text) findComponentById(ResourceTable.Id_text_rectangle);
+ Text textRadius = (Text) findComponentById(ResourceTable.Id_text_radius);
+
+ textOval.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ slOval.setShadowColor(Color.getIntColor("#FEFFD700"));
+ }
+ });
+ textRectangle.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ slRectangle.setShadowColor(Color.getIntColor("#EE00FF7F"));
+ }
+ });
+
+ textRadius.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ slRadius.setShadowRadius(RADIUS);
+ }
+ });
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ListAbilitySlice.java b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ListAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..4e0f60f1d3a8a7c23bdfd7c6dc138a8ab0e18413
--- /dev/null
+++ b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ListAbilitySlice.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.example.hm_shadowlayout_master.slice;
+
+import com.example.hm_shadowlayout_master.ResourceTable;
+import com.example.hm_shadowlayout_master.provider.SampleItemProvider;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.ListContainer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 阴影列表页
+ *
+ * @author lijiankun
+ * @since 2021-03-08
+ */
+public class ListAbilitySlice extends AbilitySlice {
+ private ListContainer listContainer;
+ private List list;
+ private static final int COUNT = 20;
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_list);
+
+ initComponent();
+ }
+
+ private void initComponent() {
+ listContainer = (ListContainer) findComponentById(ResourceTable.Id_listContainer);
+ list = new ArrayList<>();
+
+ for (int i1 = 0; i1 < COUNT; i1++) {
+ list.add("item" + i1);
+ }
+
+ SampleItemProvider provider = new SampleItemProvider(list, this);
+ listContainer.setItemProvider(provider);
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/java/com/example/hm_shadowlayout_master/slice/MainAbilitySlice.java b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..dd4ffc9cf41ad65d34e6701c557e2b0e205c2bcc
--- /dev/null
+++ b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/MainAbilitySlice.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.example.hm_shadowlayout_master.slice;
+
+import com.example.hm_shadowlayout_master.ResourceTable;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.Text;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * 主页
+ *
+ * @author renpengfei
+ * @since 2021-03-08
+ */
+public class MainAbilitySlice extends AbilitySlice {
+ private HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, 0x00001, "ShadowLayout");
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ HiLog.info(logLabel, "onStart");
+ initComponent();
+ }
+
+ private void initComponent() {
+ Text show = (Text) findComponentById(ResourceTable.Id_text_show);
+ Text dynamicChange = (Text) findComponentById(ResourceTable.Id_text_dynamic_change);
+ Text list = (Text) findComponentById(ResourceTable.Id_text_list);
+
+ Intent intent = new Intent();
+
+ show.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ present(new ShowAbilitySlice(), intent);
+ }
+ });
+
+ dynamicChange.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ present(new DynamicChangeAbilitySlice(), intent);
+ }
+ });
+
+ list.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ present(new ListAbilitySlice(), intent);
+ }
+ });
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ HiLog.info(logLabel, "onActive");
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ HiLog.info(logLabel, "onForeground");
+ }
+
+ @Override
+ protected void onBackground() {
+ super.onBackground();
+ HiLog.info(logLabel, "onBackground");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ HiLog.info(logLabel, "onStop");
+ }
+
+ @Override
+ protected void onInactive() {
+ super.onInactive();
+ HiLog.info(logLabel, "onInactive");
+ }
+}
diff --git a/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ShowAbilitySlice.java b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ShowAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..70d2e3431c28b98cd6c284e0f368db9e7b76ce14
--- /dev/null
+++ b/entry/src/main/java/com/example/hm_shadowlayout_master/slice/ShowAbilitySlice.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.example.hm_shadowlayout_master.slice;
+
+import com.example.hm_shadowlayout_master.ResourceTable;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+
+/**
+ * 图片阴影效果展示页
+ *
+ * @author lijiankun
+ * @since 2021-03-08
+ */
+public class ShowAbilitySlice extends AbilitySlice {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_show);
+
+ initComponent();
+ }
+
+ private void initComponent() {
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..dac8add941e2ba7a9db7566b30a83a5e404c19a2
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,56 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "HM_ShadowLayout"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "main_to_show",
+ "value": "Click to ShowActivity"
+ },
+ {
+ "name": "main_to_dynamic_change",
+ "value": "Click to DynamicChangeActivity"
+ },
+ {
+ "name": "main_to_list",
+ "value": "Click to ListActivity"
+ },
+ {
+ "name": "showability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "testability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "dynamicchangeability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "dynamic_change_oval_color",
+ "value": "Click to change the color of oval shadow"
+ },
+ {
+ "name": "dynamic_change_rectangle_color",
+ "value": "Click to change the color of rectangle shadow"
+ },
+ {
+ "name": "dynamic_change_shadow_radius",
+ "value": "Click to change the radius of shadow"
+ },
+ {
+ "name": "listability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_dynamic_change.xml b/entry/src/main/resources/base/graphic/background_ability_dynamic_change.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a002c2353e78af3a15235e00738328ff566bc085
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_dynamic_change.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_list.xml b/entry/src/main/resources/base/graphic/background_ability_list.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a002c2353e78af3a15235e00738328ff566bc085
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_list.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_show.xml b/entry/src/main/resources/base/graphic/background_ability_show.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a002c2353e78af3a15235e00738328ff566bc085
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_show.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_test.xml b/entry/src/main/resources/base/graphic/background_ability_test.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a002c2353e78af3a15235e00738328ff566bc085
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_test.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/circle_bg.xml b/entry/src/main/resources/base/graphic/circle_bg.xml
new file mode 100644
index 0000000000000000000000000000000000000000..0e1195c4a44db6a7fd81e4499b13f14dfdb9c359
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/circle_bg.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_dynamic_change.xml b/entry/src/main/resources/base/layout/ability_dynamic_change.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c2d360d1f05d094e9a2d41b47fb362b79eaa6641
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_dynamic_change.xml
@@ -0,0 +1,159 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_list.xml b/entry/src/main/resources/base/layout/ability_list.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6e7fe9d2c3ab0de4d0915e90b0a0cbebef297afe
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_list.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
\ 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..21db63bdefbf61239f38cbac79141d9710df4f4f
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_show.xml b/entry/src/main/resources/base/layout/ability_show.xml
new file mode 100644
index 0000000000000000000000000000000000000000..00edfdc2bfa8166e2beb6e22d58b0b66ba898f69
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_show.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/item_sample.xml b/entry/src/main/resources/base/layout/item_sample.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6a89c3377cea1ffc1a9740f7767c3f8e1959c3eb
--- /dev/null
+++ b/entry/src/main/resources/base/layout/item_sample.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/entry/src/main/resources/base/media/test.jpg b/entry/src/main/resources/base/media/test.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..7ef6ee5f7d2d73feb90b9cd86950384117799ff8
Binary files /dev/null and b/entry/src/main/resources/base/media/test.jpg differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/entry/src/main/resources/base/media/test1.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/ic_launcher.png
rename to entry/src/main/resources/base/media/test1.png
diff --git a/entry/src/test/java/com/example/hm_shadowlayout_master/ExampleTest.java b/entry/src/test/java/com/example/hm_shadowlayout_master/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1265dce805b4ceffe9552c8ab9081585466508f0
--- /dev/null
+++ b/entry/src/test/java/com/example/hm_shadowlayout_master/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.example.hm_shadowlayout_master;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index aac7c9b4614ccfde6c721f24994cf30885a791d0..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,17 +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.
-org.gradle.jvmargs=-Xmx1536m
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
+# 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 d92d5adfa06eac6393590cf55d246a68eb3d63ac..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Tue Jan 09 22:50:59 CST 2018
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-4.4-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,26 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/image/gif.gif b/image/gif.gif
new file mode 100644
index 0000000000000000000000000000000000000000..fa0bd1c689d2a3efb4bcdbee11ebd809a9437e71
Binary files /dev/null and b/image/gif.gif differ
diff --git a/image/png.png b/image/png.png
new file mode 100644
index 0000000000000000000000000000000000000000..cd0d6d07e02ed5ac618807639cf913802a1267a1
Binary files /dev/null and b/image/png.png differ
diff --git a/library/build.gradle b/library/build.gradle
deleted file mode 100644
index 4d37fce088e80155e34ae6fe6e6410b8c6f6551c..0000000000000000000000000000000000000000
--- a/library/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-apply plugin: 'com.android.library'
-apply plugin: 'com.novoda.bintray-release'
-
-android {
- compileSdkVersion rootProject.ext.compileSdkVersion
-
- defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 1
- versionName "1.0"
-
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
-}
-
-publish {
- userOrg = 'lijiankun' // bintray.com 用户名
- groupId = 'com.lijiankun24' // jcenter 上的路径
- artifactId = 'shadowlayout' // 项目名称
- publishVersion = '1.1.0' // 版本号
- desc = 'This is a libray for android developer to add shadow to view'
- website = 'http://lijiankun24.com'
-}
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
deleted file mode 100644
index a542474a4648d6197e9940d5026bc82fd4dd31fe..0000000000000000000000000000000000000000
--- a/library/proguard-rules.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/lijiankun/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/library/src/androidTest/java/com/lijiankun24/shadowlayout/ExampleInstrumentedTest.java b/library/src/androidTest/java/com/lijiankun24/shadowlayout/ExampleInstrumentedTest.java
deleted file mode 100644
index 186caba6c12b9d37aa4e361fe597b16fc21154be..0000000000000000000000000000000000000000
--- a/library/src/androidTest/java/com/lijiankun24/shadowlayout/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.lijiankun24.shadowlayout;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.lijiankun24.library.test", appContext.getPackageName());
- }
-}
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index 8384ad4b9a346ebe9672b5b47d767d368d899ce9..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
diff --git a/library/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowDrawable.java b/library/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowDrawable.java
deleted file mode 100644
index 8b70bfcbe72911c76b0969e01afaef5e5af89401..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowDrawable.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.lijiankun24.shadowlayout.v2;
-
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.ColorFilter;
-import android.graphics.Paint;
-import android.graphics.PixelFormat;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffXfermode;
-import android.graphics.RectF;
-import android.graphics.drawable.Drawable;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.util.Log;
-
-/**
- * ShadowDrawable
- *
- * Created by lijiankun on 2018/9/28
- * Email: lijiankun03@meituan.com
- */
-public class ShadowDrawable extends Drawable {
-
- private Paint mShadowPaint;
- private int mShape;
- private float mShadowRadius;
- private float mOffsetX;
- private float mOffsetY;
- private RectF mRect;
-
- public ShadowDrawable(int shape, int shadowColor, float shadowRadius, float offsetX, float offsetY) {
- this.mShape = shape;
- this.mShadowRadius = shadowRadius;
- this.mOffsetX = offsetX;
- this.mOffsetY = offsetY;
-
- mShadowPaint = new Paint();
- mShadowPaint.setColor(Color.TRANSPARENT);
- mShadowPaint.setAntiAlias(true);
- mShadowPaint.setShadowLayer(shadowRadius, offsetX, offsetY, shadowColor);
- mShadowPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));
- }
-
- @Override
- public void setBounds(int left, int top, int right, int bottom) {
- super.setBounds(left, top, right, bottom);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds left " + left);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds top " + top);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds right " + right);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds bottom " + bottom);
- mRect = new RectF(left + mShadowRadius - mOffsetX, top + mShadowRadius - mOffsetY, right - mShadowRadius - mOffsetX,
- bottom - mShadowRadius - mOffsetY);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds mRect.left " + mRect.left);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds mRect.top " + mRect.top);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds mRect.right " + mRect.right);
- Log.i("ShadowLayout1", "ShadowDrawable1 setBounds mRect.bottom " + mRect.bottom);
- }
-
- @Override
- public void draw(@NonNull Canvas canvas) {
- Log.i("ShadowLayout3", "ShadowDrawable1 draw " + canvas);
-
- if (mShape == ShadowLayout.SHAPE_RECTANGLE) {
- canvas.drawRect(mRect, mShadowPaint);
- } else if (mShape == ShadowLayout.SHAPE_OVAL) {
- canvas.drawCircle(mRect.centerX(), mRect.centerY(), Math.min(mRect.width(), mRect.height()) / 2, mShadowPaint);
- }
- }
-
- @Override
- public void setAlpha(int alpha) {
- mShadowPaint.setAlpha(alpha);
- }
-
- @Override
- public void setColorFilter(@Nullable ColorFilter colorFilter) {
- mShadowPaint.setColorFilter(colorFilter);
- }
-
- @Override
- public int getOpacity() {
- return PixelFormat.TRANSLUCENT;
- }
-}
diff --git a/library/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout.java b/library/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout.java
deleted file mode 100644
index f94439f7170ce25e6c5a9706d51ffc1433009f62..0000000000000000000000000000000000000000
--- a/library/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout.java
+++ /dev/null
@@ -1,177 +0,0 @@
-package com.lijiankun24.shadowlayout.v2;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.view.ViewCompat;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import com.lijiankun24.shadowlayout.R;
-
-/**
- * ShadowLayout
- *
- * Created by lijiankun24 on 2018/9/25
- * Email: jiankunli24@gmail.com
- */
-public class ShadowLayout extends FrameLayout {
-
- public static final int ALL = 0x1111;
-
- public static final int LEFT = 0x0001;
-
- public static final int TOP = 0x0010;
-
- public static final int RIGHT = 0x0100;
-
- public static final int BOTTOM = 0x1000;
-
- public static final int SHAPE_RECTANGLE = 0x0001;
-
- public static final int SHAPE_OVAL = 0x0010;
-
- /**
- * 阴影的颜色
- */
- private int mShadowColor = Color.TRANSPARENT;
-
- /**
- * 阴影的大小范围
- */
- private float mShadowRadius = 0;
-
- /**
- * 阴影 x 轴的偏移量
- */
- private float mShadowDx = 0;
-
- /**
- * 阴影 y 轴的偏移量
- */
- private float mShadowDy = 0;
-
- /**
- * 阴影显示的边界
- */
- private int mShadowSide = ALL;
-
- /**
- * 阴影的形状,圆形/矩形
- */
- private int mShadowShape = SHAPE_RECTANGLE;
-
- private ShadowDrawable mShadowDrawable;
-
- public ShadowLayout(@NonNull Context context) {
- this(context, null, 0);
- }
-
- public ShadowLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public ShadowLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- initialize(attrs);
- }
-
- private void initialize(@Nullable AttributeSet attrs) {
- TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ShadowLayout);
- if (typedArray != null) {
- mShadowShape = typedArray.getInt(R.styleable.ShadowLayout_shadowShape, SHAPE_RECTANGLE);
- mShadowRadius = typedArray.getDimension(R.styleable.ShadowLayout_shadowRadius, 0);
- mShadowColor = typedArray.getColor(R.styleable.ShadowLayout_shadowColor,
- getContext().getResources().getColor(android.R.color.black));
- mShadowDx = typedArray.getDimension(R.styleable.ShadowLayout_shadowDx, 0);
- mShadowDy = typedArray.getDimension(R.styleable.ShadowLayout_shadowDy, 0);
- mShadowSide = typedArray.getInt(R.styleable.ShadowLayout_shadowSide, ALL);
-
- typedArray.recycle();
- }
-
- mShadowDrawable = new ShadowDrawable(mShadowShape, mShadowColor,
- mShadowRadius, mShadowDx, mShadowDy);
- setLayerType(View.LAYER_TYPE_SOFTWARE, null); // 关闭硬件加速
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- float effect = mShadowRadius;
- float rectLeft = 0;
- float rectTop = 0;
- float rectRight = this.getMeasuredWidth();
- float rectBottom = this.getMeasuredHeight();
- Log.i("ShadowLayout", "ShadowLayout onMeasure getMeasuredWidth " + this.getMeasuredWidth());
- Log.i("ShadowLayout", "ShadowLayout onMeasure getMeasuredHeight " + this.getMeasuredHeight());
- this.getWidth();
- if ((mShadowSide & LEFT) == LEFT) {
- rectLeft = -effect;
- }
- if ((mShadowSide & TOP) == TOP) {
- rectTop = -effect;
- }
- if ((mShadowSide & RIGHT) == RIGHT) {
- rectRight = this.getMeasuredWidth() + effect;
- }
- if ((mShadowSide & BOTTOM) == BOTTOM) {
- rectBottom = this.getMeasuredHeight() + effect;
- }
- if (mShadowDy != 0.0f) {
- rectBottom = rectBottom + mShadowDy;
- }
- if (mShadowDx != 0.0f) {
- rectRight = rectRight + mShadowDx;
- }
- widthMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize((int) (rectRight - rectLeft)), MeasureSpec.EXACTLY);
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize((int) (rectBottom - rectTop)), MeasureSpec.EXACTLY);
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- Log.i("ShadowLayout", "ShadowLayout onMeasure getMeasuredWidth " + px2dip(this.getMeasuredWidth()));
- Log.i("ShadowLayout", "ShadowLayout onMeasure getMeasuredHeight " + px2dip(this.getMeasuredHeight()));
- }
-
- @Override
- protected void dispatchDraw(Canvas canvas) {
- Log.i("ShadowLayout", "ShadowLayout dispatchDraw");
- super.dispatchDraw(canvas);
- ViewCompat.setBackground(ShadowLayout.this, mShadowDrawable);
- }
-
- @Override
- public void setPadding(int left, int top, int right, int bottom) {
- // NO OP
- }
-
- @Override
- public void setPaddingRelative(int start, int top, int end, int bottom) {
- // NO OP
- }
-
- /**
- * dip2px dp 值转 px 值
- *
- * @param dpValue dp 值
- * @return px 值
- */
- private float dp2Px(float dpValue) {
- DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
- float scale = dm.density;
- return (dpValue * scale + 0.5F);
- }
-
- /**
- * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
- */
- private int px2dip(float pxValue) {
- final float scale = getContext().getResources().getDisplayMetrics().density;
- return (int) (pxValue / scale + 0.5f);
- }
-}
-
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
deleted file mode 100644
index 75f8e87592592383eee482ea898a19ef5165cc04..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
deleted file mode 100644
index 49fc91e1dd831bf7eb837809f992376b78077d4d..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- library
-
diff --git a/library/src/main/res/values/values.xml b/library/src/main/res/values/values.xml
deleted file mode 100644
index d4f9b664550769c56574a881c864d7091a2214e6..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/values.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- #FF424242
- #FFFFFFFF
- #FF424242
- #FFFFFFFF
- #03000000
- #37000000
- 1dp
-
\ No newline at end of file
diff --git a/library/src/test/java/com/lijiankun24/shadowlayout/ExampleUnitTest.java b/library/src/test/java/com/lijiankun24/shadowlayout/ExampleUnitTest.java
deleted file mode 100644
index 3bc5d9489ef311f95101fdf0d1f518b554b90f5e..0000000000000000000000000000000000000000
--- a/library/src/test/java/com/lijiankun24/shadowlayout/ExampleUnitTest.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.lijiankun24.shadowlayout;
-
-import static junit.framework.Assert.assertEquals;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/lijiankun24 b/lijiankun24
deleted file mode 100644
index a2060007c13f249bfa33a7d01e328ee6af754a48..0000000000000000000000000000000000000000
Binary files a/lijiankun24 and /dev/null differ
diff --git a/screenshot/DynamicChange.gif b/screenshot/DynamicChange.gif
deleted file mode 100644
index c83995a5b15ed2c25d740161d1efd28ed330cd8f..0000000000000000000000000000000000000000
Binary files a/screenshot/DynamicChange.gif and /dev/null differ
diff --git a/screenshot/ShowShadowLayout.png b/screenshot/ShowShadowLayout.png
deleted file mode 100644
index b9de249b0e505ba724c6f52a37c8b188d7a5bfcf..0000000000000000000000000000000000000000
Binary files a/screenshot/ShowShadowLayout.png and /dev/null differ
diff --git a/screenshot/shadowlayout1.png b/screenshot/shadowlayout1.png
deleted file mode 100644
index 70abe2886c6ae26f65d728dcba3e94de6c73d46c..0000000000000000000000000000000000000000
Binary files a/screenshot/shadowlayout1.png and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index 33069973b21ca48fd9db7889bf3865384837327a..c8d8f43fd7ab20953ee498a68eeb94ce69b58904 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':library'
+include ':entry', ':shadowlayout'
diff --git a/library/.gitignore b/shadowlayout/.gitignore
similarity index 100%
rename from library/.gitignore
rename to shadowlayout/.gitignore
diff --git a/shadowlayout/build.gradle b/shadowlayout/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..ab88c3009d8c2ddd387481757f1eb81ba8c834fe
--- /dev/null
+++ b/shadowlayout/build.gradle
@@ -0,0 +1,13 @@
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testCompile 'junit:junit:4.12'
+}
diff --git a/shadowlayout/src/main/config.json b/shadowlayout/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..7f8ec255de351a13d8704ff3f3580d73ce5a3617
--- /dev/null
+++ b/shadowlayout/src/main/config.json
@@ -0,0 +1,28 @@
+{
+ "app": {
+ "bundleName": "com.example.hm_shadowlayout_master",
+ "vendor": "lijiankun24",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Beta3"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.lijiankun24.shadowlayout",
+ "deviceType": [
+ "phone",
+ "tv"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "shadowlayout",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/AttrUtil.java b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/AttrUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..fb08f2a3f0995bdbdc9858fa53c11bc014328f77
--- /dev/null
+++ b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/AttrUtil.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.lijiankun24.shadowlayout;
+
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.element.Element;
+import ohos.agp.utils.Color;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * 自定义属性工具类
+ *
+ * @author renpengfei
+ * @since 2021-03-08
+ */
+public class AttrUtil {
+ private static String colon = "::";
+ private static HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP,0x001,"Error");
+
+ private AttrUtil() {
+ }
+
+ /**
+ * 获取字符属性
+ *
+ * @param attrSet
+ * @param key
+ * @param defValue
+ * @return 字符
+ */
+ public static String getStringValue(AttrSet attrSet, String key, String defValue) {
+ if (attrSet.getAttr(key).isPresent()) {
+ return attrSet.getAttr(key).get().getStringValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * 获取色值属性
+ *
+ * @param attrSet
+ * @param key
+ * @param defValue
+ * @return 色值
+ */
+ public static Color getColorValue(AttrSet attrSet, String key, String defValue) {
+ if (attrSet.getAttr(key).isPresent()) {
+ return attrSet.getAttr(key).get().getColorValue();
+ } else {
+ return new Color(Color.getIntColor(defValue));
+ }
+ }
+
+ /**
+ * 获取Boolean属性
+ *
+ * @param attrSet
+ * @param key
+ * @param isValue
+ * @return boolean
+ */
+ public static boolean getBooleanValue(AttrSet attrSet, String key, boolean isValue) {
+ if (attrSet.getAttr(key).isPresent()) {
+ return attrSet.getAttr(key).get().getBoolValue();
+ } else {
+ return isValue;
+ }
+ }
+
+ /**
+ * 获取元素属性
+ *
+ * @param attrSet
+ * @param key
+ * @param defValue
+ * @return 元素
+ */
+ public static Element getElementValue(AttrSet attrSet, String key, Element defValue) {
+ if (attrSet.getAttr(key).isPresent()) {
+ return attrSet.getAttr(key).get().getElement();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * 带单位的数字
+ *
+ * @param attrSet
+ * @param key
+ * @param defDimensionValue
+ * @return 数字
+ */
+ public static int getDimension(AttrSet attrSet, String key, int defDimensionValue) {
+ if (attrSet.getAttr(key).isPresent()) {
+ return attrSet.getAttr(key).get().getDimensionValue();
+ } else {
+ return defDimensionValue;
+ }
+ }
+
+ /**
+ * 获取int数值属性
+ *
+ * @param attrSet
+ * @param key
+ * @param defValue
+ * @return int
+ */
+ public static int getIntegerValue(AttrSet attrSet, String key, int defValue) {
+ if (attrSet.getAttr(key).isPresent()) {
+ return attrSet.getAttr(key).get().getIntegerValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * 获取float数值属性
+ *
+ * @param attrSet
+ * @param key
+ * @param defValue
+ * @return float
+ */
+ public static float getFloatValue(AttrSet attrSet, String key, float defValue) {
+ if (attrSet.getAttr(key).isPresent()) {
+ return attrSet.getAttr(key).get().getFloatValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * 获取资源文件id 格式 $layout:布局名称
+ *
+ * @param attrSet
+ * @param resourceKey
+ * @param defvalue
+ * @return id
+ * @throws IllegalStateException 异常处理
+ */
+ public static int getResourceId(AttrSet attrSet, String resourceKey, int defvalue) {
+ int resourceId = defvalue;
+ if (attrSet.getAttr(resourceKey).isPresent()) {
+ String value = attrSet.getAttr(resourceKey).get().getStringValue();
+ if (value.contains(colon)) {
+ try {
+ resourceId = Integer.parseInt(value.substring(value.indexOf(":") + 1));
+ } catch (NumberFormatException e) {
+ HiLog.error(logLabel,e.toString());
+ }
+ } else {
+ throw new IllegalStateException("请确认是否添加正确的资源文件,格式@layout:布局名称");
+ }
+ }
+ return resourceId;
+ }
+
+ /**
+ * 获取资源文件id 格式 $layout:布局名称
+ *
+ * @param attrSet
+ * @param resourceKey
+ * @param defvalue
+ * @return id
+ * @throws IllegalStateException 异常处理
+ */
+ public static int getMediaId(AttrSet attrSet, String resourceKey, int defvalue) {
+ int resourceId = defvalue;
+ if (attrSet.getAttr(resourceKey).isPresent()) {
+ String value = attrSet.getAttr(resourceKey).get().getStringValue();
+ if (value.contains(colon)) {
+ try {
+ resourceId = Integer.parseInt(value.substring(value.indexOf(":") + 1));
+ } catch (NumberFormatException e) {
+ HiLog.error(logLabel,e.toString());
+ }
+ } else {
+ throw new IllegalStateException("请确认是否添加正确的资源文件,格式$Media:图片名称");
+ }
+ }
+ return resourceId;
+ }
+}
diff --git a/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/NumberUtil.java b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/NumberUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..015474782899722b9e27ef526fa4e4e78e3606ea
--- /dev/null
+++ b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/NumberUtil.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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.lijiankun24.shadowlayout;
+
+/**
+ * 算法工具类
+ *
+ * @author renpengfei
+ * @since 2021-04-08
+ */
+public class NumberUtil {
+ /**
+ * 默认除法运算精度
+ */
+ private static final int DEF_DIV_SCALE = 16;
+
+ private NumberUtil() {
+ }
+
+ /**
+ * 提供精确的加法运算。
+ *
+ * @param v1 被加数
+ * @param v2 加数
+ * @return 两个参数的和
+ */
+ public static double add(double v1, double v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.add(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的加法运算。
+ *
+ * @param v1 被加数
+ * @param v2 加数
+ * @return 两个参数的和
+ */
+ public static double add(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.add(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的减法运算。
+ *
+ * @param v1 被减数
+ * @param v2 减数
+ * @return 两个参数的差
+ */
+ public static double sub(double v1, double v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.subtract(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的减法运算。
+ *
+ * @param v1 被减数
+ * @param v2 减数
+ * @return 两个参数的差
+ */
+ public static double sub(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.subtract(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的乘法运算。
+ *
+ * @param v1 被乘数
+ * @param v2 乘数
+ * @return 两个参数的积
+ */
+ public static double mul(double v1, double v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.multiply(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的乘法运算。
+ *
+ * @param v1 被乘数
+ * @param v2 乘数
+ * @return 两个参数的积
+ */
+ public static double mul(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.multiply(b2).doubleValue();
+ }
+
+ /**
+ * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
+ *
+ * @param v1 被除数
+ * @param v2 除数
+ * @return 两个参数的商
+ */
+ public static double div(double v1, double v2) {
+ return div(v1, v2, DEF_DIV_SCALE);
+ }
+
+ /**
+ * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
+ *
+ * @param v1 被除数
+ * @param v2 除数
+ * @return 两个参数的商
+ */
+ public static double div(String v1, String v2) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
+ java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
+ return b1.divide(b2, DEF_DIV_SCALE, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ /**
+ * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
+ *
+ * @param v1 被除数
+ * @param v2 除数
+ * @param scale 表示表示需要精确到小数点以后几位。
+ * @return 两个参数的商
+ */
+ public static double div(double v1, double v2, int scale) {
+ java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
+ java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
+ return b1.divide(b2, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ /**
+ * 提供精确的小数位四舍五入处理。
+ *
+ * @param value 需要四舍五入的数字
+ * @param scale 小数点后保留几位
+ * @return 四舍五入后的结果
+ */
+ public static double round(double value, int scale) {
+ java.math.BigDecimal bigDecimal = new java.math.BigDecimal(Double.toString(value));
+ java.math.BigDecimal one = new java.math.BigDecimal("1");
+ return bigDecimal.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ /**
+ * 提供精确的小数位四舍五入处理。
+ *
+ * @param value 需要四舍五入的数字
+ * @param scale 小数点后保留几位
+ * @return 四舍五入后的结果
+ */
+ public static double round(String value, int scale) {
+ java.math.BigDecimal bigDecimal = new java.math.BigDecimal(value);
+ java.math.BigDecimal one = new java.math.BigDecimal("1");
+ return bigDecimal.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+}
diff --git a/library/src/main/java/com/lijiankun24/shadowlayout/ShadowLayout.java b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/ShadowLayout.java
similarity index 30%
rename from library/src/main/java/com/lijiankun24/shadowlayout/ShadowLayout.java
rename to shadowlayout/src/main/java/com/lijiankun24/shadowlayout/ShadowLayout.java
index 73532ce43380143b5e4754d19ce592dea05c704f..80ad4f12c516853c25d0be015eae6e4fd5e08610 100644
--- a/library/src/main/java/com/lijiankun24/shadowlayout/ShadowLayout.java
+++ b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/ShadowLayout.java
@@ -1,46 +1,101 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.lijiankun24.shadowlayout;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.view.View;
-import android.widget.RelativeLayout;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.DependentLayout;
+import ohos.agp.components.element.Element;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.MaskFilter;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.RectFloat;
+import ohos.agp.window.service.Display;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.app.Context;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+import java.util.Optional;
/**
- * ShadowLayout.java
- *
- * Created by lijiankun on 17/8/11.
+ * ShadowLayout阴影控件类型2
+ *
+ * @author lijiankun
+ * @since 2021-03-08
*/
-
-public class ShadowLayout extends RelativeLayout {
-
+public class ShadowLayout extends DependentLayout implements Component.EstimateSizeListener, Component.DrawTask {
+ /**
+ * 全部阴影
+ */
public static final int ALL = 0x1111;
-
+ /**
+ * 阴影左侧
+ */
public static final int LEFT = 0x0001;
-
+ /**
+ * 阴影上方
+ */
public static final int TOP = 0x0010;
-
+ /**
+ * 阴影右侧
+ */
public static final int RIGHT = 0x0100;
-
+ /**
+ * 阴影下方
+ */
public static final int BOTTOM = 0x1000;
+ /**
+ * 矩形
+ */
public static final int SHAPE_RECTANGLE = 0x0001;
+ /**
+ * 圆形
+ */
public static final int SHAPE_OVAL = 0x0010;
- private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private static final int DP_VALUE = 5;
+ private static final int HALF = 2;
+ private static final float DP_VALUE1 = 0.5f;
+ private static final float RADIUS = 40f;
+
+ private Paint mPaint = new Paint();
- private RectF mRectF = new RectF();
+ {
+ /**
+ * 防抖动
+ */
+ mPaint.setDither(true);
+ /**
+ * 抗锯齿,降低分辨率,提高绘制效率
+ */
+ mPaint.setAntiAlias(true);
+ }
+
+ private RectFloat mRectF = new RectFloat();
/**
* 阴影的颜色
*/
- private int mShadowColor = Color.TRANSPARENT;
+ private int mShadowColor;
/**
* 阴影的大小范围
@@ -48,12 +103,12 @@ public class ShadowLayout extends RelativeLayout {
private float mShadowRadius = 0;
/**
- * 阴影 x 轴的偏移量
+ * 阴影 x轴的偏移量
*/
private float mShadowDx = 0;
/**
- * 阴影 y 轴的偏移量
+ * 阴影 y轴的偏移量
*/
private float mShadowDy = 0;
@@ -67,32 +122,62 @@ public class ShadowLayout extends RelativeLayout {
*/
private int mShadowShape = SHAPE_RECTANGLE;
+ private HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, 0x001, "Shadow---1");
+
+ /**
+ * 构造
+ *
+ * @param context
+ */
public ShadowLayout(Context context) {
this(context, null);
}
- public ShadowLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
+ /**
+ * 有参构造
+ *
+ * @param context
+ * @param attrs
+ */
+ public ShadowLayout(Context context, AttrSet attrs) {
+ this(context, attrs, null);
}
- public ShadowLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+ /**
+ * 有参构造
+ *
+ * @param context
+ * @param attrs
+ * @param defStyleAttr
+ */
+ public ShadowLayout(Context context, AttrSet attrs, String defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
+ setEstimateSizeListener(this);
+ addDrawTask(this);
}
+ /**
+ * 测量
+ *
+ * @param i
+ * @param i1
+ * @return
+ */
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- float effect = mShadowRadius + dip2px(5);
+ public boolean onEstimateSize(int i, int i1) {
+ float effect = (float) NumberUtil.add(mShadowRadius,dip2px(DP_VALUE));
float rectLeft = 0;
float rectTop = 0;
- float rectRight = this.getMeasuredWidth();
- float rectBottom = this.getMeasuredHeight();
+ float rectRight = this.getWidth();
+ float rectBottom = this.getHeight();
int paddingLeft = 0;
int paddingTop = 0;
int paddingRight = 0;
int paddingBottom = 0;
this.getWidth();
+
+ // 计算所需的边距值
if ((mShadowSide & LEFT) == LEFT) {
rectLeft = effect;
paddingLeft = (int) effect;
@@ -102,53 +187,82 @@ public class ShadowLayout extends RelativeLayout {
paddingTop = (int) effect;
}
if ((mShadowSide & RIGHT) == RIGHT) {
- rectRight = this.getMeasuredWidth() - effect;
+ rectRight = (float) NumberUtil.sub(this.getEstimatedWidth(),effect);
paddingRight = (int) effect;
}
if ((mShadowSide & BOTTOM) == BOTTOM) {
- rectBottom = this.getMeasuredHeight() - effect;
+ rectBottom = (float) NumberUtil.sub(this.getEstimatedHeight(),effect);
paddingBottom = (int) effect;
}
- if (mShadowDy != 0.0f) {
- rectBottom = rectBottom - mShadowDy;
+ if (String.valueOf(mShadowDy) != null) {
+ rectBottom = (float) NumberUtil.sub(rectBottom,mShadowDy);
paddingBottom = paddingBottom + (int) mShadowDy;
}
- if (mShadowDx != 0.0f) {
- rectRight = rectRight - mShadowDx;
+ if (String.valueOf(mShadowDx) != null) {
+ rectRight = (float) NumberUtil.sub(rectRight,mShadowDx);
paddingRight = paddingRight + (int) mShadowDx;
}
mRectF.left = rectLeft;
mRectF.top = rectTop;
mRectF.right = rectRight;
mRectF.bottom = rectBottom;
+ /**
+ * 设置边距
+ */
this.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ HiLog.error(logLabel, "onEstimateSize---paddingLeft" + paddingLeft
+ + "--paddingTop" + paddingTop + "--paddingRight" + paddingRight + "--paddingBottom" + paddingBottom);
+
+ invalidate();
+ return false;
}
/**
* 真正绘制阴影的方法
*/
@Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
+ public void onDraw(Component component, Canvas canvas) {
setUpShadowPaint();
if (mShadowShape == SHAPE_RECTANGLE) {
+ HiLog.error(logLabel, "onDraw---执行SHAPE_RECTANGLE");
canvas.drawRect(mRectF, mPaint);
} else if (mShadowShape == SHAPE_OVAL) {
- canvas.drawCircle(mRectF.centerX(), mRectF.centerY(), Math.min(mRectF.width(), mRectF.height()) / 2, mPaint);
+ HiLog.error(logLabel, "onDraw---执行SHAPE_OVAL");
+ canvas.drawCircle(mRectF.getHorizontalCenter(), mRectF.getVerticalCenter(),
+ Math.min(mRectF.getWidth(), mRectF.getHeight()) / HALF, mPaint);
}
}
+ /**
+ * 设置背景
+ *
+ * @param element
+ */
+ @Override
+ public void setBackground(Element element) {
+ super.setBackground(element);
+ }
+
+ /**
+ * 设置阴影颜色
+ *
+ * @param shadowColor
+ */
public void setShadowColor(int shadowColor) {
mShadowColor = shadowColor;
- requestLayout();
- postInvalidate();
+ postLayout();
+ invalidate();
}
+ /**
+ * 设置阴影半径
+ *
+ * @param shadowRadius
+ */
public void setShadowRadius(float shadowRadius) {
mShadowRadius = shadowRadius;
- requestLayout();
- postInvalidate();
+ postLayout();
+ invalidate();
}
/**
@@ -156,29 +270,46 @@ public class ShadowLayout extends RelativeLayout {
*
* @param attrs 从其中获取设置的值
*/
- private void init(AttributeSet attrs) {
- setLayerType(View.LAYER_TYPE_SOFTWARE, null); // 关闭硬件加速
- this.setWillNotDraw(false); // 调用此方法后,才会执行 onDraw(Canvas) 方法
-
- TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ShadowLayout);
- if (typedArray != null) {
- mShadowColor = typedArray.getColor(R.styleable.ShadowLayout_shadowColor,
- getContext().getResources().getColor(android.R.color.black));
- mShadowRadius = typedArray.getDimension(R.styleable.ShadowLayout_shadowRadius, dip2px(0));
- mShadowDx = typedArray.getDimension(R.styleable.ShadowLayout_shadowDx, dip2px(0));
- mShadowDy = typedArray.getDimension(R.styleable.ShadowLayout_shadowDy, dip2px(0));
- mShadowSide = typedArray.getInt(R.styleable.ShadowLayout_shadowSide, ALL);
- mShadowShape = typedArray.getInt(R.styleable.ShadowLayout_shadowShape, SHAPE_RECTANGLE);
- typedArray.recycle();
- }
+ private void init(AttrSet attrs) {
+ mShadowShape = AttrUtil.getIntegerValue(attrs, "shadowShape", SHAPE_RECTANGLE);
+ mShadowRadius = AttrUtil.getFloatValue(attrs, "shadowRadius", 0f);
+ mShadowColor = Color.getIntColor(AttrUtil.getStringValue(attrs, "shadowColor", "#000000"));
+ mShadowDx = AttrUtil.getFloatValue(attrs, "shadowDx", 0f);
+ mShadowDy = AttrUtil.getFloatValue(attrs, "shadowDy", 0f);
+ mShadowSide = AttrUtil.getIntegerValue(attrs, "shadowSide", ALL);
+
setUpShadowPaint();
}
+ /**
+ * 设置阴影属性
+ */
private void setUpShadowPaint() {
+ postLayout();
+
mPaint.reset();
- mPaint.setAntiAlias(true);
- mPaint.setColor(Color.TRANSPARENT);
- mPaint.setShadowLayer(mShadowRadius, mShadowDx, mShadowDy, mShadowColor);
+
+ mPaint.setColor(new Color(mShadowColor));
+ mPaint.setStyle(Paint.Style.FILL_STYLE);
+ /**
+ * 设置阴影圆角半径
+ */
+ mPaint.setCornerPathEffectRadius(mShadowRadius);
+ /**
+ * 设置描边
+ */
+ mPaint.setStrokeJoin(Paint.Join.ROUND_JOIN);
+
+ /**
+ * 设置滤镜
+ */
+ mPaint.setMaskFilter(new MaskFilter(RADIUS, MaskFilter.Blur.OUTER));
+
+ mPaint.setGradientShaderColor(new Color[]{new Color(mShadowColor), Color.TRANSPARENT});
+
+ HiLog.error(logLabel, "setUpShadowPaint----mShadowShape" + mShadowShape + "--mShadowRadius"
+ + mShadowRadius + "--mShadowColor" + mShadowColor + "--mShadowDx"
+ + mShadowDx + "--mShadowDy" + mShadowDy + "--mShadowSide" + mShadowSide);
}
/**
@@ -188,8 +319,9 @@ public class ShadowLayout extends RelativeLayout {
* @return px 值
*/
private float dip2px(float dpValue) {
- DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
- float scale = dm.density;
- return (dpValue * scale + 0.5F);
+ Optional defaultDisplay = DisplayManager.getInstance().getDefaultDisplay(this.getContext());
+ DisplayAttributes attributes = defaultDisplay.get().getAttributes();
+ float scale = attributes.densityPixels;
+ return (float) NumberUtil.add(NumberUtil.mul(dpValue,scale),DP_VALUE1);
}
}
diff --git a/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowComponent.java b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowComponent.java
new file mode 100644
index 0000000000000000000000000000000000000000..0580e6e367015036329d1de1bc36357a331c0e2f
--- /dev/null
+++ b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowComponent.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.lijiankun24.shadowlayout.v2;
+
+import ohos.agp.render.ColorFilter;
+import ohos.media.image.common.PixelFormat;
+
+/**
+ * 阴影接口
+ *
+ * @author lijiankun
+ * @since 2021-03-08
+ */
+public interface ShadowComponent {
+ /**
+ * 设置色彩滤镜
+ *
+ * @param colorFilter
+ * @noinspection checkstyle:Indentation
+ */
+ void setColorFilter(ColorFilter colorFilter);
+
+ /**
+ * 获取透明度
+ *
+ * @return 返回像素格式
+ */
+ PixelFormat getOpacity();
+}
diff --git a/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowDrawable.java b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowDrawable.java
new file mode 100644
index 0000000000000000000000000000000000000000..071aeb8c08940392229b54fb7b46f379d75adc2c
--- /dev/null
+++ b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowDrawable.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.lijiankun24.shadowlayout.v2;
+
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.Component;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.ColorFilter;
+import ohos.agp.render.LinearShader;
+import ohos.agp.render.MaskFilter;
+import ohos.agp.render.Paint;
+import ohos.agp.render.Paint.Style;
+import ohos.agp.render.Path;
+import ohos.agp.render.Shader;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.Point;
+import ohos.agp.utils.RectFloat;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+import ohos.media.image.common.PixelFormat;
+
+/**
+ * android版
+ * ShadowDrawable
+ *
+ * @author lijiankun
+ * @since 2021-03-08
+ */
+public class ShadowDrawable extends ShapeElement implements Component.DrawTask, ShadowComponent {
+ private static final float RADIUS = 50.0f;
+ private static final float START = 0.1f;
+ private static final float STOP = 0.7f;
+ private Paint mShadowPaint = new Paint();
+ private Paint mHelpPaint = new Paint();
+ private int mShape;
+ private float mShadowRadius;
+ private float mOffsetX;
+ private float mOffsetY;
+ private RectFloat mRect;
+ private int mShadowColor;
+ private Point[] newPoints;
+ private Color[] colors;
+
+ private HiLogLabel hiLogLabel = new HiLogLabel(HiLog.LOG_APP, 0x001, "ShadowLayout1");
+
+ {
+ /**
+ * 防抖动
+ */
+ mShadowPaint.setDither(true);
+ /**
+ * 抗锯齿,降低分辨率,提高绘制效率
+ */
+ mShadowPaint.setAntiAlias(true);
+ }
+
+ /**
+ * 构造
+ *
+ * @param shape
+ * @param shadowColor
+ * @param shadowRadius
+ * @param offsetX
+ * @param offsetY
+ */
+ public ShadowDrawable(int shape, int shadowColor, float shadowRadius, float offsetX, float offsetY) {
+ this.mShape = shape;
+ this.mShadowRadius = shadowRadius;
+ this.mOffsetX = offsetX;
+ this.mOffsetY = offsetY;
+ this.mShadowColor = shadowColor;
+
+ initPaint();
+ }
+
+ private void initPaint() {
+ /**
+ * 设置画笔属性
+ */
+ mShadowPaint.setColor(new Color(mShadowColor));
+ mShadowPaint.setStyle(Style.FILL_STYLE);
+ /**
+ * 设置阴影圆角半径
+ */
+ mShadowPaint.setCornerPathEffectRadius(mShadowRadius);
+ /**
+ * 设置描边
+ */
+ mShadowPaint.setStrokeJoin(Paint.Join.ROUND_JOIN);
+
+ /**
+ * 设置滤镜
+ */
+ mShadowPaint.setMaskFilter(new MaskFilter(RADIUS, MaskFilter.Blur.OUTER));
+
+ mShadowPaint.setGradientShaderColor(new Color[]{new Color(mShadowColor), Color.YELLOW});
+
+ /**
+ * 控件内使用透明画笔
+ */
+ mHelpPaint.setColor(Color.TRANSPARENT);
+ mHelpPaint.setStyle(Paint.Style.FILL_STYLE);
+ mHelpPaint.setStrokeCap(Paint.StrokeCap.SQUARE_CAP);
+
+ mShadowPaint.setMaskFilter(new MaskFilter(RADIUS, MaskFilter.Blur.OUTER));
+ }
+
+ /**
+ * 设定阴影范围 对应四个方向
+ *
+ * @param left
+ * @param top
+ * @param right
+ * @param bottom
+ */
+ @Override
+ public void setBounds(int left, int top, int right, int bottom) {
+ super.setBounds(left, top, right, bottom);
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds left " + left);
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds top " + top);
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds right " + right);
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds bottom " + bottom);
+ mRect = new RectFloat(left + mShadowRadius - mOffsetX,
+ top + mShadowRadius - mOffsetY, right - mShadowRadius - mOffsetX, bottom - mShadowRadius - mOffsetY);
+
+ newPoints = getBoundPoint(mRect);
+ colors = new Color[]{new Color(mShadowColor), Color.TRANSPARENT};
+
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds mRect.left " + mRect.left);
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds mRect.top " + mRect.top);
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds mRect.right " + mRect.right);
+ HiLog.info(hiLogLabel, "ShadowDrawable1 setBounds mRect.bottom " + mRect.bottom);
+ }
+
+ /**
+ * 阴影绘制
+ *
+ * @param component
+ * @param canvas
+ */
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ HiLog.info(hiLogLabel, "ShadowDrawable1 draw " + canvas);
+ HiLog.error(hiLogLabel, "----" + mShape);
+
+ /**
+ * 设置着色器
+ */
+ LinearShader shader = new LinearShader(newPoints,
+ new float[]{START, STOP}, colors, Shader.TileMode.CLAMP_TILEMODE);
+ mShadowPaint.setShader(shader, Paint.ShaderType.SWEEP_SHADER);
+
+ Path path = new Path();
+ path.lineTo(0, 0);
+ path.lineTo(0, component.getHeight());
+ path.lineTo(component.getHeight(), component.getWidth());
+ path.lineTo(component.getWidth(), 0);
+
+ canvas.drawPath(path, mShadowPaint);
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ mShadowPaint.setAlpha(alpha);
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter colorFilter) {
+ mShadowPaint.setColorFilter(colorFilter);
+ }
+
+ @Override
+ public PixelFormat getOpacity() {
+ return PixelFormat.ARGB_8888;
+ }
+
+ @Override
+ public void setRgbColor(RgbColor color) {
+ super.setRgbColor(color);
+ }
+
+ /**
+ * 获取绑定点
+ *
+ * @param rectFloat
+ * @return
+ */
+ private Point[] getBoundPoint(RectFloat rectFloat) {
+ Point point1 = new Point(rectFloat.left, rectFloat.top);
+ Point point2 = new Point(rectFloat.left, rectFloat.bottom);
+
+ Point[] boundPoints = new Point[]{point1, point2};
+ return boundPoints;
+ }
+
+ /**
+ * 画矩形
+ *
+ * @param rectFloat
+ * @return
+ */
+ private float[] getBoundStops(RectFloat rectFloat) {
+ Point point1 = new Point(rectFloat.left, rectFloat.top);
+ Point point2 = new Point(rectFloat.left, rectFloat.bottom);
+ Point point3 = new Point(rectFloat.right, rectFloat.bottom);
+ Point point4 = new Point(rectFloat.right, rectFloat.top);
+
+ float[] boundStops = new float[]{
+ point1.position[0], point1.position[1], point2.position[0], point2.position[1],
+ point2.position[0], point2.position[1], point3.position[0], point3.position[1],
+ point3.position[0], point3.position[1], point4.position[0], point4.position[1],
+ point4.position[0], point4.position[1], point1.position[0], point1.position[1]};
+ return boundStops;
+ }
+}
diff --git a/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout.java b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout.java
new file mode 100644
index 0000000000000000000000000000000000000000..041f29bec00d8435f9c398c3c4f226da8acec28f
--- /dev/null
+++ b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout.java
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.lijiankun24.shadowlayout.v2;
+
+import com.lijiankun24.shadowlayout.AttrUtil;
+
+import com.lijiankun24.shadowlayout.NumberUtil;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.StackLayout;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.LinearShader;
+import ohos.agp.render.MaskFilter;
+import ohos.agp.render.Paint;
+import ohos.agp.render.Path;
+import ohos.agp.render.Shader;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.Point;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * ShadowLayout阴影控件类型1
+ *
+ * @author renpengfei
+ * @since 2021-03-08
+ */
+public class ShadowLayout extends StackLayout implements Component.EstimateSizeListener, Component.DrawTask {
+ /**
+ * 全部阴影
+ */
+ public static final int ALL = 0x1111;
+ /**
+ * 阴影左侧
+ */
+ public static final int LEFT = 0x0001;
+ /**
+ * 阴影上方
+ */
+ public static final int TOP = 0x0010;
+ /**
+ * 阴影右侧
+ */
+ public static final int RIGHT = 0x0100;
+ /**
+ * 阴影下方
+ */
+ public static final int BOTTOM = 0x1000;
+ /**
+ * 矩形阴影
+ */
+ public static final int SHAPE_RECTANGLE = 0x0001;
+ /**
+ * 圆角阴影
+ */
+ public static final int SHAPE_OVAL = 0x0010;
+
+ private static final float START = 0.1f;
+ private static final float STOP = 0.5f;
+
+ /**
+ * 阴影的颜色
+ */
+ private int mShadowColor;
+
+ /**
+ * 阴影的大小范围
+ */
+ private float mShadowRadius = 0;
+
+ /**
+ * 阴影 x轴的偏移量
+ */
+ private float mShadowDx = 0;
+
+ /**
+ * 阴影 y轴的偏移量
+ */
+ private float mShadowDy = 0;
+
+ /**
+ * 阴影显示的边界
+ */
+ private int mShadowSide = ALL;
+
+ /**
+ * 阴影画笔
+ */
+ private Paint mShadowPaint = new Paint();
+ private Paint mHelpPaint = new Paint();
+
+ {
+ /**
+ * 防抖动
+ */
+ mShadowPaint.setDither(true);
+ /**
+ * 抗锯齿,降低分辨率,提高绘制效率
+ */
+ mShadowPaint.setAntiAlias(true);
+ }
+
+ /**
+ * 区域赋值
+ */
+ private RectFloat mRectFloat;
+
+ private Point[] newPoints;
+ private float[] newStops;
+ private Color[] colors;
+ private Path path = new Path();
+
+ private HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, 0x0001, "Shadow---0");
+ private int left;
+ private int top;
+ private int right;
+ private int bottom;
+
+ /**
+ * 构造
+ *
+ * @param context
+ */
+ public ShadowLayout(Context context) {
+ this(context, null);
+ }
+
+ /**
+ * 有参构造
+ *
+ * @param context
+ * @param attrSet
+ */
+ public ShadowLayout(Context context, AttrSet attrSet) {
+ this(context, attrSet, null);
+ }
+
+ /**
+ * 有参构造
+ *
+ * @param context
+ * @param attrSet
+ * @param styleName
+ */
+ public ShadowLayout(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ initialize(attrSet);
+ setEstimateSizeListener(this);
+ addDrawTask(this);
+ }
+
+ private void initialize(AttrSet attrs) {
+ /**
+ * 获取自定义属性
+ */
+ mShadowRadius = AttrUtil.getFloatValue(attrs, "shadowRadius", 0f);
+ mShadowColor = Color.getIntColor(AttrUtil.getStringValue(attrs, "shadowColor", "#000000"));
+ mShadowDx = AttrUtil.getFloatValue(attrs, "shadowDx", 0f);
+ mShadowDy = AttrUtil.getFloatValue(attrs, "shadowDy", 0f);
+ mShadowSide = AttrUtil.getIntegerValue(attrs, "shadowSide", ALL);
+
+ initPaint();
+ }
+
+ /**
+ * 初始化画笔属性
+ */
+ private void initPaint() {
+ /**
+ * 控件内使用透明画笔
+ */
+ mHelpPaint.setColor(Color.TRANSPARENT);
+ mHelpPaint.setStyle(Paint.Style.FILL_STYLE);
+ mHelpPaint.setStrokeCap(Paint.StrokeCap.ROUND_CAP);
+
+ mShadowPaint.setColor(new Color(mShadowColor));
+ mShadowPaint.setStyle(Paint.Style.FILL_STYLE);
+ mShadowPaint.setStrokeCap(Paint.StrokeCap.ROUND_CAP);
+ /**
+ * 设置描边
+ */
+ mShadowPaint.setStrokeJoin(Paint.Join.ROUND_JOIN);
+ /**
+ * 设置滤镜
+ */
+ mShadowPaint.setMaskFilter(new MaskFilter(mShadowRadius, MaskFilter.Blur.OUTER));
+ }
+
+ /**
+ * 测量方法
+ *
+ * @param widthMeasureSpec 宽
+ * @param heightMeasureSpec 高
+ * @return boolean
+ * @noinspection checkstyle:NoWhitespaceBefore
+ */
+ @Override
+ public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) {
+ float effect = mShadowRadius;
+ float rectLeft = 0;
+ float rectTop = 0;
+ float rectRight = this.getEstimatedWidth();
+ float rectBottom = this.getEstimatedHeight();
+ int paddingLeft = 0;
+ int paddingTop = 0;
+ int paddingRight = 0;
+ int paddingBottom = 0;
+
+ HiLog.error(logLabel, "ShadowLayout onMeasure getMeasuredWidth " + this.getEstimatedWidth());
+ HiLog.error(logLabel, "ShadowLayout onMeasure getMeasuredHeight " + this.getEstimatedHeight());
+ this.getWidth();
+ /**
+ * 获取控件间距
+ */
+ if ((mShadowSide & LEFT) == LEFT) {
+ rectLeft = -effect;
+ paddingLeft = (int) effect;
+ }
+ if ((mShadowSide & TOP) == TOP) {
+ rectTop = -effect;
+ paddingTop = (int) effect;
+ }
+ if ((mShadowSide & RIGHT) == RIGHT) {
+ rectRight = (float) NumberUtil.add(this.getEstimatedWidth(),effect);
+ paddingRight = (int) effect;
+ }
+ if ((mShadowSide & BOTTOM) == BOTTOM) {
+ rectBottom = (float) NumberUtil.add(this.getEstimatedHeight(),effect);
+ paddingBottom = (int) effect;
+ }
+ if (String.valueOf(mShadowDy) != null) {
+ rectBottom = (float) NumberUtil.add(rectBottom,mShadowDy);
+ paddingBottom = paddingBottom + (int) mShadowDy;
+ }
+ if (String.valueOf(mShadowDx) != null) {
+ rectRight = (float) NumberUtil.add(rectRight,mShadowDx);
+ paddingRight = paddingRight + (int) mShadowDx;
+ }
+ EstimateSpec.getSizeWithMode(
+ EstimateSpec.getSize((int) NumberUtil.sub(rectRight,rectLeft)), EstimateSpec.PRECISE);
+ EstimateSpec.getSizeWithMode(
+ EstimateSpec.getSize((int) NumberUtil.sub(rectBottom,rectTop)), EstimateSpec.PRECISE);
+
+ /**
+ * 设置间距
+ */
+ this.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
+ return false;
+ }
+
+ /**
+ * 绘制
+ *
+ * @param component
+ * @param canvas
+ */
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ left = component.getLeft();
+ top = component.getTop();
+ right = component.getRight();
+ bottom = component.getBottom();
+ double mRectFloatLeft = NumberUtil.sub(NumberUtil.add(left, mShadowRadius), mShadowDx);
+ double mRectFloatTop = NumberUtil.sub(NumberUtil.add(top, mShadowRadius), mShadowDy);
+ double mRectFloatRight = NumberUtil.sub(NumberUtil.sub(right, mShadowRadius), mShadowDx);
+ double mRectFloatBottom = NumberUtil.sub(NumberUtil.sub(bottom, mShadowRadius), mShadowDy);
+
+ mRectFloat = new RectFloat((float) mRectFloatLeft, (float) mRectFloatTop,
+ (float) mRectFloatRight, (float) mRectFloatBottom);
+
+ newPoints = getBoundPoint(mRectFloat);
+ newStops = new float[]{START, STOP};
+ colors = new Color[]{new Color(mShadowColor), Color.TRANSPARENT};
+
+ /**
+ * 添加着色器 坐标点,渐变值组,颜色值组,模式
+ */
+ LinearShader shader = new LinearShader(newPoints, newStops, colors, Shader.TileMode.CLAMP_TILEMODE);
+ mShadowPaint.setShader(shader, Paint.ShaderType.LINEAR_SHADER);
+ /**
+ * 绘制宽度
+ */
+ mShadowPaint.setStrokeWidth(mShadowRadius);
+
+ HiLog.error(logLabel, "width--" + component.getWidth() + "--height--" + component.getHeight());
+ HiLog.error(logLabel, "left--" + left + "--top--" + top + "--right--" + right + "--bottom--" + bottom);
+ HiLog.error(logLabel, "mRectFloat.getWidth--"
+ + mRectFloat.getWidth() + "--mRectFloat.getHeight--" + mRectFloat.getHeight());
+
+ /**
+ * 绘制矩形添加阴影
+ */
+ path.lineTo(mShadowRadius, mShadowRadius);
+ path.lineTo(mShadowRadius, (float) NumberUtil.add(mRectFloat.getHeight(),mShadowRadius));
+ path.lineTo((float) NumberUtil.add(mRectFloat.getWidth(),mShadowRadius),
+ (float) NumberUtil.add(mRectFloat.getHeight(),mShadowRadius));
+ path.lineTo((float) NumberUtil.add(mRectFloat.getWidth(),mShadowRadius), mShadowRadius);
+ path.lineTo(mShadowRadius, mShadowRadius);
+
+ path.close();
+
+ canvas.drawRect(mRectFloat, mHelpPaint);
+
+ canvas.drawPath(path, mShadowPaint);
+ }
+
+ @Override
+ public void setAlpha(float alpha) {
+ super.setAlpha(alpha);
+ mShadowPaint.setAlpha(alpha);
+ }
+
+ /**
+ * 获取绑定点
+ *
+ * @param rectFloat
+ * @return
+ */
+ private Point[] getBoundPoint(RectFloat rectFloat) {
+ Point point1 = new Point(rectFloat.left, rectFloat.top);
+ Point point2 = new Point(rectFloat.left, rectFloat.bottom);
+ Point point3 = new Point(rectFloat.right, rectFloat.bottom);
+ Point point4 = new Point(rectFloat.right, rectFloat.top);
+
+ return new Point[]{point1, point2, point3, point4};
+ }
+}
diff --git a/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout1.java b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout1.java
new file mode 100644
index 0000000000000000000000000000000000000000..bd00c556ffbf880af008c568b19cf77acd1d60db
--- /dev/null
+++ b/shadowlayout/src/main/java/com/lijiankun24/shadowlayout/v2/ShadowLayout1.java
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International 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 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.lijiankun24.shadowlayout.v2;
+
+import com.lijiankun24.shadowlayout.AttrUtil;
+
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.StackLayout;
+import ohos.agp.render.BlendMode;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.ColorFilter;
+import ohos.agp.utils.Color;
+import ohos.agp.window.service.Display;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.app.Context;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+import java.util.Optional;
+
+/**
+ * android版
+ * ShadowLayout
+ *
+ * @author lijiankun
+ * @since 2021-03-08
+ */
+public class ShadowLayout1 extends StackLayout implements Component.EstimateSizeListener,Component.DrawTask {
+
+ /**
+ * 全部阴影
+ */
+ public static final int ALL = 0x1111;
+ /**
+ * 阴影左侧
+ */
+ public static final int LEFT = 0x0001;
+ /**
+ * 阴影上方
+ */
+ public static final int TOP = 0x0010;
+ /**
+ * 阴影右侧
+ */
+ public static final int RIGHT = 0x0100;
+ /**
+ * 阴影下方
+ */
+ public static final int BOTTOM = 0x1000;
+ /**
+ * 矩形阴影
+ */
+ public static final int SHAPE_RECTANGLE = 0x0001;
+ /**
+ * 圆角阴影
+ */
+ public static final int SHAPE_OVAL = 0x0010;
+
+ private static final float NUM = 0.5f;
+ private static final int RED = 0xff0000;
+ private static final int GREEN = 0x00ff00;
+ private static final int BLUE = 0x0000ff;
+ private static final int SIXTEEN = 16;
+ private static final int EIGHT = 16;
+
+ private static final int ALPHA = 30;
+ private static final int TWO = 2;
+
+ /**
+ * 阴影的颜色
+ */
+ private int mShadowColor;
+
+ /**
+ * 阴影的大小范围
+ */
+ private float mShadowRadius = 0;
+
+ /**
+ * 阴影 x轴的偏移量
+ */
+ private float mShadowDx = 0;
+
+ /**
+ * 阴影 y轴的偏移量
+ */
+ private float mShadowDy = 0;
+
+ /**
+ * 阴影显示的边界
+ */
+ private int mShadowSide = ALL;
+
+ /**
+ * 阴影的形状,圆形/矩形
+ */
+ private int mShadowShape = SHAPE_RECTANGLE;
+
+ private ShadowDrawable mShadowDrawable;
+
+ private HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP,0x0001,"TAG--0");
+
+ /**
+ * 构造
+ *
+ * @param context
+ */
+ public ShadowLayout1(Context context) {
+ this(context, null);
+ }
+
+ /**
+ * 有参构造
+ *
+ * @param context
+ * @param attrs
+ */
+ public ShadowLayout1(Context context, AttrSet attrs) {
+ this(context, attrs, null);
+ }
+
+ /**
+ * 有参构造
+ *
+ * @param context
+ * @param attrs
+ * @param defStyleAttr
+ */
+ public ShadowLayout1(Context context, AttrSet attrs, String defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ initialize(attrs);
+ setEstimateSizeListener(this);
+ addDrawTask(this);
+ }
+
+ private void initialize(AttrSet attrs) {
+ /**
+ * 获取自定义属性
+ */
+ mShadowShape = AttrUtil.getIntegerValue(attrs,"shadowShape",SHAPE_OVAL);
+ mShadowRadius = AttrUtil.getFloatValue(attrs,"shadowRadius",0f);
+ mShadowColor = Color.getIntColor(AttrUtil.getStringValue(attrs,"shadowColor","#000000"));
+ mShadowDx = AttrUtil.getFloatValue(attrs,"shadowDx",0f);
+ mShadowDy = AttrUtil.getFloatValue(attrs,"shadowDy",0f);
+ mShadowSide = AttrUtil.getIntegerValue(attrs,"shadowSide",ALL);
+
+ /**
+ * 自定义阴影
+ */
+ mShadowDrawable = new ShadowDrawable(mShadowShape, mShadowColor,
+ mShadowRadius, mShadowDx, mShadowDy);
+ }
+
+ /**
+ * 测量方法与Android中onMeasure相似
+ *
+ * @param widthMeasureSpec
+ * @param heightMeasureSpec
+ * @return
+ */
+ @Override
+ public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) {
+ float effect = mShadowRadius;
+ float rectLeft = 0;
+ float rectTop = 0;
+ float rectRight = this.getWidth();
+ float rectBottom = this.getHeight();
+
+ int paddingLeft = 0;
+ int paddingTop = 0;
+ int paddingRight = 0;
+ int paddingBottom = 0;
+
+ HiLog.info(logLabel, "ShadowLayout onMeasure getMeasuredWidth " + this.getWidth());
+ HiLog.info(logLabel, "ShadowLayout onMeasure getMeasuredHeight " + this.getHeight());
+ this.getWidth();
+ if ((mShadowSide & LEFT) == LEFT) {
+ rectLeft = -effect;
+ paddingLeft = (int) effect;
+ }
+ if ((mShadowSide & TOP) == TOP) {
+ rectTop = -effect;
+ paddingTop = (int) effect;
+ }
+ if ((mShadowSide & RIGHT) == RIGHT) {
+ rectRight = this.getWidth() + effect;
+ paddingRight = (int) effect;
+ }
+ if ((mShadowSide & BOTTOM) == BOTTOM) {
+ rectBottom = this.getHeight() + effect;
+ paddingBottom = (int) effect;
+ }
+ if (String.valueOf(mShadowDy) != null) {
+ rectBottom = rectBottom + mShadowDy;
+ paddingBottom = paddingBottom + (int) mShadowDy;
+ }
+ if (String.valueOf(mShadowDx) != null) {
+ rectRight = rectRight + mShadowDx;
+ paddingRight = paddingRight + (int) mShadowDx;
+ }
+ EstimateSpec.getSizeWithMode((int) rectRight, (int) rectLeft);
+ EstimateSpec.getSizeWithMode((int) rectBottom, (int) rectTop);
+
+ this.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
+ HiLog.info(logLabel, "ShadowLayout onMeasure getMeasuredWidth " + px2dip(this.getWidth()));
+ HiLog.info(logLabel, "ShadowLayout onMeasure getMeasuredHeight " + px2dip(this.getHeight()));
+ return false;
+ }
+
+ /**
+ * 绘制
+ *
+ * @param component
+ * @param canvas
+ */
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ int[] colors = toRgb(mShadowColor);
+
+ int red = Math.abs(colors[0]);
+ int green = Math.abs(colors[1]);
+ int blue = Math.abs(colors[TWO]);
+
+ setBackground(mShadowDrawable);
+ mShadowDrawable.setRgbColor(new RgbColor(red,green,blue,ALPHA));
+ mShadowDrawable.setColorFilter(new ColorFilter(mShadowColor, BlendMode.COLOR));
+ }
+
+ @Override
+ public void setPadding(int left, int top, int right, int bottom) {
+ // NO OP
+ }
+
+ @Override
+ public void setPaddingRelative(int start, int top, int end, int bottom) {
+ // NO OP
+ }
+
+ /**
+ * dip2px dp 值转 px 值
+ *
+ * @param dpValue dp 值
+ * @return px 值
+ */
+ private float dp2Px(float dpValue) {
+ Optional defaultDisplay = DisplayManager.getInstance().getDefaultDisplay(this.getContext());
+ DisplayAttributes attributes = defaultDisplay.get().getAttributes();
+ float scale = attributes.densityPixels;
+ return (float) (dpValue * scale + NUM);
+ }
+
+ /**
+ * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
+ */
+ private int px2dip(float pxValue) {
+ Optional defaultDisplay = DisplayManager.getInstance().getDefaultDisplay(this.getContext());
+ DisplayAttributes attributes = defaultDisplay.get().getAttributes();
+ final float scale = attributes.densityPixels;
+ return (int) (pxValue / scale + NUM);
+ }
+
+ /**
+ * Color int类型转RGB
+ */
+ private int[] toRgb(int color) {
+
+ int red = (color & RED) >> SIXTEEN;
+ int green = (color & GREEN) >> EIGHT;
+ int blue = color & BLUE;
+ return new int[]{red,green,blue};
+ }
+
+}
+
diff --git a/shadowlayout/src/main/resources/base/element/string.json b/shadowlayout/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..e75550e18a3cbbfb53a4b058114585d4bc36b9e8
--- /dev/null
+++ b/shadowlayout/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "shadowlayout"
+ }
+ ]
+}