Skip to content

Commit

Permalink
opt(download): download remove permission request, default cache path
Browse files Browse the repository at this point in the history
  • Loading branch information
Justson committed Dec 9, 2023
1 parent 5ee0585 commit 7e77aac
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 59 deletions.
9 changes: 0 additions & 9 deletions agentweb-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/web_files_public"/>
</provider>
<activity
android:name="com.just.agentweb.AgentActionFragment"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="false"
android:launchMode="standard"
android:theme="@style/actionActivity"
android:windowSoftInputMode="stateHidden|stateAlwaysHidden">

</activity>

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,53 +114,13 @@ protected void onDownloadStartInternal(String url, String userAgent, String cont
}
ResourceRequest resourceRequest = createResourceRequest(url);
this.mDownloadTasks.put(url, resourceRequest);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
List<String> mList = null;
if ((mList = checkNeedPermission()).isEmpty()) {
preDownload(url);
} else {
Action mAction = Action.createPermissionsAction(mList.toArray(new String[]{}));
mAction.setPermissionListener(getPermissionListener(url));
AgentActionFragment.start(mActivityWeakReference.get(), mAction);
}
} else {
preDownload(url);
}
preDownload(url);
}

protected ResourceRequest createResourceRequest(String url) {
return DownloadImpl.getInstance(this.mContext).with(url).setEnableIndicator(true).autoOpenIgnoreMD5();
}

protected AgentActionFragment.PermissionListener getPermissionListener(final String url) {
return new AgentActionFragment.PermissionListener() {
@Override
public void onRequestPermissionsResult(@NonNull String[] permissions, @NonNull int[] grantResults, Bundle extras) {
if (checkNeedPermission().isEmpty()) {
preDownload(url);
} else {
if (null != mAgentWebUIController.get()) {
mAgentWebUIController
.get()
.onPermissionsDeny(
checkNeedPermission().
toArray(new String[]{}),
AgentWebPermissions.ACTION_STORAGE, "Download");
}
LogUtils.e(TAG, "储存权限获取失败~");
}

}
};
}

protected List<String> checkNeedPermission() {
List<String> deniedPermissions = new ArrayList<>();
if (!AgentWebUtils.hasPermission(mActivityWeakReference.get(), AgentWebPermissions.STORAGE)) {
deniedPermissions.addAll(Arrays.asList(AgentWebPermissions.STORAGE));
}
return deniedPermissions;
}

protected void preDownload(String url) {
// 移动数据
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
COMPILE_SDK_VERSION=32
BUILD_TOOL_VERSION=32.0.0
SUPPORT_LIB_VERSION=32.0.0
TARGET_SDK_VERSION=32
BUILD_TOOL_VERSION=33.0.0
SUPPORT_LIB_VERSION=33.0.0
TARGET_SDK_VERSION=33
android.useAndroidX=true
android.enableJetifier=true
# When configured, Gradle will run in incubating parallel mode.
Expand Down
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Nov 12 09:45:14 CST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ plugins {
}

android {
compileSdk 32
buildToolsVersion '32.0.0'
compileSdk 33
buildToolsVersion '33.0.0'
defaultConfig {
applicationId "com.just.agentweb.sample"
minSdkVersion 19
targetSdkVersion TARGET_SDK_VERSION.toInteger()
multiDexEnabled true
versionCode 5
versionName "5.0.0"
versionName "5.0.7"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
signingConfigs {
Expand Down

0 comments on commit 7e77aac

Please sign in to comment.