Commit 21623b920dd41fbdd3af74cfa1b4031a6173db20
1 parent
75bd9b74
1 去除媒体库
Showing
4 changed files
with
254 additions
and
3 deletions
build.gradle
| ... | ... | @@ -53,9 +53,10 @@ ext { |
| 53 | 53 | |
| 54 | 54 | compileSdkVersion = 29 |
| 55 | 55 | buildToolsVersion = "29.0.2" |
| 56 | - minSdkVersion = 16 | |
| 56 | + minSdkVersion = 19 | |
| 57 | 57 | targetSdkVersion = 29 |
| 58 | 58 | |
| 59 | + libNewMediaPicker = '1.0.1.8' | |
| 59 | 60 | appArch = '1.3.6.2-androidx-beta1' |
| 60 | 61 | //qmui |
| 61 | 62 | qmui = '1.1.5' | ... | ... |
moudle_pedometer/build.gradle
| ... | ... | @@ -119,7 +119,6 @@ dependencies { |
| 119 | 119 | exclude group: 'com.android.support' |
| 120 | 120 | exclude group: 'com.cnlive' |
| 121 | 121 | } |
| 122 | - implementation "com.cnlive.libs:mediapicker:$rootProject.libMediaPicker" | |
| 123 | 122 | implementation 'org.apache.httpcomponents:httpcore:4.4.2' |
| 124 | 123 | //气泡提醒 |
| 125 | 124 | implementation 'q.rorbin:badgeview:1.1.3' | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/UploadProvider.java
| ... | ... | @@ -24,7 +24,6 @@ import com.cnlive.libs.upload.model.acl.CNCannedAccessControlList; |
| 24 | 24 | import com.cnlive.libs.upload.services.CNPutObjectRequest; |
| 25 | 25 | import com.cnlive.libs.upload.upload.CNUpload; |
| 26 | 26 | import com.cnlive.libs.upload.upload.callback.OnInitListener; |
| 27 | -import com.cnlive.media.picker.utils.FileTypeUtil; | |
| 28 | 27 | import com.cnlive.moudle.pedometer.net.ApiSubscriber; |
| 29 | 28 | import com.cnlive.moudle.pedometer.net.SubscriptionRequest; |
| 30 | 29 | import com.cnlive.moudle.pedometer.net.bean.BaseInfo; |
| ... | ... | @@ -32,6 +31,7 @@ import com.cnlive.moudle.pedometer.net.bean.upload.StorageInfoData; |
| 32 | 31 | import com.cnlive.moudle.pedometer.net.bean.upload.UploadAuthData; |
| 33 | 32 | import com.cnlive.moudle.pedometer.net.bean.upload.api.ApiServiceMoment; |
| 34 | 33 | import com.cnlive.moudle.pedometer.net.bean.upload.api.ApiServiceOpen; |
| 34 | +import com.cnlive.moudle.pedometer.upload.utils.FileTypeUtil; | |
| 35 | 35 | import com.cnlive.moudle.pedometer.utils.FileUtil; |
| 36 | 36 | import com.cnlive.moudle.pedometer.utils.IDUtils; |
| 37 | 37 | import com.cnlive.moudle.pedometer.utils.MD5; | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/utils/FileTypeUtil.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.upload.utils; | |
| 2 | + | |
| 3 | +import android.content.ContentResolver; | |
| 4 | +import android.content.Context; | |
| 5 | +import android.net.Uri; | |
| 6 | +import android.text.TextUtils; | |
| 7 | + | |
| 8 | +import java.io.FileInputStream; | |
| 9 | +import java.io.IOException; | |
| 10 | +import java.io.InputStream; | |
| 11 | +import java.util.HashMap; | |
| 12 | +import java.util.Map; | |
| 13 | + | |
| 14 | +public class FileTypeUtil { | |
| 15 | + public static final Map<String, String> FILE_TYPE_MAP = new HashMap(); | |
| 16 | + private static final String video_types = ".avi.asf.asx.flv.lsf.lsx.mov.mp3.mp4.mpeg.mpg4"; | |
| 17 | + private static final String gif_types = ".gif"; | |
| 18 | + private static final String no_support_types = ".bmp"; | |
| 19 | + | |
| 20 | + private FileTypeUtil() { | |
| 21 | + } | |
| 22 | + | |
| 23 | + private static void getAllFileType() { | |
| 24 | + FILE_TYPE_MAP.put("ffd8ff", "jpg"); | |
| 25 | + FILE_TYPE_MAP.put("89504e", "png"); | |
| 26 | + FILE_TYPE_MAP.put("474946", "gif"); | |
| 27 | + FILE_TYPE_MAP.put("49492a", "tif"); | |
| 28 | + FILE_TYPE_MAP.put("424d22", "bmp"); | |
| 29 | + FILE_TYPE_MAP.put("424d82", "bmp"); | |
| 30 | + FILE_TYPE_MAP.put("424d8e", "bmp"); | |
| 31 | + FILE_TYPE_MAP.put("424d38", "bmp"); | |
| 32 | + FILE_TYPE_MAP.put("414331", "dwg"); | |
| 33 | + FILE_TYPE_MAP.put("3c2144", "html"); | |
| 34 | + FILE_TYPE_MAP.put("3c2164", "htm"); | |
| 35 | + FILE_TYPE_MAP.put("48544d", "css"); | |
| 36 | + FILE_TYPE_MAP.put("696b2e", "js"); | |
| 37 | + FILE_TYPE_MAP.put("7b5c72", "rtf"); | |
| 38 | + FILE_TYPE_MAP.put("384250", "psd"); | |
| 39 | + FILE_TYPE_MAP.put("46726f", "eml"); | |
| 40 | + FILE_TYPE_MAP.put("d0cf11", "doc"); | |
| 41 | + FILE_TYPE_MAP.put("d0cf11", "vsd"); | |
| 42 | + FILE_TYPE_MAP.put("537461", "mdb"); | |
| 43 | + FILE_TYPE_MAP.put("252150", "ps"); | |
| 44 | + FILE_TYPE_MAP.put("255044", "pdf"); | |
| 45 | + FILE_TYPE_MAP.put("2e524d", "rmvb"); | |
| 46 | + FILE_TYPE_MAP.put("464c56", "flv"); | |
| 47 | + FILE_TYPE_MAP.put("000000", "mp4"); | |
| 48 | + FILE_TYPE_MAP.put("494433", "mp3"); | |
| 49 | + FILE_TYPE_MAP.put("000001", "mpg"); | |
| 50 | + FILE_TYPE_MAP.put("3026b2", "wmv"); | |
| 51 | + FILE_TYPE_MAP.put("524946", "wav"); | |
| 52 | + FILE_TYPE_MAP.put("524946", "avi"); | |
| 53 | + FILE_TYPE_MAP.put("4d5468", "mid"); | |
| 54 | + FILE_TYPE_MAP.put("504b03", "zip"); | |
| 55 | + FILE_TYPE_MAP.put("526172", "rar"); | |
| 56 | + FILE_TYPE_MAP.put("235468", "ini"); | |
| 57 | + FILE_TYPE_MAP.put("504b03", "jar"); | |
| 58 | + FILE_TYPE_MAP.put("4d5a90", "exe"); | |
| 59 | + FILE_TYPE_MAP.put("3c2540", "jsp"); | |
| 60 | + FILE_TYPE_MAP.put("4d616e", "mf"); | |
| 61 | + FILE_TYPE_MAP.put("3c3f78", "xml"); | |
| 62 | + FILE_TYPE_MAP.put("494e53", "sql"); | |
| 63 | + FILE_TYPE_MAP.put("706163", "java"); | |
| 64 | + FILE_TYPE_MAP.put("406563", "bat"); | |
| 65 | + FILE_TYPE_MAP.put("1f8b08", "gz"); | |
| 66 | + FILE_TYPE_MAP.put("6c6f67", "properties"); | |
| 67 | + FILE_TYPE_MAP.put("cafeba", "class"); | |
| 68 | + FILE_TYPE_MAP.put("495453", "chm"); | |
| 69 | + FILE_TYPE_MAP.put("040000", "mxp"); | |
| 70 | + FILE_TYPE_MAP.put("504b03", "docx"); | |
| 71 | + FILE_TYPE_MAP.put("d0cf11", "wps"); | |
| 72 | + FILE_TYPE_MAP.put("643130", "torrent"); | |
| 73 | + FILE_TYPE_MAP.put("3c6874", "htm"); | |
| 74 | + FILE_TYPE_MAP.put("46726f", "mht"); | |
| 75 | + FILE_TYPE_MAP.put("6D6F6", "mov"); | |
| 76 | + FILE_TYPE_MAP.put("FF575", "wpd"); | |
| 77 | + FILE_TYPE_MAP.put("CFAD1", "dbx"); | |
| 78 | + FILE_TYPE_MAP.put("21424", "pst"); | |
| 79 | + FILE_TYPE_MAP.put("AC9EB", "qdf"); | |
| 80 | + FILE_TYPE_MAP.put("E3828", "pwl"); | |
| 81 | + FILE_TYPE_MAP.put("2E726", "ram"); | |
| 82 | + } | |
| 83 | + | |
| 84 | + public static String bytesToHexString(byte[] src) { | |
| 85 | + StringBuilder stringBuilder = new StringBuilder(); | |
| 86 | + if (src != null && src.length > 0) { | |
| 87 | + for(int i = 0; i < src.length; ++i) { | |
| 88 | + int v = src[i] & 255; | |
| 89 | + String hv = Integer.toHexString(v); | |
| 90 | + if (hv.length() < 2) { | |
| 91 | + stringBuilder.append(0); | |
| 92 | + } | |
| 93 | + | |
| 94 | + stringBuilder.append(hv); | |
| 95 | + } | |
| 96 | + | |
| 97 | + return stringBuilder.toString(); | |
| 98 | + } else { | |
| 99 | + return null; | |
| 100 | + } | |
| 101 | + } | |
| 102 | + | |
| 103 | + public static String getFileType(String filePath) { | |
| 104 | + FileInputStream is = null; | |
| 105 | + String value = null; | |
| 106 | + | |
| 107 | + try { | |
| 108 | + is = new FileInputStream(filePath); | |
| 109 | + byte[] b = new byte[3]; | |
| 110 | + is.read(b, 0, b.length); | |
| 111 | + value = bytesToHexString(b); | |
| 112 | + } catch (Exception var12) { | |
| 113 | + } finally { | |
| 114 | + if (null != is) { | |
| 115 | + try { | |
| 116 | + is.close(); | |
| 117 | + } catch (IOException var11) { | |
| 118 | + } | |
| 119 | + } | |
| 120 | + | |
| 121 | + } | |
| 122 | + | |
| 123 | + String type = (String)FILE_TYPE_MAP.get(value); | |
| 124 | + return type == null ? "" : type; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public static String getFileUriType(Context context, String filePath) { | |
| 128 | + InputStream inStream = null; | |
| 129 | + String value = null; | |
| 130 | + | |
| 131 | + try { | |
| 132 | + ContentResolver resolver = context.getContentResolver(); | |
| 133 | + inStream = resolver.openInputStream(Uri.parse(filePath)); | |
| 134 | + byte[] b = new byte[3]; | |
| 135 | + inStream.read(b, 0, b.length); | |
| 136 | + value = bytesToHexString(b); | |
| 137 | + } catch (Exception var14) { | |
| 138 | + } finally { | |
| 139 | + if (null != inStream) { | |
| 140 | + try { | |
| 141 | + inStream.close(); | |
| 142 | + } catch (IOException var13) { | |
| 143 | + } | |
| 144 | + } | |
| 145 | + | |
| 146 | + } | |
| 147 | + | |
| 148 | + String type = (String)FILE_TYPE_MAP.get(value); | |
| 149 | + return type == null ? "" : type; | |
| 150 | + } | |
| 151 | + | |
| 152 | + public static String getFileType(String filePath, boolean isImage) { | |
| 153 | + FileInputStream is = null; | |
| 154 | + String value = null; | |
| 155 | + | |
| 156 | + try { | |
| 157 | + is = new FileInputStream(filePath); | |
| 158 | + byte[] b = new byte[3]; | |
| 159 | + is.read(b, 0, b.length); | |
| 160 | + value = bytesToHexString(b); | |
| 161 | + } catch (Exception var13) { | |
| 162 | + } finally { | |
| 163 | + if (null != is) { | |
| 164 | + try { | |
| 165 | + is.close(); | |
| 166 | + } catch (IOException var12) { | |
| 167 | + } | |
| 168 | + } | |
| 169 | + | |
| 170 | + } | |
| 171 | + | |
| 172 | + String type = (String)FILE_TYPE_MAP.get(value); | |
| 173 | + if (isImage && !TextUtils.isEmpty(value) && "524946".equals(value)) { | |
| 174 | + type = "webp"; | |
| 175 | + } | |
| 176 | + | |
| 177 | + return type == null ? "" : type; | |
| 178 | + } | |
| 179 | + | |
| 180 | + public static String getFileType(InputStream stream) { | |
| 181 | + String value = null; | |
| 182 | + | |
| 183 | + try { | |
| 184 | + byte[] b = new byte[3]; | |
| 185 | + stream.read(b, 0, b.length); | |
| 186 | + value = bytesToHexString(b); | |
| 187 | + } catch (Exception var11) { | |
| 188 | + } finally { | |
| 189 | + if (null != stream) { | |
| 190 | + try { | |
| 191 | + stream.close(); | |
| 192 | + } catch (IOException var10) { | |
| 193 | + } | |
| 194 | + } | |
| 195 | + | |
| 196 | + } | |
| 197 | + | |
| 198 | + String type = (String)FILE_TYPE_MAP.get(value); | |
| 199 | + return type == null ? "" : type; | |
| 200 | + } | |
| 201 | + | |
| 202 | + public static boolean checkVideoType(String path) { | |
| 203 | + if (TextUtils.isEmpty(path)) { | |
| 204 | + return false; | |
| 205 | + } else { | |
| 206 | + int end = path.lastIndexOf("."); | |
| 207 | + if (end <= 0) { | |
| 208 | + return false; | |
| 209 | + } else { | |
| 210 | + String type = path.substring(end); | |
| 211 | + if (TextUtils.isEmpty(type)) { | |
| 212 | + return false; | |
| 213 | + } else { | |
| 214 | + return !".avi.asf.asx.flv.lsf.lsx.mov.mp3.mp4.mpeg.mpg4".contains(type); | |
| 215 | + } | |
| 216 | + } | |
| 217 | + } | |
| 218 | + } | |
| 219 | + | |
| 220 | + public static boolean isGif(String path) { | |
| 221 | + if (TextUtils.isEmpty(path)) { | |
| 222 | + return false; | |
| 223 | + } else { | |
| 224 | + int end = path.lastIndexOf("."); | |
| 225 | + if (end <= 0) { | |
| 226 | + return false; | |
| 227 | + } else { | |
| 228 | + String type = path.substring(end); | |
| 229 | + return TextUtils.isEmpty(type) ? false : ".gif".contains(type); | |
| 230 | + } | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + public static boolean isNoSupport(String path) { | |
| 235 | + if (TextUtils.isEmpty(path)) { | |
| 236 | + return false; | |
| 237 | + } else { | |
| 238 | + int end = path.lastIndexOf("."); | |
| 239 | + if (end <= 0) { | |
| 240 | + return false; | |
| 241 | + } else { | |
| 242 | + String type = path.substring(end); | |
| 243 | + return TextUtils.isEmpty(type) ? false : ".bmp".contains(type); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + } | |
| 247 | + | |
| 248 | + static { | |
| 249 | + getAllFileType(); | |
| 250 | + } | |
| 251 | +} | ... | ... |