登录页面,关于移动办公页面底部增加备案号
parent
e9c32ad686
commit
068f5d93a0
@ -0,0 +1,237 @@
|
||||
package com.rehome.zhdcoa.base;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import com.just.agentweb.AgentWeb;
|
||||
import com.just.agentweb.AgentWebSettingsImpl;
|
||||
import com.just.agentweb.AgentWebUIControllerImplBase;
|
||||
import com.just.agentweb.DefaultWebClient;
|
||||
import com.just.agentweb.IAgentWebSettings;
|
||||
import com.just.agentweb.IWebLayout;
|
||||
import com.just.agentweb.MiddlewareWebChromeBase;
|
||||
import com.just.agentweb.MiddlewareWebClientBase;
|
||||
import com.just.agentweb.PermissionInterceptor;
|
||||
import com.just.agentweb.WebChromeClient;
|
||||
import com.just.agentweb.WebViewClient;
|
||||
|
||||
/**
|
||||
* Created by huangwenfei on 2024/3/27.
|
||||
* <p>
|
||||
* source code https://github.com/Justson/AgentWeb
|
||||
*/
|
||||
|
||||
public abstract class BaseAgentWebActivity extends AppCompatActivity {
|
||||
|
||||
protected AgentWeb mAgentWeb;
|
||||
private AgentWebUIControllerImplBase mAgentWebUIController;
|
||||
private ErrorLayoutEntity mErrorLayoutEntity;
|
||||
private MiddlewareWebChromeBase mMiddleWareWebChrome;
|
||||
private MiddlewareWebClientBase mMiddleWareWebClient;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(@LayoutRes int layoutResID) {
|
||||
super.setContentView(layoutResID);
|
||||
buildAgentWeb();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(View view) {
|
||||
super.setContentView(view);
|
||||
buildAgentWeb();
|
||||
}
|
||||
|
||||
protected void buildAgentWeb() {
|
||||
ErrorLayoutEntity mErrorLayoutEntity = getErrorLayoutEntity();
|
||||
mAgentWeb = AgentWeb.with(this)
|
||||
.setAgentWebParent(getAgentWebParent(), new ViewGroup.LayoutParams(-1, -1))
|
||||
.useDefaultIndicator(getIndicatorColor(), getIndicatorHeight())
|
||||
.setWebChromeClient(getWebChromeClient())
|
||||
.setWebViewClient(getWebViewClient())
|
||||
.setWebView(getWebView())
|
||||
.setPermissionInterceptor(getPermissionInterceptor())
|
||||
.setWebLayout(getWebLayout())
|
||||
.setAgentWebUIController(getAgentWebUIController())
|
||||
.interceptUnkownUrl()
|
||||
.setOpenOtherPageWays(getOpenOtherAppWay())
|
||||
.useMiddlewareWebChrome(getMiddleWareWebChrome())
|
||||
.useMiddlewareWebClient(getMiddleWareWebClient())
|
||||
.setAgentWebWebSettings(getAgentWebSettings())
|
||||
.setMainFrameErrorView(mErrorLayoutEntity.layoutRes, mErrorLayoutEntity.reloadId)
|
||||
.setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
|
||||
.createAgentWeb()
|
||||
.ready()
|
||||
.go(getUrl());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected @NonNull
|
||||
ErrorLayoutEntity getErrorLayoutEntity() {
|
||||
if (this.mErrorLayoutEntity == null) {
|
||||
this.mErrorLayoutEntity = new ErrorLayoutEntity();
|
||||
}
|
||||
return mErrorLayoutEntity;
|
||||
}
|
||||
|
||||
protected AgentWeb getAgentWeb() {
|
||||
return this.mAgentWeb;
|
||||
}
|
||||
|
||||
|
||||
protected static class ErrorLayoutEntity {
|
||||
private int layoutRes = com.just.agentweb.R.layout.agentweb_error_page;
|
||||
private int reloadId;
|
||||
|
||||
public void setLayoutRes(int layoutRes) {
|
||||
this.layoutRes = layoutRes;
|
||||
if (layoutRes <= 0) {
|
||||
layoutRes = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setReloadId(int reloadId) {
|
||||
this.reloadId = reloadId;
|
||||
if (reloadId <= 0) {
|
||||
reloadId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
|
||||
if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (mAgentWeb != null) {
|
||||
mAgentWeb.getWebLifeCycle().onPause();
|
||||
}
|
||||
super.onPause();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (mAgentWeb != null) {
|
||||
mAgentWeb.getWebLifeCycle().onResume();
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mAgentWeb != null) {
|
||||
mAgentWeb.getWebLifeCycle().onDestroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
protected
|
||||
@Nullable
|
||||
String getUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public @Nullable
|
||||
IAgentWebSettings getAgentWebSettings() {
|
||||
return AgentWebSettingsImpl.getInstance();
|
||||
}
|
||||
|
||||
protected abstract @NonNull
|
||||
ViewGroup getAgentWebParent();
|
||||
|
||||
protected @Nullable
|
||||
WebChromeClient getWebChromeClient() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected @ColorInt
|
||||
int getIndicatorColor() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected int getIndicatorHeight() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected @Nullable
|
||||
WebViewClient getWebViewClient() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected @Nullable
|
||||
WebView getWebView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected @Nullable
|
||||
IWebLayout getWebLayout() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected @Nullable
|
||||
PermissionInterceptor getPermissionInterceptor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public @Nullable
|
||||
AgentWebUIControllerImplBase getAgentWebUIController() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public @Nullable
|
||||
DefaultWebClient.OpenOtherPageWays getOpenOtherAppWay() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected @NonNull
|
||||
MiddlewareWebChromeBase getMiddleWareWebChrome() {
|
||||
return this.mMiddleWareWebChrome = new MiddlewareWebChromeBase() {
|
||||
@Override
|
||||
public void onReceivedTitle(WebView view, String title) {
|
||||
super.onReceivedTitle(view, title);
|
||||
setTitle(view, title);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void setTitle(WebView view, String title) {
|
||||
|
||||
}
|
||||
|
||||
protected @NonNull
|
||||
MiddlewareWebClientBase getMiddleWareWebClient() {
|
||||
return this.mMiddleWareWebClient = new MiddlewareWebClientBase() {
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package com.rehome.zhdcoa.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.just.agentweb.AgentWeb;
|
||||
import com.just.agentweb.DefaultWebClient;
|
||||
import com.just.agentweb.WebChromeClient;
|
||||
import com.just.agentweb.WebViewClient;
|
||||
import com.rehome.zhdcoa.R;
|
||||
import com.rehome.zhdcoa.weiget.WebLayout;
|
||||
|
||||
public class BeiAnWebActivity extends AppCompatActivity {
|
||||
protected AgentWeb mAgentWeb;
|
||||
private LinearLayout mLinearLayout;
|
||||
private Toolbar mToolbar;
|
||||
private TextView mTitleTextView;
|
||||
private AlertDialog mAlertDialog;
|
||||
private Intent intent;
|
||||
private String beiAnNo;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_bei_an_web);
|
||||
mLinearLayout = this.findViewById(R.id.container);
|
||||
mToolbar = this.findViewById(R.id.toolbar);
|
||||
mToolbar.setTitleTextColor(Color.WHITE);
|
||||
mToolbar.setTitle("");
|
||||
mTitleTextView = this.findViewById(R.id.toolbar_title);
|
||||
this.setSupportActionBar(mToolbar);
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
mToolbar.setNavigationOnClickListener(v -> BeiAnWebActivity.this.finish());
|
||||
intent = getIntent();
|
||||
beiAnNo = intent.getStringExtra("beiAnNo");
|
||||
|
||||
mAgentWeb = AgentWeb.with(this)
|
||||
.setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
|
||||
.useDefaultIndicator()
|
||||
.setWebChromeClient(mWebChromeClient)
|
||||
.setWebViewClient(mWebViewClient)
|
||||
.setMainFrameErrorView(com.just.agentweb.R.layout.agentweb_error_page, -1)
|
||||
.setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
|
||||
.setWebLayout(new WebLayout(this))
|
||||
.setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他应用时,弹窗咨询用户是否前往其他应用
|
||||
.interceptUnkownUrl() //拦截找不到相关页面的Scheme
|
||||
.createAgentWeb()
|
||||
.ready()
|
||||
.go(getUrl());
|
||||
}
|
||||
|
||||
private final com.just.agentweb.WebViewClient mWebViewClient = new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||
return super.shouldOverrideUrlLoading(view, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
}
|
||||
};
|
||||
private final com.just.agentweb.WebChromeClient mWebChromeClient = new WebChromeClient() {
|
||||
@Override
|
||||
public void onReceivedTitle(WebView view, String title) {
|
||||
super.onReceivedTitle(view, title);
|
||||
if (mTitleTextView != null) {
|
||||
mTitleTextView.setText("ICP备案");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public String getUrl() {
|
||||
return "https://beian.miit.gov.cn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (mAgentWeb.handleKeyEvent(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
mAgentWeb.getWebLifeCycle().onPause();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
mAgentWeb.getWebLifeCycle().onResume();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mAgentWeb.getWebLifeCycle().onDestroy();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.activity.BeiAnWebActivity">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:titleTextColor="@android:color/white"
|
||||
app:theme="@style/Widget.AppCompat.Toolbar"
|
||||
app:titleTextColor="@android:color/white">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="5dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp"/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue