├── .gitignore ├── README-cn.md ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── code19 │ │ └── androidcommon │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── code19 │ │ │ └── androidcommon │ │ │ ├── HandlerActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── model │ │ │ ├── AppBean.java │ │ │ ├── AppBiz.java │ │ │ └── IAppBiz.java │ │ │ ├── presenter │ │ │ └── AppPresenter.java │ │ │ ├── ui │ │ │ ├── activity │ │ │ │ ├── AppManagerActivity.java │ │ │ │ ├── DeviceActivity.java │ │ │ │ └── VerificationActivity.java │ │ │ └── adapter │ │ │ │ └── AppRecyAdapter.java │ │ │ └── view │ │ │ └── IAppView.java │ └── res │ │ ├── layout │ │ ├── activity_app_manager.xml │ │ ├── activity_device.xml │ │ ├── activity_main.xml │ │ ├── activity_virification.xml │ │ └── app_recy.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── code19 │ └── androidcommon │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── code19 │ │ └── library │ │ ├── AppUtils.java │ │ ├── CipherUtils.java │ │ ├── CoordinateTransformUtil.java │ │ ├── DateUtils.java │ │ ├── DensityUtil.java │ │ ├── DeviceUtils.java │ │ ├── FileUtils.java │ │ ├── JsonUtils.java │ │ ├── L.java │ │ ├── NetUtils.java │ │ ├── RadixUtils.java │ │ ├── SPUtils.java │ │ ├── StringUtils.java │ │ ├── SystemUtils.java │ │ └── VerificationUtils.java │ └── res │ ├── drawable │ └── divider.xml │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | /build 7 | /captures 8 | /.idea 9 | /library/src/test 10 | /library/src/androidTest 11 | /*.properties 12 | -------------------------------------------------------------------------------- /README-cn.md: -------------------------------------------------------------------------------- 1 | # gradle使用方式 2 | ```gradle 3 | compile 'com.code19.library:library:0.1.4' 4 | ``` 5 | # 常用工具类 6 | - 常用代码片段收集 Issues 7 | - 如果你有更好的代码,请提交Pull request 8 | 9 | ``` 10 | 使用示例: 11 | AppUtils.getAppName(MainActivity.this,com.code19.androidcommon); 12 | ``` 13 | 14 | ## library Module中的类: 15 | 16 | - AppUtils.java 应用工具类 17 | * getAppName 获取应用名称 18 | * getAppIcon 获取应用图标 19 | * getAppFirstInstallTime 获取应用第一次安装日期 20 | * getAppLastUpdateTime 获取应用更新日期 21 | * getAppSize 获取应用大小 22 | * getAppApk 获取应用apk文件 23 | * getAppVersionName 获取应用版本名称 24 | * getAppVersionCode 获取应用版本号 25 | * getAppInstaller 获取应用的安装市场 26 | * getAppSign 获取应用签名 27 | * getAppTargetSdkVersion 获取应用兼容sdk 28 | * getAppUid 获取应用uid 29 | * getNumCores 获取Cpu内核数 30 | * getRootPermission 获得root权限 31 | * getAppPermissions 获取应用的所有权限 32 | * hasPermission 是否有权限 33 | * isInstalled 应用是否安装 34 | * ~~installApk 安装应用~~ 35 | * ~~uninstallApk 卸载应用~~ 36 | * isSystemApp 是否是系统应用 37 | * isServiceRunning 服务是否在运行 38 | * stopRunningService 停止服务 39 | * killProcesses 结束进程 40 | * runScript 运行脚本 41 | * runApp 启动应用 42 | * cleanCache 清除应用内部缓存 43 | * cleanDatabases 清除应用内部数据库 44 | * cleanSharedPreference 清除应用内部SP 45 | 46 | - CacheUtils.java 缓存工具类 47 | * setCache 设置缓存 48 | * getCache 获取缓存 49 | 50 | - CipherUtils.java 密码工具类 51 | * md5(String input) 字符串md5 52 | * md5L(String input) 字符串md5,返回小写密文 53 | * md5(InputStream in) 输入流md5 54 | * base64Encode Base64加密 55 | * base64Decode Base64解密 56 | * XorEncode 异或加密 57 | * XorDecode 异或解密 58 | * sha1 字符串sha1值 59 | * sha1 文件hash校验 60 | 61 | - CoordinateTransformUtil.java GPS坐标转换工具 62 | * 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换的工具 63 | * bd09towgs84 百度坐标系(BD-09)转WGS坐标(百度坐标纬度,百度坐标经度),WGS84坐标数组 64 | * wgs84tobd09 WGS坐标转百度坐标系(BD-09)(WGS84坐标系的经度,WGS84坐标系的纬度),百度坐标数组 65 | * gcj02tobd09 火星坐标系(GCJ-02)转百度坐标系(BD-09)(火星坐标经度,火星坐标纬度),百度坐标数组 66 | * bd09togcj02 百度坐标系(BD-09)转火星坐标系(GCJ-02)(百度坐标纬度,百度坐标经度),火星坐标数组 67 | * wgs84togcj02 WGS84转GCJ02(火星坐标系)(WGS84坐标系的经度,WGS84坐标系的纬度),火星坐标数组 68 | * gcj02towgs84 GCJ02(火星坐标系)转GPS84(火星坐标系的经度,火星坐标系纬度),WGS84坐标数组 69 | * transformlat 纬度转换 70 | * transformlng 经度转换 71 | * out_of_china 判断是否在国内,不在国内不做偏移 72 | 73 | - DateUtil.java 日期工具类 74 | * formatDataTime 格式化日期时间 75 | * formatDate 格式化日期 76 | * formatTime 格式化时间 77 | * formatDateCustom 自定义格式的格式化日期时间 78 | * string2Date 将时间字符串转换成Date 79 | * getDate 获取系统日期 80 | * getTime 获取系统时间 81 | * getDateTime 获取系统日期时间 82 | * subtractDate 计算两个时间差 83 | * getDateAfter 得到几天后的时间 84 | * getWeekOfMonth 获取当前时间为本月的第几周 85 | * getDayOfWeek 获取当前时间为本周的第几天 86 | 87 | - DensityUtil.java 屏幕工具类 88 | * dip2px dp转像素 89 | * dip2sp dip转sp 90 | * px2dip 像素转dp 91 | * px2sp 像素转sp 92 | * sp2px sp转像素 93 | * sp2dip sp转dip 94 | * getScreenW 获取屏幕宽度 95 | * getScreenH 获取屏幕高度 96 | * getScreenRealSize 获取屏幕的真实高度 97 | * getStatusBarH 获取状态栏高度 98 | * getNavigationBarrH 获取导航栏高度 99 | 100 | - DeviceUtils.java 设备信息工具 101 | * getAndroidID 获取AndroidID 102 | * getIMEI 获取设备IMEI码 103 | * getIMSI 获取设备IMSI码 104 | * getWifiMacAddr 获取MAC地址 105 | * getIP 获取网络IP地址(优先获取wifi地址) 106 | * getWifiIP 获取WIFI连接下的ip地址 107 | * getGPRSIP 获取GPRS连接下的ip地址 108 | * getSerial 获取设备序列号 109 | * getSIMSerial 获取SIM序列号 110 | * getMNC 获取网络运营商 46000,46002,46007 中国移动,46001 中国联通,46003 中国电信 111 | * getCarrier 获取网络运营商:中国电信,中国移动,中国联通 112 | * getModel 获取硬件型号 113 | * getBuildBrand 获取编译厂商 114 | * getBuildHost 获取编译服务器主机 115 | * getBuildTags 获取描述Build的标签 116 | * getBuildTime 获取系统编译时间 117 | * getBuildUser 获取系统编译作者 118 | * getBuildVersionRelease 获取编译系统版本(5.1) 119 | * getBuildVersionCodename 获取开发代号 120 | * getBuildVersionIncremental 获取源码控制版本号 121 | * getBuildVersionSDK 获取编译的SDK 122 | * getBuildID 获取修订版本列表(LMY47D) 123 | * getSupportedABIS CPU指令集 124 | * getManufacturer 获取硬件制造厂商 125 | * getBootloader 获取系统启动程序版本号 126 | * getScreenDisplayID 127 | * getDisplayVersion 获取系统版本号 128 | * getLanguage 获取语言 129 | * getCountry 获取国家 130 | * getOSVersion 获取系统版本:5.1.1 131 | * getGSFID 获取GSF序列号 132 | * getBluetoothMAC 获取蓝牙地址 133 | * getPsuedoUniqueID Android设备物理唯一标识符 134 | * getFingerprint 构建标识,包括brand,name,device,version.release,id,version.incremental,type,tags这些信息 135 | * getHardware 获取硬件信息 136 | * getProduct 获取产品信息 137 | * getDevice 获取设备信息 138 | * getBoard 获取主板信息 139 | * getRadioVersion 获取基带版本(无线电固件版本 Api14以上) 140 | * getUA 获取的浏览器指纹(User-Agent) 141 | * getDensity 获取得屏幕密度 142 | * getGoogleAccounts 获取google账号 143 | 144 | 145 | - FileUtils.java 文件工具类 146 | * closeIO 关闭IO流 147 | * isFileExist 文件是否存在 148 | * writeFile 将字符串写入到文件 149 | * readFile 从文件中读取字符串 150 | * readFile 从文件中读取字符串(可设置编码) 151 | * copyFile 复制文件 152 | * copyFileFast 快速复制 153 | * shareFile 分享文件 154 | * zip zip压缩 155 | * unzip zip解压 156 | * formatFileSize 格式化文件大小 157 | * Stream2File 将输入流写入到文件 158 | * createFolder 创建文件夹 159 | * createFolder 创建文件夹(支持覆盖已存在的同名文件夹) 160 | * getFileName 获取文件名 161 | * getFileSize 获取文件大小 162 | * rename 重名名文件\文件夹 163 | * getFolderName 获取文件夹名称 164 | * getFilesArray 获取文件夹下所有文件 165 | * deleteFile 删除文件 166 | * deleteFileByDirectory 删除目录下的所有文件 167 | * openImage 打开图片 168 | * openVideo 打开视频 169 | * openURL 打开URL 170 | * downloadFile 下载文件 171 | * upgradeApp 通过APKURL升级应用 172 | * isSDCardAvailable 是否挂在SDCard 173 | * getAppExternalPath 获取应用在SDCard上的工作路径 174 | * getExtraPath 获取SDCard上目录的路径 175 | 176 | - JsonUtils.java Json工具类(需要依赖Gson 2.0以上) 177 | * toJson 对象转json 178 | * fromJson json转对象 179 | * mapToJson Map转为JSONObject 180 | * collection2Json 集合转换为JSONArray 181 | * object2Json Object对象转换为JSONArray 182 | * string2JSONObject json字符串生成JSONObject对象 183 | 184 | - L.java 日志工具 185 | * init 初始化日志开关和TAG(默认日志为开,TAG为"ghost") 186 | * v VERBOSE 187 | * d DEBUG 188 | * i INFO 189 | * w WARN 190 | * e ERROR 191 | * a ASSERT 192 | * json 输出json 193 | * xml 输出xml 194 | 195 | - NetUtils.java 网络工具 196 | * getNetworkType 获取网络类型 197 | * getNetworkTypeName 获取网络名称 198 | * isConnected 检查网络状态 199 | * isNetworkAvailable 网络可用性 200 | * isWiFi 是否wifi 201 | * openNetSetting 打开网络设置界面 202 | * setWifiEnabled 设置wifi状态 203 | * setDataEnabled 设置数据流量状态 204 | * getWifiScanResults 获取wifi列表 205 | * getScanResultsByBSSID 过滤扫描结果 206 | * getWifiConnectionInfo 获取wifi连接信息 207 | 208 | - RadixUtils 进制工具类 209 | * 210 | - SPUtils.java SharedPreferences工具 211 | * setSP 存储SharedPreferences值 212 | * getSp 获取SharedPreferences值 213 | * cleanAllSP 清除所有的SP值 214 | 215 | - StringUtils.java 字符串工具 216 | * getChsAscii 汉字转成ASCII码 217 | * convert 单字解析 218 | * getSelling 词组解析 219 | * parseEmpty 将null转化为"" 220 | * isEmpty 是否是空字符串 221 | * chineseLength 中文长度 222 | * strLength 字符串长度 223 | * subStringLength 获取指定长度的字符所在位置 224 | * isChinese 是否是中文 225 | * isContainChinese 是否包含中文 226 | * strFormat2 不足2位前面补0 227 | * convert2Int 类型安全转换 228 | * decimalFormat 指定小数输出 229 | 230 | - SystemUtils.java 系统工具 231 | * sendSMS 调用系统发送短信 232 | * forwardToDial 跳转到拨号 233 | * sendMail 发邮件 234 | * openWeb 打开浏览器 235 | * openContacts 打开联系人 236 | * openSettings 打开系统设置 237 | ``` 238 | /** 239 | * com.android.settings.AccessibilitySettings 辅助功能设置 240 | * com.android.settings.ActivityPicker 选择活动 241 | * com.android.settings.ApnSettings APN设置 242 | * com.android.settings.ApplicationSettings 应用程序设置 243 | * com.android.settings.BandMode 设置GSM/UMTS波段 244 | * com.android.settings.BatteryInfo 电池信息 245 | * com.android.settings.DateTimeSettings 日期和时间设置 246 | * com.android.settings.DateTimeSettingsSetupWizard 日期和时间设置 247 | * com.android.settings.DevelopmentSettings 应用程序设置=》开发设置 248 | * com.android.settings.DeviceAdminSettings 设备管理器 249 | * com.android.settings.DeviceInfoSettings 关于手机 250 | * com.android.settings.Display 显示——设置显示字体大小及预览 251 | * com.android.settings.DisplaySettings 显示设置 252 | * com.android.settings.DockSettings 底座设置 253 | * com.android.settings.IccLockSettings SIM卡锁定设置 254 | * com.android.settings.InstalledAppDetails 语言和键盘设置 255 | * com.android.settings.LanguageSettings 语言和键盘设置 256 | * com.android.settings.LocalePicker 选择手机语言 257 | * com.android.settings.LocalePickerInSetupWizard 选择手机语言 258 | * com.android.settings.ManageApplications 已下载(安装)软件列表 259 | * com.android.settings.MasterClear 恢复出厂设置 260 | * com.android.settings.MediaFormat 格式化手机闪存 261 | * com.android.settings.PhysicalKeyboardSettings 设置键盘 262 | * com.android.settings.PrivacySettings 隐私设置 263 | * com.android.settings.ProxySelector 代理设置 264 | * com.android.settings.RadioInfo 手机信息 265 | * com.android.settings.RunningServices 正在运行的程序(服务) 266 | * com.android.settings.SecuritySettings 位置和安全设置 267 | * com.android.settings.Settings 系统设置 268 | * com.android.settings.SettingsSafetyLegalActivity 安全信息 269 | * com.android.settings.SoundSettings 声音设置 270 | * com.android.settings.TestingSettings 测试——显示手机信息、电池信息、使用情况统计、Wifi 271 | * information、服务信息 com.android.settings.TetherSettings 绑定与便携式热点 272 | * com.android.settings.TextToSpeechSettings 文字转语音设置 273 | * com.android.settings.UsageStats 使用情况统计 274 | * com.android.settings.UserDictionarySettings 用户词典 275 | * com.android.settings.VoiceInputOutputSettings 语音输入与输出设置 276 | * com.android.settings.WirelessSettings 无线和网络设置 277 | */ 278 | ``` 279 | 280 | * hideKeyBoard 隐藏系统键盘 281 | * isBackground 判断当前应用程序是否后台运行 282 | * isSleeping 判断手机是否处理睡眠 283 | * installApk 安装apk 284 | * isRooted 是否root 285 | * isRunningOnEmulator 当前设备是否是模拟器 286 | * goHome 返回Home 287 | * hexdigest 32位签名 288 | * getDeviceUsableMemory 获取设备可用空间 289 | * gc 清理后台进程和服务 290 | * getProcessName 获取进程名字 291 | * createDeskShortCut 创建桌面快捷方式 292 | * createShortcut 创建快捷方式 293 | * shareText 分享文本 294 | * shareFile 分享文件(此方法是调用FileUtils.shareFile中的方式) 295 | * getShareTargets 获取可接受分享的应用 296 | * getCurrentLanguage 获取当前系统的语言 297 | * getLanguage 获取当前系统的语言 298 | * isGpsEnabled GPS是否打开 299 | * showSoftInputMethod 显示软键盘 300 | * closeSoftInputMethod 关闭软键盘 301 | * showSoftInput 显示软键盘 302 | * closeSoftInput 关闭软键盘 303 | * toWeChatScan 打开微信扫描 304 | * toAliPayScan 打开支付宝扫描 305 | * toAliPayPayCode 打开支付宝支付码 306 | * getRandomNumber 获取随机数 307 | 308 | - VerificationUtils.java 验证工具类 309 | * matcherRealName 判断姓名格式 310 | ``` 311 | 真实姓名可以是汉字,也可以是字母,但是不能两者都有,也不能包含任何符号和数字 312 | 1.如果是英文名,可以允许英文名字中出现空格 313 | 2.英文名的空格可以是多个,但是不能连续出现多个 314 | 3.汉字不能出现空格 315 | ``` 316 | * matcherPhoneNum 判断手机号格式 (匹配11数字,并且13-19开头) 317 | * matcherAccount 判断账号格式 (4-20位字符) 318 | * matcherPassword 判断密码格式 (6-12位字母或数字) 319 | * matcherPassword2 判断密码格式 (6-12位字母或数字,必须同时包含字母和数字) 320 | * matcherEmail 判断邮箱格式 321 | * matcherIP 判断IP地址 322 | * matcherUrl 判断URL (http,https,ftp) 323 | * matcherVehicleNumber 判断中国民用车辆号牌 324 | * matcherIdentityCard 判断身份证号码格式 325 | * isNumeric 是否数值型 326 | * testRegex 是否匹配正则 327 | * checkPostcode 匹配中国邮政编码 328 | 329 | 330 | ```shell 331 | 332 | /** 333 | * 身份证校验 334 | *

335 | * 根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。 336 | * 排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。 337 | * 地址码表示编码对象常住户口所在县(市、旗、区)的行政区划代码。 338 | * 出生日期码表示编码对象出生的年、月、日,其中年份用四位数字表示,年、月、日之间不用分隔符。 339 | * 顺序码表示同一地址码所标识的区域范围内,对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性,偶数分给女性。 340 | * 校验码是根据前面十七位数字码,按照ISO 7064:1983.MOD 11-2校验码计算出来的检验码。 341 | * 出生日期计算方法。 342 | * 15位的身份证编码首先把出生年扩展为4位,简单的就是增加一个19或18,这样就包含了所有1800-1999年出生的人; 343 | * 2000年后出生的肯定都是18位的了没有这个烦恼,至于1800年前出生的,那啥那时应该还没身份证号这个东东,⊙﹏⊙b汗... 344 | * 下面是正则表达式: 345 | * 出生日期1800-2099 /(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])/ 346 | * 身份证正则表达式 /^[1-9]\d{5}((1[89]|20)\d{2})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dx]$/i 347 | * 15位校验规则 6位地址编码+6位出生日期+3位顺序号 348 | * 18位校验规则 6位地址编码+8位出生日期+3位顺序号+1位校验位 349 | * 校验位规则 公式:∑(ai×Wi)(mod 11)……………………………………(1) 350 | * 公式(1)中: 351 | * i----表示号码字符从由至左包括校验码在内的位置序号; 352 | * ai----表示第i位置上的号码字符值; 353 | * Wi----示第i位置上的加权因子,其数值依据公式Wi=2^(n-1)(mod 11)计算得出。 354 | * i 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 355 | * Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1 356 | *

357 | * 358 | * @author Yoojia.Chen (yoojia.chen@gmail.com) 359 | * @version version 2015-05-21 360 | * @since 2.0 361 | */ 362 | ``` 363 | 364 | # 这个库参考了众多网络的中的代码,在此对这些无私奉献的人致以最诚挚的感谢。 365 | License 366 | ---- 367 | 368 | Copyright (C) 2016 android@19code.com 369 | 370 | Licensed under the Apache License, Version 2.0 (the "License"); 371 | you may not use this file except in compliance with the License. 372 | You may obtain a copy of the License at 373 | 374 | http://www.apache.org/licenses/LICENSE-2.0 375 | 376 | Unless required by applicable law or agreed to in writing, software 377 | distributed under the License is distributed on an "AS IS" BASIS, 378 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 379 | See the License for the specific language governing permissions and 380 | limitations under the License. 381 | 382 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to use In Android Studio 2 | ```gradle 3 | compile 'com.code19.library:library:0.1.4' 4 | ``` 5 | 6 | # notes 7 | [0.1.4 removed](https://github.com/h4de5ing/AndroidCommon/commit/f4cb414ce8a7732fb152c510833f782b0cf0fd6d "0.1.4 we removed") ``ToastUtils``,``ViewUtils.java``,``SpannableStringUtils.java``,if you used then,you can use 0.1.2. 8 | 9 | # Common Utils 10 | - Collection Chop [Issues](https://github.com/h4de5ing/AndroidCommon/issues) 11 | - Show Me The Best Code [Pull request](https://github.com/h4de5ing/AndroidCommon/pulls) 12 | 13 | ``` 14 | Demo: 15 | AppUtils.getAppName(MainActivity.this,"com.code19.androidcommon"); 16 | ``` 17 | ## [中文文档](README-cn.md) 18 | ## library Module: 19 | 20 | - AppUtils.java (about Application tools) 21 | * getAppName 22 | * getAppIcon 23 | * getAppFirstInstallTime 24 | * getAppLastUpdateTime 25 | * getAppSize 26 | * getAppApk 27 | * getAppVersionName 28 | * getAppVersionCode 29 | * getAppInstaller 30 | * getAppSign 31 | * getAppTargetSdkVersion 32 | * getAppUid 33 | * getNumCores 34 | * getRootPermission 35 | * getAppPermissions 36 | * hasPermission 37 | * isInstalled 38 | * ~~installApk~~ 39 | * ~~uninstallApk~~ 40 | * isSystemApp 41 | * isServiceRunning 42 | * stopRunningService 43 | * killProcesses 44 | * runScript 45 | * runApp 46 | * cleanCache 47 | * cleanDatabases 48 | * cleanSharedPreference 49 | 50 | - CipherUtils.java 51 | * md5(String input) 52 | * md5L(String input) 53 | * md5(InputStream in) 54 | * base64Encode 55 | * base64Decode 56 | * XorEncode 57 | * XorDecode 58 | * sha1(String str) 59 | * sha1(File file) 60 | 61 | - DateUtil.java 62 | * formatDataTime 63 | * formatDate 64 | * formatTime 65 | * formatDateCustom 66 | * string2Date 67 | * getDate 68 | * getTime 69 | * getDateTime 70 | * subtractDate 71 | * getDateAfter 72 | * getWeekOfMonth 73 | * getDayOfWeek 74 | 75 | - DensityUtil.java 76 | * dip2px 77 | * dip2sp 78 | * px2dip 79 | * px2sp 80 | * sp2px 81 | * sp2dip 82 | * getScreenW 83 | * getScreenH 84 | * getScreenRealSize 85 | * getStatusBarH 86 | * getNavigationBarrH 87 | 88 | - DeviceUtils.java 89 | * getAndroidID 90 | * getIMEI 91 | * getIMSI 92 | * getWifiMacAddr 93 | * getIP 94 | * getWifiIP 95 | * getGPRSIP 96 | * getSerial 97 | * getSIMSerial 98 | * getMNC 99 | * getCarrier 100 | * getModel 101 | * getBuildBrand 102 | * getBuildHost 103 | * getBuildTags 104 | * getBuildTime 105 | * getBuildUser 106 | * getBuildVersionRelease 107 | * getBuildVersionCodename 108 | * getBuildVersionIncremental 109 | * getBuildVersionSDK 110 | * getBuildID 111 | * getSupportedABIS 112 | * getManufacturer 113 | * getBootloader 114 | * getScreenDisplayID 115 | * getDisplayVersion 116 | * getLanguage 117 | * getCountry 118 | * getOSVersion 119 | * getGSFID 120 | * getBluetoothMAC 121 | * getPsuedoUniqueID 122 | * getFingerprint 123 | * getHardware 124 | * getProduct 125 | * getDevice 126 | * getBoard 127 | * getRadioVersion 128 | * getUA 129 | * getDensity 130 | * getGoogleAccounts 131 | 132 | 133 | - FileUtils.java 134 | * closeIO 135 | * isFileExist 136 | * writeFile 137 | * readFile 138 | * readFile 139 | * copyFile 140 | * copyFileFast 141 | * shareFile 142 | * zip 143 | * unzip 144 | * formatFileSize 145 | * Stream2File 146 | * createFolder 147 | * createFolder 148 | * getFileName 149 | * getFileSize 150 | * rename 151 | * getFolderName 152 | * getFilesArray 153 | * deleteFile 154 | * deleteFileByDirectory 155 | * openImage 156 | * openVideo 157 | * openURL 158 | * downloadFile 159 | * upgradeApp 160 | * isSDCardAvailable 161 | * getAppExternalPath 162 | * getExtraPath 163 | 164 | - JsonUtils.java 165 | * toJson 166 | * fromJson 167 | * mapToJson 168 | * collection2Json 169 | * object2Json 170 | * string2JSONObject 171 | 172 | - L.java 173 | * init //Init the Log set Debug and Tag 174 | * v VERBOSE 175 | * d DEBUG 176 | * i INFO 177 | * w WARN 178 | * e ERROR 179 | * a ASSERT 180 | * json 181 | * xml 182 | 183 | - NetUtils.java 184 | * getNetworkType 185 | * getNetworkTypeName 186 | * isConnected 187 | * isNetworkAvailable 188 | * isWiFi 189 | * openNetSetting 190 | * setWifiEnabled 191 | * setDataEnabled 192 | * getWifiScanResults 193 | * getScanResultsByBSSID 194 | * getWifiConnectionInfo 195 | 196 | - SPUtils.java 197 | * setSP 198 | * getSp 199 | * cleanAllSP 200 | 201 | - StringUtils.java 202 | * getChsAscii 203 | * convert 204 | * getSelling 205 | * parseEmpty 206 | * isEmpty 207 | * chineseLength 208 | * strLength 209 | * subStringLength 210 | * isChinese 211 | * isContainChinese 212 | * strFormat2 213 | * convert2Int 214 | * decimalFormat 215 | 216 | - SystemUtils.java 217 | * sendSMS 218 | * forwardToDial 219 | * sendMail 220 | * openWeb 221 | * openContacts 222 | * openSettings 223 | * hideKeyBoard 224 | * isBackground 225 | * isSleeping 226 | * installApk 227 | * isRooted 228 | * isRunningOnEmulator 229 | * goHome 230 | * hexdigest 231 | * getDeviceUsableMemory 232 | * gc 233 | * getProcessName 234 | * createDeskShortCut 235 | * createShortcut 236 | * shareText 237 | * shareFile 238 | * getShareTargets 239 | * getCurrentLanguage 240 | * getLanguage 241 | * isGpsEnabled 242 | * showSoftInputMethod 243 | * closeSoftInputMethod 244 | * showSoftInput 245 | * closeSoftInput 246 | * toWeChatScan 247 | * toAliPayScan 248 | * toAliPayPayCode 249 | * getRandomNumber 250 | 251 | - VerificationUtils.java 252 | * matcherRealName 253 | * matcherPhoneNum //just matcher chinese phone number 254 | * matcherAccount 255 | * matcherPassword 256 | * matcherPassword2 257 | * matcherEmail 258 | * matcherIP 259 | * matcherUrl 260 | * isNumeric 261 | * testRegex 262 | 263 | # Thanks to all the open source programmers 264 | License 265 | ---- 266 | 267 | Copyright (C) 2016 moxi1992@gmail.com 268 | 269 | Licensed under the Apache License, Version 2.0 (the "License"); 270 | you may not use this file except in compliance with the License. 271 | You may obtain a copy of the License at 272 | 273 | http://www.apache.org/licenses/LICENSE-2.0 274 | 275 | Unless required by applicable law or agreed to in writing, software 276 | distributed under the License is distributed on an "AS IS" BASIS, 277 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 278 | See the License for the specific language governing permissions and 279 | limitations under the License. 280 | 281 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '25.0.0' 6 | 7 | defaultConfig { 8 | applicationId "com.code19.androidcommon" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.3.0' 26 | compile project(':library') 27 | compile 'com.android.support:recyclerview-v7:23.3.0' 28 | compile 'com.android.support:cardview-v7:23.3.0' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/code19/androidcommon/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon; 18 | 19 | import android.app.Application; 20 | import android.test.ApplicationTestCase; 21 | 22 | /** 23 | * Testing Fundamentals 24 | */ 25 | public class ApplicationTest extends ApplicationTestCase { 26 | public ApplicationTest() { 27 | super(Application.class); 28 | } 29 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/HandlerActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon; 18 | 19 | import android.os.Bundle; 20 | import android.os.Handler; 21 | import android.os.Message; 22 | import android.os.PersistableBundle; 23 | import android.support.v7.app.AppCompatActivity; 24 | 25 | import java.lang.ref.WeakReference; 26 | 27 | /** 28 | * Create by h4de5ing 2016/5/10 010 29 | * 论Handler的正确使用方式, 参考自:https://yq.aliyun.com/articles/3009 Android 内存泄漏总结 30 | */ 31 | public class HandlerActivity extends AppCompatActivity { 32 | private static class MyHandler extends Handler { 33 | private final WeakReference mMainActivityWeakReference; 34 | 35 | public MyHandler(HandlerActivity activity) { 36 | mMainActivityWeakReference = new WeakReference<>(activity); 37 | } 38 | 39 | @Override 40 | public void handleMessage(Message msg) { 41 | super.handleMessage(msg); 42 | HandlerActivity activity = mMainActivityWeakReference.get(); 43 | if (activity != null) { 44 | // 处理msg 45 | switch (msg.what) { 46 | case 0: 47 | break; 48 | case 1: 49 | break; 50 | case 2: 51 | break; 52 | } 53 | 54 | } 55 | } 56 | } 57 | 58 | 59 | private final MyHandler mMyHandler = new MyHandler(this); 60 | private static final Runnable sRunnable = new Runnable() { 61 | @Override 62 | public void run() { 63 | // 执行的内容 64 | Message message = new Message(); 65 | message.arg1 = 1; 66 | } 67 | }; 68 | 69 | @Override 70 | public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { 71 | super.onCreate(savedInstanceState, persistentState); 72 | mMyHandler.postDelayed(sRunnable, 1000 * 6);//6秒钟后执行 73 | finish(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon; 18 | 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | import android.support.v7.app.AppCompatActivity; 22 | import android.view.View; 23 | import android.widget.Button; 24 | import android.widget.LinearLayout; 25 | 26 | import com.code19.androidcommon.ui.activity.AppManagerActivity; 27 | import com.code19.androidcommon.ui.activity.DeviceActivity; 28 | import com.code19.androidcommon.ui.activity.VerificationActivity; 29 | import com.code19.library.FileUtils; 30 | 31 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 32 | private LinearLayout mMain; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.activity_main); 38 | mMain = (LinearLayout) findViewById(R.id.main); 39 | Button virification = (Button) findViewById(R.id.virification); 40 | Button deviceutils = (Button) findViewById(R.id.deviceutils); 41 | Button testutils = (Button) findViewById(R.id.testutils); 42 | Button fileutils = (Button) findViewById(R.id.fileutils); 43 | Button apputils = (Button) findViewById(R.id.apputils); 44 | testutils.setOnClickListener(this); 45 | fileutils.setOnClickListener(this); 46 | apputils.setOnClickListener(this); 47 | deviceutils.setOnClickListener(this); 48 | virification.setOnClickListener(this); 49 | } 50 | 51 | @Override 52 | public void onClick(View v) { 53 | switch (v.getId()) { 54 | case R.id.apputils: 55 | startActivity(new Intent(MainActivity.this, AppManagerActivity.class)); 56 | break; 57 | case R.id.deviceutils: 58 | startActivity(new Intent(MainActivity.this, DeviceActivity.class)); 59 | break; 60 | case R.id.fileutils: 61 | String url = "http://3lin9.19code.com/app.apk"; 62 | FileUtils.upgradeApp(MainActivity.this, url); 63 | break; 64 | case R.id.testutils: 65 | //Bitmap bitmap = ViewUtils.createViewBitmap(mMain); 66 | //ImageUtils.bitmap2gallery(this, bitmap, "main.png"); 67 | break; 68 | case R.id.virification: 69 | startActivity(new Intent(MainActivity.this, VerificationActivity.class)); 70 | break; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/model/AppBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.model; 18 | 19 | import android.graphics.drawable.Drawable; 20 | 21 | /** 22 | * Create by h4de5ing 2016/5/24 024 23 | */ 24 | public class AppBean { 25 | private String appName; 26 | private Drawable appIcon; 27 | private long appDate; 28 | private long appSize; 29 | private String appAPk; 30 | private String appVerName; 31 | private int appVerCode; 32 | private String appInstaller; 33 | private boolean isSystemApp; 34 | private String appPackage; 35 | 36 | public String getAppPackage() { 37 | return appPackage; 38 | } 39 | 40 | public void setAppPackage(String appPackage) { 41 | this.appPackage = appPackage; 42 | } 43 | 44 | 45 | public String getAppName() { 46 | return appName; 47 | } 48 | 49 | public void setAppName(String appName) { 50 | this.appName = appName; 51 | } 52 | 53 | public Drawable getAppIcon() { 54 | return appIcon; 55 | } 56 | 57 | public void setAppIcon(Drawable appIcon) { 58 | this.appIcon = appIcon; 59 | } 60 | 61 | public long getAppDate() { 62 | return appDate; 63 | } 64 | 65 | public void setAppDate(long appDate) { 66 | this.appDate = appDate; 67 | } 68 | 69 | public long getAppSize() { 70 | return appSize; 71 | } 72 | 73 | public void setAppSize(long appSize) { 74 | this.appSize = appSize; 75 | } 76 | 77 | public String getAppAPk() { 78 | return appAPk; 79 | } 80 | 81 | public void setAppAPk(String appAPk) { 82 | this.appAPk = appAPk; 83 | } 84 | 85 | public String getAppVerName() { 86 | return appVerName; 87 | } 88 | 89 | public void setAppVerName(String appVerName) { 90 | this.appVerName = appVerName; 91 | } 92 | 93 | public int getAppVerCode() { 94 | return appVerCode; 95 | } 96 | 97 | public void setAppVerCode(int appVerCode) { 98 | this.appVerCode = appVerCode; 99 | } 100 | 101 | public String getAppInstaller() { 102 | return appInstaller; 103 | } 104 | 105 | public void setAppInstaller(String appInstaller) { 106 | this.appInstaller = appInstaller; 107 | } 108 | 109 | public boolean isSystemApp() { 110 | return isSystemApp; 111 | } 112 | 113 | public void setSystemApp(boolean systemApp) { 114 | isSystemApp = systemApp; 115 | } 116 | 117 | @Override 118 | public String toString() { 119 | return "AppBean{" + 120 | "appName='" + appName + '\'' + 121 | ", appDate=" + appDate + 122 | ", appSize=" + appSize + 123 | ", appAPk='" + appAPk + '\'' + 124 | ", appVerName='" + appVerName + '\'' + 125 | ", appVerCode=" + appVerCode + 126 | ", appInstaller='" + appInstaller + '\'' + 127 | ", isSystemApp=" + isSystemApp + 128 | '}'; 129 | } 130 | } -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/model/AppBiz.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.model; 18 | 19 | import android.content.Context; 20 | import android.content.pm.PackageInfo; 21 | import android.graphics.drawable.Drawable; 22 | import android.text.TextUtils; 23 | 24 | import com.code19.library.AppUtils; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | 29 | /** 30 | * Create by h4de5ing 2016/5/24 024 31 | */ 32 | public class AppBiz implements IAppBiz { 33 | 34 | @Override 35 | public void getData(Context c, OnAppLoadListener onAppLoadListener) { 36 | List list = new ArrayList<>(); 37 | List installedPackages = c.getPackageManager().getInstalledPackages(0); 38 | for (PackageInfo info : installedPackages) { 39 | String appName = AppUtils.getAppName(c, info.packageName); 40 | Drawable appIcon = AppUtils.getAppIcon(c, info.packageName); 41 | long appDate = AppUtils.getAppDate(c, info.packageName); 42 | long appSize = AppUtils.getAppSize(c, info.packageName); 43 | String appApk = AppUtils.getAppApk(c, info.packageName); 44 | String appVersionName = AppUtils.getAppVersionName(c, info.packageName); 45 | int appVersionCode = AppUtils.getAppVersionCode(c, info.packageName); 46 | String appInstaller = AppUtils.getAppInstaller(c, info.packageName); 47 | boolean systemApp = AppUtils.isSystemApp(c, info.packageName); 48 | if (!TextUtils.isEmpty(appName) && 49 | !TextUtils.isEmpty(appApk) && 50 | !TextUtils.isEmpty(appVersionName) && 51 | !TextUtils.isEmpty(appInstaller) && 52 | appIcon != null 53 | && appDate > 0 54 | && appSize > 0 55 | && appVersionCode > 0) { 56 | AppBean appBean = new AppBean(); 57 | appBean.setAppName(appName); 58 | appBean.setAppIcon(appIcon); 59 | appBean.setAppDate(appDate); 60 | appBean.setAppSize(appSize); 61 | appBean.setAppAPk(appApk); 62 | appBean.setAppVerName(appVersionName); 63 | appBean.setAppVerCode(appVersionCode); 64 | appBean.setAppInstaller(appInstaller); 65 | appBean.setSystemApp(systemApp); 66 | appBean.setAppPackage(info.packageName); 67 | list.add(appBean); 68 | } 69 | } 70 | onAppLoadListener.loadSuccess(list); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/model/IAppBiz.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.model; 18 | 19 | import android.content.Context; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * Create by h4de5ing 2016/5/24 024 25 | */ 26 | public interface IAppBiz { 27 | void getData(Context context, OnAppLoadListener onAppLoadListener); 28 | 29 | interface OnAppLoadListener { 30 | void loading(); 31 | 32 | void loadSuccess(List list); 33 | 34 | void loadFaile(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/presenter/AppPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.presenter; 18 | 19 | import android.content.Context; 20 | import android.os.Handler; 21 | 22 | import com.code19.androidcommon.model.AppBean; 23 | import com.code19.androidcommon.model.AppBiz; 24 | import com.code19.androidcommon.model.IAppBiz; 25 | import com.code19.androidcommon.view.IAppView; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Create by h4de5ing 2016/5/24 024 31 | */ 32 | public class AppPresenter { 33 | private IAppBiz mIAppBiz; 34 | private IAppView mIAppView; 35 | private Handler mHandler; 36 | private Context mContext; 37 | 38 | public AppPresenter(Context context, IAppView iAppView) { 39 | this.mContext = context; 40 | this.mHandler = new Handler(); 41 | this.mIAppBiz = new AppBiz(); 42 | this.mIAppView = iAppView; 43 | } 44 | 45 | public void getData() { 46 | new Thread(new Runnable() { 47 | @Override 48 | public void run() { 49 | mIAppBiz.getData(mContext, new IAppBiz.OnAppLoadListener() { 50 | @Override 51 | public void loading() { 52 | mIAppView.showLoading(); 53 | } 54 | 55 | @Override 56 | public void loadSuccess(final List list) { 57 | mIAppView.hideLoading(); 58 | mHandler.post(new Runnable() { 59 | @Override 60 | public void run() { 61 | mIAppView.referData(list); 62 | } 63 | }); 64 | } 65 | 66 | @Override 67 | public void loadFaile() { 68 | mIAppView.hideLoading(); 69 | } 70 | }); 71 | } 72 | }).start(); 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/ui/activity/AppManagerActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.ui.activity; 18 | 19 | import android.app.ProgressDialog; 20 | import android.os.Bundle; 21 | import android.support.v7.app.AppCompatActivity; 22 | import android.support.v7.widget.GridLayoutManager; 23 | import android.support.v7.widget.RecyclerView; 24 | 25 | import com.code19.androidcommon.R; 26 | import com.code19.androidcommon.model.AppBean; 27 | import com.code19.androidcommon.presenter.AppPresenter; 28 | import com.code19.androidcommon.ui.adapter.AppRecyAdapter; 29 | import com.code19.androidcommon.view.IAppView; 30 | import com.code19.library.L; 31 | 32 | import java.util.List; 33 | 34 | public class AppManagerActivity extends AppCompatActivity implements IAppView { 35 | private static final String TAG = "ghost"; 36 | 37 | private AppPresenter mPresenter; 38 | private ProgressDialog mDialog; 39 | private RecyclerView mRecyapp; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_app_manager); 45 | mRecyapp = (RecyclerView) findViewById(R.id.recy_app); 46 | mRecyapp.setLayoutManager(new GridLayoutManager(this, 4)); 47 | mRecyapp.setHasFixedSize(true); 48 | initProgress(); 49 | mPresenter = new AppPresenter(this, this); 50 | new Thread(new Runnable() { 51 | @Override 52 | public void run() { 53 | mPresenter.getData(); 54 | } 55 | }).start(); 56 | } 57 | 58 | private void initProgress() { 59 | mDialog = new ProgressDialog(this); 60 | mDialog.setMessage(getString(R.string.loading)); 61 | mDialog.setCancelable(true); 62 | mDialog.setCanceledOnTouchOutside(false); 63 | mDialog.show(); 64 | } 65 | 66 | @Override 67 | public void showLoading() { 68 | mDialog.show(); 69 | } 70 | 71 | @Override 72 | public void hideLoading() { 73 | mDialog.cancel(); 74 | } 75 | 76 | @Override 77 | public void referData(List list) { 78 | for (AppBean bean : list) { 79 | L.i(TAG, "app: " + bean.toString()); 80 | } 81 | mRecyapp.setAdapter(new AppRecyAdapter(this, list)); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/ui/activity/DeviceActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.ui.activity; 18 | 19 | import android.content.Context; 20 | import android.os.Bundle; 21 | import android.support.v7.app.AppCompatActivity; 22 | import android.util.Log; 23 | import android.widget.TextView; 24 | 25 | import com.code19.androidcommon.R; 26 | import com.code19.library.DensityUtil; 27 | import com.code19.library.DeviceUtils; 28 | import com.code19.library.SystemUtils; 29 | 30 | public class DeviceActivity extends AppCompatActivity { 31 | private Context c; 32 | private TextView mDeviceutilstextview; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.activity_device); 38 | c = this; 39 | mDeviceutilstextview = (TextView) findViewById(R.id.deviceutils_textview); 40 | initDeviecesInfos(); 41 | } 42 | 43 | private void initDeviecesInfos() { 44 | StringBuilder sb = new StringBuilder(); 45 | sb.append("AndroidID--" + DeviceUtils.getAndroidID(c) + "\n"); 46 | sb.append("getIMEI--" + DeviceUtils.getIMEI(c) + "\n"); 47 | sb.append("getIMSI--" + DeviceUtils.getIMSI(c) + "\n"); 48 | sb.append("getWifiMacAddr--" + DeviceUtils.getWifiMacAddr(c) + "\n"); 49 | //sb.append("getIP--" + DeviceUtils.getIP(c) + "\n"); 50 | sb.append("getSerial--" + DeviceUtils.getSerial() + "\n"); 51 | sb.append("getSIMSerial--" + DeviceUtils.getSIMSerial(c) + "\n"); 52 | sb.append("getMNC--" + DeviceUtils.getMNC(c) + "\n"); 53 | sb.append("getBuildBrand--" + DeviceUtils.getBuildBrand() + "\n"); 54 | sb.append("getBuildHost--" + DeviceUtils.getBuildHost() + "\n"); 55 | sb.append("getBuildTags--" + DeviceUtils.getBuildTags() + "\n"); 56 | sb.append("getBuildTime--" + DeviceUtils.getBuildTime() + "\n"); 57 | sb.append("getBuildUser--" + DeviceUtils.getBuildUser() + "\n"); 58 | sb.append("getBuildVersionRelease--" + DeviceUtils.getBuildVersionRelease() + "\n"); 59 | sb.append("getBuildVersionCodename--" + DeviceUtils.getBuildVersionCodename() + "\n"); 60 | sb.append("getBuildVersionIncremental--" + DeviceUtils.getBuildVersionIncremental() + "\n"); 61 | sb.append("getBuildVersionSDK--" + DeviceUtils.getBuildVersionSDK() + "\n"); 62 | sb.append("getSupportedABIS--" + DeviceUtils.getSupportedABIS()[0] + DeviceUtils.getSupportedABIS()[1] + "\n"); 63 | sb.append("getManufacturer--" + DeviceUtils.getManufacturer() + "\n"); 64 | sb.append("getBootloader--" + DeviceUtils.getBootloader() + "\n"); 65 | sb.append("getScreenDisplayID--" + DeviceUtils.getScreenDisplayID(c) + "\n"); 66 | sb.append("getDisplayVersion--" + DeviceUtils.getDisplayVersion() + "\n"); 67 | sb.append("getLanguage--" + DeviceUtils.getLanguage() + "\n"); 68 | sb.append("getCountry--" + DeviceUtils.getCountry(c) + "\n"); 69 | sb.append("getOSVersion--" + DeviceUtils.getOSVersion() + "\n"); 70 | //sb.append("getGSFID--" + DeviceUtils.getGSFID(c) + "\n"); 71 | sb.append("getBluetoothMAC--" + DeviceUtils.getBluetoothMAC(c) + "\n"); 72 | sb.append("getPsuedoUniqueID--" + DeviceUtils.getPsuedoUniqueID() + "\n"); 73 | sb.append("getFingerprint--" + DeviceUtils.getFingerprint() + "\n"); 74 | sb.append("getHardware--" + DeviceUtils.getHardware() + "\n"); 75 | sb.append("getProduct--" + DeviceUtils.getProduct() + "\n"); 76 | sb.append("getDevice--" + DeviceUtils.getDevice() + "\n"); 77 | sb.append("getBoard--" + DeviceUtils.getBoard() + "\n"); 78 | sb.append("getRadioVersion--" + DeviceUtils.getRadioVersion() + "\n"); 79 | sb.append("getUA--" + DeviceUtils.getUA(c) + "\n"); 80 | sb.append("getDensity--" + DeviceUtils.getDensity(c) + "\n"); 81 | //sb.append("getAccounts--" + DeviceUtils.getGoogleAccounts(c)[0] + "\n"); 82 | sb.append("isRunningOnEmulator--" + SystemUtils.isRunningOnEmulator() + "\n"); 83 | sb.append("isRooted--" + SystemUtils.isRooted() + "\n"); 84 | sb.append("ScreenWidth x ScreenHeight--" + DensityUtil.getScreenW(c) + "x" + (DensityUtil.getScreenRealH(c)) + "\n"); 85 | Log.i("ghost", "StatusBar:" + DensityUtil.getStatusBarH(c) + ",Nav:" + DensityUtil.getNavigationBarrH(c)); 86 | mDeviceutilstextview.setText(sb); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/ui/activity/VerificationActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.ui.activity; 18 | 19 | import android.os.Bundle; 20 | import android.support.v7.app.AppCompatActivity; 21 | import android.view.View; 22 | import android.widget.Button; 23 | import android.widget.EditText; 24 | 25 | import com.code19.androidcommon.R; 26 | import com.code19.library.VerificationUtils; 27 | 28 | public class VerificationActivity extends AppCompatActivity { 29 | 30 | private EditText mVirisnumber; 31 | private EditText mVirname; 32 | private EditText mVirphonenumber; 33 | private EditText mViraccount; 34 | private EditText mVirpassword; 35 | private EditText mVirpassword2; 36 | private EditText mViremail; 37 | private EditText mVirip; 38 | private EditText mVirurl; 39 | private EditText mViridcard; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_virification); 45 | Button virsubmit = (Button) findViewById(R.id.vir_submit); 46 | mVirisnumber = (EditText) findViewById(R.id.vir_isnumber); 47 | mViridcard = (EditText) findViewById(R.id.vir_idcard); 48 | mVirurl = (EditText) findViewById(R.id.vir_url); 49 | mVirip = (EditText) findViewById(R.id.vir_ip); 50 | mViremail = (EditText) findViewById(R.id.vir_email); 51 | mVirpassword2 = (EditText) findViewById(R.id.vir_password2); 52 | mVirpassword = (EditText) findViewById(R.id.vir_password); 53 | mViraccount = (EditText) findViewById(R.id.vir_account); 54 | mVirphonenumber = (EditText) findViewById(R.id.vir_phonenumber); 55 | mVirname = (EditText) findViewById(R.id.vir_name); 56 | if (virsubmit != null) { 57 | virsubmit.setOnClickListener( 58 | new View.OnClickListener() { 59 | @Override 60 | public void onClick(View v) { 61 | if (!VerificationUtils.matcherRealName(mVirname.getText().toString())) { 62 | mVirname.setError("姓名不匹配"); 63 | } else if (!VerificationUtils.matcherPhoneNum(mVirphonenumber.getText().toString())) { 64 | mVirphonenumber.setError("电话号码不匹配"); 65 | } else if (!VerificationUtils.matcherAccount(mViraccount.getText().toString())) { 66 | mViraccount.setError("账号不匹配"); 67 | } else if (!VerificationUtils.matcherPassword(mVirpassword.getText().toString())) { 68 | mVirpassword.setError("密码1不匹配"); 69 | } else if (!VerificationUtils.matcherPassword2(mVirpassword2.getText().toString())) { 70 | mVirpassword2.setError("密码2不匹配"); 71 | } else if (!VerificationUtils.matcherEmail(mViremail.getText().toString())) { 72 | mViremail.setError("邮箱不匹配"); 73 | } else if (!VerificationUtils.matcherIP(mVirip.getText().toString())) { 74 | mVirip.setError("IP不匹配"); 75 | } else if (!VerificationUtils.matcherUrl(mVirurl.getText().toString())) { 76 | mVirurl.setError("URL不匹配"); 77 | } else if (!VerificationUtils.matcherIdentityCard(mViridcard.getText().toString())) { 78 | mViridcard.setError("身份证号码不匹配"); 79 | } else if (!VerificationUtils.isNumeric(mVirisnumber.getText().toString())) { 80 | mVirisnumber.setError("不是数字"); 81 | } 82 | } 83 | } 84 | ); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/ui/adapter/AppRecyAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.ui.adapter; 18 | 19 | import android.content.Context; 20 | import android.support.v7.widget.RecyclerView; 21 | import android.view.LayoutInflater; 22 | import android.view.View; 23 | import android.view.ViewGroup; 24 | import android.widget.ImageView; 25 | import android.widget.TextView; 26 | 27 | import com.code19.androidcommon.R; 28 | import com.code19.androidcommon.model.AppBean; 29 | import com.code19.library.AppUtils; 30 | import com.code19.library.L; 31 | 32 | import java.util.List; 33 | 34 | /** 35 | * Create by h4de5ing 2016/5/24 024 36 | */ 37 | public class AppRecyAdapter extends RecyclerView.Adapter { 38 | private Context mContext; 39 | private List mDatas; 40 | private LayoutInflater mLayoutInflater; 41 | 42 | public AppRecyAdapter(Context context, List list) { 43 | this.mContext = context; 44 | this.mDatas = list; 45 | this.mLayoutInflater = LayoutInflater.from(context); 46 | } 47 | 48 | 49 | @Override 50 | public AppViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 51 | return new AppViewHolder(mLayoutInflater.inflate(R.layout.app_recy, parent, false)); 52 | } 53 | 54 | @Override 55 | public int getItemCount() { 56 | return mDatas.size() != 0 ? mDatas.size() : 0; 57 | } 58 | 59 | @Override 60 | public void onBindViewHolder(AppViewHolder holder, int position) { 61 | holder.tv_name.setText(mDatas.get(position).getAppName()); 62 | holder.iv_icon.setImageDrawable(mDatas.get(position).getAppIcon()); 63 | } 64 | 65 | class AppViewHolder extends RecyclerView.ViewHolder { 66 | TextView tv_name; 67 | ImageView iv_icon; 68 | 69 | public AppViewHolder(View itemView) { 70 | super(itemView); 71 | tv_name = (TextView) itemView.findViewById(R.id.recy_name); 72 | iv_icon = (ImageView) itemView.findViewById(R.id.recy_icon); 73 | itemView.setOnClickListener(new View.OnClickListener() { 74 | @Override 75 | public void onClick(View v) { 76 | L.i(mDatas.get(getAdapterPosition()).getAppPackage(), getAdapterPosition()); 77 | //Toast.makeText(mContext, "点击了Item" + getAdapterPosition(), Toast.LENGTH_SHORT).show(); 78 | AppUtils.runApp(mContext, mDatas.get(getAdapterPosition()).getAppPackage()); 79 | } 80 | }); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/code19/androidcommon/view/IAppView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 android@19code.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.code19.androidcommon.view; 18 | 19 | import com.code19.androidcommon.model.AppBean; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * Create by h4de5ing 2016/5/24 024 25 | */ 26 | public interface IAppView { 27 | void showLoading(); 28 | 29 | void hideLoading(); 30 | 31 | void referData(List list); 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_app_manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_device.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 27 | 28 | 29 |