@@ -41,7 +41,23 @@ const extToMimeType = new Map<string, string>([
41
41
const extToBinaryEncoding = new Set < string > ( [ 'gif' , 'jpeg' , 'jpg' , 'otf' , 'png' , 'ttf' ] ) ;
42
42
43
43
//#region android_native_classes
44
- let cacheModeMap : Map < CacheMode , number > ;
44
+ const cacheModeMap = {
45
+ get cache_first ( ) {
46
+ return android . webkit . WebSettings . LOAD_CACHE_ELSE_NETWORK ;
47
+ } ,
48
+ get cache_only ( ) {
49
+ return android . webkit . WebSettings . LOAD_CACHE_ONLY ;
50
+ } ,
51
+ get default ( ) {
52
+ return android . webkit . WebSettings . LOAD_DEFAULT ;
53
+ } ,
54
+ get no_cache ( ) {
55
+ return android . webkit . WebSettings . LOAD_NO_CACHE ;
56
+ } ,
57
+ get normal ( ) {
58
+ return android . webkit . WebSettings . LOAD_NORMAL ;
59
+ }
60
+ } ;
45
61
46
62
export interface AndroidWebViewClient extends android . webkit . WebViewClient { }
47
63
@@ -62,14 +78,6 @@ function initializeWebViewClient(): void {
62
78
return ;
63
79
}
64
80
65
- cacheModeMap = new Map < CacheMode , number > ( [
66
- [ 'cache_first' , android . webkit . WebSettings . LOAD_CACHE_ELSE_NETWORK ] ,
67
- [ 'cache_only' , android . webkit . WebSettings . LOAD_CACHE_ONLY ] ,
68
- [ 'default' , android . webkit . WebSettings . LOAD_DEFAULT ] ,
69
- [ 'no_cache' , android . webkit . WebSettings . LOAD_NO_CACHE ] ,
70
- [ 'normal' , android . webkit . WebSettings . LOAD_NORMAL ]
71
- ] ) ;
72
-
73
81
@NativeClass ( )
74
82
class WebViewExtClientImpl extends android . webkit . WebViewClient {
75
83
private owner : WeakRef < AWebView > ;
@@ -899,20 +907,22 @@ export class AWebView extends WebViewExtBase {
899
907
}
900
908
901
909
[ cacheModeProperty . getDefault ] ( ) : CacheMode | null {
902
- const androidWebView = this . nativeViewProtected ;
903
- if ( ! androidWebView ) {
904
- return null ;
905
- }
910
+ return 'default' ;
911
+ // const androidWebView = this.nativeViewProtected;
912
+ // if (!androidWebView) {
913
+ // return null;
914
+ // }
906
915
907
- const settings = androidWebView . getSettings ( ) ;
908
- const cacheModeInt = settings . getCacheMode ( ) ;
909
- for ( const [ key , value ] of cacheModeMap ) {
910
- if ( value === cacheModeInt ) {
911
- return key ;
912
- }
913
- }
916
+ // const settings = androidWebView.getSettings();
917
+ // const cacheModeInt = settings.getCacheMode();
918
+
919
+ // for (const key of Object.keys(cacheModeMap)) {
920
+ // if (cacheModeMap[key] === cacheModeInt) {
921
+ // return key as CacheMode;
922
+ // }
923
+ // }
914
924
915
- return null ;
925
+ // return null;
916
926
}
917
927
918
928
[ cacheModeProperty . setNative ] ( cacheMode : CacheMode ) {
@@ -922,13 +932,7 @@ export class AWebView extends WebViewExtBase {
922
932
}
923
933
924
934
const settings = androidWebView . getSettings ( ) ;
925
- for ( const [ key , nativeValue ] of cacheModeMap ) {
926
- if ( key === cacheMode ) {
927
- settings . setCacheMode ( nativeValue ) ;
928
-
929
- return ;
930
- }
931
- }
935
+ settings . setCacheMode ( cacheModeMap [ cacheMode ] ) ;
932
936
}
933
937
934
938
[ databaseStorageProperty . getDefault ] ( ) {
0 commit comments