2 Star 4 Fork 0

CHINASOFT5_OHOS / RxImagePicker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

RxImagePicker

项目介绍

  • 项目名称:RxImagePicker
  • 所属系列:openharmony的第三方组件适配移植
  • 功能:相册图片选择
  • 项目移植状态:主功能完成
  • 调用差异:无
  • 开发版本:sdk6,DevEco Studio2.2 Beta1
  • 基线版本:tag 2.5.6

效果演示

输入图片说明

安装教程

1.在项目根目录下的build.gradle文件中,

allprojects {
   repositories {
       maven {
           url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
       }
   }
}

2.在entry模块的build.gradle文件中,

dependencies {
   implementation('com.gitee.chinasoft_ohos:rximagepicker:0.0.1-SNAPSHOT')
   implementation('com.gitee.chinasoft_ohos:rximagepicker_support:0.0.1-SNAPSHOT')
   implementation('com.gitee.chinasoft_ohos:rximagepicker_support_zhihu:0.0.1-SNAPSHOT')
   implementation('com.gitee.chinasoft_ohos:rximagepicker_support_wechat:0.0.1-SNAPSHOT')
   ......  
}

在sdk6,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下

使用说明

声明一个接口,并进行基础的配置:

系统风格的样式
public interface MyImagePicker {

    @Gallery    // 打开相册选择图片
    Observable<Result> openGallery(Context context);

    @Camera     // 打开相机拍照
    Observable<Result> openCamera(Context context);
}
//在您的FractionAbility使用
    //重写onRequestPermissionsFromUserResult
    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        AbilityUtils.onRequestPermissionsFromUserResult(this, requestCode, permissions, grantResults);

    }
    //onAbilityResult
    @Override
    protected void onAbilityResult(int requestCode, int resultCode, Intent resultData) {
        super.onAbilityResult(requestCode, resultCode, resultData);
        AbilityUtils.onAbilityResult(this, requestCode, resultCode, resultData);
    }
    Consumer<Result> consumer = new Consumer<Result>() {
            @Override
            public void accept(Result result) throws Throwable {
                
            }
        }
    //打开系统默认的相册
    RxImagePicker.create(MyImagePicker.class).openGallery(this)
            .subscribe(consumer);
    //打开相机
    RxImagePicker.create(MyImagePicker.class).openCamera(this)
            .subscribe(consumer);
    
微信风格的样式
    public interface WechatImagePicker {
        @Gallery(componentClazz = WechatImagePickerAbility.class,
                openAsFragment = false)
        Observable<Result> openGallery(Context context, ICustomPickerConfiguration config);
    
        @Camera
        Observable<Result> openCamera(Context context);
    }
//在您的FractionAbility使用
    @Override
        protected void onAbilityResult(int requestCode, int resultCode, Intent resultData) {
            super.onAbilityResult(requestCode, resultCode, resultData);
            AbilityUtils.onAbilityResult(this, requestCode, resultCode, resultData);
    }

   RxImagePicker  rxImagePicker = RxImagePicker
                    .create(WechatImagePicker.class);
    //打开相机
    rxImagePicker.openCamera(this) .subscribe(onNext(), onError());
    //打开相册
    rxImagePicker.openGallery(this,
                    new WechatConfigrationBuilder(MimeType.ofAll(), false)
                            .capture(true)
                            .maxSelectable(9)
                            .countable(true)
                            .spanCount(4)
                            .countable(false)
                            .build())
                    .subscribe(onNext(), onError());
知乎风格的样式
    public interface ZhihuImagePicker {
        @Gallery(
                componentClazz = ZhihuImagePickerAbility.class,
                openAsFragment = false
        )
        Observable<Result> openGalleryAsNormal(Context context, ICustomPickerConfiguration iCustomPickerConfiguration);
    
        @Gallery(
                componentClazz = ZhihuImagePickerAbility.class,
                openAsFragment = false
        )
        Observable<Result> openGalleryAsDracula(Context context, ICustomPickerConfiguration iCustomPickerConfiguration);
    
        @Camera
        Observable<Result> openCamera(Context context);
    }
    //在您的FractionAbility使用
    @Override
    protected void onAbilityResult(int requestCode, int resultCode, Intent resultData) {
            super.onAbilityResult(requestCode, resultCode, resultData);
            AbilityUtils.onAbilityResult(this, requestCode, resultCode, resultData);
    }
    RxImagePicker rxImagePicker = RxImagePicker
                    .create(ZhihuImagePicker.class);
    rxImagePicker.openCamera(this)
                    .subscribe(fetchUriObserver());
    //风格1
    rxImagePicker.openGalleryAsNormal(this,
                    new ZhihuConfigurationBuilder(MimeType.ofImage(), false)
                            .capture(true)
                            .maxSelectable(9)
                            .countable(true)
                            .spanCount(4)
                            .theme(com.qingmei2.rximagepicker_extension_zhihu.ResourceTable.Pattern_Zhihu_Normal)
                            .build())
                    .subscribe(fetchUriObserver());
    //风格2
    rxImagePicker.openGalleryAsDracula(this,
                    new ZhihuConfigurationBuilder(MimeType.ofImage(), false)
                            .capture(true)
                            .spanCount(3)
                            .maxSelectable(1)
                            .theme(com.qingmei2.rximagepicker_extension_zhihu.ResourceTable.Pattern_Zhihu_Dracula)
                            .build())
                    .subscribe(fetchUriObserver());
自定义风格属性文件

属性文件事例


JSON Attribute Description
colorPrimary 相册主题色
colorPrimaryDark 相册副主题色
album.dropdown.title.color 相薄弹出框title字体色
album.dropdown.count.color 相薄弹出框tcount字体色
album.dropdown.popup.bg.color 相薄弹出框t背景色
album.element.color 箭头颜色
album.thumbnail.placeholder 占位图颜色
album.emptyView 空视图图片
item.placeholder 占位图颜色
item.checkCircle.backgroundColor 选择框背景
item.checkCircle.borderColor 选择框边框背景
page.bg 相薄背景
bottomToolbar.bg 底部框背景
bottomToolbar.preview.textColor 底部预览字体颜色(可选择)
bottomToolbar.preview.textColor.disable 底部预览字体颜色(默认)
bottomToolbar.apply.textColor 底部使用字体颜色(可选择)
bottomToolbar.apply.textColor.disable 底部使用字体颜色(默认)
preview.bottomToolbar.back.textColor 预览返回字体颜色
preview.bottomToolbar.apply.textColor 预览底部使用字体颜色(可选择)
preview.bottomToolbar.apply.textColor.disable 预览底部使用字体颜色(默认)
capture.textColor 相机按钮颜色

测试信息

CodeCheck代码测试无异常

CloudTest代码测试无异常

病毒安全检测通过

当前版本demo功能与原组件基本无差异

版本迭代

  • 0.0.1-SNAPSHOT

版权和许可信息

Copyright (c) 2018 qingmei2

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License Copyright (c) 2018 qingmei2 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

相册图片选择 展开 收起
Java
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/chinasoft5_ohos/RxImagePicker.git
git@gitee.com:chinasoft5_ohos/RxImagePicker.git
chinasoft5_ohos
RxImagePicker
RxImagePicker
2.x

搜索帮助