mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Remove all compile errors
This commit is contained in:
parent
89db8847bf
commit
bf61d2d8b2
3 changed files with 19 additions and 10 deletions
|
|
@ -12,6 +12,7 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
@ -21,6 +22,9 @@ import java.lang.ref.WeakReference;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.caching.CacheController;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
|
|
@ -39,6 +43,10 @@ public class FileProcessor {
|
||||||
private boolean haveCheckedForOtherImages = false;
|
private boolean haveCheckedForOtherImages = false;
|
||||||
private String filePath;
|
private String filePath;
|
||||||
private boolean useExtStorage;
|
private boolean useExtStorage;
|
||||||
|
private boolean cacheFound;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CacheController cacheController;
|
||||||
|
|
||||||
FileProcessor(Uri mediaUri, ContentResolver contentResolver, SharedPreferences prefs, Context context) {
|
FileProcessor(Uri mediaUri, ContentResolver contentResolver, SharedPreferences prefs, Context context) {
|
||||||
this.mediaUri = mediaUri;
|
this.mediaUri = mediaUri;
|
||||||
|
|
@ -86,7 +94,6 @@ public class FileProcessor {
|
||||||
void getFileCoordinates(boolean gpsEnabled) {
|
void getFileCoordinates(boolean gpsEnabled) {
|
||||||
Timber.d("Calling GPSExtractor");
|
Timber.d("Calling GPSExtractor");
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ParcelFileDescriptor descriptor = contentResolver.openFileDescriptor(mediaUri, "r");
|
ParcelFileDescriptor descriptor = contentResolver.openFileDescriptor(mediaUri, "r");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
|
|
@ -128,8 +135,7 @@ public class FileProcessor {
|
||||||
//Make sure the photos were taken within 20seconds
|
//Make sure the photos were taken within 20seconds
|
||||||
Timber.d("fild date:"+file.lastModified()+ " time of creation"+timeOfCreation);
|
Timber.d("fild date:"+file.lastModified()+ " time of creation"+timeOfCreation);
|
||||||
tempImageObj = null;//Temporary GPSExtractor to extract coords from these photos
|
tempImageObj = null;//Temporary GPSExtractor to extract coords from these photos
|
||||||
ParcelFileDescriptor descriptor
|
ParcelFileDescriptor descriptor = null;
|
||||||
= null;
|
|
||||||
try {
|
try {
|
||||||
descriptor = contentResolver.openFileDescriptor(Uri.parse(file.getAbsolutePath()), "r");
|
descriptor = contentResolver.openFileDescriptor(Uri.parse(file.getAbsolutePath()), "r");
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
|
@ -149,15 +155,14 @@ public class FileProcessor {
|
||||||
Timber.d("not null fild EXIF"+tempImageObj.imageCoordsExists +" coords"+tempImageObj.getCoords(gpsEnabled));
|
Timber.d("not null fild EXIF"+tempImageObj.imageCoordsExists +" coords"+tempImageObj.getCoords(gpsEnabled));
|
||||||
if(tempImageObj.getCoords(gpsEnabled)!=null && tempImageObj.imageCoordsExists){
|
if(tempImageObj.getCoords(gpsEnabled)!=null && tempImageObj.imageCoordsExists){
|
||||||
// Current image has gps coordinates and it's not current gps locaiton
|
// Current image has gps coordinates and it's not current gps locaiton
|
||||||
Timber.d("This fild has image coords:"+ file.getAbsolutePath());
|
Timber.d("This file has image coords:"+ file.getAbsolutePath());
|
||||||
// Create a dialog fragment for the suggestion
|
// Create a dialog fragment for the suggestion
|
||||||
FragmentManager fragmentManager = (Fragment) context.getSupportFragmentManager();
|
|
||||||
SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment();
|
SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("originalImagePath",filePath);
|
args.putString("originalImagePath",filePath);
|
||||||
args.putString("possibleImagePath",file.getAbsolutePath());
|
args.putString("possibleImagePath",file.getAbsolutePath());
|
||||||
newFragment.setArguments(args);
|
newFragment.setArguments(args);
|
||||||
newFragment.show(fragmentManager, "dialog");
|
newFragment.show(((AppCompatActivity)context).getSupportFragmentManager(), "dialog");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +180,7 @@ public class FileProcessor {
|
||||||
public void useImageCoords() {
|
public void useImageCoords() {
|
||||||
if (decimalCoords != null) {
|
if (decimalCoords != null) {
|
||||||
Timber.d("Decimal coords of image: %s", decimalCoords);
|
Timber.d("Decimal coords of image: %s", decimalCoords);
|
||||||
Timber.d("is EXIF data present:"+imageObj.imageCoordsExists+" from findOther image:"+(imageObj==tempImageObj));
|
Timber.d("is EXIF data present:"+imageObj.imageCoordsExists+" from findOther image");
|
||||||
|
|
||||||
// Only set cache for this point if image has coords
|
// Only set cache for this point if image has coords
|
||||||
if (imageObj.imageCoordsExists) {
|
if (imageObj.imageCoordsExists) {
|
||||||
|
|
@ -184,11 +189,12 @@ public class FileProcessor {
|
||||||
cacheController.setQtPoint(decLongitude, decLatitude);
|
cacheController.setQtPoint(decLongitude, decLatitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
MwVolleyApi apiCall = new MwVolleyApi(context);
|
||||||
|
|
||||||
List<String> displayCatList = cacheController.findCategory();
|
List<String> displayCatList = cacheController.findCategory();
|
||||||
boolean catListEmpty = displayCatList.isEmpty();
|
boolean catListEmpty = displayCatList.isEmpty();
|
||||||
|
|
||||||
|
|
||||||
// If no categories found in cache, call MediaWiki API to match image coords with nearby Commons categories
|
// If no categories found in cache, call MediaWiki API to match image coords with nearby Commons categories
|
||||||
if (catListEmpty) {
|
if (catListEmpty) {
|
||||||
cacheFound = false;
|
cacheFound = false;
|
||||||
|
|
@ -202,7 +208,10 @@ public class FileProcessor {
|
||||||
}else{
|
}else{
|
||||||
Timber.d("EXIF: no coords");
|
Timber.d("EXIF: no coords");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isCacheFound() {
|
||||||
|
return cacheFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import timber.log.Timber;
|
||||||
* is uploaded, extract latitude and longitude from EXIF data of image. If a picture without
|
* is uploaded, extract latitude and longitude from EXIF data of image. If a picture without
|
||||||
* geolocation is uploaded, retrieve user's location (if enabled in Settings).
|
* geolocation is uploaded, retrieve user's location (if enabled in Settings).
|
||||||
*/
|
*/
|
||||||
public class GPSExtractor extends FileProcessor {
|
public class GPSExtractor {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ public class ShareActivity
|
||||||
Toast startingToast = Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG);
|
Toast startingToast = Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG);
|
||||||
startingToast.show();
|
startingToast.show();
|
||||||
|
|
||||||
if (!cacheFound) {
|
if (!fileObj.isCacheFound()) {
|
||||||
//Has to be called after apiCall.request()
|
//Has to be called after apiCall.request()
|
||||||
cacheController.cacheCategory();
|
cacheController.cacheCategory();
|
||||||
Timber.d("Cache the categories found");
|
Timber.d("Cache the categories found");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue