Skip to content

Commit

Permalink
feat(agentweb): upgrade gradle version to 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Justson committed Dec 9, 2023
1 parent 7e77aac commit 62b346b
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 82 deletions.
16 changes: 5 additions & 11 deletions agentweb-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
buildToolsVersion "${BUILD_TOOL_VERSION}"
compileSdk COMPILE_SDK_VERSION.toInteger()


defaultConfig {
minSdkVersion 14
targetSdkVersion TARGET_SDK_VERSION.toInteger()
namespace 'com.just.agentweb'
versionCode 3
versionName "5.0.0"

versionName VERSION_NAME
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

Expand All @@ -19,12 +19,6 @@ android {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', 'VERSION_NAME', "\"" + "5.0.0" + "\""
}
debug {
buildConfigField 'String', 'VERSION_NAME', "\"" + "5.0.0" + "\""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
Expand All @@ -48,7 +42,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
compileOnly 'com.github.Justson:Downloader:v4.1.9-androidx'
compileOnly 'com.github.Justson:Downloader:v5.0.4-androidx'
compileOnly 'com.google.android.material:material:1.0.0'
compileOnly 'androidx.legacy:legacy-support-v4:1.0.0'
compileOnly fileTree(include: ['*.jar'], dir: 'providedLibs')
Expand Down
4 changes: 1 addition & 3 deletions agentweb-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.just.agentweb"
>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ private void settings(WebView webView) {
}
mWebSettings.setTextZoom(100);
mWebSettings.setDatabaseEnabled(true);
mWebSettings.setAppCacheEnabled(true);
mWebSettings.setLoadsImagesAutomatically(true);
mWebSettings.setSupportMultipleWindows(false);
// 是否阻塞加载网络图片 协议http or https
Expand Down Expand Up @@ -116,9 +115,6 @@ private void settings(WebView webView) {
//设置数据库路径 api19 已经废弃,这里只针对 webkit 起作用
mWebSettings.setGeolocationDatabasePath(dir);
mWebSettings.setDatabasePath(dir);
mWebSettings.setAppCachePath(dir);
//缓存文件最大值
mWebSettings.setAppCacheMaxSize(Long.MAX_VALUE);
mWebSettings.setUserAgentString(getWebSettings()
.getUserAgentString()
.concat(USERAGENT_AGENTWEB)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class AgentWebConfig {
/**
* AgentWeb 的版本
*/
public static final String AGENTWEB_VERSION = AGENTWEB_NAME + "/" + BuildConfig.VERSION_NAME;
public static final String AGENTWEB_VERSION = AGENTWEB_NAME + "/" + "5.0.8";
/**
* 通过JS获取的文件大小, 这里限制最大为5MB ,太大会抛出 OutOfMemoryError
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.just.agentweb;

import android.Manifest;
import android.os.Build;


/**
Expand All @@ -36,8 +37,17 @@ public class AgentWebPermissions {
LOCATION = new String[]{
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION};
STORAGE = new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE};

if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
STORAGE = new String[]{
Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.READ_MEDIA_VIDEO,
Manifest.permission.READ_MEDIA_AUDIO,
};
} else {
STORAGE = new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,6 @@ public void onExceededDatabaseQuota(String url, String databaseIdentifier, long
quotaUpdater.updateQuota(totalQuota * 2);
}

@Override
public void onReachedMaxAppCacheSize(long requiredStorage, long quota, WebStorage.QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(requiredStorage * 2);
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,6 @@ public void onExceededDatabaseQuota(String url, String databaseIdentifier,

}

@Override
@Deprecated
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
WebStorage.QuotaUpdater quotaUpdater) {
if (this.mDelegate != null) {
this.mDelegate.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
return;
}
super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
}

@Override
public void onGeolocationPermissionsShowPrompt(String origin,
Expand Down
6 changes: 3 additions & 3 deletions agentweb-filechooser/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
buildToolsVersion "${BUILD_TOOL_VERSION}"
compileSdk COMPILE_SDK_VERSION.toInteger()

defaultConfig {
minSdkVersion 14
namespace 'com.just.agentweb.filechooser'
targetSdkVersion TARGET_SDK_VERSION.toInteger()
versionCode 2
versionName "5.0.0"
versionName VERSION_NAME

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

Expand Down
3 changes: 1 addition & 2 deletions agentweb-filechooser/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.just.agentweb.filechooser"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ private void openFileChooserInternal() {
this.mAgentWebUIController
.get()
.onSelectItemsPrompt(this.mWebView, mWebView.getUrl(),
new String[]{mActivity.getString(R.string.agentweb_camera),
mActivity.getString(R.string.agentweb_file_chooser)}, getCallBack());
new String[]{mActivity.getString(com.just.agentweb.R.string.agentweb_camera),
mActivity.getString(com.just.agentweb.R.string.agentweb_file_chooser)}, getCallBack());
}

}
Expand Down Expand Up @@ -576,7 +576,7 @@ public void onReceiveValue(Uri[] value) {

if (sum > AgentWebConfig.MAX_FILE_LENGTH) {
if (mAgentWebUIController.get() != null) {
mAgentWebUIController.get().onShowMessage(mActivity.getString(R.string.agentweb_max_file_length_limit, (AgentWebConfig.MAX_FILE_LENGTH / 1024 / 1024) + ""), "convertFileAndCallback");
mAgentWebUIController.get().onShowMessage(mActivity.getString(com.just.agentweb.R.string.agentweb_max_file_length_limit, (AgentWebConfig.MAX_FILE_LENGTH / 1024 / 1024) + ""), "convertFileAndCallback");
}
mJsChannelCallback.call(null);
return;
Expand Down Expand Up @@ -661,7 +661,7 @@ private void aboveLollipopCheckFilesAndCallback(final Uri[] datas, boolean isCam
return;
}
final String path = paths[0];
mAgentWebUIController.get().onLoading(mActivity.getString(R.string.agentweb_loading));
mAgentWebUIController.get().onLoading(mActivity.getString(com.just.agentweb.R.string.agentweb_loading));
AsyncTask.THREAD_POOL_EXECUTOR.execute(new WaitPhotoRunnable(path, new AboveLCallback(mUriValueCallbacks, datas, mAgentWebUIController)));
mUriValueCallbacks = null;

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "com.android.tools.build:gradle:8.1.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
}
}
Expand Down
11 changes: 7 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
COMPILE_SDK_VERSION=32
BUILD_TOOL_VERSION=33.0.0
SUPPORT_LIB_VERSION=33.0.0
TARGET_SDK_VERSION=33
COMPILE_SDK_VERSION=34
BUILD_TOOL_VERSION=34.0.0
SUPPORT_LIB_VERSION=34.0.0
TARGET_SDK_VERSION=34
VERSION_NAME="5.0.8"
android.useAndroidX=true
android.enableJetifier=true
# When configured, Gradle will run in incubating parallel mode.
Expand All @@ -25,3 +26,5 @@ android.enableJetifier=true
#systemProp.https.proxyHost=127.0.0.1
#systemProp.https.proxyPort=1087
android.injected.testOnly=false
android.nonFinalResIds=false
org.gradle.java.home=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home/
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 7 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
}

apply plugin: 'com.android.application'

android {
compileSdk 33
buildToolsVersion '33.0.0'
compileSdk COMPILE_SDK_VERSION.toInteger()
buildToolsVersion BUILD_TOOL_VERSION

defaultConfig {
applicationId "com.just.agentweb.sample"
namespace 'com.just.agentweb.sample'
minSdkVersion 19
targetSdkVersion TARGET_SDK_VERSION.toInteger()
multiDexEnabled true
versionCode 5
versionName "5.0.7"
versionName VERSION_NAME
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
signingConfigs {
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void onClick(View v) {
.useDefaultIndicator()
.setWebChromeClient(mWebChromeClient)
.setWebViewClient(mWebViewClient)
.setMainFrameErrorView(R.layout.agentweb_error_page, -1)
.setMainFrameErrorView(com.just.agentweb.R.layout.agentweb_error_page, -1)
.setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
.setWebLayout(new WebLayout(this))
.setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他应用时,弹窗咨询用户是否前往其他应用
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.just.agentweb.sample.fragment;


import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
Expand Down Expand Up @@ -65,6 +66,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Objects;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
Expand Down Expand Up @@ -127,7 +129,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
.setPermissionInterceptor(mPermissionInterceptor) //权限拦截 2.0.0 加入。
.setSecurityType(AgentWeb.SecurityType.STRICT_CHECK) //严格模式 Android 4.2.2 以下会放弃注入对象 ,使用AgentWebView没影响。
.setAgentWebUIController(new UIController(getActivity())) //自定义UI AgentWeb3.0.0 加入。
.setMainFrameErrorView(R.layout.agentweb_error_page, -1) //参数1是错误显示的布局,参数2点击刷新控件ID -1表示点击整个布局都刷新, AgentWeb 3.0.0 加入。
.setMainFrameErrorView(com.just.agentweb.R.layout.agentweb_error_page, -1) //参数1是错误显示的布局,参数2点击刷新控件ID -1表示点击整个布局都刷新, AgentWeb 3.0.0 加入。
.useMiddlewareWebChrome(getMiddlewareWebChrome()) //设置WebChromeClient中间件,支持多个WebChromeClient,AgentWeb 3.0.0 加入。
.additionalHttpHeader(getUrl(), "cookie", "41bc7ddf04a26b91803f6b11817a5a1c")
.useMiddlewareWebClient(getMiddlewareWebClient()) //设置WebViewClient中间件,支持多个WebViewClient, AgentWeb 3.0.0 加入。
Expand Down Expand Up @@ -399,7 +401,7 @@ protected void initView(View view) {
mSimpleSearchView = view.findViewById(R.id.search_view);
pageNavigator(View.GONE);
mSimpleSearchView.setHint("请输入网址");
EditText editText = mSimpleSearchView.findViewById(R.id.searchEditText);
EditText editText = mSimpleSearchView.findViewById(com.ferfalk.simplesearchview.R.id.searchEditText);
editText.setImeOptions(EditorInfo.IME_ACTION_GO);
// mSimpleSearchView.setSearchBackground(new ColorDrawable(getColorPrimary()));
mSimpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() {
Expand Down Expand Up @@ -427,11 +429,11 @@ public boolean onQueryTextCleared() {

}

public int getColorPrimary() {
TypedValue typedValue = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
return typedValue.data;
}
// public int getColorPrimary() {
// TypedValue typedValue = new TypedValue();
// requireActivity().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
// return typedValue.data;
// }


private void pageNavigator(int tag) {
Expand Down Expand Up @@ -505,6 +507,7 @@ private void showPoPup(View view) {
* 菜单事件
*/
private PopupMenu.OnMenuItemClickListener mOnMenuItemClickListener = new PopupMenu.OnMenuItemClickListener() {
@SuppressLint("NonConstantResourceId")
@Override
public boolean onMenuItemClick(MenuItem item) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
.setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
.interceptUnkownUrl()
.setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)
.setMainFrameErrorView(R.layout.agentweb_error_page, -1)
.setMainFrameErrorView(com.just.agentweb.R.layout.agentweb_error_page, -1)
.createAgentWeb()//
.ready()//
.go(getUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,15 @@ private void pageNavigator(int tag) {
public void onClick(View v) {


switch (v.getId()) {
case R.id.iv_back:
if (!mAgentWeb.back()) {
EasyWebFragment.this.getActivity().finish();
}
break;
case R.id.iv_finish:
if (v.getId() == R.id.iv_back) {
if (!mAgentWeb.back()) {
EasyWebFragment.this.getActivity().finish();
break;
default:
break;


}
} else if (v.getId() == R.id.iv_finish) {
EasyWebFragment.this.getActivity().finish();
}
}


}
};

@Override
Expand Down
1 change: 0 additions & 1 deletion sample/src/main/res/layout/toorbar_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
<com.ferfalk.simplesearchview.SimpleSearchView
android:id="@+id/search_view"
android:layout_width="match_parent"

android:layout_height="match_parent"
android:background="@color/colorPrimary" />
</FrameLayout>
Expand Down

0 comments on commit 62b346b

Please sign in to comment.