diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..e02d0e910b49b026b606905081ed9d2da19fc18a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +## 0.0.1-SNAPSHOT +ohos 第一个版本,完整实现了原库的全部 api \ No newline at end of file diff --git a/README.OPENSOURCE b/README.OPENSOURCE new file mode 100644 index 0000000000000000000000000000000000000000..68babb5597c6889fab8f68dde3144529f47c0a36 --- /dev/null +++ b/README.OPENSOURCE @@ -0,0 +1,10 @@ +[ + { + "Name": "ImageSelector", + "License": "Apache License 2.0", + "License File": "LICENSE", + "Version Number": "v1.9.3", + "Upstream URL": "https://github.com/donkingliang/ImageSelector", + "Description": "Android图片选择器,仿微信的图片选择器的样式和效果。支持图片的单选、限数量的多选和不限数量的多选。支持图片预览和图片文件夹的切换。支持在选择图片时调用相机拍照,也支持不用打开相册直接调用相机拍照。" + } +] \ No newline at end of file diff --git a/README.md b/README.md index 468d64c592d975bb059a74ad142fd01626566647..5ac3ed5720314ee5931b05871c51c374edeffdc3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # ImageSelector -**本项目基于开源项目ImageSelector -进行OpenHarmony化的移植和开发,可以通过项目标签以及github地址( https://github.com/donkingliang/ImageSelector )追踪到原项目版本** - #### 项目介绍 - 项目名称:ImageSelector - 所属系列:OpenHarmony的第三方组件适配移植 @@ -11,7 +8,6 @@ - 项目移植状态:主功能完成 - 调用差异:无 - 开发版本:sdk5,DevEco Studio2.1 beta4 -- 原项目Doc地址:https://github.com/donkingliang/ImageSelector #### 效果演示 diff --git a/changelog.md b/changelog.md deleted file mode 100644 index 32ff53bdbb0e5cf1d6327f941a1907fa970afa78..0000000000000000000000000000000000000000 --- a/changelog.md +++ /dev/null @@ -1,18 +0,0 @@ -# 基本功能: - - 一个功能强大的图片选择器。支持图片的单选、限数量的多选和不限数量的多选。支持图片预览和图片文件夹的切换。支持在选择图片时调用相机拍照,也支持不用打开相册直接调用相机拍照。 - -# 修改点: - -1、采用harmony的方式实现 拍照,图库查询,图片裁剪,图片预览。 - -2、目前功能开发是自研,所有功能都是采用harmony的方式实现。 - -# 遗留问题(暂不支持的功能): - -1、目前使用三方库,图片加载缓慢,内存占用高。 - -2、目前模拟器无法拍照 - - - diff --git a/entry/src/main/config.json b/entry/src/main/config.json index 6731a5cf5571983a29f0e1479e639cebe32c1623..d0cc2a3d4740672d7444ae558ee51ef61b874c02 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -9,7 +9,7 @@ "apiVersion": { "compatible": 5, "target": 5, - "releaseType": "Beta1" + "releaseType": "Release" } }, "deviceConfig": {}, diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json index d5f4fb135ef1a0a83e2b976f29a1201cef85eb37..3c611199d9cadd2d06d1dd62b3d1ddb9fdb721bb 100644 --- a/entry/src/ohosTest/config.json +++ b/entry/src/ohosTest/config.json @@ -9,7 +9,7 @@ "apiVersion": { "compatible": 5, "target": 5, - "releaseType": "Beta1" + "releaseType": "Release" } }, "deviceConfig": {}, @@ -30,7 +30,7 @@ "name": "decc.testkit.runner.EntryAbility", "description": "Test Entry Ability", "icon": "$media:icon", - "label": "$string:app_name", + "label": "ImageSelector", "launchType": "standard", "orientation": "landscape", "visible": true, diff --git a/entry/src/ohosTest/java/com/donkingliang/imageselector/ExampleOhosTest.java b/entry/src/ohosTest/java/com/donkingliang/imageselector/ExampleOhosTest.java deleted file mode 100644 index a69cdb1d5f3c70e0ff0cab3063f62df8d6cb3c39..0000000000000000000000000000000000000000 --- a/entry/src/ohosTest/java/com/donkingliang/imageselector/ExampleOhosTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.donkingliang.imageselector; - -import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ExampleOhosTest { - @Test - public void testBundleName() { - final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); - assertEquals("com.donkingliang.imageselector", actualBundleName); - } -} \ No newline at end of file diff --git a/entry/src/ohosTest/java/com/donkingliang/imageselector/MainAbilityTest.java b/entry/src/ohosTest/java/com/donkingliang/imageselector/MainAbilityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..62eca2e9c85240ed7a40a492667541458d1545fa --- /dev/null +++ b/entry/src/ohosTest/java/com/donkingliang/imageselector/MainAbilityTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain an copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.donkingliang.imageselector; + +import com.donkingliang.imageselector.util.HeLog; +import com.flask.colorpicker.cameralibrary.util.AngleUtil; +import com.flask.colorpicker.cameralibrary.util.ScreenUtils; +import ohos.aafwk.ability.Ability; +import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; +import org.junit.Assert; +import org.junit.Test; + +/** + * 测试类 + * + * @author ImageSelector + * @since 2021-05-25 + */ +public class MainAbilityTest { + Ability ability = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility(); + + /** + * 测试类 + */ + @Test + public void onStart() { + HeLog.d("HiLog","单元测试"); + int senSer = AngleUtil.getSensorAngle(10.0f,20.0f); + Assert.assertEquals(0, senSer); + ScreenUtils.getScreenHeight(ability.getApplicationContext()); + ScreenUtils.getScreenWidth(ability.getApplicationContext()); + } + + /** + * 测试类 + */ + @Test + public void enterPage() { + } + + /** + * 测试类 + */ + @Test + public void onRequestPermissionsFromUserResult() { + } + + /** + * 测试类 + */ + @Test + public void onAbilityResult() { + } + + /** + * 测试类 + */ + @Test + public void cropImg() { + } +} \ No newline at end of file diff --git a/imagepicker/src/main/java/com/lzy/imagepicker/util/BitmapUtil.java b/imagepicker/src/main/java/com/lzy/imagepicker/util/BitmapUtil.java index 27baa832fe80346c8610652c2af7edc6682679da..d578e94ddba158f1c1ba6b7dddf8f54f3f0cb72e 100644 --- a/imagepicker/src/main/java/com/lzy/imagepicker/util/BitmapUtil.java +++ b/imagepicker/src/main/java/com/lzy/imagepicker/util/BitmapUtil.java @@ -30,6 +30,7 @@ public class BitmapUtil { DataAbilityHelper helper = DataAbilityHelper.creator(ability); ImageSource.SourceOptions options = new ImageSource.SourceOptions(); ImageSource source = ImageSource.create(helper.openFile(Uri.parse(uriScheme), "r"), options); + degree = source.getImagePropertyInt(PropertyKey.Exif.ORIENTATION, 0); } catch (DataAbilityRemoteException | FileNotFoundException e) { return degree; diff --git a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java index 8ea3ceed91554dc0abc6da0d6e1c5535872696ff..2ea135d1353884e64858ed476a543271b5086115 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java @@ -129,8 +129,8 @@ public class BitmapCropTask implements CropResult{ // Rotate if needed if (mCurrentAngle != 0) { - //安卓逻辑:将Bitmap缩放、旋转 - //鸿蒙逻辑:将PixelMap保存,再读取,读取时缩放并旋转.保存需要路径,所以需要Ability传进来Context + //逻辑:将Bitmap缩放、旋转 + //逻辑:将PixelMap保存,再读取,读取时缩放并旋转.保存需要路径,所以需要Ability传进来Context //获取缩放和旋转参数 Matrix tempMatrix = new Matrix(); diff --git a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java index ccfcf4f5c56b91236c0b5de0182f94285200feff..9bbbc8103fd8d8c34daa7a5996ded8e6cd77ed66 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java @@ -89,9 +89,9 @@ public class BitmapLoadTask { boolean decodeAttemptSuccess = false; while (!decodeAttemptSuccess) { try { - //安卓通过InputUri获取InputStream + //通过InputUri获取InputStream //InputStream stream = mContext.getContentResolver().openInputStream(mInputUri); - //鸿蒙通过InputUri获取InputStream + //通过InputUri获取InputStream InputStream stream; DataAbilityHelper helper = DataAbilityHelper.creator(mContext); FileDescriptor fd = helper.openFile(mInputUri, "r"); @@ -227,9 +227,9 @@ public class BitmapLoadTask { InputStream inputStream; OutputStream outputStream; try { - //安卓通过InputUri获取InputStream + //通过InputUri获取InputStream //inputStream = mContext.getContentResolver().openInputStream(inputUri); - //鸿蒙通过InputUri获取InputStream + //通过InputUri获取InputStream DataAbilityHelper helper = DataAbilityHelper.creator(mContext); FileDescriptor fd_i = helper.openFile(mInputUri, "r"); inputStream = new FileInputStream(fd_i); @@ -273,9 +273,9 @@ public class BitmapLoadTask { assert response.body() != null; source = response.body().source(); - //安卓通过OutputUri获取OutputStream + //通过OutputUri获取OutputStream //OutputStream outputStream = mContext.getContentResolver().openOutputStream(outputUri); - //鸿蒙通过OutputUri获取OutputStream + //通过OutputUri获取OutputStream OutputStream outputStream; DataAbilityHelper helper = DataAbilityHelper.creator(mContext); FileDescriptor fd = helper.openFile(outputUri,"w"); diff --git a/ucrop/src/main/java/com/yalantis/ucrop/util/BitmapLoadUtils.java b/ucrop/src/main/java/com/yalantis/ucrop/util/BitmapLoadUtils.java index a58109b6322e272a0ecc0dcab3b50f9520837881..1be3611101fcdad0b2d9e30af4f0a547c5996804 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/util/BitmapLoadUtils.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/util/BitmapLoadUtils.java @@ -36,18 +36,18 @@ public class BitmapLoadUtils { Uri uri, Uri outputUri, int requiredWidth, int requiredHeight, BitmapLoadCallback loadCallback) { -//原安卓接口 +//原接口 // new BitmapLoadTask(context, uri, outputUri, requiredWidth, requiredHeight, loadCallback) // .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -//鸿蒙版 +//版 new BitmapLoadTask(context, uri, outputUri, requiredWidth, requiredHeight, loadCallback).doInBackground(); } public PixelMap transformBitmap(PixelMap bitmap, float degrees, float scale_X, Context context) { try { - //安卓逻辑:对位图使用矩阵进行先旋转再缩放、平移 + //逻辑:对位图使用矩阵进行先旋转再缩放、平移 // PixelMap converted = PixelMap.create(bitmap, 0, 0, bitmap.getImageInfo().getWidth(), bitmap.getHeight(), transformMatrix, true); - //鸿蒙逻辑:先保存位图,再读取,读取时旋转和缩放、平移 + //逻辑:先保存位图,再读取,读取时旋转和缩放、平移 File file_path = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES); File temp_file = new File(file_path + "/temp.jpg"); _saveImage(temp_file, bitmap); @@ -125,9 +125,9 @@ public class BitmapLoadUtils { System.out.println(context); int orientation = 0; try { - //安卓通过InputUri获取InputStream + //通过InputUri获取InputStream //InputStream stream = context.getContentResolver().openInputStream(imageUri); - //鸿蒙通过InputUri获取InputStream + //通过InputUri获取InputStream InputStream stream = null; HttpURLConnection connection = null; URL url = new URL(String.valueOf(imageUri)); @@ -214,7 +214,7 @@ public class BitmapLoadUtils { int maxBitmapSize = (int) Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); // Check for max texture size via Canvas - //鸿蒙无此参数,故预设一个大数 + //无此参数,故预设一个大数 //final int maxCanvasSize = Math.min(canvas.getMaximumBitmapWidth(), canvas.getMaximumBitmapHeight()); final int maxCanvasSize = 10000000; if (maxCanvasSize > 0) { diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/GestureCropImageView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/GestureCropImageView.java index a18bed771e068e1f2ba37f125164670d8db895f5..47ea4d00766164bc4460754528f5d2dd616176cd 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/view/GestureCropImageView.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/view/GestureCropImageView.java @@ -40,7 +40,7 @@ public class GestureCropImageView extends CropImageView implements Component.Tou mScaledListener = new ScaleListener(); setScaledListener(mScaledListener); } - //由于鸿蒙滑动监听缺陷,所以滑动操作整合在触摸监听里 + //由于滑动监听缺陷,所以滑动操作整合在触摸监听里 @Override public boolean onTouchEvent(Component component, TouchEvent event) { if ((event.getAction() ) == TouchEvent.PRIMARY_POINT_DOWN) { diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/TransformImageView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/TransformImageView.java index 542c6c4bc786395f809565598e440c9ed9d656ed..67a7485bf3cd58d73181a7730f21210598f8d9e9 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/view/TransformImageView.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/view/TransformImageView.java @@ -63,7 +63,7 @@ public class TransformImageView extends PositionLayout implements Component.Layo public static final int MSKEW_X = 1; //!< use with getValues/setValues public static final int MSKEW_Y = 3; //!< use with getValues/setValues - //添加一个全局变量PixelMapHolder用于传递图片,解决鸿蒙操作canvas时图像不变换的问题 + //添加一个全局变量PixelMapHolder用于传递图片,解决openharmony操作canvas时图像不变换的问题 public PixelMapHolder mBitmapHolder; @Override @@ -128,9 +128,9 @@ public class TransformImageView extends PositionLayout implements Component.Layo // @Override public void setPixelMap(final PixelMap bitmap) { - //原安卓:FastBitmapDrawable是一个Drawable,Drawbale可以被画在View里,所以直接set一个FastBitmapDrawable即可完成对图像的绘制 + //原:FastBitmapDrawable是一个Drawable,Drawbale可以被画在View里,所以直接set一个FastBitmapDrawable即可完成对图像的绘制 //setImageElement(new FastBitmapDrawable(mContext, bitmap)); - //鸿蒙:Drawable对标的是Element,但是由于功能缺陷,Element不支持自定义绘制,如果将FastBitmapDrawable继承Element则不能完成绘制任务 + //Drawable对标的是Element,但是由于功能缺陷,Element不支持自定义绘制,如果将FastBitmapDrawable继承Element则不能完成绘制任务 //所以FastBitmapDrawable需要是一个Image,然而TransformImageView不能支持内置另一个Image,所以有必要将TransformImageView继承一个ComponentContainer //此处选择PositionLayout Component fastBitmapDrawable = new FastBitmapDrawable(mContext, bitmap);