修复外部应用传入view action时的处理方法Bug
This commit is contained in:
parent
641098f8fb
commit
c04be60b13
@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed Jun 11 13:59:15 HKT 2025
|
||||
#Wed Jun 11 18:41:20 GMT 2025
|
||||
stageCount=5
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.4
|
||||
buildCount=0
|
||||
buildCount=17
|
||||
baseBetaVersion=15.0.5
|
||||
|
@ -9,6 +9,7 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.ValueCallback;
|
||||
@ -18,13 +19,13 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.activities.AboutActivity;
|
||||
import cc.winboll.studio.webpagesources.fragment.SourcesFragment;
|
||||
import cc.winboll.studio.webpagesources.fragment.WebFragment;
|
||||
import cc.winboll.studio.webpagesources.view.StatusBarView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
@ -57,7 +58,7 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
||||
FragmentTransaction ft = ((FragmentManager)getSupportFragmentManager()).beginTransaction();
|
||||
mSourcesFragment = new SourcesFragment();
|
||||
ft.add(R.id.activitymainFrameLayout1, mSourcesFragment, SourcesFragment.TAG);
|
||||
@ -67,24 +68,23 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
ft.add(R.id.activitymainFrameLayout1, mWebFragment, WebFragment.TAG);
|
||||
ft.show(mWebFragment);
|
||||
ft.commit();
|
||||
|
||||
// 处理 onCreate 时的 Intent
|
||||
handleIntent(getIntent());
|
||||
|
||||
|
||||
mStatusBarView = findViewById(R.id.activitymainStatusBarView1);
|
||||
_MainActivity = this;
|
||||
postStatusBarMessage("主窗口加载完成。");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
// 处理 onNewIntent 时的 Intent(Activity 已存在时调用)
|
||||
handleIntent(intent);
|
||||
//ToastUtils.show("Start");
|
||||
}
|
||||
|
||||
private void handleIntent(Intent intent) {
|
||||
// @Override
|
||||
// protected void onNewIntent(Intent intent) {
|
||||
// super.onNewIntent(intent);
|
||||
// // 处理 onNewIntent 时的 Intent(Activity 已存在时调用)
|
||||
// handleIntent(intent);
|
||||
// }
|
||||
|
||||
private String getIntentUrl(Intent intent) {
|
||||
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
ToastUtils.show("ACTION_VIEW");
|
||||
Uri data = intent.getData();
|
||||
if (data != null) {
|
||||
String url = data.toString(); // 获取完整 URL
|
||||
@ -93,17 +93,19 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
|
||||
// 在界面显示 URL
|
||||
//tvUrl.setText("接收到的 URL:\n" + url);
|
||||
mWebFragment.loadUrl(url);
|
||||
//ToastUtils.show(String.format("url %s", url));
|
||||
return url;
|
||||
|
||||
// 示例:打开系统浏览器访问该 URL
|
||||
// Intent browserIntent = new Intent(Intent.ACTION_VIEW, data);
|
||||
// startActivity(browserIntent);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void postStatusBarMessage(String msg) {
|
||||
if(_MainActivity != null) {
|
||||
if (_MainActivity != null) {
|
||||
_MainActivity.mStatusBarView.postMessage(msg);
|
||||
}
|
||||
}
|
||||
@ -111,13 +113,18 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
if (_mIsLoadedHomePage) {
|
||||
//ToastUtils.show("重新加载当前页面");
|
||||
mWebFragment.reloadLastUrl();
|
||||
String intentUrl = getIntentUrl(getIntent());
|
||||
if (intentUrl != null && !intentUrl.trim().equals("")) {
|
||||
mWebFragment.loadUrl(intentUrl);
|
||||
} else {
|
||||
//ToastUtils.show("加载默认主页");
|
||||
mWebFragment.loadUrl(getApplicationContext().getString(R.string.app_homepage));
|
||||
_mIsLoadedHomePage = true;
|
||||
if (_mIsLoadedHomePage) {
|
||||
//ToastUtils.show("重新加载当前页面");
|
||||
mWebFragment.reloadLastUrl();
|
||||
} else {
|
||||
//ToastUtils.show("加载默认主页");
|
||||
mWebFragment.loadUrl(getApplicationContext().getString(R.string.app_homepage));
|
||||
_mIsLoadedHomePage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,18 +381,5 @@ public class BaseWebView extends WebView {
|
||||
public void setOnPageFinished(IOnPageFinished iOnPageFinished) {
|
||||
mIOnPageFinished = iOnPageFinished;
|
||||
}
|
||||
|
||||
public class JSConsole {
|
||||
private Context mContext;
|
||||
|
||||
public JSConsole(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void log(String message) {
|
||||
LogUtils.d(TAG, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import android.view.ViewParent;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.libaes.views.AButton;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.common.BaseWebView;
|
||||
import cc.winboll.studio.webpagesources.view.URLAddressView;
|
||||
@ -99,7 +100,9 @@ public class WebFragment extends Fragment {
|
||||
}
|
||||
|
||||
public void loadUrl(String szUrl) {
|
||||
mBaseWebView.loadUrl(szUrl);
|
||||
if(mBaseWebView != null) {
|
||||
mBaseWebView.loadUrl(szUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadLastUrl() {
|
||||
|
@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<!-- 允许 provider.winboll.cc 及其子域名的明文流量 -->
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="true">provider.winboll.cc</domain>
|
||||
</domain-config>
|
||||
|
||||
<!-- 允许 winboll.cc 及其子域名的明文流量 -->
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="true">winboll.cc</domain>
|
||||
@ -14,4 +19,13 @@
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="false">192.168.*.*</domain>
|
||||
</domain-config>
|
||||
|
||||
<!-- 允许 http://10.8.0.250:456 的明文流量 -->
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="false">10.8.0.250</domain>
|
||||
</domain-config>
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="false">10.8.0.250:456</domain>
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user