8
8
import android .graphics .BitmapRegionDecoder ;
9
9
import android .net .Uri ;
10
10
import android .support .annotation .Nullable ;
11
- import android .util .Log ;
12
11
13
12
import java .io .File ;
14
- import java .io .FileInputStream ;
15
13
import java .io .IOException ;
16
14
import java .util .ArrayList ;
17
15
import java .util .Date ;
26
24
import fr .free .nrw .commons .contributions .Contribution ;
27
25
import fr .free .nrw .commons .mwapi .MediaWikiApi ;
28
26
import fr .free .nrw .commons .settings .Prefs ;
27
+ import fr .free .nrw .commons .utils .BitmapRegionDecoderWrapper ;
29
28
import fr .free .nrw .commons .utils .ImageUtils ;
29
+ import fr .free .nrw .commons .utils .ImageUtilsWrapper ;
30
30
import io .reactivex .Observable ;
31
31
import io .reactivex .Single ;
32
32
import io .reactivex .disposables .Disposable ;
@@ -57,6 +57,8 @@ public class UploadModel {
57
57
private SessionManager sessionManager ;
58
58
private Uri currentMediaUri ;
59
59
private FileUtilsWrapper fileUtilsWrapper ;
60
+ private ImageUtilsWrapper imageUtilsWrapper ;
61
+ private BitmapRegionDecoderWrapper bitmapRegionDecoderWrapper ;
60
62
private FileProcessor fileProcessor ;
61
63
62
64
@ Inject
@@ -67,9 +69,12 @@ public class UploadModel {
67
69
MediaWikiApi mwApi ,
68
70
SessionManager sessionManager ,
69
71
FileUtilsWrapper fileUtilsWrapper ,
72
+ ImageUtilsWrapper imageUtilsWrapper ,
73
+ BitmapRegionDecoderWrapper bitmapRegionDecoderWrapper ,
70
74
FileProcessor fileProcessor ) {
71
75
this .licenses = licenses ;
72
76
this .prefs = prefs ;
77
+ this .bitmapRegionDecoderWrapper = bitmapRegionDecoderWrapper ;
73
78
this .license = Prefs .Licenses .CC_BY_SA_3 ;
74
79
this .licensesByName = licensesByName ;
75
80
this .context = context ;
@@ -78,6 +83,7 @@ public class UploadModel {
78
83
this .sessionManager = sessionManager ;
79
84
this .fileUtilsWrapper = fileUtilsWrapper ;
80
85
this .fileProcessor = fileProcessor ;
86
+ this .imageUtilsWrapper = imageUtilsWrapper ;
81
87
useExtStorage = this .prefs .getBoolean ("useExternalStorage" , false );
82
88
}
83
89
@@ -103,8 +109,8 @@ void receive(List<Uri> mediaUri, String mimeType, String source, SimilarImageInt
103
109
.map (b -> b ? ImageUtils .IMAGE_DUPLICATE : ImageUtils .IMAGE_OK ),
104
110
Single .fromCallable (() ->
105
111
fileUtilsWrapper .getFileInputStream (filePath ))
106
- .map (file -> BitmapRegionDecoder .newInstance (file , false ))
107
- .map (ImageUtils ::checkIfImageIsTooDark ), //Returns IMAGE_DARK or IMAGE_OK
112
+ .map (file -> bitmapRegionDecoderWrapper .newInstance (file , false ))
113
+ .map (imageUtilsWrapper ::checkIfImageIsTooDark ), //Returns IMAGE_DARK or IMAGE_OK
108
114
(dupe , dark ) -> dupe | dark )
109
115
.observeOn (Schedulers .io ())
110
116
.subscribe (item .imageQuality ::onNext , Timber ::e );
@@ -134,15 +140,14 @@ void receiveDirect(Uri media, String mimeType, String source, String wikidataEnt
134
140
.map (fileUtilsWrapper ::getSHA1 )
135
141
.map (mwApi ::existingFile )
136
142
.map (b -> b ? ImageUtils .IMAGE_DUPLICATE : ImageUtils .IMAGE_OK ),
137
- Single .fromCallable (() ->
138
- filePath )
139
- .map (FileUtils ::getGeolocationOfFile )
140
- .map (geoLocation -> ImageUtils .checkImageGeolocationIsDifferent (geoLocation ,wikidataItemLocation ))
143
+ Single .fromCallable (() -> filePath )
144
+ .map (fileUtilsWrapper ::getGeolocationOfFile )
145
+ .map (geoLocation -> imageUtilsWrapper .checkImageGeolocationIsDifferent (geoLocation ,wikidataItemLocation ))
141
146
.map (r -> r ? ImageUtils .IMAGE_GEOLOCATION_DIFFERENT : ImageUtils .IMAGE_OK ),
142
147
Single .fromCallable (() ->
143
148
fileUtilsWrapper .getFileInputStream (filePath ))
144
- .map (file -> BitmapRegionDecoder .newInstance (file , false ))
145
- .map (ImageUtils ::checkIfImageIsTooDark ), //Returns IMAGE_DARK or IMAGE_OK
149
+ .map (file -> bitmapRegionDecoderWrapper .newInstance (file , false ))
150
+ .map (imageUtilsWrapper ::checkIfImageIsTooDark ), //Returns IMAGE_DARK or IMAGE_OK
146
151
(dupe , wrongGeo , dark ) -> dupe | wrongGeo | dark ).subscribe (item .imageQuality ::onNext );
147
152
items .add (item );
148
153
items .get (0 ).selected = true ;
0 commit comments