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 | package com.cnlive.outside_share.activity; | 1 | package com.cnlive.outside_share.activity; |
| 2 | 2 | ||
| 3 | -import android.Manifest; | ||
| 4 | import android.annotation.TargetApi; | 3 | import android.annotation.TargetApi; |
| 5 | -import android.app.Activity; | ||
| 6 | import android.content.ContentUris; | 4 | import android.content.ContentUris; |
| 7 | import android.content.Context; | 5 | import android.content.Context; |
| 8 | import android.content.Intent; | 6 | import android.content.Intent; |
| 9 | import android.content.SharedPreferences; | 7 | import android.content.SharedPreferences; |
| 10 | -import android.content.pm.PackageManager; | ||
| 11 | -import android.content.pm.ResolveInfo; | ||
| 12 | import android.database.Cursor; | 8 | import android.database.Cursor; |
| 13 | import android.media.MediaPlayer; | 9 | import android.media.MediaPlayer; |
| 14 | import android.net.Uri; | 10 | import android.net.Uri; |
| @@ -16,7 +12,6 @@ import android.os.Build; | @@ -16,7 +12,6 @@ import android.os.Build; | ||
| 16 | import android.os.Bundle; | 12 | import android.os.Bundle; |
| 17 | import android.os.Environment; | 13 | import android.os.Environment; |
| 18 | import android.provider.MediaStore; | 14 | import android.provider.MediaStore; |
| 19 | -import android.provider.Settings; | ||
| 20 | import android.text.TextUtils; | 15 | import android.text.TextUtils; |
| 21 | import android.util.Log; | 16 | import android.util.Log; |
| 22 | 17 | ||
| @@ -28,8 +23,6 @@ import com.cnlive.libs.base.util.MD5Util; | @@ -28,8 +23,6 @@ import com.cnlive.libs.base.util.MD5Util; | ||
| 28 | import com.cnlive.libs.base.util.StringUtils; | 23 | import com.cnlive.libs.base.util.StringUtils; |
| 29 | import com.cnlive.libs.data.network.util.UriUtil; | 24 | import com.cnlive.libs.data.network.util.UriUtil; |
| 30 | import com.cnlive.media.picker.utils.AndroidQUtil; | 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 | import com.cnlive.outside_share.R; | 26 | import com.cnlive.outside_share.R; |
| 34 | import com.cnlive.outside_share.util.FileType; | 27 | import com.cnlive.outside_share.util.FileType; |
| 35 | import com.cnlive.outside_share.util.FileUtil; | 28 | import com.cnlive.outside_share.util.FileUtil; |
| @@ -59,7 +52,6 @@ import androidx.annotation.Nullable; | @@ -59,7 +52,6 @@ import androidx.annotation.Nullable; | ||
| 59 | import androidx.annotation.RequiresApi; | 52 | import androidx.annotation.RequiresApi; |
| 60 | import androidx.appcompat.app.AppCompatActivity; | 53 | import androidx.appcompat.app.AppCompatActivity; |
| 61 | 54 | ||
| 62 | -import static com.cnlive.media.picker.ui.PickerActivity.REQUEST_CODE_PERMISSION_CAMERA; | ||
| 63 | import static com.cnlive.outside_share.activity.ShareMomentActivity.getFilePathFromURI; | 55 | import static com.cnlive.outside_share.activity.ShareMomentActivity.getFilePathFromURI; |
| 64 | import static com.cnlive.outside_share.activity.ShareMomentActivity.getPath; | 56 | import static com.cnlive.outside_share.activity.ShareMomentActivity.getPath; |
| 65 | 57 | ||
| @@ -78,10 +70,8 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -78,10 +70,8 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 78 | public static final int VIDEO_MAX_SIZE = 100 * 1024 * 1024; | 70 | public static final int VIDEO_MAX_SIZE = 100 * 1024 * 1024; |
| 79 | //聊天页面图片文件最大100M | 71 | //聊天页面图片文件最大100M |
| 80 | public static final int IMAGE_MAX_SIZE = 25 * 1024 * 1024; | 72 | public static final int IMAGE_MAX_SIZE = 25 * 1024 * 1024; |
| 81 | - | ||
| 82 | private File filevideo; | 73 | private File filevideo; |
| 83 | - private Timer timer; | ||
| 84 | - private Timer photoTimer; | 74 | + private Timer timer, photoTimer; |
| 85 | private SharedPreferences preferences; | 75 | private SharedPreferences preferences; |
| 86 | private boolean isQ; | 76 | private boolean isQ; |
| 87 | private String outTyp, action, type; | 77 | private String outTyp, action, type; |
| @@ -89,12 +79,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -89,12 +79,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 89 | private String TEXT = "android.intent.extra.TEXT"; | 79 | private String TEXT = "android.intent.extra.TEXT"; |
| 90 | private String SUBJECT = "android.intent.extra.SUBJECT"; | 80 | private String SUBJECT = "android.intent.extra.SUBJECT"; |
| 91 | private ArrayList<String> mutil; | 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 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) | 84 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) |
| 100 | @Override | 85 | @Override |
| @@ -102,6 +87,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -102,6 +87,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 102 | super.onCreate(savedInstanceState); | 87 | super.onCreate(savedInstanceState); |
| 103 | setContentView(R.layout.sharemoment); | 88 | setContentView(R.layout.sharemoment); |
| 104 | timer = new Timer(); | 89 | timer = new Timer(); |
| 90 | + photoTimer = new Timer(); | ||
| 105 | type = getIntent().getStringExtra("type"); | 91 | type = getIntent().getStringExtra("type"); |
| 106 | bundle = getIntent().getBundleExtra("bundle"); | 92 | bundle = getIntent().getBundleExtra("bundle"); |
| 107 | action = getIntent().getStringExtra("action"); | 93 | action = getIntent().getStringExtra("action"); |
| @@ -117,11 +103,12 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -117,11 +103,12 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 117 | protected void onDestroy() { | 103 | protected void onDestroy() { |
| 118 | super.onDestroy(); | 104 | super.onDestroy(); |
| 119 | if (timer != null) timer.cancel(); | 105 | if (timer != null) timer.cancel(); |
| 120 | - if (photoTimer != null) photoTimer.cancel(); | ||
| 121 | } | 106 | } |
| 122 | 107 | ||
| 123 | @TargetApi(Build.VERSION_CODES.KITKAT) | 108 | @TargetApi(Build.VERSION_CODES.KITKAT) |
| 124 | public void checkIntent() { | 109 | public void checkIntent() { |
| 110 | + equals = "shareIM".equals(outTyp); //是否二次登陆 以下所有type均需要判断是否二次登录 | ||
| 111 | + preferences = this.getSharedPreferences("OutShare", MODE_PRIVATE); | ||
| 125 | if (bundle != null && action != null) { | 112 | if (bundle != null && action != null) { |
| 126 | switch (action) { | 113 | switch (action) { |
| 127 | case Intent.ACTION_SEND: | 114 | case Intent.ACTION_SEND: |
| @@ -137,13 +124,6 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -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 | public static String processUrlData(String shareInfoUrl) { | 127 | public static String processUrlData(String shareInfoUrl) { |
| 148 | Uri uri = Uri.parse(shareInfoUrl); | 128 | Uri uri = Uri.parse(shareInfoUrl); |
| 149 | String[] urls = shareInfoUrl.split("\\?"); | 129 | String[] urls = shareInfoUrl.split("\\?"); |
| @@ -156,7 +136,6 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -156,7 +136,6 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 156 | } | 136 | } |
| 157 | pageUrl = deleteCharOfEnd(pageUrl, "&", true); | 137 | pageUrl = deleteCharOfEnd(pageUrl, "&", true); |
| 158 | shareInfoUrl = pageUrl.toString(); | 138 | shareInfoUrl = pageUrl.toString(); |
| 159 | - | ||
| 160 | return shareInfoUrl; | 139 | return shareInfoUrl; |
| 161 | } | 140 | } |
| 162 | 141 | ||
| @@ -172,35 +151,30 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -172,35 +151,30 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 172 | 151 | ||
| 173 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) | 152 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) |
| 174 | private void jumpToSend(Context context, Bundle bundle) { | 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 | AlertUtil.showDeftToast(this, "数据获取异常,暂不支持此机型分享."); | 155 | AlertUtil.showDeftToast(this, "数据获取异常,暂不支持此机型分享."); |
| 179 | killTime(); | 156 | killTime(); |
| 180 | - } | ||
| 181 | - if (type.startsWith("text/")) { | ||
| 182 | - //case "text/plain": | 157 | + } else if (type.startsWith("text/")) { |
| 183 | String link; | 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 | sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, textUri)); | 160 | sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, textUri)); |
| 186 | if (textUri == null || TextUtils.isEmpty(textUri.toString())) { | 161 | if (textUri == null || TextUtils.isEmpty(textUri.toString())) { |
| 187 | - if ("shareIM".equals(outTyp)) { | 162 | + if (equals) { |
| 188 | link = preferences.getString("extratext", ""); | 163 | link = preferences.getString("extratext", ""); |
| 189 | } else { | 164 | } else { |
| 190 | - link = bundle == null ? "" : bundle.get(TEXT).toString(); | 165 | + link = bundle.get(TEXT) + ""; |
| 191 | } | 166 | } |
| 192 | if (!TextUtils.isEmpty(link)) { | 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 | new Thread(new Runnable() { | 171 | new Thread(new Runnable() { |
| 197 | - | ||
| 198 | private String srcjs; | 172 | private String srcjs; |
| 199 | private String h2; | 173 | private String h2; |
| 200 | 174 | ||
| 201 | @Override | 175 | @Override |
| 202 | public void run() { | 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 | Document document = null; | 178 | Document document = null; |
| 205 | try { | 179 | try { |
| 206 | document = connect.get(); | 180 | document = connect.get(); |
| @@ -208,7 +182,6 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -208,7 +182,6 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 208 | e.printStackTrace(); | 182 | e.printStackTrace(); |
| 209 | } | 183 | } |
| 210 | if (document == null) return; | 184 | if (document == null) return; |
| 211 | - | ||
| 212 | Elements es_img = document.getElementsByTag("img"); | 185 | Elements es_img = document.getElementsByTag("img"); |
| 213 | if (es_img == null || es_img.size() <= 0) return; | 186 | if (es_img == null || es_img.size() <= 0) return; |
| 214 | for (int i = 0; i < es_img.size(); i++) { | 187 | for (int i = 0; i < es_img.size(); i++) { |
| @@ -225,27 +198,26 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -225,27 +198,26 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 225 | if (es_h2 != null && es_h2.size() > 0) | 198 | if (es_h2 != null && es_h2.size() > 0) |
| 226 | h2 = es_h2.get(0).ownText(); | 199 | h2 = es_h2.get(0).ownText(); |
| 227 | if (TextUtils.isEmpty(h2)) h2 = "链接"; | 200 | if (TextUtils.isEmpty(h2)) h2 = "链接"; |
| 228 | - | ||
| 229 | String rich_media_content = document.getElementsByClass("rich_media_content").get(0).toString(); | 201 | String rich_media_content = document.getElementsByClass("rich_media_content").get(0).toString(); |
| 230 | String reg = "[^\u4e00-\u9fa5]"; | 202 | String reg = "[^\u4e00-\u9fa5]"; |
| 231 | String s = rich_media_content.replaceAll(reg, ""); | 203 | String s = rich_media_content.replaceAll(reg, ""); |
| 232 | String desc = s.substring(0, Math.min(s.length(), 40)); | 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 | finish(); | 206 | finish(); |
| 235 | } | 207 | } |
| 236 | }).start(); | 208 | }).start(); |
| 237 | } else { | 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 | finish(); | 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 | if (begin > 0 && end > 0) { | 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 | finish(); | 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 | new Thread(new Runnable() { | 221 | new Thread(new Runnable() { |
| 250 | 222 | ||
| 251 | private String srcjsoup; | 223 | private String srcjsoup; |
| @@ -253,9 +225,9 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -253,9 +225,9 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 253 | 225 | ||
| 254 | @Override | 226 | @Override |
| 255 | public void run() { | 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 | Connection connect = Jsoup.connect(substring); | 231 | Connection connect = Jsoup.connect(substring); |
| 260 | Document document = null; | 232 | Document document = null; |
| 261 | try { | 233 | try { |
| @@ -288,15 +260,15 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -288,15 +260,15 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 288 | } | 260 | } |
| 289 | }).start(); | 261 | }).start(); |
| 290 | } else { | 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 | finish(); | 264 | finish(); |
| 293 | } | 265 | } |
| 294 | } else { | 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 | finish(); | 269 | finish(); |
| 298 | } else { | 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 | int end; | 272 | int end; |
| 301 | int begin = linkcontext.indexOf("http"); | 273 | int begin = linkcontext.indexOf("http"); |
| 302 | if (linkcontext.contains("(")) { | 274 | if (linkcontext.contains("(")) { |
| @@ -306,10 +278,10 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -306,10 +278,10 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 306 | } | 278 | } |
| 307 | 279 | ||
| 308 | if (begin > 0 && end > 0) { | 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 | finish(); | 282 | finish(); |
| 311 | } else { | 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 | finish(); | 285 | finish(); |
| 314 | } | 286 | } |
| 315 | } | 287 | } |
| @@ -320,15 +292,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -320,15 +292,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 320 | } | 292 | } |
| 321 | } else { | 293 | } else { |
| 322 | if ((textUri + "").contains("file://")) { | 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 | Uri mediaUri = MediaStore.Files.getContentUri("external"); | 295 | Uri mediaUri = MediaStore.Files.getContentUri("external"); |
| 330 | - | ||
| 331 | - | ||
| 332 | String[] projection = {MediaStore.Files.FileColumns._ID, | 296 | String[] projection = {MediaStore.Files.FileColumns._ID, |
| 333 | MediaStore.Files.FileColumns.MIME_TYPE, | 297 | MediaStore.Files.FileColumns.MIME_TYPE, |
| 334 | MediaStore.Files.FileColumns.DATA, | 298 | MediaStore.Files.FileColumns.DATA, |
| @@ -429,7 +393,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -429,7 +393,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 429 | 393 | ||
| 430 | String fileType = FileType.getFileType(path); | 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 | AlertUtil.showDeftToast(context, "该文件路径不存在,无法完成分享."); | 397 | AlertUtil.showDeftToast(context, "该文件路径不存在,无法完成分享."); |
| 434 | killTime(); | 398 | killTime(); |
| 435 | } else if ("wbmp".equals(fileType)) { | 399 | } else if ("wbmp".equals(fileType)) { |
| @@ -463,7 +427,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -463,7 +427,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 463 | } else if (path != null && ("jpg".equals(fileType) || "png".equals(fileType) || path.endsWith("png") || path.endsWith("jpg")) && !(imageUri + "").contains("com.tencent.mtt")) { | 427 | } else if (path != null && ("jpg".equals(fileType) || "png".equals(fileType) || path.endsWith("png") || path.endsWith("jpg")) && !(imageUri + "").contains("com.tencent.mtt")) { |
| 464 | startSelectForwardActivity(context, path, TYPE_SHARE_IMAGE, IN_TYPE_EXT_SHARE); | 428 | startSelectForwardActivity(context, path, TYPE_SHARE_IMAGE, IN_TYPE_EXT_SHARE); |
| 465 | killTime(); | 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 | bundle.get(TEXT) != null && !(bundle.get(TEXT) + "").contains("http")) { //腾讯文件Android Q | 431 | bundle.get(TEXT) != null && !(bundle.get(TEXT) + "").contains("http")) { //腾讯文件Android Q |
| 468 | photoTimer.schedule(new TimerTask() { | 432 | photoTimer.schedule(new TimerTask() { |
| 469 | @Override | 433 | @Override |
| @@ -483,7 +447,6 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -483,7 +447,6 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 483 | MediaStore.Images.Media.DISPLAY_NAME + "= ?", | 447 | MediaStore.Images.Media.DISPLAY_NAME + "= ?", |
| 484 | new String[]{pathImg.substring(pathImg.lastIndexOf("/") + 1)}, | 448 | new String[]{pathImg.substring(pathImg.lastIndexOf("/") + 1)}, |
| 485 | null); | 449 | null); |
| 486 | - Log.d("asxsaxaxsax", pathImg); | ||
| 487 | Uri uri = null; | 450 | Uri uri = null; |
| 488 | if (cursor != null && cursor.moveToFirst()) { | 451 | if (cursor != null && cursor.moveToFirst()) { |
| 489 | uri = ContentUris.withAppendedId(mediaUri, | 452 | uri = ContentUris.withAppendedId(mediaUri, |
| @@ -496,9 +459,9 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -496,9 +459,9 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 496 | if (cursor != null) cursor.close(); | 459 | if (cursor != null) cursor.close(); |
| 497 | } | 460 | } |
| 498 | }, 3000); | 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 | bundle.get(TEXT) != null && (bundle.get(TEXT) + "").contains("http")) { | 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 | if (link.contains("http") && !link.startsWith("http")) { | 465 | if (link.contains("http") && !link.startsWith("http")) { |
| 503 | int begin = link.indexOf("http"); | 466 | int begin = link.indexOf("http"); |
| 504 | int end = link.length(); | 467 | int end = link.length(); |
| @@ -513,7 +476,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -513,7 +476,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 513 | AlertUtil.showDeftToast(this, "网家家暂不支持此类型信息分享."); | 476 | AlertUtil.showDeftToast(this, "网家家暂不支持此类型信息分享."); |
| 514 | killTime(); | 477 | killTime(); |
| 515 | } else if (String.valueOf(imageUri).startsWith("content://") && !"wbmp".equals(fileType)) { | 478 | } else if (String.valueOf(imageUri).startsWith("content://") && !"wbmp".equals(fileType)) { |
| 516 | - if (("shareIM".equals(outTyp))) { | 479 | + if ((equals)) { |
| 517 | String chromePath = preferences.getString("chromePath", ""); | 480 | String chromePath = preferences.getString("chromePath", ""); |
| 518 | String chromeName = preferences.getString("chromeName", ""); | 481 | String chromeName = preferences.getString("chromeName", ""); |
| 519 | long chromeLength = preferences.getLong("chromeLength", 10); | 482 | long chromeLength = preferences.getLong("chromeLength", 10); |
| @@ -539,9 +502,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -539,9 +502,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 539 | startSelectForwardActivity(context, pathImg, TYPE_SHARE_FILE, IN_TYPE_EXT_SHARE); | 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 | killTime(); | 506 | killTime(); |
| 546 | } | 507 | } |
| 547 | } | 508 | } |
| @@ -558,8 +519,6 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -558,8 +519,6 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 558 | 519 | ||
| 559 | String pathImg = getPath(context, videoUri); | 520 | String pathImg = getPath(context, videoUri); |
| 560 | Uri mediaUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; | 521 | Uri mediaUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; |
| 561 | - | ||
| 562 | - | ||
| 563 | String[] projection = {MediaStore.Video.Media._ID, | 522 | String[] projection = {MediaStore.Video.Media._ID, |
| 564 | MediaStore.Video.Media.DATA, | 523 | MediaStore.Video.Media.DATA, |
| 565 | MediaStore.Video.Media.DATE_ADDED, | 524 | MediaStore.Video.Media.DATE_ADDED, |
| @@ -864,7 +823,7 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -864,7 +823,7 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 864 | killTime(); | 823 | killTime(); |
| 865 | } else { | 824 | } else { |
| 866 | if (type.startsWith("image/")) { | 825 | if (type.startsWith("image/")) { |
| 867 | - if (("shareIM".equals(outTyp))) { | 826 | + if ((equals)) { |
| 868 | String clipDataImg = preferences.getString("clipDataImg", ""); | 827 | String clipDataImg = preferences.getString("clipDataImg", ""); |
| 869 | Gson gson = new Gson(); | 828 | Gson gson = new Gson(); |
| 870 | Type listType = new TypeToken<List<String>>() { | 829 | Type listType = new TypeToken<List<String>>() { |
| @@ -929,28 +888,6 @@ public class ShareIMActivity extends AppCompatActivity { | @@ -929,28 +888,6 @@ public class ShareIMActivity extends AppCompatActivity { | ||
| 929 | int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); | 888 | int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); |
| 930 | actualimagecursor.moveToFirst(); | 889 | actualimagecursor.moveToFirst(); |
| 931 | String img_path = actualimagecursor.getString(actual_image_column_index); | 890 | String img_path = actualimagecursor.getString(actual_image_column_index); |
| 932 | - // File file = new File(img_path); | ||
| 933 | - // Uri fileUri = Uri.fromFile(file); | ||
| 934 | return img_path; | 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,6 +90,8 @@ public class ShareMomentActivity extends AppCompatActivity { | ||
| 90 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) | 90 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) |
| 91 | public void checkIntent() { | 91 | public void checkIntent() { |
| 92 | equals = "shareMom".equals(outTyp); ////是否二次登陆 以下所有type均需要判断是否二次登录 | 92 | equals = "shareMom".equals(outTyp); ////是否二次登陆 以下所有type均需要判断是否二次登录 |
| 93 | + preferences = this.getSharedPreferences("OutShare", MODE_PRIVATE); //IM重连前存储信息 | ||
| 94 | + | ||
| 93 | if (bundle != null && action != null) { | 95 | if (bundle != null && action != null) { |
| 94 | switch (action) { | 96 | switch (action) { |
| 95 | case Intent.ACTION_SEND: | 97 | case Intent.ACTION_SEND: |
| @@ -107,7 +109,6 @@ public class ShareMomentActivity extends AppCompatActivity { | @@ -107,7 +109,6 @@ public class ShareMomentActivity extends AppCompatActivity { | ||
| 107 | 109 | ||
| 108 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) //单发 | 110 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) //单发 |
| 109 | private void jumpToSend(Context context, String type, Bundle bundle) { | 111 | private void jumpToSend(Context context, String type, Bundle bundle) { |
| 110 | - preferences = this.getSharedPreferences("OutShare", MODE_PRIVATE); //IM重连前存储信息 | ||
| 111 | File filelogo = new File(getPath("/strike/cache/") + "sharefirst.jpg"); | 112 | File filelogo = new File(getPath("/strike/cache/") + "sharefirst.jpg"); |
| 112 | if (!filelogo.exists()) { | 113 | if (!filelogo.exists()) { |
| 113 | new Thread() { | 114 | new Thread() { |