diff --git a/README.md b/README.md index 55b399c5..078e7dd2 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ allprojects { dependencies { ... //androidx project - implementation 'com.github.xuexiangjys:XUI:1.1.8' + implementation 'com.github.xuexiangjys:XUI:1.1.9' implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.recyclerview:recyclerview:1.2.1' @@ -315,6 +315,27 @@ J*o | 10.24¥ | WeChat *维 | 5¥ | WeChat *鑫 | 188.88¥ | Alipay *玉 | 10¥ | Alipay +**贺 | 100¥ | Alipay +**伟 | 65¥ | Alipay +*G | 1¥ | WeChat +M*u | 10.24¥ | WeChat +S*m | 10.24¥ | WeChat +T*g | 15¥ | WeChat +*边 | 10.24¥ | WeChat +*寻 | 20.48¥ | WeChat +*凉 | 10.24¥ | WeChat +S*y | 10.24¥ | WeChat +M*n | 1¥ | WeChat +J*e | 10.24¥ | WeChat +*、 | 10.24¥ | WeChat +禹*) | 1¥ | WeChat +X*? | 18.88¥ | WeChat +*事 | 5¥ | WeChat +*之 | 10¥ | WeChat +*安 | 18.88¥ | WeChat +*🎵 | 10.24¥ | WeChat +*👔 | 10¥ | WeChat +*洲 | 10¥ | WeChat ## Contact diff --git a/README_ZH.md b/README_ZH.md index e31cb928..f0142a72 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -78,7 +78,7 @@ allprojects { dependencies { ... //androidx项目 - implementation 'com.github.xuexiangjys:XUI:1.1.8' + implementation 'com.github.xuexiangjys:XUI:1.1.9' implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.recyclerview:recyclerview:1.2.1' @@ -309,6 +309,27 @@ J*o | 10.24¥ | 微信 *维 | 5¥ | 微信 *鑫 | 188.88¥ | 支付宝 *玉 | 10¥ | 支付宝 +**贺 | 100¥ | 支付宝 +**伟 | 65¥ | 支付宝 +*G | 1¥ | 微信 +M*u | 10.24¥ | 微信 +S*m | 10.24¥ | 微信 +T*g | 15¥ | 微信 +*边 | 10.24¥ | 微信 +*寻 | 20.48¥ | 微信 +*凉 | 10.24¥ | 微信 +S*y | 10.24¥ | 微信 +M*n | 1¥ | 微信 +J*e | 10.24¥ | 微信 +*、 | 10.24¥ | 微信 +禹*) | 1¥ | 微信 +X*? | 18.88¥ | 微信 +*事 | 5¥ | 微信 +*之 | 10¥ | 微信 +*安 | 18.88¥ | 微信 +*🎵 | 10.24¥ | 微信 +*👔 | 10¥ | 微信 +*洲 | 10¥ | 微信 ## 联系方式 diff --git a/VersionAdapter.md b/VersionAdapter.md new file mode 100644 index 00000000..5693bdff --- /dev/null +++ b/VersionAdapter.md @@ -0,0 +1,104 @@ +# Android版本简介 + +| Android 版本 | API 等级 | 版本代号 | 发布时间 | +| :--------: | :-----: | :----------: | :------------------: | +| Android 12 | 31 | S | 2021 年 10 月 4 日 | +| Android 11 | 30 | R | 2020 年 9 月 9 日 | +| Android 10 | 29 | Q | 2019 年 9 月 3 日 | +| Android 9.0 | 28 | P | 2018 年 8 月 7 日 | +| Android 8.1 | 27 | O_MR1 | 2017 年 12 月 5 日 | +| Android 8.0 | 26 | O | 2017 年 8 月 22 日 | +| Android 7.1 | 25 | N_MR1 | 2016 年 12 月 5 日 | +| Android 7.0 | 24 | N | 2016 年 8 月 22 日 | +| Android 6.0 | 23 | M | 2015 年 9 月 29 日 | +| Android 5.1 | 22 | LOLLIPOP_MR1 | 2015 年 3 月 10 日 | +| Android 5.0 | 21 | LOLLIPOP | 2014 年 10 月 15 日 | +| Android 4.4 | 19 | KITKAT | 2013 年 10 月 31 日 | + +# Android各版本重大变化说明 + +> 详细Android各版本变化可参见:[AndroidVersionAdapter](https://github.com/getActivity/AndroidVersionAdapter) 或者 [官方文档](https://developer.android.google.cn/about/versions) + +## Android 12.0 + +* [启动画面](https://developer.android.google.cn/about/versions/12/features/splash-screen?hl=zh-cn) +* [性能等级](https://developer.android.google.cn/about/versions/12/features/performance-class?hl=zh-cn) +* [Android 12 中的新蓝牙权限](https://developer.android.google.cn/about/versions/12/features/bluetooth-permissions?hl=zh-cn) +* [更安全的组件导出](https://developer.android.google.cn/about/versions/12/behavior-changes-12?hl=zh-cn#exported) +* [自定义通知模板](https://developer.android.google.cn/about/versions/12/behavior-changes-12?hl=zh-cn#custom-notifications) +* [通知 trampoline 限制](https://developer.android.google.cn/about/versions/12/behavior-changes-12?hl=zh-cn#notification-trampolines) +* [前台服务启动限制](https://developer.android.google.cn/about/versions/12/behavior-changes-12?hl=zh-cn#foreground-service-launch-restrictions) +* [应用无法关闭系统对话框](https://developer.android.google.cn/about/versions/12/behavior-changes-all?hl=zh-cn#close-system-dialogs) + +## Android 11.0 + +* [强制执行分区存储](https://developer.android.google.cn/about/versions/11/privacy/storage?hl=zh-cn#scoped-storage) +* [单次授权](https://developer.android.google.cn/about/versions/11/privacy/permissions?hl=zh-cn#one-time) +* [系统提醒窗口权限](https://developer.android.google.cn/about/versions/11/privacy/permissions?hl=zh-cn#system-alert) +* [在后台访问位置信息的权限](https://developer.android.google.cn/about/versions/11/privacy/location?hl=zh-cn#background-location) +* [Toast后台显示限制](https://developer.android.google.cn/about/versions/11/behavior-changes-11?hl=zh-cn#toasts) + +## Android 10.0 + +* [Android 10(Q)/11(R) 分区存储适配](https://juejin.cn/post/6862633674089693197) +* [Android 10 深色主题适配](https://guolin.blog.csdn.net/article/details/106061657) +* [Android 折叠屏适配攻略](https://juejin.cn/post/6844903889267867656) +* [后台启动 Activity 的限制](https://juejin.cn/post/6844904073024503822#heading-13) +* [限制非 SDK 接口](https://developer.android.google.cn/about/versions/10/behavior-changes-all?hl=zh-cn#non-sdk-restrictions) +* [设备唯一标识符限制](https://juejin.cn/post/6844904073024503822#heading-20) +* [5G 网络](https://developer.android.google.cn/about/versions/10/highlights?hl=zh-cn#5g_networks) + +## Android 9.0 + +* [Apache HTTP 客户端弃用](https://developer.android.google.cn/about/versions/pie/android-9.0-changes-28?hl=zh-cn#apache-p) +* [前台服务](https://developer.android.google.cn/about/versions/pie/android-9.0-changes-28?hl=zh-cn#fg-svc) +* [不允许调用hide api](https://weishu.me/2019/03/16/another-free-reflection-above-android-p/) +* [Android刘海屏适配](https://www.jianshu.com/p/561f7241153b) +* [强制执行 `FLAG_ACTIVITY_NEW_TASK` 要求](https://developer.android.google.cn/about/versions/pie/android-9.0-changes-all?hl=zh-cn#fant-required) + +## Android 8.0/8.1 + +* [通知全面重新设计(渠道等)](https://developer.android.google.cn/about/versions/oreo/android-8.0?hl=zh-cn#notifications) +* [后台执行限制](https://developer.android.google.cn/about/versions/oreo/android-8.0-changes?hl=zh-cn#back-all) +* 隐式广播限制 +* 开启后台Service限制 +* 应用安装REQUEST_INSTALL_PACKAGES权限 +* [自动填充框架](https://developer.android.google.cn/about/versions/oreo/android-8.0?hl=zh-cn#af) +* [画中画模式](https://developer.android.google.cn/about/versions/oreo/android-8.0?hl=zh-cn#opip) +* [自适应图标](https://developer.android.google.cn/about/versions/oreo/android-8.0?hl=zh-cn#ai) +* [应用快捷键](https://developer.android.google.cn/about/versions/oreo/android-8.0-changes?hl=zh-cn#as) + +## Android 7.0/7.1.1 + +* [多窗口支持](https://developer.android.google.cn/about/versions/nougat/android-7.0?hl=zh-cn#multi-window_support) +* [配置文件指导的 JIT/AOT 编译](https://developer.android.google.cn/about/versions/nougat/android-7.0?hl=zh-cn#jit_aot) +* [VR 支持](https://developer.android.google.cn/about/versions/nougat/android-7.0?hl=zh-cn#vr) +* [应用快捷方式](https://developer.android.google.cn/about/versions/nougat/android-7.1?hl=zh-cn#shortcuts) +* [在应用间共享文件FileProvider](https://developer.android.google.cn/about/versions/nougat/android-7.0-changes?hl=zh-cn#sharing-files) +* [进一步的电池和内存优化](https://developer.android.google.cn/about/versions/nougat/android-7.0-changes?hl=zh-cn#perf) + +## Android 6.0 + +* [运行时权限](https://developer.android.google.cn/about/versions/marshmallow/android-6.0-changes?hl=zh-cn#behavior-runtime-permissions) +* [指纹身份验证](https://developer.android.google.cn/about/versions/marshmallow/android-6.0?hl=zh-cn#fingerprint-authentication) +* [应用链接](https://developer.android.google.cn/about/versions/marshmallow/android-6.0?hl=zh-cn#app-linking) +* [低电耗模式和应用待机模式(Doze电量管理)](https://developer.android.google.cn/about/versions/marshmallow/android-6.0-changes?hl=zh-cn#behavior-power) + +## Android 5.0/5.1 + +* [Material Design支持](https://developer.android.google.cn/about/versions/android-5.0?hl=zh-cn#MaterialDesign) +* [Android Runtime (ART)](https://developer.android.google.cn/about/versions/android-5.0-changes?hl=zh-cn#ART) +* [WebView 更新](https://developer.android.google.cn/about/versions/android-5.0?hl=zh-cn#WebView) +* [蓝牙低功耗](https://developer.android.google.cn/about/versions/android-5.0?hl=zh-cn#BluetoothBroadcasting) + +## Android 4.4 + +* [Google打印框架](https://developer.android.google.cn/about/versions/android-4.4?hl=zh-cn#Printing) +* [沉浸式全屏模式](https://developer.android.google.cn/about/versions/android-4.4?hl=zh-cn#ImmersiveMode) +* [透明系统状态栏](https://developer.android.google.cn/about/versions/android-4.4?hl=zh-cn#TranslucentBars) +* [可绘制的RTL布局镜像](https://developer.android.google.cn/about/versions/android-4.4?hl=zh-cn#DrawableMirroring) +* [无障碍功能](https://developer.android.google.cn/about/versions/android-4.4?hl=zh-cn#A11y) + +## Android 4.3 + +* BLE支持 \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 568bcca4..78421b1e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,8 +14,8 @@ android { applicationId "com.xuexiang.xuidemo" minSdkVersion 17 targetSdkVersion build_versions.target_sdk - versionCode 19 - versionName "1.1.8" + versionCode 20 + versionName "1.1.9" multiDexEnabled true vectorDrawables.useSupportLibrary = true @@ -102,119 +102,121 @@ dependencies { implementation 'com.google.android.material:material:1.4.0' implementation 'com.github.bumptech.glide:glide:4.12.0' - //XUI框架 -// implementation project(':xui_lib') - implementation 'com.github.xuexiangjys:XUI:1.1.8' + // XUI框架 + implementation project(':xui_lib') +// implementation 'com.github.xuexiangjys:XUI:1.1.9' // implementation 'com.qmuiteam:qmui:1.2.0' - //工具类 + // 工具类 implementation 'com.github.xuexiangjys.XUtil:xutil-core:2.0.0' implementation 'com.github.xuexiangjys.XUtil:xutil-sub:2.0.0' - //切片 + // 切片 implementation 'com.github.xuexiangjys.XAOP:xaop-runtime:1.1.0' - //页面路由 + // 页面路由 implementation 'com.github.xuexiangjys.XRouter:xrouter-runtime:1.0.1' annotationProcessor 'com.github.xuexiangjys.XRouter:xrouter-compiler:1.0.1' - //XPage页面框架 - implementation 'com.github.xuexiangjys.XPage:xpage-lib:3.1.1' + // XPage页面框架 + implementation 'com.github.xuexiangjys.XPage:xpage-lib:3.2.0' annotationProcessor project(':widget_compiler') - //ButterKnife + // ButterKnife implementation deps.butterknife.runtime annotationProcessor deps.butterknife.compiler // LeakCanary内存泄漏检测 debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6' - //弹性布局 + // 弹性布局 implementation 'com.google.android:flexbox:0.3.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' - //悬浮按钮 + // 悬浮按钮 implementation 'com.github.clans:fab:1.6.4' - //RxUtil2 + // RxUtil2 implementation deps.rxjava2 implementation deps.rxandroid - //RxBinding的sdk + // RxBinding的sdk implementation deps.rxbinding implementation 'com.github.xuexiangjys:RxUtil2:1.2.1' + // 任务框架 + implementation 'com.github.xuexiangjys.XTask:xtask-core:1.0.0' - //PictureSelector图片选择 + // PictureSelector图片选择 implementation 'com.github.xuexiangjys.PictureSelector:picture-core:1.0.5' - //下拉刷新 + // 下拉刷新 implementation 'com.github.xuexiangjys.SmartRefreshLayout:refresh-header:1.1.5' implementation 'com.github.xuexiangjys.SmartRefreshLayout:refresh-layout:1.1.5' - //列表侧滑菜单 + // 列表侧滑菜单 implementation 'com.yanzhenjie.recyclerview:support:1.3.2' - //预加载占位控件 + // 预加载占位控件 implementation 'me.samlss:broccoli:1.0.0' // //XVideo,太大,暂时去除 // implementation 'com.github.xuexiangjys:XVideo:1.0.2' // implementation 'com.github.xuexiangjys:NiceVieoPlayer:3.0.3' - //WebView + // WebView implementation 'com.github.xuexiangjys.AgentWeb:agentweb-core:1.0.0' implementation 'com.github.xuexiangjys.AgentWeb:agentweb-download:1.0.0'//选填 implementation 'com.github.xuexiangjys.AgentWeb:agentweb-filechooser:1.0.0'//选填 - //数据库 + // 数据库 implementation 'com.github.xuexiangjys.XOrmlite:xormlite-runtime:1.0.2' annotationProcessor 'com.github.xuexiangjys.XOrmlite:xormlite-compiler:1.0.2' - //侧边栏菜单 + // 侧边栏菜单 implementation 'com.yarolegovich:sliding-root-nav:1.1.0' - //XQRCode二维码扫描 + // XQRCode二维码扫描 implementation 'com.github.xuexiangjys:XQRCode:1.1.0' - //CityPicker + // CityPicker implementation "com.github.xuexiangjys:CityPicker:1.0.2" - //XFloatView悬浮窗口 + // XFloatView悬浮窗口 implementation 'com.github.xuexiangjys:XFloatView:1.0.2' - //android进程监控 + // android进程监控 implementation 'com.jaredrummler:android-processes:1.1.1' - //Android图表库 + // Android图表库 implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' - //ECharts图表库 + // ECharts图表库 implementation 'com.github.abel533:ECharts:3.0.0.2' - //TabBar + // TabBar implementation 'com.github.xuexiangjys:JPTabBar:1.0.1' - //日历控件 + // 日历控件 implementation 'com.github.xuexiangjys:CalendarExaple:1.0.1' implementation 'com.haibin:calendarview:3.6.3' - //图标库 + // 图标库 implementation "com.mikepenz:iconics-core:4.0.2" - //图标库控件(可选) + // 图标库控件(可选) implementation "com.mikepenz:iconics-views:4.0.2" - //相机拍摄 + // 相机拍摄 implementation 'com.github.xuexiangjys:CameraView:1.0.3' - //另一款相机拍摄库,使用更简单 + // 另一款相机拍摄库,使用更简单 implementation 'com.wonderkiln:camerakit:0.13.1' - //阿里巴巴组件 + // 阿里巴巴组件 implementation 'com.alibaba.android:vlayout:1.3.0' implementation 'com.alibaba.android:ultraviewpager:1.0.7.8' implementation 'com.alibaba.android:tangram:3.3.6' - //版本更新 - implementation 'com.github.xuexiangjys:XUpdate:2.0.9' + // 版本更新 + implementation 'com.github.xuexiangjys:XUpdate:2.1.1' implementation 'com.zhy:okhttputils:2.6.2' implementation deps.gson implementation deps.okhttp3 - //腾讯的键值对存储mmkv + // 腾讯的键值对存储mmkv implementation 'com.tencent:mmkv:1.2.10' - //腾讯x5TBS + // 腾讯x5TBS implementation 'com.tencent.tbs.tbssdk:sdk:43967' - //富文本 + // 富文本 implementation 'com.zzhoujay.richtext:richtext:3.0.8' - //双列表联动 + // 双列表联动 implementation 'com.kunminx.linkage:linkage-recyclerview:1.9.2' - //umeng统计 + // umeng统计 implementation 'com.umeng.umsdk:common:9.3.8' implementation 'com.umeng.umsdk:asms:1.2.1' - //ANR异常捕获 + // ANR异常捕获 implementation 'com.github.anrwatchdog:anrwatchdog:1.4.0' } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 4961b27d..fde832bf 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -325,9 +325,6 @@ native ; } -# materialedittext --keep class com.xuexiang.xui.widget.edittext.materialedittext.** { *; } - # vlayout -keepattributes InnerClasses -keep class com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx { *; } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 710edb6f..50d6379a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,6 +26,8 @@ + + @@ -200,6 +204,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/xuexiang/xuidemo/MyApp.java b/app/src/main/java/com/xuexiang/xuidemo/MyApp.java index 6ce05cac..99b642da 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/MyApp.java +++ b/app/src/main/java/com/xuexiang/xuidemo/MyApp.java @@ -5,20 +5,11 @@ import androidx.multidex.MultiDex; -import com.google.android.cameraview.CameraView; -import com.luck.picture.lib.tools.PictureFileUtils; -import com.mikepenz.iconics.Iconics; import com.xuexiang.xormlite.annotation.DataBase; import com.xuexiang.xormlite.enums.DataBaseType; -import com.xuexiang.xui.XUI; -import com.xuexiang.xuidemo.utils.SettingSPUtils; -import com.xuexiang.xuidemo.utils.sdkinit.ANRWatchDogInit; -import com.xuexiang.xuidemo.utils.sdkinit.AutoCameraStrategy; -import com.xuexiang.xuidemo.utils.sdkinit.TbsInit; -import com.xuexiang.xuidemo.utils.sdkinit.UMengInit; -import com.xuexiang.xuidemo.utils.sdkinit.XBasicLibInit; -import com.xuexiang.xuidemo.utils.sdkinit.XUpdateInit; -import com.xuexiang.xuidemo.widget.iconfont.XUIIconFont; +import com.xuexiang.xtask.XTask; +import com.xuexiang.xuidemo.utils.task.AsyncInitTask; +import com.xuexiang.xuidemo.utils.task.MainInitTask; /** @@ -40,40 +31,15 @@ protected void attachBaseContext(Context base) { @Override public void onCreate() { super.onCreate(); - //初始化基础库 - XBasicLibInit.init(this); - initUI(); - //三方SDK初始化 - XUpdateInit.init(this); - TbsInit.init(this); - UMengInit.init(this); - //ANR监控 - ANRWatchDogInit.init(); + XTask.debug(MyApp.isDebug()); + XTask.getTaskChain() + .addTask(new MainInitTask(this)) + .addTask(new AsyncInitTask(this)) + .start(); } - /** - * 初始化XUI 框架 - */ - private void initUI() { - XUI.debug(MyApp.isDebug()); - if (SettingSPUtils.getInstance().isUseCustomFont()) { - //设置默认字体为华文行楷 - XUI.initFontStyle("fonts/hwxk.ttf"); - } - PictureFileUtils.setAppName("xui"); - - //字体图标库 - Iconics.init(this); - //这是自己定义的图标库 - Iconics.registerFont(new XUIIconFont()); - - CameraView.setICameraStrategy(new AutoCameraStrategy(1920 * 1080)); - } - - public static boolean isDebug() { return BuildConfig.DEBUG; } - } diff --git a/app/src/main/java/com/xuexiang/xuidemo/activity/SettingsActivity.java b/app/src/main/java/com/xuexiang/xuidemo/activity/SettingsActivity.java index 84e1582a..dc346cef 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/activity/SettingsActivity.java +++ b/app/src/main/java/com/xuexiang/xuidemo/activity/SettingsActivity.java @@ -32,6 +32,7 @@ import com.xuexiang.xuidemo.R; import com.xuexiang.xuidemo.base.AppCompatPreferenceActivity; +import com.xuexiang.xuidemo.utils.Utils; import com.xuexiang.xuidemo.utils.XToastUtils; /** @@ -125,12 +126,17 @@ public boolean onMenuItemSelected(int featureId, MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { if (!super.onMenuItemSelected(featureId, item)) { -// NavUtils.navigateUpFromSameTask(this); finish(); + Utils.syncMainPageStatus(); } return true; } return super.onMenuItemSelected(featureId, item); } + @Override + public void onBackPressed() { + Utils.syncMainPageStatus(); + super.onBackPressed(); + } } diff --git a/app/src/main/java/com/xuexiang/xuidemo/adapter/SimpleListViewAdapter.java b/app/src/main/java/com/xuexiang/xuidemo/adapter/SimpleListViewAdapter.java new file mode 100644 index 00000000..18de4098 --- /dev/null +++ b/app/src/main/java/com/xuexiang/xuidemo/adapter/SimpleListViewAdapter.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com) + * + * 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. + * + */ + +package com.xuexiang.xuidemo.adapter; + +import android.content.Context; +import android.view.View; + +import com.xuexiang.xui.adapter.listview.BaseListAdapter; +import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder; +import com.xuexiang.xui.utils.ResUtils; +import com.xuexiang.xuidemo.R; + +import java.util.Collection; + +/** + * @author xuexiang + * @since 2021/11/15 7:02 PM + */ +public class SimpleListViewAdapter extends BaseListAdapter { + + public SimpleListViewAdapter(Context context) { + super(context); + } + + public SimpleListViewAdapter(Context context, Collection data) { + super(context, data); + } + + public SimpleListViewAdapter(Context context, String[] data) { + super(context, data); + } + + @Override + protected RecyclerViewHolder newViewHolder(View convertView) { + return new RecyclerViewHolder(convertView); + } + + @Override + protected int getLayoutId() { + return android.R.layout.simple_list_item_2; + } + + @Override + protected void convert(RecyclerViewHolder holder, String item, int position) { + holder.text(android.R.id.text1, ResUtils.getResources().getString(R.string.item_example_number_title, position)); + holder.text(android.R.id.text2, ResUtils.getResources().getString(R.string.item_example_number_abstract, position)); + holder.textColorId(android.R.id.text2, R.color.xui_config_color_light_blue_gray); + } + +} diff --git a/app/src/main/java/com/xuexiang/xuidemo/adapter/SimpleRecyclerAdapter.java b/app/src/main/java/com/xuexiang/xuidemo/adapter/SimpleRecyclerAdapter.java index 89889a5d..da5cf595 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/adapter/SimpleRecyclerAdapter.java +++ b/app/src/main/java/com/xuexiang/xuidemo/adapter/SimpleRecyclerAdapter.java @@ -1,7 +1,9 @@ package com.xuexiang.xuidemo.adapter; -import com.scwang.smartrefresh.layout.adapter.SmartRecyclerAdapter; -import com.scwang.smartrefresh.layout.adapter.SmartViewHolder; +import androidx.annotation.NonNull; + +import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter; +import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder; import com.xuexiang.xui.utils.ResUtils; import com.xuexiang.xuidemo.R; @@ -13,27 +15,25 @@ * @author XUE * @since 2019/4/1 11:04 */ -public class SimpleRecyclerAdapter extends SmartRecyclerAdapter { +public class SimpleRecyclerAdapter extends BaseRecyclerAdapter { public SimpleRecyclerAdapter() { - super(android.R.layout.simple_list_item_2); } - public SimpleRecyclerAdapter(Collection data) { - super(data, android.R.layout.simple_list_item_2); + public SimpleRecyclerAdapter(Collection list) { + super(list); } - /** - * 绑定布局控件 - * - * @param holder - * @param model - * @param position - */ @Override - protected void onBindViewHolder(SmartViewHolder holder, String model, int position) { + protected void bindData(@NonNull RecyclerViewHolder holder, int position, String item) { holder.text(android.R.id.text1, ResUtils.getResources().getString(R.string.item_example_number_title, position)); holder.text(android.R.id.text2, ResUtils.getResources().getString(R.string.item_example_number_abstract, position)); holder.textColorId(android.R.id.text2, R.color.xui_config_color_light_blue_gray); } + + @Override + protected int getItemLayoutId(int viewType) { + return android.R.layout.simple_list_item_2; + } + } diff --git a/app/src/main/java/com/xuexiang/xuidemo/base/AppCompatPreferenceActivity.java b/app/src/main/java/com/xuexiang/xuidemo/base/AppCompatPreferenceActivity.java index b3dd380e..ec209ff5 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/base/AppCompatPreferenceActivity.java +++ b/app/src/main/java/com/xuexiang/xuidemo/base/AppCompatPreferenceActivity.java @@ -59,7 +59,7 @@ protected void onCreate(Bundle savedInstanceState) { getDelegate().onCreate(savedInstanceState); super.onCreate(savedInstanceState); - SlideBack.with(this) + SlideBack.withFixSize(this) .haveScroll(true) .callBack(this::finish) .register(); diff --git a/app/src/main/java/com/xuexiang/xuidemo/base/BaseActivity.java b/app/src/main/java/com/xuexiang/xuidemo/base/BaseActivity.java index f6f59800..51611a17 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/base/BaseActivity.java +++ b/app/src/main/java/com/xuexiang/xuidemo/base/BaseActivity.java @@ -4,18 +4,13 @@ import android.content.res.Configuration; import android.os.Bundle; -import androidx.annotation.Keep; import androidx.annotation.NonNull; -import com.jpeng.jptabbar.anno.NorIcons; -import com.jpeng.jptabbar.anno.SeleIcons; -import com.jpeng.jptabbar.anno.Titles; import com.xuexiang.xpage.base.XPageActivity; import com.xuexiang.xpage.base.XPageFragment; import com.xuexiang.xpage.core.CoreSwitchBean; import com.xuexiang.xui.utils.ResUtils; import com.xuexiang.xui.widget.slideback.SlideBack; -import com.xuexiang.xuidemo.R; import com.xuexiang.xuidemo.utils.Utils; import butterknife.ButterKnife; @@ -28,18 +23,8 @@ * @author XUE * @since 2019/3/22 11:21 */ -@Keep public class BaseActivity extends XPageActivity { - //==============需要注意的是,由于JPTabBar反射获取注解的是context,也就是容器Activity,因此需要将注解写在容器Activity内======================// - @Titles - public static final int[] mTitles = {R.string.tab1, R.string.tab2, R.string.tab3, R.string.tab4}; - @SeleIcons - public static final int[] mSelectIcons = {R.drawable.nav_01_pre, R.drawable.nav_02_pre, R.drawable.nav_04_pre, R.drawable.nav_05_pre}; - @NorIcons - public static final int[] mNormalIcons = {R.drawable.nav_01_nor, R.drawable.nav_02_nor, R.drawable.nav_04_nor, R.drawable.nav_05_nor}; - - //============================================================================================================================================================// /** * 是否支持侧滑返回 */ @@ -132,7 +117,7 @@ protected boolean isSupportSlideBack() { */ protected void registerSlideBack() { if (isSupportSlideBack()) { - SlideBack.with(this) + SlideBack.withFixSize(this) .haveScroll(true) .edgeMode(ResUtils.isRtl() ? SlideBack.EDGE_RIGHT : SlideBack.EDGE_LEFT) .callBack(this::popPage) diff --git a/app/src/main/java/com/xuexiang/xuidemo/base/webview/AgentWebActivity.java b/app/src/main/java/com/xuexiang/xuidemo/base/webview/AgentWebActivity.java index 4c30b1b4..fc51c54c 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/base/webview/AgentWebActivity.java +++ b/app/src/main/java/com/xuexiang/xuidemo/base/webview/AgentWebActivity.java @@ -47,7 +47,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_agent_web); - SlideBack.with(this) + SlideBack.withFixSize(this) .haveScroll(true) .callBack(this::finish) .register(); diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/edittext/VerifyCodeEditTextFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/edittext/VerifyCodeEditTextFragment.java index a0706d65..ead0d5a1 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/edittext/VerifyCodeEditTextFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/edittext/VerifyCodeEditTextFragment.java @@ -24,6 +24,8 @@ public class VerifyCodeEditTextFragment extends BaseFragment implements VerifyCo VerifyCodeEditText vcet3; @BindView(R.id.vcet_4) VerifyCodeEditText vcet4; + @BindView(R.id.vcet_5) + VerifyCodeEditText vcet5; @Override protected int getLayoutId() { @@ -41,6 +43,7 @@ protected void initListeners() { vcet2.setOnInputListener(this); vcet3.setOnInputListener(this); vcet4.setOnInputListener(this); + vcet5.setOnInputListener(this); } @Override @@ -64,5 +67,6 @@ public void onViewClicked() { vcet2.clearInputValue(); vcet3.clearInputValue(); vcet4.clearInputValue(); + vcet5.clearInputValue(); } } diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/pickerview/TimePickerFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/pickerview/TimePickerFragment.java index 411473fc..dd85430a 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/pickerview/TimePickerFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/pickerview/TimePickerFragment.java @@ -102,6 +102,8 @@ private void showDatePicker() { .setTimeSelectChangeListener(date -> Log.i("pvTime", "onTimeSelectChanged")) .setTitleText("日期选择") .build(); +// // 这样设置日月年显示 +// mDatePicker.getWheelTime().getView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); } mDatePicker.show(); } diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/SwipeRefreshLayoutFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/SwipeRefreshLayoutFragment.java index 8a112199..af90ebf8 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/SwipeRefreshLayoutFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/SwipeRefreshLayoutFragment.java @@ -20,6 +20,9 @@ */ @Page(name = "SwipeRefreshLayout\n谷歌官方下拉刷新控件") public class SwipeRefreshLayoutFragment extends BaseFragment { + + private static final int[] COLORS = new int[]{0xff0099cc, 0xffff4444, 0xff669900, 0xffaa66cc, 0xffff8800}; + private SimpleRecyclerAdapter mAdapter; @BindView(R.id.recyclerView) @@ -27,11 +30,6 @@ public class SwipeRefreshLayoutFragment extends BaseFragment { @BindView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout; - /** - * 布局的资源id - * - * @return - */ @Override protected int getLayoutId() { return R.layout.fragment_swipe_refresh_layout; @@ -46,7 +44,7 @@ protected void initViews() { recyclerView.setAdapter(mAdapter = new SimpleRecyclerAdapter()); - swipeRefreshLayout.setColorSchemeColors(0xff0099cc, 0xffff4444, 0xff669900, 0xffaa66cc, 0xffff8800); + swipeRefreshLayout.setColorSchemeColors(COLORS); } @Override diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/RefreshBasicFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/RefreshBasicFragment.java index 81878153..e3c61ca7 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/RefreshBasicFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/RefreshBasicFragment.java @@ -16,10 +16,11 @@ package com.xuexiang.xuidemo.fragment.components.refresh.smartrefresh; -import android.widget.AbsListView; +import androidx.recyclerview.widget.RecyclerView; import com.scwang.smartrefresh.layout.api.RefreshLayout; import com.xuexiang.xpage.annotation.Page; +import com.xuexiang.xui.utils.WidgetUtils; import com.xuexiang.xuidemo.DemoDataProvider; import com.xuexiang.xuidemo.R; import com.xuexiang.xuidemo.adapter.SimpleRecyclerAdapter; @@ -34,11 +35,6 @@ public class RefreshBasicFragment extends BaseFragment { private SimpleRecyclerAdapter mAdapter; - /** - * 布局的资源id - * - * @return - */ @Override protected int getLayoutId() { return R.layout.fragment_refresh_basic; @@ -49,18 +45,20 @@ protected int getLayoutId() { */ @Override protected void initViews() { - AbsListView listView = findViewById(R.id.listView); - listView.setAdapter(mAdapter = new SimpleRecyclerAdapter()); + RecyclerView recyclerView = findViewById(R.id.recyclerView); + WidgetUtils.initRecyclerView(recyclerView); + recyclerView.setAdapter(mAdapter = new SimpleRecyclerAdapter()); final RefreshLayout refreshLayout = findViewById(R.id.refreshLayout); - refreshLayout.setEnableAutoLoadMore(true);//开启自动加载功能(非必须) - //下拉刷新 + // 开启自动加载功能(非必须) + refreshLayout.setEnableAutoLoadMore(true); + // 下拉刷新 refreshLayout.setOnRefreshListener(refreshLayout12 -> refreshLayout12.getLayout().postDelayed(() -> { mAdapter.refresh(DemoDataProvider.getDemoData()); refreshLayout12.finishRefresh(); refreshLayout12.resetNoMoreData();//setNoMoreData(false); }, 2000)); - //上拉加载 + // 上拉加载 refreshLayout.setOnLoadMoreListener(refreshLayout1 -> refreshLayout1.getLayout().postDelayed(() -> { if (mAdapter.getItemCount() > 30) { XToastUtils.toast("数据全部加载完毕"); @@ -71,14 +69,14 @@ protected void initViews() { } }, 2000)); - //触发自动刷新 + // 触发自动刷新 refreshLayout.autoRefresh(); - //item 点击测试 - mAdapter.setOnItemClickListener((itemView, position) -> XToastUtils.toast("点击:" + position)); + // item 点击测试 + mAdapter.setOnItemClickListener((itemView, item, position) -> XToastUtils.toast("点击:" + position)); - mAdapter.setOnItemLongClickListener((itemView, position) -> XToastUtils.toast("长按:" + position)); + mAdapter.setOnItemLongClickListener((itemView, item, position) -> XToastUtils.toast("长按:" + position)); -// //点击测试 +// // 点击测试 // RefreshFooter footer = refreshLayout.getRefreshFooter(); // if (footer != null) { // refreshLayout.getRefreshFooter().getView().findViewById(ClassicsFooter.ID_TEXT_TITLE).setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshAllStyleFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshAllStyleFragment.java index 2f3d55bc..7ee46e9a 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshAllStyleFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshAllStyleFragment.java @@ -19,15 +19,17 @@ import android.content.Context; import android.view.View; +import androidx.annotation.NonNull; import androidx.annotation.StringRes; import androidx.recyclerview.widget.RecyclerView; import com.scwang.smartrefresh.layout.SmartRefreshLayout; -import com.scwang.smartrefresh.layout.adapter.SmartRecyclerAdapter; import com.scwang.smartrefresh.layout.adapter.SmartViewHolder; import com.scwang.smartrefresh.layout.api.RefreshHeader; import com.scwang.smartrefresh.layout.constant.RefreshState; import com.xuexiang.xpage.annotation.Page; +import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter; +import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder; import com.xuexiang.xui.utils.WidgetUtils; import com.xuexiang.xuidemo.R; import com.xuexiang.xuidemo.base.BaseFragment; @@ -37,8 +39,6 @@ import butterknife.BindView; -import static android.R.layout.simple_list_item_2; - /** * @author xuexiang * @since 2018/12/7 下午2:32 @@ -118,13 +118,18 @@ protected int getLayoutId() { protected void initViews() { WidgetUtils.initRecyclerView(mRecyclerView); - mRecyclerView.setAdapter(new SmartRecyclerAdapter(Arrays.asList(Item.values()), simple_list_item_2, this) { + mRecyclerView.setAdapter(new BaseRecyclerAdapter(Arrays.asList(Item.values())) { @Override - protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) { - holder.text(android.R.id.text1, model.name()); - holder.text(android.R.id.text2, model.nameId); + protected void bindData(@NonNull RecyclerViewHolder holder, int position, Item item) { + holder.text(android.R.id.text1, item.name()); + holder.text(android.R.id.text2, item.nameId); holder.textColorId(android.R.id.text2, R.color.xui_config_color_light_blue_gray); } + + @Override + protected int getItemLayoutId(int viewType) { + return android.R.layout.simple_list_item_2; + } }); mRefreshLayout.autoRefresh();//第一次进入触发自动刷新,演示效果 diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshClassicsStyleFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshClassicsStyleFragment.java index b3aff550..31c4d372 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshClassicsStyleFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshClassicsStyleFragment.java @@ -22,17 +22,19 @@ import android.view.View; import android.widget.ImageView; +import androidx.annotation.NonNull; import androidx.annotation.StringRes; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.scwang.smartrefresh.layout.SmartRefreshLayout; -import com.scwang.smartrefresh.layout.adapter.SmartRecyclerAdapter; import com.scwang.smartrefresh.layout.adapter.SmartViewHolder; import com.scwang.smartrefresh.layout.constant.RefreshState; import com.scwang.smartrefresh.layout.constant.SpinnerStyle; import com.scwang.smartrefresh.layout.header.ClassicsHeader; import com.xuexiang.xpage.annotation.Page; +import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter; +import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder; import com.xuexiang.xui.utils.ViewUtils; import com.xuexiang.xui.utils.WidgetUtils; import com.xuexiang.xui.widget.actionbar.TitleBar; @@ -48,8 +50,6 @@ import butterknife.BindView; -import static android.R.layout.simple_list_item_2; - /** * @author xuexiang * @since 2018/12/7 上午12:45 @@ -200,13 +200,18 @@ protected void initViews() { RecyclerView recyclerView = (RecyclerView) view; WidgetUtils.initRecyclerView(recyclerView); - recyclerView.setAdapter(new SmartRecyclerAdapter(Arrays.asList(Item.values()), simple_list_item_2, this) { + recyclerView.setAdapter(new BaseRecyclerAdapter(Arrays.asList(Item.values())) { @Override - protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) { - holder.text(android.R.id.text1, model.name()); - holder.text(android.R.id.text2, model.nameId); + protected void bindData(@NonNull RecyclerViewHolder holder, int position, Item item) { + holder.text(android.R.id.text1, item.name()); + holder.text(android.R.id.text2, item.nameId); holder.textColorId(android.R.id.text2, R.color.xui_config_color_light_blue_gray); } + + @Override + protected int getItemLayoutId(int viewType) { + return android.R.layout.simple_list_item_2; + } }); mRecyclerView = recyclerView; //触发自动刷新 diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshMaterialStyleFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshMaterialStyleFragment.java index 5d81ffc0..2cda1a45 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshMaterialStyleFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/smartrefresh/style/RefreshMaterialStyleFragment.java @@ -19,16 +19,18 @@ import android.os.Build; import android.view.View; +import androidx.annotation.NonNull; import androidx.annotation.StringRes; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.scwang.smartrefresh.header.MaterialHeader; import com.scwang.smartrefresh.layout.SmartRefreshLayout; -import com.scwang.smartrefresh.layout.adapter.SmartRecyclerAdapter; import com.scwang.smartrefresh.layout.adapter.SmartViewHolder; import com.scwang.smartrefresh.layout.constant.RefreshState; import com.xuexiang.xpage.annotation.Page; +import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter; +import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder; import com.xuexiang.xui.utils.WidgetUtils; import com.xuexiang.xui.widget.actionbar.TitleBar; import com.xuexiang.xuidemo.R; @@ -38,8 +40,6 @@ import butterknife.BindView; -import static android.R.layout.simple_list_item_2; - /** * @author xuexiang * @since 2018/12/7 上午1:43 @@ -148,13 +148,18 @@ protected void initViews() { RecyclerView recyclerView = (RecyclerView) view; WidgetUtils.initRecyclerView(recyclerView); - recyclerView.setAdapter(new SmartRecyclerAdapter(Arrays.asList(Item.values()), simple_list_item_2,this) { + recyclerView.setAdapter(new BaseRecyclerAdapter(Arrays.asList(Item.values())) { @Override - protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) { - holder.text(android.R.id.text1, model.name()); - holder.text(android.R.id.text2, model.nameId); + protected void bindData(@NonNull RecyclerViewHolder holder, int position, Item item) { + holder.text(android.R.id.text1, item.name()); + holder.text(android.R.id.text2, item.nameId); holder.textColorId(android.R.id.text2, R.color.xui_config_color_light_blue_gray); } + + @Override + protected int getItemLayoutId(int viewType) { + return android.R.layout.simple_list_item_2; + } }); } mRefreshLayout.autoRefresh();//第一次进入触发自动刷新,演示效果 diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/swipe/SwipeHeadFootViewFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/swipe/SwipeHeadFootViewFragment.java index bf53e2af..1d83946d 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/swipe/SwipeHeadFootViewFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/refresh/swipe/SwipeHeadFootViewFragment.java @@ -55,7 +55,7 @@ protected void initViews() { final SimpleRecyclerAdapter adapter = new SimpleRecyclerAdapter(DemoDataProvider.getDemoData1()); recyclerView.setAdapter(adapter); - adapter.setOnItemClickListener((itemView, position) -> { + adapter.setOnItemClickListener((itemView, item, position) -> { //需要注意的是,因为加了一个HeaderView,所以position都被自动加了1,因此获取内容时需要减1 XToastUtils.toast("点击了第" + position + "个条目:" + adapter.getItem(position - 1)); }); diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/statelayout/status/adapter/DefaultStatusView.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/statelayout/status/adapter/DefaultStatusView.java index d45ce761..a63e6a5e 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/statelayout/status/adapter/DefaultStatusView.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/statelayout/status/adapter/DefaultStatusView.java @@ -88,10 +88,10 @@ private int getLayoutIdByStatus(int status) { layoutId = R.layout.msv_layout_loading_view; break; case STATUS_LOAD_FAILED: - layoutId = R.layout.msv_layout_empty_view; + layoutId = R.layout.msv_layout_error_view; break; case STATUS_EMPTY_DATA: - layoutId = R.layout.msv_layout_error_view; + layoutId = R.layout.msv_layout_empty_view; break; case STATUS_CUSTOM: layoutId = R.layout.msv_layout_no_network_view; diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/tabbar/JPTabBarFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/tabbar/JPTabBarFragment.java index e8061f3e..7c0c5036 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/components/tabbar/JPTabBarFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/components/tabbar/JPTabBarFragment.java @@ -14,7 +14,6 @@ import com.xuexiang.xpage.annotation.Page; import com.xuexiang.xui.XUI; import com.xuexiang.xuidemo.R; -import com.xuexiang.xuidemo.base.BaseActivity; import com.xuexiang.xuidemo.base.BaseFragment; import com.xuexiang.xuidemo.utils.XToastUtils; @@ -23,8 +22,6 @@ import butterknife.BindView; -import static com.xuexiang.xuidemo.base.BaseActivity.mTitles; - /** * @author xuexiang * @since 2019/4/14 下午8:07 @@ -37,6 +34,10 @@ public class JPTabBarFragment extends BaseFragment implements OnTabSelectListene @BindView(R.id.tabbar) JPTabBar mTabbar; + private int[] mTitles = {R.string.tab1, R.string.tab2, R.string.tab3, R.string.tab4}; + private int[] mSelectIcons = {R.drawable.nav_01_pre, R.drawable.nav_02_pre, R.drawable.nav_04_pre, R.drawable.nav_05_pre}; + private int[] mNormalIcons = {R.drawable.nav_01_nor, R.drawable.nav_02_nor, R.drawable.nav_04_nor, R.drawable.nav_05_nor}; + private Map mPageMap = new HashMap<>(); private PagerAdapter mPagerAdapter = new PagerAdapter() { @@ -89,13 +90,13 @@ protected int getLayoutId() { /** * 初始化控件 - * mTabbar的设置详细参见 - * {@link BaseActivity#mTitles} - * {@link BaseActivity#mSelectIcons} - * {@link BaseActivity#mNormalIcons} */ @Override protected void initViews() { + mTabbar.setTitles(mTitles); + mTabbar.setNormalIcons(mNormalIcons); + mTabbar.setSelectedIcons(mSelectIcons); + mTabbar.generate(); //页面可以滑动 mTabbar.setGradientEnable(true); mTabbar.setPageAnimateEnable(true); @@ -108,7 +109,7 @@ protected void initViews() { mTabbar.getMiddleView().setOnClickListener(v -> XToastUtils.toast("中间点击")); } - mTabbar.showBadge(2,"", true); + mTabbar.showBadge(2, "", true); } @Override diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/ChineseCalendarFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/ChineseCalendarFragment.java index 8498d7e7..de70bab4 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/ChineseCalendarFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/ChineseCalendarFragment.java @@ -27,7 +27,7 @@ import com.xuexiang.xpage.annotation.Page; import com.xuexiang.xuidemo.DemoDataProvider; import com.xuexiang.xuidemo.R; -import com.xuexiang.xuidemo.adapter.SimpleRecyclerAdapter; +import com.xuexiang.xuidemo.adapter.SimpleListViewAdapter; import com.xuexiang.xuidemo.base.BaseFragment; import java.util.Date; @@ -90,9 +90,8 @@ protected void initViews() { tvTitle.setText(ChinaDateUtils.oneDay(data.year, data.month, data.day)); - listView.setAdapter(new SimpleRecyclerAdapter(DemoDataProvider.getDemoData())); + listView.setAdapter(new SimpleListViewAdapter(getContext(), DemoDataProvider.getDemoData())); } - } diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/DingDingCalendarFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/DingDingCalendarFragment.java index e21d5cb4..4972bd14 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/DingDingCalendarFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/calendar/DingDingCalendarFragment.java @@ -28,7 +28,7 @@ import com.xuexiang.xui.utils.DensityUtils; import com.xuexiang.xuidemo.DemoDataProvider; import com.xuexiang.xuidemo.R; -import com.xuexiang.xuidemo.adapter.SimpleRecyclerAdapter; +import com.xuexiang.xuidemo.adapter.SimpleListViewAdapter; import com.xuexiang.xuidemo.base.BaseFragment; import java.util.Date; @@ -92,7 +92,7 @@ protected void initViews() { tvTitle.setText(String.format("%d/%d/%d", data.year, data.month, data.day)); - listview.setAdapter(new SimpleRecyclerAdapter(DemoDataProvider.getDemoData())); + listview.setAdapter(new SimpleListViewAdapter(getContext(), DemoDataProvider.getDemoData())); } diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/materialdesign/ToolBarFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/materialdesign/ToolBarFragment.java index 98832bcd..bce56572 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/materialdesign/ToolBarFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/expands/materialdesign/ToolBarFragment.java @@ -2,15 +2,23 @@ import android.view.View; import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; import androidx.appcompat.widget.Toolbar; import com.xuexiang.xpage.annotation.Page; +import com.xuexiang.xui.utils.ResUtils; +import com.xuexiang.xui.utils.ViewUtils; +import com.xuexiang.xui.widget.popupwindow.popup.XUISimplePopup; import com.xuexiang.xuidemo.R; import com.xuexiang.xuidemo.base.BaseFragment; import com.xuexiang.xuidemo.utils.XToastUtils; +import com.xuexiang.xutil.common.StringUtils; +import com.xuexiang.xutil.display.DensityUtils; import butterknife.BindView; +import butterknife.OnClick; /** * @author xuexiang @@ -28,6 +36,15 @@ public class ToolBarFragment extends BaseFragment { EditText editSearch; @BindView(R.id.tool_bar_4) Toolbar toolBar4; + @BindView(R.id.ll_action) + LinearLayout llAction; + @BindView(R.id.tool_bar_5) + Toolbar toolBar5; + @BindView(R.id.tv_title) + TextView tvTitle; + @BindView(R.id.tv_sub_title) + TextView tvSubTitle; + /** * 布局的资源id @@ -48,9 +65,10 @@ protected void initViews() { initToolbar2(); initToolbar3(); initToolbar4(); + initToolbar5(); } - private void initToolbar1(){ + private void initToolbar1() { //设置NavigationIcon toolBar1.setNavigationIcon(R.drawable.ic_navigation_menu); // 设置 NavigationIcon 点击事件 @@ -76,36 +94,55 @@ private void initToolbar1(){ toolBar1.setOnMenuItemClickListener(menuItemClickListener); } - private void initToolbar2(){ + private void initToolbar2() { toolBar2.setNavigationOnClickListener(onClickListener); toolBar2.inflateMenu(R.menu.menu_setting); toolBar2.setOnMenuItemClickListener(menuItemClickListener); } - private void initToolbar3(){ + private void initToolbar3() { toolBar3.setNavigationOnClickListener(onClickListener); toolBar3.inflateMenu(R.menu.menu_setting); toolBar3.setOnMenuItemClickListener(menuItemClickListener); } - private void initToolbar4(){ + private void initToolbar4() { toolBar4.setNavigationOnClickListener(onClickListener); toolBar4.inflateMenu(R.menu.menu_search); toolBar4.setOnMenuItemClickListener(menuItemClickListener); } + private void initToolbar5() { + toolBar5.setNavigationOnClickListener(onClickListener); + toolBar5.setOnMenuItemClickListener(menuItemClickListener); + tvTitle.setText("主页"); + } + + private View.OnClickListener onClickListener = v -> XToastUtils.toast("点击了NavigationIcon"); Toolbar.OnMenuItemClickListener menuItemClickListener = item -> { XToastUtils.toast("点击了:" + item.getTitle()); - switch (item.getItemId()){ - case R.id.item_setting: - //点击设置 - break; - default: - break; + if (item.getItemId() == R.id.item_setting) { + //点击设置 } return false; }; + + @OnClick(R.id.ll_action) + public void onViewClicked(View view) { + if (view.getId() == R.id.ll_action) { + showSelectPopWindow(view); + } + } + + private void showSelectPopWindow(View view) { + new XUISimplePopup<>(getContext(), ResUtils.getStringArray(R.array.grid_titles_entry)) + .create(DensityUtils.dip2px(getContext(), 170), (adapter, item, position) -> { + ViewUtils.setText(tvSubTitle, String.format("<%s>", item)); + }) + .setHasDivider(true) + .showDown(view); + } } diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/ShortcutUtilsFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/ShortcutUtilsFragment.java new file mode 100644 index 00000000..88b3260b --- /dev/null +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/ShortcutUtilsFragment.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com) + * + * 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. + * + */ + +package com.xuexiang.xuidemo.fragment.utils; + +import android.view.View; + +import com.xuexiang.xaop.annotation.SingleClick; +import com.xuexiang.xpage.annotation.Page; +import com.xuexiang.xui.utils.ResUtils; +import com.xuexiang.xui.utils.ShortcutUtils; +import com.xuexiang.xui.widget.actionbar.TitleBar; +import com.xuexiang.xui.widget.grouplist.XUIGroupListView; +import com.xuexiang.xuidemo.R; +import com.xuexiang.xuidemo.activity.SearchComponentActivity; +import com.xuexiang.xuidemo.activity.SettingsActivity; +import com.xuexiang.xuidemo.base.BaseFragment; +import com.xuexiang.xuidemo.fragment.utils.shortcut.ShortcutReceiver; +import com.xuexiang.xuidemo.utils.Utils; + +import butterknife.BindView; + +/** + * 快捷方式创建工具类 + * + * @author xuexiang + * @since 2021/10/6 3:33 PM + */ +@Page(name = "ShortcutUtils", extra = R.drawable.ic_util_shortcut) +public class ShortcutUtilsFragment extends BaseFragment { + + @BindView(R.id.groupListView) + XUIGroupListView groupListView; + + @Override + protected TitleBar initTitle() { + return super.initTitle().setLeftClickListener(new View.OnClickListener() { + @SingleClick + @Override + public void onClick(View v) { + popToBack(); + Utils.syncMainPageStatus(); + } + }); + } + + @Override + protected int getLayoutId() { + return R.layout.fragment_shortcututils; + } + + @Override + protected void initViews() { + XUIGroupListView.newSection(getContext()) + .setDescription("支持7.0以上版本的桌面快捷方式的创建") + .addItemView(groupListView.createItemView("增加搜索至桌面快捷方式"), v -> createSearchShortcut()) + .addItemView(groupListView.createItemView("增加设置至桌面快捷方式"), v -> createSettingShortcut()) + .addTo(groupListView); + } + + /** + * 创建搜索桌面快捷方式 + */ + private void createSearchShortcut() { + ShortcutUtils.addPinShortcut(getContext(), + SearchComponentActivity.class, + "shortcut_search_id", + R.drawable.ic_action_search, ResUtils.getString(R.string.shortcut_label_search), ShortcutReceiver.class); + } + + /** + * 创建搜索桌面快捷方式s + */ + private void createSettingShortcut() { + ShortcutUtils.addPinShortcut(getContext(), + SettingsActivity.class, + "shortcut_setting_id", + R.drawable.ic_action_setting, ResUtils.getString(R.string.shortcut_label_setting), ShortcutReceiver.class); + } +} diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/StatusBarUtilsFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/StatusBarUtilsFragment.java index 2a7b2225..dbc3008a 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/StatusBarUtilsFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/StatusBarUtilsFragment.java @@ -96,6 +96,15 @@ private void showSimpleTipDialog() { .positiveText(R.string.lab_submit) .build(); StatusBarUtils.showDialog(getActivity(), dialog); + +// MiniLoadingDialog dialog = new MiniLoadingDialog(getContext()); +// dialog.showIfSync(true); +// new Handler().postDelayed(new Runnable() { +// @Override +// public void run() { +// dialog.dismiss(); +// } +// }, 3000); } diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/shortcut/CreateShortcutResultIntentActivity.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/shortcut/CreateShortcutResultIntentActivity.java new file mode 100644 index 00000000..ad17c0ac --- /dev/null +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/shortcut/CreateShortcutResultIntentActivity.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com) + * + * 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. + * + */ + +package com.xuexiang.xuidemo.fragment.utils.shortcut; + +import android.os.Bundle; + +import com.xuexiang.xpage.core.PageOption; +import com.xuexiang.xpage.enums.CoreAnim; +import com.xuexiang.xuidemo.base.BaseActivity; +import com.xuexiang.xuidemo.fragment.utils.ShortcutUtilsFragment; +import com.xuexiang.xuidemo.utils.Utils; + +/** + * @author xuexiang + * @since 2021/10/7 7:00 PM + */ +public class CreateShortcutResultIntentActivity extends BaseActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + PageOption.to(ShortcutUtilsFragment.class) + .setAnim(CoreAnim.none) + .open(this); + } + + @Override + public void onBackPressed() { + if (this.getSupportFragmentManager().getBackStackEntryCount() == 1) { + Utils.syncMainPageStatus(); + } + super.onBackPressed(); + } +} diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/shortcut/ShortcutReceiver.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/shortcut/ShortcutReceiver.java new file mode 100644 index 00000000..d469a98e --- /dev/null +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/utils/shortcut/ShortcutReceiver.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com) + * + * 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. + * + */ + +package com.xuexiang.xuidemo.fragment.utils.shortcut; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import com.xuexiang.xuidemo.utils.XToastUtils; +import com.xuexiang.xutil.common.logger.Logger; + +/** + * 快捷方式创建接收广播 + * + * @author xuexiang + * @since 2021/10/6 4:43 PM + */ +public class ShortcutReceiver extends BroadcastReceiver { + + private static final String TAG = "ShortcutReceiver"; + + @Override + public void onReceive(Context context, Intent intent) { + Logger.dTag(TAG, "onReceive:" + intent.getAction()); + XToastUtils.toast("开始创建快捷方式"); + } +} diff --git a/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java b/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java index 5afb3758..85ea11b6 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java +++ b/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java @@ -59,13 +59,11 @@ public static void init(Application application) { /** * 初始化工具类 * - * @param application + * @param application 应用上下文 */ private static void initUtils(Application application) { XUtil.init(application); XUtil.debug(MyApp.isDebug()); - //百度定位 - LocationService.get().init(application); TokenUtils.init(application); } diff --git a/app/src/main/java/com/xuexiang/xuidemo/utils/task/AsyncInitTask.java b/app/src/main/java/com/xuexiang/xuidemo/utils/task/AsyncInitTask.java new file mode 100644 index 00000000..096d9d6b --- /dev/null +++ b/app/src/main/java/com/xuexiang/xuidemo/utils/task/AsyncInitTask.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2022 xuexiangjys(xuexiangjys@163.com) + * + * 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. + * + */ + +package com.xuexiang.xuidemo.utils.task; + +import android.app.Application; + +import androidx.annotation.NonNull; + +import com.google.android.cameraview.CameraView; +import com.luck.picture.lib.tools.PictureFileUtils; +import com.xuexiang.xtask.api.step.SimpleTaskStep; +import com.xuexiang.xtask.core.ThreadType; +import com.xuexiang.xuidemo.utils.LocationService; +import com.xuexiang.xuidemo.utils.sdkinit.ANRWatchDogInit; +import com.xuexiang.xuidemo.utils.sdkinit.AutoCameraStrategy; +import com.xuexiang.xuidemo.utils.sdkinit.TbsInit; +import com.xuexiang.xuidemo.utils.sdkinit.UMengInit; + +/** + * 异步初始化任务 + * 放一些优先级不是很高的、耗时的初始化任务 + * + * @author xuexiang + * @since 2/17/22 12:26 AM + */ +public class AsyncInitTask extends SimpleTaskStep { + + private Application mApplication; + + /** + * 构造方法 + * + * @param application 应用上下文 + */ + public AsyncInitTask(Application application) { + mApplication = application; + } + + @Override + public void doTask() throws Exception { + // 友盟SDK + UMengInit.init(mApplication); + // ANR监控 + ANRWatchDogInit.init(); + + TbsInit.init(mApplication); + // 百度定位 + LocationService.get().init(mApplication); + // 图片路径 + PictureFileUtils.setAppName("xui"); + // 照相机 + CameraView.setICameraStrategy(new AutoCameraStrategy(1920 * 1080)); + } + + @Override + public String getName() { + return "AsyncInitTask"; + } + + @NonNull + @Override + public ThreadType getThreadType() { + return ThreadType.ASYNC; + } +} diff --git a/app/src/main/java/com/xuexiang/xuidemo/utils/task/MainInitTask.java b/app/src/main/java/com/xuexiang/xuidemo/utils/task/MainInitTask.java new file mode 100644 index 00000000..590b4e40 --- /dev/null +++ b/app/src/main/java/com/xuexiang/xuidemo/utils/task/MainInitTask.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2022 xuexiangjys(xuexiangjys@163.com) + * + * 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. + * + */ + +package com.xuexiang.xuidemo.utils.task; + +import android.app.Application; + +import androidx.annotation.NonNull; + +import com.mikepenz.iconics.Iconics; +import com.xuexiang.xtask.api.step.SimpleTaskStep; +import com.xuexiang.xtask.core.ThreadType; +import com.xuexiang.xui.XUI; +import com.xuexiang.xuidemo.MyApp; +import com.xuexiang.xuidemo.utils.SettingSPUtils; +import com.xuexiang.xuidemo.utils.sdkinit.XBasicLibInit; +import com.xuexiang.xuidemo.utils.sdkinit.XUpdateInit; +import com.xuexiang.xuidemo.widget.iconfont.XUIIconFont; + +/** + * 主要初始化任务,放在第一位执行 + * + * @author xuexiang + * @since 2/17/22 12:43 AM + */ +public class MainInitTask extends SimpleTaskStep { + + private Application mApplication; + + /** + * 构造方法 + * + * @param application 应用上下文 + */ + public MainInitTask(Application application) { + mApplication = application; + } + + @Override + public void doTask() throws Exception { + // 初始化基础库 + XBasicLibInit.init(mApplication); + // 初始化UI框架 + initUi(); + // XUpdate版本更新 + XUpdateInit.init(mApplication); + } + + /** + * 初始化UI框架 + */ + private void initUi() { + XUI.debug(MyApp.isDebug()); + if (SettingSPUtils.getInstance().isUseCustomFont()) { + //设置默认字体为华文行楷 + XUI.initFontStyle("fonts/hwxk.ttf"); + } + //字体图标库 + Iconics.init(mApplication); + //这是自己定义的图标库 + Iconics.registerFont(new XUIIconFont()); + } + + @Override + public String getName() { + return "MainInitTask"; + } + + @NonNull + @Override + public ThreadType getThreadType() { + return ThreadType.SYNC; + } +} diff --git a/app/src/main/java/com/xuexiang/xuidemo/widget/iconfont/IconFontActivity.java b/app/src/main/java/com/xuexiang/xuidemo/widget/iconfont/IconFontActivity.java index 4df7adb5..9da1830c 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/widget/iconfont/IconFontActivity.java +++ b/app/src/main/java/com/xuexiang/xuidemo/widget/iconfont/IconFontActivity.java @@ -123,7 +123,7 @@ protected boolean isSupportSlideBack() { */ protected void registerSlideBack() { if (isSupportSlideBack()) { - SlideBack.with(this) + SlideBack.withFixSize(this) .haveScroll(true) .edgeMode(ResUtils.isRtl() ? SlideBack.EDGE_RIGHT : SlideBack.EDGE_LEFT) .callBack(this::popPage) diff --git a/app/src/main/res/drawable-hdpi/ic_expand_alibaba.png b/app/src/main/res/drawable-hdpi/ic_expand_alibaba.png index f5cf7328..da1fbc81 100644 Binary files a/app/src/main/res/drawable-hdpi/ic_expand_alibaba.png and b/app/src/main/res/drawable-hdpi/ic_expand_alibaba.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_expand_camera.png b/app/src/main/res/drawable-hdpi/ic_expand_camera.png index 099a8c9b..716424e0 100644 Binary files a/app/src/main/res/drawable-hdpi/ic_expand_camera.png and b/app/src/main/res/drawable-hdpi/ic_expand_camera.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_util_shortcut.png b/app/src/main/res/drawable-hdpi/ic_util_shortcut.png new file mode 100644 index 00000000..98cda894 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_util_shortcut.png differ diff --git a/app/src/main/res/layout/fragment_arcloadingview.xml b/app/src/main/res/layout/fragment_arcloadingview.xml index eaf606e9..dbdfcce0 100644 --- a/app/src/main/res/layout/fragment_arcloadingview.xml +++ b/app/src/main/res/layout/fragment_arcloadingview.xml @@ -5,9 +5,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - + - + - + - + + android:paddingBottom="?attr/xui_config_content_spacing_horizontal"> @@ -102,8 +100,8 @@ @@ -143,8 +141,8 @@ diff --git a/app/src/main/res/layout/fragment_easy_indicator.xml b/app/src/main/res/layout/fragment_easy_indicator.xml index bffa7a74..dda64729 100644 --- a/app/src/main/res/layout/fragment_easy_indicator.xml +++ b/app/src/main/res/layout/fragment_easy_indicator.xml @@ -37,6 +37,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="10dp" + app:indicator_background="@color/xui_config_color_transparent" app:indicator_height="42dp" app:indicator_line_height="5dp" app:indicator_line_res="@drawable/shape_indicator_line" @@ -44,8 +45,9 @@ app:indicator_line_width="30dp" app:indicator_selected_color="#FF6100" app:indicator_textSize="14sp" - app:indicator_vertical_line_h="30dp" - app:indicator_vertical_line_w="1dp" + app:indicator_vertical_line_color="@color/xui_config_color_white" + app:indicator_vertical_line_h="20dp" + app:indicator_vertical_line_w="1.5dp" app:indicator_width="300dp" /> - + - - + + android:layout_height="wrap_content" /> + android:layout_height="wrap_content" /> + app:ftl_single_cancelable="true" /> + app:ftl_selecteds="@array/tags_selects_values" /> + android:text="添加标签" /> + android:text="清除标签" /> @@ -118,7 +114,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" app:ftl_check_mode="display" - app:ftl_entries="@array/tags_values"/> + app:ftl_entries="@array/tags_values" /> diff --git a/app/src/main/res/layout/fragment_guidecase_view_style.xml b/app/src/main/res/layout/fragment_guidecase_view_style.xml index 80e1c4f2..0ab93dc3 100755 --- a/app/src/main/res/layout/fragment_guidecase_view_style.xml +++ b/app/src/main/res/layout/fragment_guidecase_view_style.xml @@ -4,9 +4,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - + - + - + - + - + - - + + android:inputType="numberDecimal" /> + android:layout_marginStart="10dp" + android:text="设值" /> + android:text="取值" /> @@ -58,18 +56,18 @@ android:layout_height="120dp" android:layout_margin="10dp" + app:rv_bgColor="#fcfffc" app:rv_firstScale="50" - app:rv_minScale="0" + app:rv_largeScaleColor="#50b586" app:rv_maxScale="100" - app:rv_scaleCount="10" - app:rv_unit="kg" - - app:rv_bgColor="#fcfffc" - app:rv_smallScaleColor="#aaaaaa" app:rv_midScaleColor="#999999" - app:rv_largeScaleColor="#50b586" + + app:rv_minScale="0" app:rv_resultNumColor="#50b586" + app:rv_scaleCount="10" app:rv_scaleNumColor="#666666" + app:rv_smallScaleColor="#aaaaaa" + app:rv_unit="kg" app:rv_unitColor="#50b586" app:rv_unitTextSize="10sp" /> @@ -83,18 +81,18 @@ android:layout_height="120dp" android:layout_margin="10dp" + app:rv_bgColor="#fcfffc" app:rv_firstScale="175" - app:rv_minScale="50" + app:rv_largeScaleColor="@color/colorAccent" app:rv_maxScale="230" - app:rv_scaleCount="5" - app:rv_unit="cm" - - app:rv_bgColor="#fcfffc" - app:rv_smallScaleColor="@color/colorPrimary" app:rv_midScaleColor="@color/colorPrimaryDark" - app:rv_largeScaleColor="@color/colorAccent" + + app:rv_minScale="50" app:rv_resultNumColor="#50b586" + app:rv_scaleCount="5" app:rv_scaleNumColor="#666666" + app:rv_smallScaleColor="@color/colorPrimary" + app:rv_unit="cm" app:rv_unitColor="#50b586" app:rv_unitTextSize="10sp" /> @@ -108,18 +106,18 @@ android:layout_height="120dp" android:layout_margin="10dp" + app:rv_bgColor="#fcfffc" app:rv_firstScale="1.0" - app:rv_minScale="0" + app:rv_largeScaleColor="#50b586" app:rv_maxScale="6" - app:rv_scaleCount="10" - app:rv_unit=" " - - app:rv_bgColor="#fcfffc" - app:rv_smallScaleColor="#aaaaaa" app:rv_midScaleColor="#999999" - app:rv_largeScaleColor="#50b586" + + app:rv_minScale="0" app:rv_resultNumColor="#50b586" + app:rv_scaleCount="10" app:rv_scaleNumColor="#666666" + app:rv_smallScaleColor="#aaaaaa" + app:rv_unit=" " app:rv_unitColor="#50b586" app:rv_unitTextSize="10sp" /> diff --git a/app/src/main/res/layout/fragment_shadowbutton.xml b/app/src/main/res/layout/fragment_shadowbutton.xml index 4bd501a2..db2ff599 100755 --- a/app/src/main/res/layout/fragment_shadowbutton.xml +++ b/app/src/main/res/layout/fragment_shadowbutton.xml @@ -5,10 +5,7 @@ android:gravity="center_vertical" android:orientation="vertical"> - + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_super_picture_loading.xml b/app/src/main/res/layout/fragment_super_picture_loading.xml index d8bd2aa5..8eb30245 100755 --- a/app/src/main/res/layout/fragment_super_picture_loading.xml +++ b/app/src/main/res/layout/fragment_super_picture_loading.xml @@ -6,10 +6,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_util_statusbar.xml b/app/src/main/res/layout/fragment_util_statusbar.xml index 7cb8d13c..b9b8a55f 100644 --- a/app/src/main/res/layout/fragment_util_statusbar.xml +++ b/app/src/main/res/layout/fragment_util_statusbar.xml @@ -4,9 +4,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - + - - - - - - - - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_xui_popup.xml b/app/src/main/res/layout/fragment_xui_popup.xml index 95744c40..47b88403 100644 --- a/app/src/main/res/layout/fragment_xui_popup.xml +++ b/app/src/main/res/layout/fragment_xui_popup.xml @@ -4,9 +4,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - + data) { + public BaseListAdapter(Context context, Collection data) { super(context, data); } diff --git a/xui_lib/src/main/java/com/xuexiang/xui/adapter/listview/XListAdapter.java b/xui_lib/src/main/java/com/xuexiang/xui/adapter/listview/XListAdapter.java index ecdb5df0..68501e93 100755 --- a/xui_lib/src/main/java/com/xuexiang/xui/adapter/listview/XListAdapter.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/adapter/listview/XListAdapter.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; /** @@ -46,7 +47,7 @@ public XListAdapter(Context context) { mContext = context; } - public XListAdapter(Context context, List data) { + public XListAdapter(Context context, Collection data) { mContext = context; setData(data); } @@ -56,7 +57,7 @@ public XListAdapter(Context context, T[] data) { setData(data); } - public void setData(List data) { + public void setData(Collection data) { if (data != null) { mData.clear(); mData.addAll(data); diff --git a/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/DividerItemDecoration.java b/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/DividerItemDecoration.java index 4a7c3287..92c58f86 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/DividerItemDecoration.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/DividerItemDecoration.java @@ -95,7 +95,7 @@ public DividerItemDecoration(Context context, int orientation, int dividerHeight /** * 自定义分割线 * - * @param context + * @param context 上下文 * @param orientation 列表方向 * @param dividerHeight 分割线高度 * @param dividerColor 分割线颜色 @@ -108,6 +108,12 @@ public DividerItemDecoration(Context context, int orientation, int dividerHeight mPaint.setStyle(Paint.Style.FILL); } + /** + * 设置分割线 + * + * @param divider 分割线 + * @return this + */ public DividerItemDecoration setDivider(@NonNull Drawable divider) { mDivider = divider; mDividerHeight = mDivider.getIntrinsicHeight(); @@ -117,7 +123,7 @@ public DividerItemDecoration setDivider(@NonNull Drawable divider) { /** * 自定义分割线 * - * @param context + * @param context 上下文 * @param orientation 列表方向 * @param dividerHeight 分割线高度 * @param dividerColor 分割线颜色 @@ -134,11 +140,6 @@ public DividerItemDecoration(Context context, int orientation, int dividerHeight /** * 获取分割线尺寸 - * - * @param outRect - * @param view - * @param parent - * @param state */ @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { @@ -152,10 +153,6 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R /** * 绘制分割线 - * - * @param canvas - * @param parent - * @param state */ @Override public void onDraw(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { @@ -183,12 +180,13 @@ private void drawVertical(Canvas canvas, RecyclerView parent) { RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int top = child.getBottom() + layoutParams.bottomMargin; final int bottom = top + mDividerHeight; - if (mDivider != null) { - mDivider.setBounds(left, top, right, bottom); - mDivider.draw(canvas); - } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); + } else { + if (mDivider != null) { + mDivider.setBounds(left, top, right, bottom); + mDivider.draw(canvas); + } } } } @@ -209,12 +207,13 @@ private void drawHorizontal(Canvas canvas, RecyclerView parent) { RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + layoutParams.rightMargin; final int right = left + mDividerHeight; - if (mDivider != null) { - mDivider.setBounds(left, top, right, bottom); - mDivider.draw(canvas); - } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); + } else { + if (mDivider != null) { + mDivider.setBounds(left, top, right, bottom); + mDivider.draw(canvas); + } } } } diff --git a/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/GridDividerItemDecoration.java b/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/GridDividerItemDecoration.java index a0647998..eaf68979 100755 --- a/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/GridDividerItemDecoration.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/adapter/recyclerview/GridDividerItemDecoration.java @@ -60,7 +60,7 @@ public GridDividerItemDecoration(Context context, int spanCount) { mDivider = a.getDrawable(0); a.recycle(); if (mDivider != null) { - mDividerWidth = mDivider.getIntrinsicHeight(); + mDividerWidth = mDivider.getIntrinsicWidth(); } else { mDividerWidth = DensityUtils.dp2px(1); } @@ -94,6 +94,18 @@ public GridDividerItemDecoration(Context context, int spanCount, int dividerWidt mPaint.setStyle(Paint.Style.FILL); } + /** + * 设置分割线 + * + * @param divider 分割线 + * @return this + */ + public GridDividerItemDecoration setDivider(@NonNull Drawable divider) { + mDivider = divider; + mDividerWidth = mDivider.getIntrinsicWidth(); + return this; + } + @Override public void onDraw(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { super.onDraw(canvas, parent, state); @@ -101,30 +113,33 @@ public void onDraw(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNul for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); int position = parent.getChildLayoutPosition(child); - int column = (position + 1) % 3; - column = column == 0 ? mSpanCount : column; - + int column = (position + 1) % mSpanCount; + if (column == 0) { + column = mSpanCount; + } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int top = child.getBottom() + params.bottomMargin + Math.round(ViewCompat.getTranslationY(child)); final int bottom = top + mDividerWidth; final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child)); final int right = left + mDividerWidth; - if (mPaint != null) { - mDivider.setBounds(child.getLeft(), top, right, bottom); - mDivider.draw(canvas); - } if (mPaint != null) { canvas.drawRect(child.getLeft(), top, right, bottom, mPaint); + } else { + if (mDivider != null) { + mDivider.setBounds(child.getLeft(), top, right, bottom); + mDivider.draw(canvas); + } } if (column < mSpanCount) { - if (mPaint != null) { - mDivider.setBounds(left, child.getTop(), right, bottom); - mDivider.draw(canvas); - } if (mPaint != null) { canvas.drawRect(left, child.getTop(), right, bottom, mPaint); + } else { + if (mDivider != null) { + mDivider.setBounds(left, child.getTop(), right, bottom); + mDivider.draw(canvas); + } } } @@ -136,7 +151,6 @@ public void onDraw(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNul public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); int position = parent.getChildLayoutPosition(view); - RecyclerView.Adapter adapter = parent.getAdapter(); if (adapter != null) { int itemCount = parent.getAdapter().getItemCount(); diff --git a/xui_lib/src/main/java/com/xuexiang/xui/utils/DensityUtils.java b/xui_lib/src/main/java/com/xuexiang/xui/utils/DensityUtils.java index 45b966b8..4a68aef8 100755 --- a/xui_lib/src/main/java/com/xuexiang/xui/utils/DensityUtils.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/utils/DensityUtils.java @@ -192,6 +192,30 @@ public static Point getDisplaySize(Context context, boolean isReal) { return point; } + /** + * 获取上下文所在的宽度 + * + * @param context 上下文 + * @param isReal 是否是真实的尺寸 + * @return 上下文所在的宽度 + */ + public static int getDisplayWidth(Context context, boolean isReal) { + Point point = getDisplaySize(context, isReal); + return point != null ? point.x : 0; + } + + /** + * 获取上下文所在的高度 + * + * @param context 上下文 + * @param isReal 是否是真实的尺寸 + * @return 上下文所在的高度 + */ + public static int getDisplayHeight(Context context, boolean isReal) { + Point point = getDisplaySize(context, isReal); + return point != null ? point.y : 0; + } + /** * 获取应用窗口的度量信息 * diff --git a/xui_lib/src/main/java/com/xuexiang/xui/utils/ShortcutUtils.java b/xui_lib/src/main/java/com/xuexiang/xui/utils/ShortcutUtils.java new file mode 100644 index 00000000..a28821cb --- /dev/null +++ b/xui_lib/src/main/java/com/xuexiang/xui/utils/ShortcutUtils.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com) + * + * 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. + * + */ + +package com.xuexiang.xui.utils; + +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Build; + +import androidx.annotation.AnyRes; +import androidx.annotation.NonNull; +import androidx.core.content.pm.ShortcutInfoCompat; +import androidx.core.content.pm.ShortcutManagerCompat; +import androidx.core.graphics.drawable.IconCompat; + +/** + * Shortcut应用快捷方式创建工具类 + * + * @author xuexiang + * @since 2021/10/6 2:50 PM + */ +public final class ShortcutUtils { + + private static final String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; + + private ShortcutUtils() { + throw new UnsupportedOperationException("u can't instantiate me..."); + } + + /** + * 增加桌面快捷方式 + * + * @param context 上下文 + * @param targetClass 快捷方式跳转的目标页面 + * @param shortcutId 快捷方式id + * @param iconResourceId 快捷方式的图标 + * @param shortLabel 快捷方式的标题 + * @param resultReceiver 添加结果的接收器 + * @return 是否添加成功 + */ + public static boolean addPinShortcut(@NonNull Context context, @NonNull Class targetClass, @NonNull String shortcutId, @AnyRes int iconResourceId, @NonNull CharSequence shortLabel, Class resultReceiver) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + return addPinShortcutAboveN(context, targetClass, shortcutId, IconCompat.createWithResource(context, iconResourceId), shortLabel, resultReceiver); + } else { + return addShortcutBelowAndroidN(context, targetClass, iconResourceId, shortLabel); + } + } + + /** + * 增加桌面快捷方式 + * + * @param context 上下文 + * @param targetClass 快捷方式跳转的目标页面 + * @param shortcutId 快捷方式id + * @param icon 快捷方式的图标 + * @param shortLabel 快捷方式的标题 + * @param resultReceiver 添加结果的接收器 + * @return 是否添加成功 + */ + public static boolean addPinShortcutAboveN(@NonNull Context context, @NonNull Class targetClass, @NonNull String shortcutId, @NonNull IconCompat icon, @NonNull CharSequence shortLabel, Class resultReceiver) { + if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) { + Intent shortcutInfoIntent = new Intent(context, targetClass); + shortcutInfoIntent.setAction(Intent.ACTION_VIEW); + ShortcutInfoCompat info = new ShortcutInfoCompat.Builder(context, shortcutId) + .setIcon(icon) + .setShortLabel(shortLabel) + .setIntent(shortcutInfoIntent) + .build(); + // 当添加快捷方式的确认弹框弹出来时,将被回调 + Intent resultIntent = resultReceiver != null ? new Intent(context, resultReceiver) : ShortcutManagerCompat.createShortcutResultIntent(context, info); + PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); + return ShortcutManagerCompat.requestPinShortcut(context, info, shortcutCallbackIntent.getIntentSender()); + } + return false; + } + + + /** + * 增加桌面快捷方式 + * + * @param context 上下文 + * @param targetClass 快捷方式跳转的目标页面 + * @param shortLabel 快捷方式的标题 + * @param iconResourceId 快捷方式的图标 + * @return 是否添加成功 + */ + public static boolean addShortcutBelowAndroidN(@NonNull Context context, @NonNull Class targetClass, @AnyRes int iconResourceId, @NonNull CharSequence shortLabel) { + try { + Intent addShortcutIntent = new Intent(ACTION_ADD_SHORTCUT); + // 不允许重复创建,不是根据快捷方式的名字判断重复的 + addShortcutIntent.putExtra("duplicate", false); + // 快捷方式的图标 + addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, iconResourceId)); + // 快捷方式的名称 + addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortLabel); + // 设置关联程序 + Intent launcherIntent = new Intent(); + launcherIntent.setClass(context, targetClass); + addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launcherIntent); + // 发送广播 + context.sendBroadcast(addShortcutIntent); + return true; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + +} diff --git a/xui_lib/src/main/java/com/xuexiang/xui/utils/StatusBarUtils.java b/xui_lib/src/main/java/com/xuexiang/xui/utils/StatusBarUtils.java index 24a7fec0..3ad94a0b 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/utils/StatusBarUtils.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/utils/StatusBarUtils.java @@ -43,7 +43,7 @@ public class StatusBarUtils { public static float sVirtualDensityDpi = -1; private static int sStatusbarHeight = -1; private static @StatusBarType - int mStatuBarType = STATUSBAR_TYPE_DEFAULT; + int mStatusBarType = STATUSBAR_TYPE_DEFAULT; private static Integer sTransparentValue; public static void translucent(Activity activity) { @@ -207,19 +207,19 @@ public static boolean setStatusBarLightMode(Activity activity) { return false; } - if (mStatuBarType != STATUSBAR_TYPE_DEFAULT) { - return setStatusBarLightMode(activity, mStatuBarType); + if (mStatusBarType != STATUSBAR_TYPE_DEFAULT) { + return setStatusBarLightMode(activity, mStatusBarType); } if (Build.VERSION.SDK_INT >= KITKAT) { if (isMIUICustomStatusBarLightModeImpl() && MIUISetStatusBarLightMode(activity.getWindow(), true)) { - mStatuBarType = STATUSBAR_TYPE_MIUI; + mStatusBarType = STATUSBAR_TYPE_MIUI; return true; } else if (FlymeSetStatusBarLightMode(activity.getWindow(), true)) { - mStatuBarType = STATUSBAR_TYPE_FLYME; + mStatusBarType = STATUSBAR_TYPE_FLYME; return true; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Android6SetStatusBarLightMode(activity.getWindow(), true); - mStatuBarType = STATUSBAR_TYPE_ANDROID6; + mStatusBarType = STATUSBAR_TYPE_ANDROID6; return true; } } @@ -253,16 +253,16 @@ public static boolean setStatusBarDarkMode(Activity activity) { if (activity == null) { return false; } - if (mStatuBarType == STATUSBAR_TYPE_DEFAULT) { + if (mStatusBarType == STATUSBAR_TYPE_DEFAULT) { // 默认状态,不需要处理 return true; } - if (mStatuBarType == STATUSBAR_TYPE_MIUI) { + if (mStatusBarType == STATUSBAR_TYPE_MIUI) { return MIUISetStatusBarLightMode(activity.getWindow(), false); - } else if (mStatuBarType == STATUSBAR_TYPE_FLYME) { + } else if (mStatusBarType == STATUSBAR_TYPE_FLYME) { return FlymeSetStatusBarLightMode(activity.getWindow(), false); - } else if (mStatuBarType == STATUSBAR_TYPE_ANDROID6) { + } else if (mStatusBarType == STATUSBAR_TYPE_ANDROID6) { return Android6SetStatusBarLightMode(activity.getWindow(), false); } return true; @@ -450,57 +450,17 @@ public static boolean supportTransclentStatusBar6() { /** * 获取状态栏的高度。 + * + * @param context 上下文 + * @return 状态栏高度 */ public static int getStatusBarHeight(Context context) { if (sStatusbarHeight == -1) { - initStatusBarHeight(context); + sStatusbarHeight = Utils.getStatusBarHeight(context); } return sStatusbarHeight; } - private static void initStatusBarHeight(Context context) { - Class clazz; - Object obj = null; - Field field = null; - try { - clazz = Class.forName("com.android.internal.R$dimen"); - obj = clazz.newInstance(); - if (DeviceUtils.isMeizu()) { - try { - field = clazz.getField("status_bar_height_large"); - } catch (Throwable t) { - t.printStackTrace(); - } - } - if (field == null) { - field = clazz.getField("status_bar_height"); - } - } catch (Throwable t) { - t.printStackTrace(); - } - if (field != null && obj != null) { - try { - int id = Integer.parseInt(field.get(obj).toString()); - sStatusbarHeight = context.getResources().getDimensionPixelSize(id); - } catch (Throwable t) { - t.printStackTrace(); - } - } - if (DeviceUtils.isTablet(context) - && sStatusbarHeight > DensityUtils.dp2px(context, STATUS_BAR_DEFAULT_HEIGHT_DP)) { - //状态栏高度大于25dp的平板,状态栏通常在下方 - sStatusbarHeight = 0; - } else { - if (sStatusbarHeight <= 0) { - if (sVirtualDensity == -1) { - sStatusbarHeight = DensityUtils.dp2px(context, STATUS_BAR_DEFAULT_HEIGHT_DP); - } else { - sStatusbarHeight = (int) (STATUS_BAR_DEFAULT_HEIGHT_DP * sVirtualDensity + 0.5f); - } - } - } - } - public static void setVirtualDensity(float density) { sVirtualDensity = density; } @@ -607,7 +567,6 @@ public static void cancelFullScreen(Window window) { cancelFullScreen(window, -1, -1); } - /** * 设置底部导航条的颜色 * @@ -716,15 +675,17 @@ public void show(Window window) { * @param activity 活动窗口 * @param window 需要显示的窗口 * @param iWindowShower 窗口显示接口 + * @return 是否执行成功 */ - public static void showWindow(Activity activity, Window window, IWindowShower iWindowShower) { + public static boolean showWindow(Activity activity, Window window, IWindowShower iWindowShower) { if (activity == null || window == null || iWindowShower == null) { - return; + return false; } window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); iWindowShower.show(window); StatusBarUtils.syncSystemUiVisibility(activity, window); window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + return true; } /** @@ -732,12 +693,13 @@ public static void showWindow(Activity activity, Window window, IWindowShower iW * * @param original 活动窗口 * @param target 目标窗口 + * @return 是否执行成功 */ - public static void syncSystemUiVisibility(Activity original, Window target) { + public static boolean syncSystemUiVisibility(Activity original, Window target) { if (original == null) { - return; + return false; } - syncSystemUiVisibility(original.getWindow(), target); + return syncSystemUiVisibility(original.getWindow(), target); } /** @@ -745,12 +707,14 @@ public static void syncSystemUiVisibility(Activity original, Window target) { * * @param original 原始窗口 * @param target 目标窗口 + * @return 是否执行成功 */ - public static void syncSystemUiVisibility(Window original, Window target) { + public static boolean syncSystemUiVisibility(Window original, Window target) { if (original == null || target == null) { - return; + return false; } target.getDecorView().setSystemUiVisibility(original.getDecorView().getSystemUiVisibility()); + return true; } /** diff --git a/xui_lib/src/main/java/com/xuexiang/xui/utils/Utils.java b/xui_lib/src/main/java/com/xuexiang/xui/utils/Utils.java index 3fe908d5..763d7aa8 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/utils/Utils.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/utils/Utils.java @@ -80,6 +80,20 @@ public static int getScreenHeight(Context context) { private static final String STATUS_BAR_HEIGHT_RES_NAME = "status_bar_height"; + /** + * 计算状态栏高度 getStatusBarHeight + * + * @param context 上下文 + * @return 状态栏高度 + */ + public static int getStatusBarHeight(Context context) { + if (context == null) { + return getStatusBarHeight(); + } + return getInternalDimensionSize(context.getResources(), + STATUS_BAR_HEIGHT_RES_NAME); + } + /** * 计算状态栏高度 getStatusBarHeight * diff --git a/xui_lib/src/main/java/com/xuexiang/xui/utils/WidgetUtils.java b/xui_lib/src/main/java/com/xuexiang/xui/utils/WidgetUtils.java index 8d5d8673..466fbd73 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/utils/WidgetUtils.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/utils/WidgetUtils.java @@ -19,6 +19,7 @@ import android.app.Activity; import android.content.Context; +import android.content.ContextWrapper; import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; @@ -471,4 +472,21 @@ public static void clearAllViewBackground(View view) { view.setBackgroundColor(Color.TRANSPARENT); } + /** + * 根据上下文获取Activity + * + * @param context 上下文 + * @return Activity + */ + public static Activity findActivity(Context context) { + if (context instanceof Activity) { + return (Activity) context; + } + if (context instanceof ContextWrapper) { + ContextWrapper wrapper = (ContextWrapper) context; + return findActivity(wrapper.getBaseContext()); + } + return null; + } + } diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/actionbar/TitleBar.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/actionbar/TitleBar.java index 02310200..feca95ca 100755 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/actionbar/TitleBar.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/actionbar/TitleBar.java @@ -23,7 +23,6 @@ import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.Drawable; -import android.os.Build; import android.text.TextPaint; import android.text.TextUtils; import android.util.AttributeSet; @@ -250,8 +249,8 @@ public TitleBar setImmersive(boolean immersive) { /** * 设置状态栏高度 * - * @param height - * @return + * @param height 状态栏高度 + * @return this */ public TitleBar setHeight(int height) { mBarHeight = height; @@ -269,8 +268,8 @@ public TitleBar setLeftImageResource(int resId) { /** * 设置左侧图标 * - * @param leftImageDrawable - * @return + * @param leftImageDrawable 左侧图标 + * @return this */ public TitleBar setLeftImageDrawable(Drawable leftImageDrawable) { mLeftImageResource = leftImageDrawable; @@ -283,8 +282,8 @@ public TitleBar setLeftImageDrawable(Drawable leftImageDrawable) { /** * 设置左侧文字是否加粗 * - * @param isBold - * @return + * @param isBold 左侧文字是否加粗 + * @return this */ public TitleBar setLeftTextBold(boolean isBold) { if (mLeftText != null) { @@ -296,8 +295,8 @@ public TitleBar setLeftTextBold(boolean isBold) { /** * 设置中间文字是否加粗 * - * @param isBold - * @return + * @param isBold 中间文字是否加粗 + * @return this */ public TitleBar setCenterTextBold(boolean isBold) { if (mCenterText != null) { @@ -309,8 +308,8 @@ public TitleBar setCenterTextBold(boolean isBold) { /** * 设置左侧图标 * - * @param resId - * @return + * @param resId 左侧图标资源id + * @return this */ @Deprecated public TitleBar setBackImageResource(int resId) { @@ -328,8 +327,8 @@ public TitleBar setBackImageResource(int resId) { /** * 设置左侧点击事件 * - * @param l - * @return + * @param l 左侧点击事件 + * @return this */ public TitleBar setLeftClickListener(OnClickListener l) { mLeftText.setOnClickListener(l); @@ -339,8 +338,8 @@ public TitleBar setLeftClickListener(OnClickListener l) { /** * 设置左侧文字 * - * @param title - * @return + * @param title 左侧文字 + * @return this */ public TitleBar setLeftText(CharSequence title) { mLeftText.setText(title); @@ -350,8 +349,8 @@ public TitleBar setLeftText(CharSequence title) { /** * 设置左侧文字 * - * @param resId - * @return + * @param resId 左侧文字资源id + * @return this */ public TitleBar setLeftText(int resId) { mLeftText.setText(resId); @@ -361,8 +360,8 @@ public TitleBar setLeftText(int resId) { /** * 设置左侧文字大小 * - * @param size - * @return + * @param size 左侧文字大小【单位px】 + * @return this */ public TitleBar setLeftTextSize(float size) { mLeftText.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); @@ -372,8 +371,8 @@ public TitleBar setLeftTextSize(float size) { /** * 设置左侧文字的最大长度 * - * @param maxEms - * @return + * @param maxEms 左侧文字的最大长度 + * @return this */ public TitleBar setLeftTextMaxEms(int maxEms) { mLeftText.setMaxEms(maxEms); @@ -383,8 +382,8 @@ public TitleBar setLeftTextMaxEms(int maxEms) { /** * 设置左侧文字的最大宽度 * - * @param maxPixels - * @return + * @param maxPixels 左侧文字的最大宽度 + * @return this */ public TitleBar setLeftTextMaxWidth(int maxPixels) { mLeftText.setMaxWidth(maxPixels); @@ -394,8 +393,8 @@ public TitleBar setLeftTextMaxWidth(int maxPixels) { /** * 设置左侧文字长度超出的处理 * - * @param where - * @return + * @param where 左侧文字长度超出的处理 + * @return this */ public TitleBar setLeftTextEllipsize(TextUtils.TruncateAt where) { mLeftText.setEllipsize(where); @@ -403,11 +402,11 @@ public TitleBar setLeftTextEllipsize(TextUtils.TruncateAt where) { } /** - * 左侧文字的Padding + * 设置左侧文字的Padding * - * @param paddingStart - * @param paddingEnd - * @return + * @param paddingStart paddingStart + * @param paddingEnd paddingEnd + * @return this */ public TitleBar setLeftTextPadding(int paddingStart, int paddingEnd) { mLeftText.setPaddingRelative(paddingStart, 0, paddingEnd, 0); @@ -415,10 +414,10 @@ public TitleBar setLeftTextPadding(int paddingStart, int paddingEnd) { } /** - * 左侧文字的颜色 + * 设置左侧文字的颜色 * - * @param color - * @return + * @param color 左侧文字的颜色 + * @return this */ public TitleBar setLeftTextColor(int color) { mLeftText.setTextColor(color); @@ -428,8 +427,8 @@ public TitleBar setLeftTextColor(int color) { /** * 设置左侧文字是否可显示 * - * @param visible - * @return + * @param visible 左侧文字是否可显示 + * @return this */ public TitleBar setLeftVisible(boolean visible) { mLeftText.setVisibility(visible ? View.VISIBLE : View.GONE); @@ -439,7 +438,7 @@ public TitleBar setLeftVisible(boolean visible) { /** * 禁用左侧控件 * - * @return + * @return this */ public TitleBar disableLeftView() { setBackImageResource(0); @@ -450,10 +449,10 @@ public TitleBar disableLeftView() { /** - * 设置标题文字 + * 设置标题文字【"\n"为垂直方向,"\t"为水平方向】 * - * @param title - * @return + * @param title 标题文字 + * @return this */ public TitleBar setTitle(CharSequence title) { int index = title.toString().indexOf("\n"); @@ -477,7 +476,7 @@ public TitleBar setTitle(CharSequence title) { * @param title 标题 * @param subTitle 副标题 * @param orientation 对齐方式 - * @return + * @return this */ public TitleBar setTitle(CharSequence title, CharSequence subTitle, int orientation) { mCenterLayout.setOrientation(orientation); @@ -489,12 +488,28 @@ public TitleBar setTitle(CharSequence title, CharSequence subTitle, int orientat } /** - * 设置标题和副标题的文字 + * 设置副标题的文字 * * @param subTitle 副标题 - * @return + * @return this + */ + public TitleBar setSubTitle(CharSequence subTitle, int orientation) { + mCenterLayout.setOrientation(orientation); + mSubTitleText.setText(subTitle); + mSubTitleText.setVisibility(View.VISIBLE); + return this; + } + + /** + * 设置副标题的文字 + * + * @param subTitle 副标题 + * @return this */ public TitleBar setSubTitle(CharSequence subTitle) { + if (!TextUtils.isEmpty(subTitle)) { + mCenterLayout.setOrientation(LinearLayout.VERTICAL); + } mSubTitleText.setText(subTitle); mSubTitleText.setVisibility(View.VISIBLE); return this; @@ -503,8 +518,8 @@ public TitleBar setSubTitle(CharSequence subTitle) { /** * 设置中间内容的对齐方式 * - * @param gravity - * @return + * @param gravity 中间内容的对齐方式 + * @return this */ public TitleBar setCenterGravity(int gravity) { mCenterLayout.setGravity(gravity); @@ -516,19 +531,19 @@ public TitleBar setCenterGravity(int gravity) { /** * 设置中心点击 * - * @param l - * @return + * @param centerClickListener 中心点击监听 + * @return this */ - public TitleBar setCenterClickListener(OnClickListener l) { - mCenterLayout.setOnClickListener(l); + public TitleBar setCenterClickListener(OnClickListener centerClickListener) { + mCenterLayout.setOnClickListener(centerClickListener); return this; } /** * 设置标题文字 * - * @param resId - * @return + * @param resId 文字资源id + * @return this */ public TitleBar setTitle(int resId) { setTitle(getResources().getString(resId)); @@ -538,8 +553,8 @@ public TitleBar setTitle(int resId) { /** * 设置标题文字颜色 * - * @param resId - * @return + * @param resId 文字颜色资源id + * @return this */ public TitleBar setTitleColor(int resId) { mCenterText.setTextColor(resId); @@ -549,8 +564,8 @@ public TitleBar setTitleColor(int resId) { /** * 设置标题文字大小 * - * @param size - * @return + * @param size 文字大小【单位px】 + * @return this */ public TitleBar setTitleSize(float size) { mCenterText.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); @@ -560,8 +575,8 @@ public TitleBar setTitleSize(float size) { /** * 设置标题背景 * - * @param resId - * @return + * @param resId 标题背景资源id + * @return this */ public TitleBar setTitleBackground(int resId) { mCenterText.setBackgroundResource(resId); diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/banner/recycler/BannerLayout.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/banner/recycler/BannerLayout.java index 7d790990..117aebca 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/banner/recycler/BannerLayout.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/banner/recycler/BannerLayout.java @@ -78,7 +78,7 @@ public class BannerLayout extends FrameLayout { protected Handler mHandler = new Handler(new Handler.Callback() { @Override - public boolean handleMessage(Message msg) { + public boolean handleMessage(@NonNull Message msg) { if (msg.what == WHAT_AUTO_PLAY) { if (mCurrentIndex == mLayoutManager.getCurrentPosition()) { ++mCurrentIndex; diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/BaseDialog.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/BaseDialog.java index 906a01f5..999439e2 100755 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/BaseDialog.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/BaseDialog.java @@ -30,17 +30,26 @@ import com.xuexiang.xui.R; import com.xuexiang.xui.utils.KeyboardUtils; import com.xuexiang.xui.utils.ResUtils; +import com.xuexiang.xui.utils.StatusBarUtils; +import com.xuexiang.xui.utils.WidgetUtils; /** * 基类Dialog - * 触摸Dialog屏幕以外的区域,dialog消失同时隐藏键盘 + * 1.触摸Dialog屏幕以外的区域,dialog消失同时隐藏键盘 + * 2.可以同步系统控制器显示状态 * * @author xuexiang * @since 2018/12/6 下午3:29 */ public class BaseDialog extends AppCompatDialog { + private View mContentView; + /** + * 是否同步系统控制器显示状态,默认false【状态栏、三键导航栏等】 + */ + private boolean mIsSyncSystemUiVisibility; + public BaseDialog(Context context, int layoutId) { this(context, R.style.XUIDialog_Custom, layoutId); } @@ -78,8 +87,8 @@ private void init(View view) { /** * 设置弹窗的宽和高 * - * @param width - * @param height + * @param width 宽 + * @param height 高 */ public BaseDialog setDialogSize(int width, int height) { // 获取对话框当前的参数值 @@ -106,6 +115,53 @@ public Drawable getDrawable(int resId) { return ResUtils.getDrawable(getContext(), resId); } + /** + * 设置是否同步系统控制器显示状态 + * + * @param isSyncSystemUiVisibility 是否同步系统控制器显示状态 + * @return this + */ + public BaseDialog setIsSyncSystemUiVisibility(boolean isSyncSystemUiVisibility) { + mIsSyncSystemUiVisibility = isSyncSystemUiVisibility; + return this; + } + + /** + * 显示加载 + */ + @Override + public void show() { + showIfSync(mIsSyncSystemUiVisibility); + } + + /** + * 显示弹窗,是否同步系统控制器显示状态 + * + * @param isSyncSystemUiVisibility 是否同步系统控制器显示状态 + */ + public void showIfSync(boolean isSyncSystemUiVisibility) { + if (isSyncSystemUiVisibility) { + boolean isHandled = StatusBarUtils.showWindow(WidgetUtils.findActivity(getContext()), getWindow(), new StatusBarUtils.IWindowShower() { + @Override + public void show(Window window) { + performShow(); + } + }); + if (!isHandled) { + performShow(); + } + } else { + performShow(); + } + } + + /** + * 真正执行显示的方法 + */ + protected void performShow() { + super.show(); + } + @Override public boolean onTouchEvent(@NonNull MotionEvent ev) { KeyboardUtils.dispatchTouchEvent(ev, this); diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/LoadingDialog.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/LoadingDialog.java index 22725942..023da982 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/LoadingDialog.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/LoadingDialog.java @@ -154,8 +154,8 @@ public LoadingDialog setLoadingSpeed(int speed) { } @Override - public void show() { - super.show(); + public void performShow() { + super.performShow(); if (mLoadingView != null) { mLoadingView.start(); } diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/MiniLoadingDialog.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/MiniLoadingDialog.java index 4620f624..8f128aff 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/MiniLoadingDialog.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/dialog/MiniLoadingDialog.java @@ -2,13 +2,12 @@ import android.content.Context; import android.content.DialogInterface; - -import androidx.annotation.StyleRes; - import android.text.TextUtils; import android.view.View; import android.widget.TextView; +import androidx.annotation.StyleRes; + import com.xuexiang.xui.R; import com.xuexiang.xui.widget.progress.loading.IMessageLoader; import com.xuexiang.xui.widget.progress.loading.LoadingCancelListener; @@ -59,11 +58,11 @@ private void initView(String tipMessage) { } + /** * 更新提示信息 * - * @param tipMessage - * @return + * @param tipMessage 提示信息 */ @Override public void updateMessage(String tipMessage) { @@ -81,21 +80,16 @@ public void updateMessage(String tipMessage) { /** * 更新提示信息 * - * @param tipMessageId - * @return + * @param tipMessageId 提示信息的id */ @Override public void updateMessage(int tipMessageId) { updateMessage(getString(tipMessageId)); } - - /** - * 显示加载 - */ @Override - public void show() { - super.show(); + protected void performShow() { + super.performShow(); if (mLoadingView != null) { mLoadingView.start(); } diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/edittext/verify/VerifyCodeEditText.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/edittext/verify/VerifyCodeEditText.java index daf51ed0..3e06cb94 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/edittext/verify/VerifyCodeEditText.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/edittext/verify/VerifyCodeEditText.java @@ -1,6 +1,7 @@ package com.xuexiang.xui.widget.edittext.verify; import android.content.Context; +import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.drawable.Drawable; @@ -14,12 +15,14 @@ import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.TextView; import com.xuexiang.xui.R; +import com.xuexiang.xui.utils.DensityUtils; import com.xuexiang.xui.utils.ResUtils; /** @@ -28,11 +31,14 @@ * @author XUE * @since 2019/5/7 11:22 */ -public class VerifyCodeEditText extends RelativeLayout { +public class VerifyCodeEditText extends FrameLayout { + + private static final int DEFAULT_HEIGHT = 50; + + private static final int DEFAULT_EDIT_TEXT_SIZE = 4; private LinearLayout mLlContainer; private PwdEditText mEditText; - /** * 输入框数量 */ @@ -41,6 +47,10 @@ public class VerifyCodeEditText extends RelativeLayout { * 输入框的宽度 */ private int mEtWidth; + /** + * 是否等分输入框 + */ + private boolean mIsDivideEqually; /** * 输入框分割线 */ @@ -102,13 +112,14 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr) { mEditText = findViewById(R.id.et_input); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.VerifyCodeEditText, defStyleAttr, 0); - mEtNumber = typedArray.getInteger(R.styleable.VerifyCodeEditText_vcet_number, 4); + mEtNumber = typedArray.getInteger(R.styleable.VerifyCodeEditText_vcet_number, DEFAULT_EDIT_TEXT_SIZE); mEtWidth = typedArray.getDimensionPixelSize(R.styleable.VerifyCodeEditText_vcet_width, ResUtils.getDimensionPixelSize(R.dimen.default_vcet_width)); - mEtDivider = ResUtils.getDrawableAttrRes(getContext(), typedArray, R.styleable.VerifyCodeEditText_vcet_divider); + mIsDivideEqually = typedArray.getBoolean(R.styleable.VerifyCodeEditText_vcet_is_divide_equally, false); + mEtDivider = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.VerifyCodeEditText_vcet_divider); mEtTextSize = typedArray.getDimensionPixelSize(R.styleable.VerifyCodeEditText_vcet_text_size, ResUtils.getDimensionPixelSize(R.dimen.default_vcet_text_size)); mEtTextColor = typedArray.getColor(R.styleable.VerifyCodeEditText_vcet_text_color, Color.BLACK); - mBackgroundFocus = ResUtils.getDrawableAttrRes(getContext(), typedArray, R.styleable.VerifyCodeEditText_vcet_bg_focus); - mBackgroundNormal = ResUtils.getDrawableAttrRes(getContext(), typedArray, R.styleable.VerifyCodeEditText_vcet_bg_normal); + mBackgroundFocus = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.VerifyCodeEditText_vcet_bg_focus); + mBackgroundNormal = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.VerifyCodeEditText_vcet_bg_normal); mIsPwd = typedArray.getBoolean(R.styleable.VerifyCodeEditText_vcet_is_pwd, false); mPwdRadius = typedArray.getDimensionPixelSize(R.styleable.VerifyCodeEditText_vcet_pwd_radius, ResUtils.getDimensionPixelSize(R.dimen.default_vcet_pwd_radius)); //释放资源 @@ -116,33 +127,83 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr) { // 当xml中未配置时 这里进行初始配置默认图片 if (mEtDivider == null) { - mEtDivider = ResUtils.getDrawable(getContext(), R.drawable.vcet_shape_divider); + mEtDivider = ResUtils.getDrawable(context, R.drawable.vcet_shape_divider); } if (mBackgroundFocus == null) { - mBackgroundFocus = ResUtils.getDrawable(getContext(), R.drawable.vcet_shape_bg_focus); + mBackgroundFocus = ResUtils.getDrawable(context, R.drawable.vcet_shape_bg_focus); } if (mBackgroundNormal == null) { - mBackgroundNormal = ResUtils.getDrawable(getContext(), R.drawable.vcet_shape_bg_normal); + mBackgroundNormal = ResUtils.getDrawable(context, R.drawable.vcet_shape_bg_normal); } + // 平分每个输入框的宽度 + if (mIsDivideEqually) { + post(new Runnable() { + @Override + public void run() { + refreshEditSizeWhenDivideEqually(); + initView(getContext()); + } + }); + } else { + initView(context); + } + } + + private void refreshEditSizeWhenDivideEqually() { + MarginLayoutParams params = (MarginLayoutParams) getLayoutParams(); + int dividerWidth = mEtDivider != null ? mEtDivider.getMinimumWidth() : 0; + mEtWidth = (DensityUtils.getDisplayWidth(getContext(), true) - dividerWidth * (mEtNumber - 1) - getPaddingLeft() - getPaddingRight() - params.leftMargin - params.rightMargin) / mEtNumber; + } - initUI(); + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + if (mIsDivideEqually) { + String input = getInputValue(); + mEditText.removeTextChangedListener(mTextWatcher); + mLlContainer.removeAllViews(); + refreshEditSizeWhenDivideEqually(); + restoreView(getContext(), input); + } } - // 初始UI - private void initUI() { - initTextViews(getContext(), mEtNumber, mEtWidth, mEtDivider, mEtTextSize, mEtTextColor); + private void restoreView(Context context, String input) { + initTextViews(context, mEtNumber, mEtWidth, mEtDivider, mEtTextSize, mEtTextColor); + initEtContainer(mPwdTextViews); + if (!TextUtils.isEmpty(input)) { + String[] strArray = input.split(""); + for (int i = 0; i < strArray.length; i++) { + // 不能大于输入框个数 + if (i > mEtNumber) { + break; + } + setText(strArray[i], true); + } + } + setListener(); + } + + /** + * 初始化控件 + * + * @param context 上下文 + */ + private void initView(Context context) { + initTextViews(context, mEtNumber, mEtWidth, mEtDivider, mEtTextSize, mEtTextColor); initEtContainer(mPwdTextViews); setListener(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - // 设置当 高为 warpContent 模式时的默认值 为 50dp int heightMeasureSpecValue = heightMeasureSpec; - int heightMode = MeasureSpec.getMode(heightMeasureSpecValue); if (heightMode == MeasureSpec.AT_MOST) { - heightMeasureSpecValue = MeasureSpec.makeMeasureSpec((int) dp2px(50, getContext()), MeasureSpec.EXACTLY); + // 设置当高为 warpContent 模式时的最小高度是50dp + int minHeight = (int) dp2px(DEFAULT_HEIGHT, getContext()); + if (mEtWidth < minHeight) { + heightMeasureSpecValue = MeasureSpec.makeMeasureSpec(minHeight, MeasureSpec.EXACTLY); + } } super.onMeasure(widthMeasureSpec, heightMeasureSpecValue); } @@ -170,12 +231,13 @@ private void initTextViews(Context context, int etNumber, int etWidth, Drawable mLlContainer.setDividerDrawable(etDividerDrawable); } mPwdTextViews = new PwdTextView[etNumber]; - for (int i = 0; i < mPwdTextViews.length; i++) { PwdTextView textView = new PwdTextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, etTextSize); textView.setTextColor(etTextColor); - textView.setWidth(etWidth); + if (!mIsDivideEqually) { + textView.setWidth(etWidth); + } textView.setHeight(etWidth); if (i == 0) { textView.setBackgroundDrawable(mBackgroundFocus); @@ -191,11 +253,27 @@ private void initTextViews(Context context, int etNumber, int etWidth, Drawable /** * 初始化存储TextView 的容器 * - * @param mTextViews + * @param textViews 输入文字 */ - private void initEtContainer(TextView[] mTextViews) { - for (TextView mTextView : mTextViews) { - mLlContainer.addView(mTextView); + private void initEtContainer(TextView[] textViews) { + if (mIsDivideEqually) { + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mLlContainer.getLayoutParams(); + if (layoutParams == null) { + layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + layoutParams.gravity = Gravity.CENTER; + } else { + layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; + } + mLlContainer.setLayoutParams(layoutParams); + LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT); + childParams.weight = 1; + for (TextView textView : textViews) { + mLlContainer.addView(textView, childParams); + } + } else { + for (TextView textView : textViews) { + mLlContainer.addView(textView); + } } } @@ -222,8 +300,13 @@ public boolean onBackspace() { }); } - // 给TextView 设置文字 - private void setText(String inputContent) { + /** + * 设置输入 + * + * @param inputContent 输入内容 + * @param isSilent 是否静默输入 + */ + private void setText(String inputContent, boolean isSilent) { if (TextUtils.isEmpty(inputContent)) { return; } @@ -237,11 +320,11 @@ private void setText(String inputContent) { tv.setBackgroundDrawable(mBackgroundNormal); if (i < mEtNumber - 1) { mPwdTextViews[i + 1].setBackgroundDrawable(mBackgroundFocus); - if (mOnInputListener != null) { + if (mOnInputListener != null && !isSilent) { mOnInputListener.onChange(getInputValue()); } } else if (i == mEtNumber - 1) { - if (mOnInputListener != null) { + if (mOnInputListener != null && !isSilent) { mOnInputListener.onComplete(getInputValue()); } } @@ -318,13 +401,16 @@ public void clearInputValue() { /** * 设置输入框个数 * - * @param etNumber + * @param etNumber 输入框个数 */ public void setEtNumber(int etNumber) { mEtNumber = etNumber; mEditText.removeTextChangedListener(mTextWatcher); mLlContainer.removeAllViews(); - initUI(); + if (mIsDivideEqually) { + refreshEditSizeWhenDivideEqually(); + } + initView(getContext()); } /** @@ -338,9 +424,9 @@ public int getEtNumber() { /** - * 设置是否是密码模式 默认不是 + * 设置是否是密码模式 默认false * - * @param isPwdMode + * @param isPwdMode 是否是密码模式 */ public void setPwdMode(boolean isPwdMode) { this.mIsPwd = isPwdMode; @@ -356,7 +442,9 @@ public EditText getEditText() { return mEditText; } - // 输入完成 和 删除成功 的监听 + /** + * 输入完成 和 删除成功 的监听 + */ private OnInputListener mOnInputListener; public void setOnInputListener(OnInputListener onInputListener) { @@ -370,13 +458,15 @@ public void setOnInputListener(OnInputListener onInputListener) { public interface OnInputListener { /** * 输入完成 + * + * @param input 输入内容 */ void onComplete(String input); /** * 输入变化 * - * @param input + * @param input 变化内容 */ void onChange(String input); @@ -423,7 +513,7 @@ public void afterTextChanged(Editable editable) { if (i > mEtNumber) { break; } - setText(strArray[i]); + setText(strArray[i], false); mEditText.setText(""); } } diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/picker/widget/TimePickerView.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/picker/widget/TimePickerView.java index 91001158..0dd8d9f9 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/picker/widget/TimePickerView.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/picker/widget/TimePickerView.java @@ -40,7 +40,10 @@ */ public class TimePickerView extends BasePickerView implements View.OnClickListener { - private WheelTime wheelTime; //自定义控件 + /** + * 自定义时间选择控件 + */ + private WheelTime wheelTime; private static final String TAG_SUBMIT = "submit"; private static final String TAG_CANCEL = "cancel"; @@ -301,6 +304,14 @@ public boolean isLunarCalendar() { return wheelTime.isLunarMode(); } + /** + * 获取时间选择控件 + * + * @return 时间选择控件 + */ + public WheelTime getWheelTime() { + return wheelTime; + } @Override public boolean isDialog() { diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBack.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBack.java index fd95332a..050f13dd 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBack.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBack.java @@ -74,11 +74,49 @@ public static void unregister(Activity activity) { /** * 构建侧滑管理器 - 用于更丰富的自定义配置 * - * @param activity 目标Act + * @param activity 目标Activity * @return 构建管理器 */ public static SlideBackManager with(Activity activity) { - SlideBackManager manager = new SlideBackManager(activity); + SlideBackManager manager = new SlideBackManager(activity, false); + sSideMap.put(activity, manager); + return manager; + } + + /** + * 构建侧滑管理器 - 用于更丰富的自定义配置【固定侧滑图标的尺寸】 + * + * @param activity 目标Activity + * @return 构建管理器 + */ + public static SlideBackManager withFixSize(Activity activity) { + SlideBackManager manager = new SlideBackManager(activity, true); + sSideMap.put(activity, manager); + return manager; + } + + /** + * 构建侧滑管理器 - 用于更丰富的自定义配置 + * + * @param activity 目标Activity + * @param isFixedSize 是否固定尺寸 + * @return 构建管理器 + */ + public static SlideBackManager with(Activity activity, boolean isFixedSize) { + SlideBackManager manager = new SlideBackManager(activity, isFixedSize); + sSideMap.put(activity, manager); + return manager; + } + + /** + * 构建侧滑管理器 - 用于更丰富的自定义配置 + * + * @param activity 目标Activity + * @param slideInfo 侧滑信息 + * @return 构建管理器 + */ + public static SlideBackManager with(Activity activity, SlideInfo slideInfo) { + SlideBackManager manager = new SlideBackManager(activity, slideInfo); sSideMap.put(activity, manager); return manager; } diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBackManager.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBackManager.java index 6bcaa29c..1bb8e441 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBackManager.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/SlideBackManager.java @@ -57,28 +57,33 @@ public class SlideBackManager implements OnSlideUpdateListener { */ private SlideInfo mSlideInfo; - SlideBackManager(Activity activity) { + SlideBackManager(Activity activity, boolean isFixedSize) { mActivity = activity; mHaveScroll = false; // 获取屏幕信息,初始化控件设置 DisplayMetrics dm = activity.getResources().getDisplayMetrics(); - mSlideInfo = new SlideInfo() - // 高度默认 屏高/4 - .setBackViewHeight(dm.heightPixels / 4f) - // 箭头大小默认 5dp .setArrowSize(dp2px(5)) .setScreenWidth(dm.widthPixels) - // 最大宽度默认 屏宽/12 - .setMaxSlideLength((float) dm.widthPixels / 12) - // 侧滑响应距离默认 控件最大宽度/2 - .setSideSlideLength((float) dm.widthPixels / 24) - // 阻尼系数默认 3 .setDragRate(3) - // 侧滑返回模式 默认:左 .setAllowEdgeLeft(true) .setAllowEdgeRight(false); + if (isFixedSize) { + mSlideInfo.setBackViewHeight(dm.heightPixels / 5f) + .setMaxSlideLength(dp2px(24)) + .setSideSlideLength(dp2px(12)); + } else { + mSlideInfo.setBackViewHeight(dm.heightPixels / 4f) + .setMaxSlideLength((float) dm.widthPixels / 12) + .setSideSlideLength((float) dm.widthPixels / 24); + } + } + + SlideBackManager(Activity activity, SlideInfo slideInfo) { + mActivity = activity; + mHaveScroll = false; + mSlideInfo = slideInfo; } /** @@ -110,6 +115,17 @@ public SlideBackManager callBack(SlideCallBack callBack) { return this; } + /** + * 设置侧滑信息 + * + * @param slideInfo 侧滑信息 + * @return this + */ + public SlideBackManager setSlideInfo(SlideInfo slideInfo) { + mSlideInfo = slideInfo; + return this; + } + /** * 控件高度 默认屏高/4 */ diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/widget/SlideBackInterceptLayout.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/widget/SlideBackInterceptLayout.java index f2e9ca9f..3da7c5a8 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/widget/SlideBackInterceptLayout.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/slideback/widget/SlideBackInterceptLayout.java @@ -30,7 +30,10 @@ */ public class SlideBackInterceptLayout extends FrameLayout { - private float mSideSlideLength = 0; // 边缘滑动响应距离 + /** + * 边缘滑动响应距离 + */ + private float mSideSlideLength = 0; public SlideBackInterceptLayout(Context context) { this(context, null); diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/spinner/DropDownMenu.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/spinner/DropDownMenu.java index 7d7b06e1..5b6942db 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/spinner/DropDownMenu.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/spinner/DropDownMenu.java @@ -249,7 +249,7 @@ public void onClick(View v) { } mPopupMenuViews = new FrameLayout(getContext()); - mPopupMenuViews.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (DensityUtils.getDisplaySize(getContext(), true).y * mMenuHeightPercent))); + mPopupMenuViews.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (DensityUtils.getDisplayHeight(getContext(), true) * mMenuHeightPercent))); mPopupMenuViews.setVisibility(GONE); mContainerView.addView(mPopupMenuViews, 2); diff --git a/xui_lib/src/main/java/com/xuexiang/xui/widget/tabbar/EasyIndicator.java b/xui_lib/src/main/java/com/xuexiang/xui/widget/tabbar/EasyIndicator.java index 7911dde5..fb8527f0 100644 --- a/xui_lib/src/main/java/com/xuexiang/xui/widget/tabbar/EasyIndicator.java +++ b/xui_lib/src/main/java/com/xuexiang/xui/widget/tabbar/EasyIndicator.java @@ -156,33 +156,36 @@ public EasyIndicator(Context context, AttributeSet attrs, int defStyleAttr) { */ private void init(Context context, AttributeSet attrs, int defStyleAttr) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.EasyIndicator, defStyleAttr, 0); - if (typedArray != null) { - indicatorWidth = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_width, indicatorWidth); - indicatorHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_height, indicatorHeight); - indicatorLineShow = typedArray.getBoolean(R.styleable.EasyIndicator_indicator_line_show, indicatorLineShow); - indicatorLineWidth = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_line_width, indicatorLineWidth); - indicatorLineHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_line_height, indicatorLineHeight); - indicatorLineColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_line_color, ThemeUtils.getMainThemeColor(getContext())); - indicatorLineDrawable = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.EasyIndicator_indicator_line_res); - indicatorBottomLineHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_bottom_line_height, indicatorBottomLineHeight); - indicatorBottomLineColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_bottom_line_color, ThemeUtils.resolveColor(getContext(), R.attr.xui_config_color_separator_dark)); - indicatorSelectedColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_selected_color, ThemeUtils.getMainThemeColor(getContext())); - indicatorNormalColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_normal_color, ResUtils.getColor(R.color.xui_config_color_black)); - indicatorTextSize = getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_textSize, (int) indicatorTextSize); - indicatorVerticalLineWidth = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_vertical_line_w, indicatorVerticalLineWidth); - indicatorVerticalLineColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_vertical_line_color, ThemeUtils.resolveColor(getContext(), R.attr.xui_config_color_separator_dark)); - indicatorVerticalLineHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_vertical_line_h, indicatorVerticalLineHeight); - indicatorSelectTextSize = getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_select_textSize, 14); - // 指引器不能超过屏幕的宽度 - indicatorWidth = Math.min(indicatorWidth, screenWidth); - if (indicatorWidth == 0) { - indicatorWidth = LayoutParams.MATCH_PARENT; - } - typedArray.recycle(); + indicatorWidth = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_width, indicatorWidth); + indicatorHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_height, indicatorHeight); + Drawable indicatorBgDrawable = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.EasyIndicator_indicator_background); + indicatorLineShow = typedArray.getBoolean(R.styleable.EasyIndicator_indicator_line_show, indicatorLineShow); + indicatorLineWidth = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_line_width, indicatorLineWidth); + indicatorLineHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_line_height, indicatorLineHeight); + indicatorLineColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_line_color, ThemeUtils.getMainThemeColor(getContext())); + indicatorLineDrawable = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.EasyIndicator_indicator_line_res); + indicatorBottomLineHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_bottom_line_height, indicatorBottomLineHeight); + indicatorBottomLineColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_bottom_line_color, ThemeUtils.resolveColor(getContext(), R.attr.xui_config_color_separator_dark)); + indicatorSelectedColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_selected_color, ThemeUtils.getMainThemeColor(getContext())); + indicatorNormalColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_normal_color, ResUtils.getColor(R.color.xui_config_color_black)); + indicatorTextSize = getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_textSize, (int) indicatorTextSize); + indicatorVerticalLineWidth = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_vertical_line_w, indicatorVerticalLineWidth); + indicatorVerticalLineColor = typedArray.getColor(R.styleable.EasyIndicator_indicator_vertical_line_color, ThemeUtils.resolveColor(getContext(), R.attr.xui_config_color_separator_dark)); + indicatorVerticalLineHeight = (int) getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_vertical_line_h, indicatorVerticalLineHeight); + indicatorSelectTextSize = getDimensionPixelSize(typedArray, R.styleable.EasyIndicator_indicator_select_textSize, 14); + typedArray.recycle(); + // 指引器不能超过屏幕的宽度 + indicatorWidth = Math.min(indicatorWidth, screenWidth); + if (indicatorWidth == 0) { + indicatorWidth = LayoutParams.MATCH_PARENT; } tabContent = new LinearLayout(getContext()); LayoutParams params = new LayoutParams(indicatorWidth, LayoutParams.WRAP_CONTENT); - tabContent.setBackgroundColor(Color.WHITE); + if (indicatorBgDrawable != null) { + tabContent.setBackground(indicatorBgDrawable); + } else { + tabContent.setBackgroundColor(Color.WHITE); + } params.gravity = Gravity.CENTER; tabContent.setLayoutParams(params); tabContent.setGravity(Gravity.CENTER); @@ -424,7 +427,9 @@ private void initScreenWidth() { DisplayMetrics dm = getResources().getDisplayMetrics(); screenHeight = dm.heightPixels; screenWidth = dm.widthPixels; - } + public LinearLayout getTabContent() { + return tabContent; + } } \ No newline at end of file diff --git a/xui_lib/src/main/res/layout/xui_layout_verify_code.xml b/xui_lib/src/main/res/layout/xui_layout_verify_code.xml index 2eb6bfb0..fdd9e0f5 100644 --- a/xui_lib/src/main/res/layout/xui_layout_verify_code.xml +++ b/xui_lib/src/main/res/layout/xui_layout_verify_code.xml @@ -1,5 +1,5 @@ - @@ -7,7 +7,7 @@ android:id="@+id/ll_container" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_centerInParent="true" + android:layout_gravity="center" android:gravity="start|center_vertical" android:orientation="horizontal" android:showDividers="beginning|middle|end"> @@ -21,4 +21,4 @@ android:background="@color/xui_config_color_transparent" android:inputType="number" /> - \ No newline at end of file + \ No newline at end of file diff --git a/xui_lib/src/main/res/layout/xui_layout_xtoast.xml b/xui_lib/src/main/res/layout/xui_layout_xtoast.xml index a8f896ce..dd36c65c 100644 --- a/xui_lib/src/main/res/layout/xui_layout_xtoast.xml +++ b/xui_lib/src/main/res/layout/xui_layout_xtoast.xml @@ -9,7 +9,7 @@ android:orientation="horizontal" tools:ignore="UseCompoundDrawables"> - + + @@ -1284,6 +1286,8 @@ + +