Commit 7c556a1dd573b5ca75c426c6730cb1f353743224
1 parent
1a8cd127
fiveth
Showing
2 changed files
with
39 additions
and
101 deletions
OutSide_Share/src/main/java/com/cnlive/outside_share/activity/ShareIMActivity.java
| 1 | 1 | package com.cnlive.outside_share.activity; |
| 2 | 2 | |
| 3 | -import android.Manifest; | |
| 4 | 3 | import android.annotation.TargetApi; |
| 5 | -import android.app.Activity; | |
| 6 | 4 | import android.content.ContentUris; |
| 7 | 5 | import android.content.Context; |
| 8 | 6 | import android.content.Intent; |
| 9 | 7 | import android.content.SharedPreferences; |
| 10 | -import android.content.pm.PackageManager; | |
| 11 | -import android.content.pm.ResolveInfo; | |
| 12 | 8 | import android.database.Cursor; |
| 13 | 9 | import android.media.MediaPlayer; |
| 14 | 10 | import android.net.Uri; |
| ... | ... | @@ -16,7 +12,6 @@ import android.os.Build; |
| 16 | 12 | import android.os.Bundle; |
| 17 | 13 | import android.os.Environment; |
| 18 | 14 | import android.provider.MediaStore; |
| 19 | -import android.provider.Settings; | |
| 20 | 15 | import android.text.TextUtils; |
| 21 | 16 | import android.util.Log; |
| 22 | 17 | |
| ... | ... | @@ -28,8 +23,6 @@ import com.cnlive.libs.base.util.MD5Util; |
| 28 | 23 | import com.cnlive.libs.base.util.StringUtils; |
| 29 | 24 | import com.cnlive.libs.data.network.util.UriUtil; |
| 30 | 25 | import com.cnlive.media.picker.utils.AndroidQUtil; |
| 31 | -import com.cnlive.media.picker.utils.BrandUtils; | |
| 32 | -import com.cnlive.media.picker.utils.PermissionChecker; | |
| 33 | 26 | import com.cnlive.outside_share.R; |
| 34 | 27 | import com.cnlive.outside_share.util.FileType; |
| 35 | 28 | import com.cnlive.outside_share.util.FileUtil; |
| ... | ... | @@ -59,7 +52,6 @@ import androidx.annotation.Nullable; |
| 59 | 52 | import androidx.annotation.RequiresApi; |
| 60 | 53 | import androidx.appcompat.app.AppCompatActivity; |
| 61 | 54 | |
| 62 | -import static com.cnlive.media.picker.ui.PickerActivity.REQUEST_CODE_PERMISSION_CAMERA; | |
| 63 | 55 | import static com.cnlive.outside_share.activity.ShareMomentActivity.getFilePathFromURI; |
| 64 | 56 | import static com.cnlive.outside_share.activity.ShareMomentActivity.getPath; |
| 65 | 57 | |
| ... | ... | @@ -78,10 +70,8 @@ public class ShareIMActivity extends AppCompatActivity { |
| 78 | 70 | public static final int VIDEO_MAX_SIZE = 100 * 1024 * 1024; |
| 79 | 71 | //聊天页面图片文件最大100M |
| 80 | 72 | public static final int IMAGE_MAX_SIZE = 25 * 1024 * 1024; |
| 81 | - | |
| 82 | 73 | private File filevideo; |
| 83 | - private Timer timer; | |
| 84 | - private Timer photoTimer; | |
| 74 | + private Timer timer, photoTimer; | |
| 85 | 75 | private SharedPreferences preferences; |
| 86 | 76 | private boolean isQ; |
| 87 | 77 | private String outTyp, action, type; |
| ... | ... | @@ -89,12 +79,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 89 | 79 | private String TEXT = "android.intent.extra.TEXT"; |
| 90 | 80 | private String SUBJECT = "android.intent.extra.SUBJECT"; |
| 91 | 81 | private ArrayList<String> mutil; |
| 92 | - | |
| 93 | - public static void start(Context context, String tag) { | |
| 94 | - Intent intent = new Intent(context, ShareIMActivity.class); | |
| 95 | - intent.putExtra("type", tag); | |
| 96 | - context.startActivity(intent); | |
| 97 | - } | |
| 82 | + private boolean equals; | |
| 98 | 83 | |
| 99 | 84 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) |
| 100 | 85 | @Override |
| ... | ... | @@ -102,6 +87,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 102 | 87 | super.onCreate(savedInstanceState); |
| 103 | 88 | setContentView(R.layout.sharemoment); |
| 104 | 89 | timer = new Timer(); |
| 90 | + photoTimer = new Timer(); | |
| 105 | 91 | type = getIntent().getStringExtra("type"); |
| 106 | 92 | bundle = getIntent().getBundleExtra("bundle"); |
| 107 | 93 | action = getIntent().getStringExtra("action"); |
| ... | ... | @@ -117,11 +103,12 @@ public class ShareIMActivity extends AppCompatActivity { |
| 117 | 103 | protected void onDestroy() { |
| 118 | 104 | super.onDestroy(); |
| 119 | 105 | if (timer != null) timer.cancel(); |
| 120 | - if (photoTimer != null) photoTimer.cancel(); | |
| 121 | 106 | } |
| 122 | 107 | |
| 123 | 108 | @TargetApi(Build.VERSION_CODES.KITKAT) |
| 124 | 109 | public void checkIntent() { |
| 110 | + equals = "shareIM".equals(outTyp); //是否二次登陆 以下所有type均需要判断是否二次登录 | |
| 111 | + preferences = this.getSharedPreferences("OutShare", MODE_PRIVATE); | |
| 125 | 112 | if (bundle != null && action != null) { |
| 126 | 113 | switch (action) { |
| 127 | 114 | case Intent.ACTION_SEND: |
| ... | ... | @@ -137,13 +124,6 @@ public class ShareIMActivity extends AppCompatActivity { |
| 137 | 124 | } |
| 138 | 125 | } |
| 139 | 126 | |
| 140 | - | |
| 141 | - private boolean hasPermission() { | |
| 142 | - return PermissionChecker.checkPermissions(this | |
| 143 | - , new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE} | |
| 144 | - , REQUEST_CODE_PERMISSION_CAMERA, com.cnlive.media.picker.R.string.dialog_imagepicker_permission_share_message); | |
| 145 | - } | |
| 146 | - | |
| 147 | 127 | public static String processUrlData(String shareInfoUrl) { |
| 148 | 128 | Uri uri = Uri.parse(shareInfoUrl); |
| 149 | 129 | String[] urls = shareInfoUrl.split("\\?"); |
| ... | ... | @@ -156,7 +136,6 @@ public class ShareIMActivity extends AppCompatActivity { |
| 156 | 136 | } |
| 157 | 137 | pageUrl = deleteCharOfEnd(pageUrl, "&", true); |
| 158 | 138 | shareInfoUrl = pageUrl.toString(); |
| 159 | - | |
| 160 | 139 | return shareInfoUrl; |
| 161 | 140 | } |
| 162 | 141 | |
| ... | ... | @@ -172,35 +151,30 @@ public class ShareIMActivity extends AppCompatActivity { |
| 172 | 151 | |
| 173 | 152 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) |
| 174 | 153 | private void jumpToSend(Context context, Bundle bundle) { |
| 175 | - preferences = this.getSharedPreferences("OutShare", MODE_PRIVATE); | |
| 176 | - | |
| 177 | - if (type == null) { | |
| 154 | + if (bundle == null || type == null) { | |
| 178 | 155 | AlertUtil.showDeftToast(this, "数据获取异常,暂不支持此机型分享."); |
| 179 | 156 | killTime(); |
| 180 | - } | |
| 181 | - if (type.startsWith("text/")) { | |
| 182 | - //case "text/plain": | |
| 157 | + } else if (type.startsWith("text/")) { | |
| 183 | 158 | String link; |
| 184 | - Uri textUri = "shareIM".equals(outTyp) ? Uri.parse(preferences.getString("extrastream", "")) : bundle.getParcelable(Intent.EXTRA_STREAM); | |
| 159 | + Uri textUri = equals ? Uri.parse(preferences.getString("extrastream", "")) : bundle.getParcelable(Intent.EXTRA_STREAM); | |
| 185 | 160 | sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, textUri)); |
| 186 | 161 | if (textUri == null || TextUtils.isEmpty(textUri.toString())) { |
| 187 | - if ("shareIM".equals(outTyp)) { | |
| 162 | + if (equals) { | |
| 188 | 163 | link = preferences.getString("extratext", ""); |
| 189 | 164 | } else { |
| 190 | - link = bundle == null ? "" : bundle.get(TEXT).toString(); | |
| 165 | + link = bundle.get(TEXT) + ""; | |
| 191 | 166 | } |
| 192 | 167 | if (!TextUtils.isEmpty(link)) { |
| 193 | - if (("shareIM".equals(outTyp) ? preferences.getString("android.intent.extra.SUBJECT", "") : bundle.get("android.intent.extra.SUBJECT")) != null) { | |
| 194 | - if (("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("http") && Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().startsWith("http")) { | |
| 195 | - if (("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("mp.weixin.qq.com")) { | |
| 168 | + if ((equals ? preferences.getString(SUBJECT, "") : bundle.get(SUBJECT)) != null) { | |
| 169 | + if ((equals ? preferences.getString("extratext", "") : (bundle.get(TEXT)) + "").contains("http") && (equals ? preferences.getString("extratext", "") : (bundle.get(TEXT)) + "").startsWith("http")) { | |
| 170 | + if (((equals ? preferences.getString("extratext", "") : bundle.get(TEXT)) + "").contains("mp.weixin.qq.com")) { | |
| 196 | 171 | new Thread(new Runnable() { |
| 197 | - | |
| 198 | 172 | private String srcjs; |
| 199 | 173 | private String h2; |
| 200 | 174 | |
| 201 | 175 | @Override |
| 202 | 176 | public void run() { |
| 203 | - Connection connect = Jsoup.connect(Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString()); | |
| 177 | + Connection connect = Jsoup.connect(Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString()); | |
| 204 | 178 | Document document = null; |
| 205 | 179 | try { |
| 206 | 180 | document = connect.get(); |
| ... | ... | @@ -208,7 +182,6 @@ public class ShareIMActivity extends AppCompatActivity { |
| 208 | 182 | e.printStackTrace(); |
| 209 | 183 | } |
| 210 | 184 | if (document == null) return; |
| 211 | - | |
| 212 | 185 | Elements es_img = document.getElementsByTag("img"); |
| 213 | 186 | if (es_img == null || es_img.size() <= 0) return; |
| 214 | 187 | for (int i = 0; i < es_img.size(); i++) { |
| ... | ... | @@ -225,27 +198,26 @@ public class ShareIMActivity extends AppCompatActivity { |
| 225 | 198 | if (es_h2 != null && es_h2.size() > 0) |
| 226 | 199 | h2 = es_h2.get(0).ownText(); |
| 227 | 200 | if (TextUtils.isEmpty(h2)) h2 = "链接"; |
| 228 | - | |
| 229 | 201 | String rich_media_content = document.getElementsByClass("rich_media_content").get(0).toString(); |
| 230 | 202 | String reg = "[^\u4e00-\u9fa5]"; |
| 231 | 203 | String s = rich_media_content.replaceAll(reg, ""); |
| 232 | 204 | String desc = s.substring(0, Math.min(s.length(), 40)); |
| 233 | - startSelectForwardActivity(context, h2 == null ? Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("android.intent.extra.SUBJECT", "") : bundle.get("android.intent.extra.SUBJECT")).toString() : h2, desc, srcjs == null ? AppConfig.getShareLink() : srcjs, processUrlData(Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString()), TYPE_SHARE_LINK); | |
| 205 | + startSelectForwardActivity(context, h2 == null ? equals ? preferences.getString(SUBJECT, "") : bundle.get(SUBJECT) + "" : h2, desc, srcjs == null ? AppConfig.getShareLink() : srcjs, processUrlData(equals ? preferences.getString("extratext", "") : bundle.get(TEXT) + ""), TYPE_SHARE_LINK); | |
| 234 | 206 | finish(); |
| 235 | 207 | } |
| 236 | 208 | }).start(); |
| 237 | 209 | } else { |
| 238 | - startSelectForwardActivity(context, Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("android.intent.extra.SUBJECT", "") : bundle.get("android.intent.extra.SUBJECT")).toString(), "", AppConfig.getShareLink(), processUrlData(Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString()), TYPE_SHARE_LINK); | |
| 210 | + startSelectForwardActivity(context, equals ? preferences.getString(SUBJECT, "") : bundle.get(SUBJECT) + "", "", AppConfig.getShareLink(), processUrlData(equals ? preferences.getString("extratext", "") : bundle.get(TEXT) + ""), TYPE_SHARE_LINK); | |
| 239 | 211 | finish(); |
| 240 | 212 | } |
| 241 | - } else if (("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("http") && !Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().startsWith("http") && !("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("mp.weixin.qq.com")) { | |
| 242 | - int begin = Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().indexOf("http"); | |
| 243 | - int end = Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().length(); | |
| 213 | + } else if ((equals ? preferences.getString("extratext", "") : bundle.get(TEXT) + "").contains("http") && !Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().startsWith("http") && !(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("mp.weixin.qq.com")) { | |
| 214 | + int begin = Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().indexOf("http"); | |
| 215 | + int end = Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().length(); | |
| 244 | 216 | if (begin > 0 && end > 0) { |
| 245 | - startSelectForwardActivity(context, Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(0, begin), Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(0, begin), AppConfig.getShareLink(), processUrlData(Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(begin, end)), TYPE_SHARE_LINK); | |
| 217 | + startSelectForwardActivity(context, Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(0, begin), Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(0, begin), AppConfig.getShareLink(), processUrlData(Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(begin, end)), TYPE_SHARE_LINK); | |
| 246 | 218 | finish(); |
| 247 | 219 | } |
| 248 | - } else if (("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("http") && !Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().startsWith("http") && ("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("mp.weixin.qq.com")) { | |
| 220 | + } else if ((equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("http") && !Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().startsWith("http") && (equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().contains("mp.weixin.qq.com")) { | |
| 249 | 221 | new Thread(new Runnable() { |
| 250 | 222 | |
| 251 | 223 | private String srcjsoup; |
| ... | ... | @@ -253,9 +225,9 @@ public class ShareIMActivity extends AppCompatActivity { |
| 253 | 225 | |
| 254 | 226 | @Override |
| 255 | 227 | public void run() { |
| 256 | - int begin = Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().indexOf("http"); | |
| 257 | - int end = Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().length(); | |
| 258 | - String substring = Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(begin, end); | |
| 228 | + int begin = Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().indexOf("http"); | |
| 229 | + int end = Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().length(); | |
| 230 | + String substring = Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(begin, end); | |
| 259 | 231 | Connection connect = Jsoup.connect(substring); |
| 260 | 232 | Document document = null; |
| 261 | 233 | try { |
| ... | ... | @@ -288,15 +260,15 @@ public class ShareIMActivity extends AppCompatActivity { |
| 288 | 260 | } |
| 289 | 261 | }).start(); |
| 290 | 262 | } else { |
| 291 | - startSelectForwardActivity(context, ("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)) == null ? ("shareIM".equals(outTyp) ? preferences.getString("android.intent.extra.SUBJECT", "") : bundle.get("android.intent.extra.SUBJECT")).toString() : ("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString(), TYPE_SHARE_TEXT, IN_TYPE_EXT_SHARE); | |
| 263 | + startSelectForwardActivity(context, (equals ? preferences.getString("extratext", "") : bundle.get(TEXT)) == null ? (equals ? preferences.getString(SUBJECT, "") : bundle.get(SUBJECT)).toString() : (equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString(), TYPE_SHARE_TEXT, IN_TYPE_EXT_SHARE); | |
| 292 | 264 | finish(); |
| 293 | 265 | } |
| 294 | 266 | } else { |
| 295 | - if (Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().startsWith("http")) { | |
| 296 | - startSelectForwardActivity(context, "链接", "", AppConfig.getShareLink(), processUrlData(Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString()), TYPE_SHARE_LINK); | |
| 267 | + if (Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().startsWith("http")) { | |
| 268 | + startSelectForwardActivity(context, "链接", "", AppConfig.getShareLink(), processUrlData(Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString()), TYPE_SHARE_LINK); | |
| 297 | 269 | finish(); |
| 298 | 270 | } else { |
| 299 | - String linkcontext = Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().replaceAll("\\s*", ""); | |
| 271 | + String linkcontext = Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().replaceAll("\\s*", ""); | |
| 300 | 272 | int end; |
| 301 | 273 | int begin = linkcontext.indexOf("http"); |
| 302 | 274 | if (linkcontext.contains("(")) { |
| ... | ... | @@ -306,10 +278,10 @@ public class ShareIMActivity extends AppCompatActivity { |
| 306 | 278 | } |
| 307 | 279 | |
| 308 | 280 | if (begin > 0 && end > 0) { |
| 309 | - startSelectForwardActivity(context, Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(0, begin), "", AppConfig.getShareLink(), linkcontext.substring(begin, end), TYPE_SHARE_LINK); | |
| 281 | + startSelectForwardActivity(context, Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString().substring(0, begin), "", AppConfig.getShareLink(), linkcontext.substring(begin, end), TYPE_SHARE_LINK); | |
| 310 | 282 | finish(); |
| 311 | 283 | } else { |
| 312 | - startSelectForwardActivity(context, ("shareIM".equals(outTyp) ? preferences.getString("android.intent.extra.SUBJECT", "") : bundle.get("android.intent.extra.SUBJECT")) == null ? ("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString() : ("shareIM".equals(outTyp) ? preferences.getString("android.intent.extra.SUBJECT", "") : bundle.get("android.intent.extra.SUBJECT")).toString() + " " + ("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString(), TYPE_SHARE_TEXT, IN_TYPE_EXT_SHARE); | |
| 284 | + startSelectForwardActivity(context, (equals ? preferences.getString(SUBJECT, "") : bundle.get(SUBJECT)) == null ? (equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString() : (equals ? preferences.getString(SUBJECT, "") : bundle.get(SUBJECT)).toString() + " " + (equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString(), TYPE_SHARE_TEXT, IN_TYPE_EXT_SHARE); | |
| 313 | 285 | finish(); |
| 314 | 286 | } |
| 315 | 287 | } |
| ... | ... | @@ -320,15 +292,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 320 | 292 | } |
| 321 | 293 | } else { |
| 322 | 294 | if ((textUri + "").contains("file://")) { |
| 323 | - String pathImg = getPath(context, textUri); | |
| 324 | - /* photoTimer.schedule(new TimerTask() { | |
| 325 | - @Override | |
| 326 | - public void run() {*/ | |
| 327 | - | |
| 328 | - | |
| 329 | 295 | Uri mediaUri = MediaStore.Files.getContentUri("external"); |
| 330 | - | |
| 331 | - | |
| 332 | 296 | String[] projection = {MediaStore.Files.FileColumns._ID, |
| 333 | 297 | MediaStore.Files.FileColumns.MIME_TYPE, |
| 334 | 298 | MediaStore.Files.FileColumns.DATA, |
| ... | ... | @@ -429,7 +393,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 429 | 393 | |
| 430 | 394 | String fileType = FileType.getFileType(path); |
| 431 | 395 | |
| 432 | - if (path == null && ("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)) == null) { | |
| 396 | + if (path == null && (equals ? preferences.getString("extratext", "") : bundle.get(TEXT)) == null) { | |
| 433 | 397 | AlertUtil.showDeftToast(context, "该文件路径不存在,无法完成分享."); |
| 434 | 398 | killTime(); |
| 435 | 399 | } else if ("wbmp".equals(fileType)) { |
| ... | ... | @@ -463,7 +427,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 463 | 427 | } else if (path != null && ("jpg".equals(fileType) || "png".equals(fileType) || path.endsWith("png") || path.endsWith("jpg")) && !(imageUri + "").contains("com.tencent.mtt")) { |
| 464 | 428 | startSelectForwardActivity(context, path, TYPE_SHARE_IMAGE, IN_TYPE_EXT_SHARE); |
| 465 | 429 | killTime(); |
| 466 | - } else if (("shareIM".equals(outTyp) ? preferences.getString("extratext", null) : bundle.get(TEXT)) != null && | |
| 430 | + } else if ((equals ? preferences.getString("extratext", null) : bundle.get(TEXT)) != null && | |
| 467 | 431 | bundle.get(TEXT) != null && !(bundle.get(TEXT) + "").contains("http")) { //腾讯文件Android Q |
| 468 | 432 | photoTimer.schedule(new TimerTask() { |
| 469 | 433 | @Override |
| ... | ... | @@ -483,7 +447,6 @@ public class ShareIMActivity extends AppCompatActivity { |
| 483 | 447 | MediaStore.Images.Media.DISPLAY_NAME + "= ?", |
| 484 | 448 | new String[]{pathImg.substring(pathImg.lastIndexOf("/") + 1)}, |
| 485 | 449 | null); |
| 486 | - Log.d("asxsaxaxsax", pathImg); | |
| 487 | 450 | Uri uri = null; |
| 488 | 451 | if (cursor != null && cursor.moveToFirst()) { |
| 489 | 452 | uri = ContentUris.withAppendedId(mediaUri, |
| ... | ... | @@ -496,9 +459,9 @@ public class ShareIMActivity extends AppCompatActivity { |
| 496 | 459 | if (cursor != null) cursor.close(); |
| 497 | 460 | } |
| 498 | 461 | }, 3000); |
| 499 | - } else if (("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)) != null && | |
| 462 | + } else if ((equals ? preferences.getString("extratext", "") : bundle.get(TEXT)) != null && | |
| 500 | 463 | bundle.get(TEXT) != null && (bundle.get(TEXT) + "").contains("http")) { |
| 501 | - String link = Objects.requireNonNull("shareIM".equals(outTyp) ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString(); | |
| 464 | + String link = Objects.requireNonNull(equals ? preferences.getString("extratext", "") : bundle.get(TEXT)).toString(); | |
| 502 | 465 | if (link.contains("http") && !link.startsWith("http")) { |
| 503 | 466 | int begin = link.indexOf("http"); |
| 504 | 467 | int end = link.length(); |
| ... | ... | @@ -513,7 +476,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 513 | 476 | AlertUtil.showDeftToast(this, "网家家暂不支持此类型信息分享."); |
| 514 | 477 | killTime(); |
| 515 | 478 | } else if (String.valueOf(imageUri).startsWith("content://") && !"wbmp".equals(fileType)) { |
| 516 | - if (("shareIM".equals(outTyp))) { | |
| 479 | + if ((equals)) { | |
| 517 | 480 | String chromePath = preferences.getString("chromePath", ""); |
| 518 | 481 | String chromeName = preferences.getString("chromeName", ""); |
| 519 | 482 | long chromeLength = preferences.getLong("chromeLength", 10); |
| ... | ... | @@ -539,9 +502,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 539 | 502 | startSelectForwardActivity(context, pathImg, TYPE_SHARE_FILE, IN_TYPE_EXT_SHARE); |
| 540 | 503 | } |
| 541 | 504 | } |
| 542 | - }/* else { | |
| 543 | - ImArouterUtil.startSelectForwardActivity(context, pathImg, TYPE_SHARE_IMAGE, IN_TYPE_EXT_SHARE); //测试网络环境 | |
| 544 | - }*/ | |
| 505 | + } | |
| 545 | 506 | killTime(); |
| 546 | 507 | } |
| 547 | 508 | } |
| ... | ... | @@ -558,8 +519,6 @@ public class ShareIMActivity extends AppCompatActivity { |
| 558 | 519 | |
| 559 | 520 | String pathImg = getPath(context, videoUri); |
| 560 | 521 | Uri mediaUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; |
| 561 | - | |
| 562 | - | |
| 563 | 522 | String[] projection = {MediaStore.Video.Media._ID, |
| 564 | 523 | MediaStore.Video.Media.DATA, |
| 565 | 524 | MediaStore.Video.Media.DATE_ADDED, |
| ... | ... | @@ -864,7 +823,7 @@ public class ShareIMActivity extends AppCompatActivity { |
| 864 | 823 | killTime(); |
| 865 | 824 | } else { |
| 866 | 825 | if (type.startsWith("image/")) { |
| 867 | - if (("shareIM".equals(outTyp))) { | |
| 826 | + if ((equals)) { | |
| 868 | 827 | String clipDataImg = preferences.getString("clipDataImg", ""); |
| 869 | 828 | Gson gson = new Gson(); |
| 870 | 829 | Type listType = new TypeToken<List<String>>() { |
| ... | ... | @@ -929,28 +888,6 @@ public class ShareIMActivity extends AppCompatActivity { |
| 929 | 888 | int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); |
| 930 | 889 | actualimagecursor.moveToFirst(); |
| 931 | 890 | String img_path = actualimagecursor.getString(actual_image_column_index); |
| 932 | - // File file = new File(img_path); | |
| 933 | - // Uri fileUri = Uri.fromFile(file); | |
| 934 | 891 | return img_path; |
| 935 | 892 | } |
| 936 | - | |
| 937 | - | |
| 938 | - public static void settingPermissionActivity(Activity activity, int CODE_REQUEST_CAMERA_PERMISSIONS) { | |
| 939 | - //判断是否为小米系统 | |
| 940 | - if (TextUtils.equals(BrandUtils.getSystemInfo().getOs(), BrandUtils.SYS_MIUI)) { | |
| 941 | - Intent miuiIntent = new Intent("miui.intent.action.APP_PERM_EDITOR"); | |
| 942 | - miuiIntent.putExtra("extra_pkgname", activity.getPackageName()); | |
| 943 | - //检测是否有能接受该Intent的Activity存在 | |
| 944 | - List<ResolveInfo> resolveInfos = activity.getPackageManager().queryIntentActivities(miuiIntent, PackageManager.MATCH_DEFAULT_ONLY); | |
| 945 | - if (resolveInfos.size() > 0) { | |
| 946 | - activity.startActivityForResult(miuiIntent, CODE_REQUEST_CAMERA_PERMISSIONS); | |
| 947 | - return; | |
| 948 | - } | |
| 949 | - } | |
| 950 | - //如果不是小米系统 则打开Android系统的应用设置页 | |
| 951 | - Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
| 952 | - Uri uri = Uri.fromParts("package", activity.getPackageName(), null); | |
| 953 | - intent.setData(uri); | |
| 954 | - activity.startActivityForResult(intent, CODE_REQUEST_CAMERA_PERMISSIONS); | |
| 955 | - } | |
| 956 | 893 | } | ... | ... |
OutSide_Share/src/main/java/com/cnlive/outside_share/activity/ShareMomentActivity.java
| ... | ... | @@ -90,6 +90,8 @@ public class ShareMomentActivity extends AppCompatActivity { |
| 90 | 90 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) |
| 91 | 91 | public void checkIntent() { |
| 92 | 92 | equals = "shareMom".equals(outTyp); ////是否二次登陆 以下所有type均需要判断是否二次登录 |
| 93 | + preferences = this.getSharedPreferences("OutShare", MODE_PRIVATE); //IM重连前存储信息 | |
| 94 | + | |
| 93 | 95 | if (bundle != null && action != null) { |
| 94 | 96 | switch (action) { |
| 95 | 97 | case Intent.ACTION_SEND: |
| ... | ... | @@ -107,7 +109,6 @@ public class ShareMomentActivity extends AppCompatActivity { |
| 107 | 109 | |
| 108 | 110 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) //单发 |
| 109 | 111 | private void jumpToSend(Context context, String type, Bundle bundle) { |
| 110 | - preferences = this.getSharedPreferences("OutShare", MODE_PRIVATE); //IM重连前存储信息 | |
| 111 | 112 | File filelogo = new File(getPath("/strike/cache/") + "sharefirst.jpg"); |
| 112 | 113 | if (!filelogo.exists()) { |
| 113 | 114 | new Thread() { | ... | ... |