From efa4c25c4b381b8471df7d3002bce83ebb750721 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 17 Jul 2024 12:11:41 +0800 Subject: [PATCH 1/2] update --- .../common/dialog/GiftWallGiftInfoDialog.java | 6 +- .../main/activity/ZhuangBanActivity.java | 103 ++++++++++++++++-- .../yunbao/main/views/TestWebViewClient.java | 1 + 3 files changed, 99 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/dialog/GiftWallGiftInfoDialog.java b/common/src/main/java/com/yunbao/common/dialog/GiftWallGiftInfoDialog.java index 67cbc7d56..6fd3d9b83 100644 --- a/common/src/main/java/com/yunbao/common/dialog/GiftWallGiftInfoDialog.java +++ b/common/src/main/java/com/yunbao/common/dialog/GiftWallGiftInfoDialog.java @@ -186,8 +186,8 @@ public class GiftWallGiftInfoDialog extends AbsDialogPopupWindow { tab2.setTextColor(Color.parseColor("#FFFFFF")); list_type = 1; - ((TextView) findViewById(R.id.user_name)).setText(WordUtil.getNewString(R.string.dialog_gift_wall_list_info_list_header_rename1)); - ((TextView) findViewById(R.id.tv_rename)).setText(WordUtil.getNewString(R.string.dialog_gift_wall_list_info_list_header_rename_value1)); + ((TextView) findViewById(R.id.user_name)).setText(WordUtil.getNewString(R.string.dialog_gift_wall_assistance_user)); + ((TextView) findViewById(R.id.tv_rename)).setText(WordUtil.getNewString(R.string.dialog_gift_wall_assistance_star)); initData(); }); ViewClicksAntiShake.clicksAntiShake(tab2, () -> { @@ -356,7 +356,7 @@ public class GiftWallGiftInfoDialog extends AbsDialogPopupWindow { private void setTips(String tmp) { btn_one_tips.setText(String.format(Locale.getDefault(), "%s%s%s" - , WordUtil.isNewZh() ? "需" : "Need", + , WordUtil.isNewZh() ? "需 " : "Need ", tmp, WordUtil.isNewZh() ? "" : "")); } diff --git a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java index 8da5b78d7..2ba4d85f6 100644 --- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java @@ -1,10 +1,13 @@ package com.yunbao.main.activity; +import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.graphics.Color; import android.net.Uri; import android.os.Build; @@ -62,6 +65,8 @@ import org.greenrobot.eventbus.ThreadMode; import java.net.MalformedURLException; import java.net.URL; +import java.util.Arrays; +import java.util.List; import java.util.Locale; @Route(path = RouteUtil.PATH_ZHUANGBANACTIVITY) @@ -76,13 +81,14 @@ public class ZhuangBanActivity extends AbsActivity { private SVGAImageView svga; private View v_spacing; private LinearLayout lt_title; - + private List HTTP_SCHEMES = Arrays.asList("http", "https"); @Override public void setStatusBar() { // getWindow().setStatusBarColor(Color.parseColor("#FFFFFF")); // getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); } + @Override protected int getLayoutId() { return R.layout.activity_zhuang_ban; @@ -131,6 +137,8 @@ public class ZhuangBanActivity extends AbsActivity { if (!TextUtils.isEmpty(content)) { copy(content); } + } else if (shouldOverrideUrlLoadingInner(view, url)) { + return true; } else { view.loadUrl(url); } @@ -204,7 +212,7 @@ public class ZhuangBanActivity extends AbsActivity { } mWebView.loadUrl(url); AndroidBug5497Workaround.assistActivity(this); - if(!StringUtil.isEmpty(url)&&url.startsWith(HtmlConfig.SHOP)){ + if (!StringUtil.isEmpty(url) && url.startsWith(HtmlConfig.SHOP)) { lt_title.setVisibility(View.GONE); } } @@ -296,16 +304,16 @@ public class ZhuangBanActivity extends AbsActivity { public static void forward(Context context, String url, boolean addArgs) { if (addArgs) { if (url.contains("?")) { - url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"); + url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"); } else { - url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"); + url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"); } } Intent intent = new Intent(context, ZhuangBanActivity.class); Log.i("tag1212", url); intent.putExtra(Constants.URL, url + "&isZh=" + ((IMLoginManager.get(CommonAppContext.sInstance.getBaseContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); - if (url.contains("Noble/index.html") || url.contains("Grade/index.html")|| url.contains("Guard/index.html")) { + if (url.contains("Noble/index.html") || url.contains("Grade/index.html") || url.contains("Guard/index.html")) { intent.putExtra("title", ""); } context.startActivity(intent); @@ -404,7 +412,7 @@ public class ZhuangBanActivity extends AbsActivity { LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { @Override - public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) { + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) { if (liveBean == null) { return; } @@ -413,7 +421,7 @@ public class ZhuangBanActivity extends AbsActivity { return; } - RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw); + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk), isSw); finish(); } @@ -431,5 +439,84 @@ public class ZhuangBanActivity extends AbsActivity { }); } - + /** + * Parse the url and open it by system function. + * case 1: deal "intent://xxxx" url. + * case 2: deal custom scheme. url + * @param view: WebView + * @param url + * @return + */ + private boolean shouldOverrideUrlLoadingInner(WebView view, String url) { + if(!TextUtils.isEmpty(url)) { + Uri uri = Uri.parse(url); + if(uri != null) { + if ("intent".equals(uri.getScheme())) { + try { + Intent intent = Intent.parseUri(uri.toString(), Intent.URI_INTENT_SCHEME); + if(intent != null) { + PackageManager pm = mContext.getPackageManager(); + ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); + if(info != null) { + mContext.startActivity(Intent.parseUri(uri.toString(), Intent.URI_INTENT_SCHEME)); + return true; + } + else { + String fallbackUrl = intent.getStringExtra("browser_fallback_url"); + if (!TextUtils.isEmpty(fallbackUrl)) { + if(fallbackUrl.startsWith("market://")) + startAppMarketWithUrl(mContext, fallbackUrl, false); + else + view.loadUrl(fallbackUrl); + return true; + }else{ + mContext.startActivity(new Intent(Intent.ACTION_VIEW, uri)); + } + } + } + } catch (Exception e) { + } + } + if (!HTTP_SCHEMES.contains(uri.getScheme())) { + startUrl(mContext, url, true); + return true; + } + } + } + return false; + } + public static void startAppMarketWithUrl(Activity context, String url, boolean forceUseGoogle) { + try { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + if (forceUseGoogle || hasActivity(context, intent, "com.android.vending")) + intent.setPackage("com.android.vending"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } catch (Exception e) { + try { + startUrl(context, url, true); + } catch (Exception e1) {} + } + } + public static boolean hasActivity(Context context, Intent intent, String packageName) { + PackageManager pm = context.getPackageManager(); + List appList = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); + for (ResolveInfo info : appList) { + if (info.activityInfo.packageName.equals(packageName)) + return true; + } + return false; + } + public static void startUrl(Context context, String url, boolean isNewTask) { + if(context != null && !TextUtils.isEmpty(url)) { + try { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + if(isNewTask) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + } + context.startActivity(intent); + } catch (Exception e) { + } + } + } } diff --git a/main/src/main/java/com/yunbao/main/views/TestWebViewClient.java b/main/src/main/java/com/yunbao/main/views/TestWebViewClient.java index 858b0d253..8aace0418 100644 --- a/main/src/main/java/com/yunbao/main/views/TestWebViewClient.java +++ b/main/src/main/java/com/yunbao/main/views/TestWebViewClient.java @@ -29,6 +29,7 @@ public class TestWebViewClient extends WebViewClient { Log.d(TAG, "shouldOverrideUrlLoading url1=" + url); if(url.contains("umobile-redirect")) { openByBrowser(mContext, url); + return true; } if(shouldOverrideUrlLoadingInner(view, url)) { From 714e51b62109ca1477ce7d305efb2c0b24f51571 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 17 Jul 2024 12:12:14 +0800 Subject: [PATCH 2/2] update --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0c4e14aba..dbba0fd39 100644 --- a/build.gradle +++ b/build.gradle @@ -56,7 +56,7 @@ allprojects { ext { IS_PUBLISH_LOCAL=true LIB_VERSION="1.0.6" - AGORA_RTC_SDK= 'io.agora.rtc:agora-special-full:4.2.6.12' + AGORA_RTC_SDK= 'io.agora.rtc:agora-special-full:4.2.6.14' // AGORA_RTC_SDK= "${rootProject.rootDir.absolutePath}/sdk" // AGORA_RTC_SDK="io.agora.rtc:full-sdk:4.2.6" }