2
2
3
3
import android .annotation .SuppressLint ;
4
4
import android .content .ContentResolver ;
5
- import android .content .Context ;
6
5
import android .content .SharedPreferences ;
7
6
import android .media .ExifInterface ;
8
7
import android .net .Uri ;
9
8
import android .os .Build ;
10
- import android .os .Bundle ;
11
9
import android .os .ParcelFileDescriptor ;
12
10
import android .support .annotation .NonNull ;
13
- import android .support .annotation .Nullable ;
14
- import android .support .v7 .app .AppCompatActivity ;
15
11
16
12
import java .io .File ;
17
13
import java .io .FileNotFoundException ;
18
14
import java .io .IOException ;
19
- import java .util .Date ;
20
15
import java .util .List ;
21
16
22
17
import javax .inject .Inject ;
23
18
import javax .inject .Named ;
19
+ import javax .inject .Singleton ;
24
20
25
21
import fr .free .nrw .commons .caching .CacheController ;
26
- import fr .free .nrw .commons .di .ApplicationlessInjection ;
27
22
import fr .free .nrw .commons .mwapi .CategoryApi ;
28
23
import io .reactivex .schedulers .Schedulers ;
29
24
import timber .log .Timber ;
30
25
31
- import static com .mapbox .mapboxsdk .Mapbox .getApplicationContext ;
32
-
33
26
/**
34
27
* Processing of the image file that is about to be uploaded via ShareActivity is done here
35
28
*/
29
+ @ Singleton
36
30
public class FileProcessor implements SimilarImageDialogFragment .onResponse {
37
31
38
32
@ Inject
@@ -47,24 +41,23 @@ public class FileProcessor implements SimilarImageDialogFragment.onResponse {
47
41
private String filePath ;
48
42
private ContentResolver contentResolver ;
49
43
private GPSExtractor imageObj ;
50
- private Context context ;
51
44
private String decimalCoords ;
52
45
private ExifInterface exifInterface ;
53
- private boolean useExtStorage ;
54
46
private boolean haveCheckedForOtherImages = false ;
55
47
private GPSExtractor tempImageObj ;
56
48
57
- FileProcessor (@ NonNull String filePath , ContentResolver contentResolver , Context context ) {
49
+ @ Inject
50
+ FileProcessor () {
51
+ }
52
+
53
+ void initFileDetails (@ NonNull String filePath , ContentResolver contentResolver ) {
58
54
this .filePath = filePath ;
59
55
this .contentResolver = contentResolver ;
60
- this .context = context ;
61
- ApplicationlessInjection .getInstance (context .getApplicationContext ()).getCommonsApplicationComponent ().inject (this );
62
56
try {
63
- exifInterface = new ExifInterface (filePath );
57
+ exifInterface = new ExifInterface (filePath );
64
58
} catch (IOException e ) {
65
59
Timber .e (e );
66
60
}
67
- useExtStorage = prefs .getBoolean ("useExternalStorage" , true );
68
61
}
69
62
70
63
/**
@@ -85,10 +78,6 @@ GPSExtractor processFileCoordinates(SimilarImageInterface similarImageInterface)
85
78
return imageObj ;
86
79
}
87
80
88
- String getDecimalCoords () {
89
- return decimalCoords ;
90
- }
91
-
92
81
/**
93
82
* Find other images around the same location that were taken within the last 20 sec
94
83
* @param similarImageInterface
@@ -142,7 +131,7 @@ private void findOtherImages(SimilarImageInterface similarImageInterface) {
142
131
* Then initiates the calls to MediaWiki API through an instance of CategoryApi.
143
132
*/
144
133
@ SuppressLint ("CheckResult" )
145
- public void useImageCoords () {
134
+ private void useImageCoords () {
146
135
if (decimalCoords != null ) {
147
136
Timber .d ("Decimal coords of image: %s" , decimalCoords );
148
137
Timber .d ("is EXIF data present:" + imageObj .imageCoordsExists + " from findOther image" );
0 commit comments