mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Remove unused code from the app (#3276)
This commit is contained in:
parent
bb0a21929e
commit
2f9a71911a
27 changed files with 49 additions and 610 deletions
|
|
@ -6,7 +6,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import fr.free.nrw.commons.media.MediaClient;
|
||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
||||
import io.reactivex.Single;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -18,13 +17,10 @@ import timber.log.Timber;
|
|||
*/
|
||||
@Singleton
|
||||
public class MediaDataExtractor {
|
||||
private final OkHttpJsonApiClient okHttpJsonApiClient;
|
||||
private final MediaClient mediaClient;
|
||||
|
||||
@Inject
|
||||
public MediaDataExtractor(OkHttpJsonApiClient okHttpJsonApiClient,
|
||||
MediaClient mediaClient) {
|
||||
this.okHttpJsonApiClient = okHttpJsonApiClient;
|
||||
public MediaDataExtractor(MediaClient mediaClient) {
|
||||
this.mediaClient = mediaClient;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ package fr.free.nrw.commons.achievements;
|
|||
*/
|
||||
public class Achievements {
|
||||
private int uniqueUsedImages;
|
||||
private int articlesUsingImages;
|
||||
private int thanksReceived;
|
||||
private int imagesEditedBySomeoneElse;
|
||||
private int featuredImages;
|
||||
private int imagesUploaded;
|
||||
private int revertCount;
|
||||
|
|
@ -19,24 +17,18 @@ public class Achievements {
|
|||
/**
|
||||
* constructor for achievements class to set its data members
|
||||
* @param uniqueUsedImages
|
||||
* @param articlesUsingImages
|
||||
* @param thanksReceived
|
||||
* @param imagesEditedBySomeoneElse
|
||||
* @param featuredImages
|
||||
* @param imagesUploaded
|
||||
* @param revertCount
|
||||
*/
|
||||
public Achievements(int uniqueUsedImages,
|
||||
int articlesUsingImages,
|
||||
int thanksReceived,
|
||||
int imagesEditedBySomeoneElse,
|
||||
int featuredImages,
|
||||
int imagesUploaded,
|
||||
int revertCount) {
|
||||
this.uniqueUsedImages = uniqueUsedImages;
|
||||
this.articlesUsingImages = articlesUsingImages;
|
||||
this.thanksReceived = thanksReceived;
|
||||
this.imagesEditedBySomeoneElse = imagesEditedBySomeoneElse;
|
||||
this.featuredImages = featuredImages;
|
||||
this.imagesUploaded = imagesUploaded;
|
||||
this.revertCount = revertCount;
|
||||
|
|
@ -50,9 +42,7 @@ public class Achievements {
|
|||
*/
|
||||
public static Achievements from(FeedbackResponse response) {
|
||||
return new Achievements(response.getUniqueUsedImages(),
|
||||
response.getArticlesUsingImages(),
|
||||
response.getThanksReceived(),
|
||||
response.getImagesEditedBySomeoneElse(),
|
||||
response.getFeaturedImages().getQualityImages()
|
||||
+ response.getFeaturedImages().getFeaturedPicturesOnWikimediaCommons(),
|
||||
0,
|
||||
|
|
@ -99,54 +89,6 @@ public class Achievements {
|
|||
this.imagesUploaded = imagesUploaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter function to set count of featured images
|
||||
* @param featuredImages
|
||||
*/
|
||||
public void setFeaturedImages(int featuredImages) {
|
||||
this.featuredImages = featuredImages;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter function to set the count of images edited by someone
|
||||
* @param imagesEditedBySomeoneElse
|
||||
*/
|
||||
public void setImagesEditedBySomeoneElse(int imagesEditedBySomeoneElse) {
|
||||
this.imagesEditedBySomeoneElse = imagesEditedBySomeoneElse;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter function to set count of thanks received
|
||||
* @param thanksReceived
|
||||
*/
|
||||
public void setThanksReceived(int thanksReceived) {
|
||||
this.thanksReceived = thanksReceived;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter function to count of articles using images uploaded
|
||||
* @param articlesUsingImages
|
||||
*/
|
||||
public void setArticlesUsingImages(int articlesUsingImages) {
|
||||
this.articlesUsingImages = articlesUsingImages;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter function to set count of uniques images used by wiki
|
||||
* @param uniqueUsedImages
|
||||
*/
|
||||
public void setUniqueUsedImages(int uniqueUsedImages) {
|
||||
this.uniqueUsedImages = uniqueUsedImages;
|
||||
}
|
||||
|
||||
/**
|
||||
* to set count of images reverted
|
||||
* @param revertCount
|
||||
*/
|
||||
public void setRevertCount(int revertCount) {
|
||||
this.revertCount = revertCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* used to calculate the percentages of images that haven't been reverted
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -2,36 +2,26 @@ package fr.free.nrw.commons.achievements;
|
|||
|
||||
public class FeedbackResponse {
|
||||
|
||||
private final String status;
|
||||
private final int uniqueUsedImages;
|
||||
private final int articlesUsingImages;
|
||||
private final int deletedUploads;
|
||||
private final FeaturedImages featuredImages;
|
||||
private final int thanksReceived;
|
||||
private final String user;
|
||||
private final int imagesEditedBySomeoneElse;
|
||||
|
||||
|
||||
public FeedbackResponse(String status,
|
||||
int uniqueUsedImages,
|
||||
public FeedbackResponse(int uniqueUsedImages,
|
||||
int articlesUsingImages,
|
||||
int deletedUploads,
|
||||
FeaturedImages featuredImages,
|
||||
int thanksReceived,
|
||||
String user,
|
||||
int imagesEditedBySomeoneElse) {
|
||||
this.status = status;
|
||||
String user) {
|
||||
this.uniqueUsedImages = uniqueUsedImages;
|
||||
this.articlesUsingImages = articlesUsingImages;
|
||||
this.deletedUploads = deletedUploads;
|
||||
this.featuredImages = featuredImages;
|
||||
this.thanksReceived = thanksReceived;
|
||||
this.user = user;
|
||||
this.imagesEditedBySomeoneElse = imagesEditedBySomeoneElse;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public int getUniqueUsedImages() {
|
||||
|
|
@ -58,7 +48,4 @@ public class FeedbackResponse {
|
|||
return user;
|
||||
}
|
||||
|
||||
public int getImagesEditedBySomeoneElse() {
|
||||
return imagesEditedBySomeoneElse;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import timber.log.Timber;
|
|||
|
||||
public class AccountUtil {
|
||||
|
||||
public static final String AUTH_COOKIE = "authCookie";
|
||||
public static final String AUTH_TOKEN_TYPE = "CommonsAndroid";
|
||||
|
||||
public AccountUtil() {
|
||||
|
|
@ -38,12 +37,6 @@ public class AccountUtil {
|
|||
return account == null ? null : account.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getPassword(Context context) {
|
||||
Account account = account(context);
|
||||
return account == null ? null : accountManager(context).getPassword(account);
|
||||
}
|
||||
|
||||
private static AccountManager accountManager(Context context) {
|
||||
return AccountManager.get(context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.content.ContentResolver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
|
@ -109,16 +110,6 @@ public class WikiAccountAuthenticator extends AbstractAccountAuthenticator {
|
|||
return bundle;
|
||||
}
|
||||
|
||||
private Bundle unsupportedOperation() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
|
||||
|
||||
// HACK: the docs indicate that this is a required key bit it's not displayed to the user.
|
||||
bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "");
|
||||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response,
|
||||
Account account) throws NetworkErrorException {
|
||||
|
|
|
|||
|
|
@ -40,11 +40,4 @@ public class Bookmark {
|
|||
return contentUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the content URI - marking this bookmark as already saved in the database
|
||||
* @param contentUri the content URI
|
||||
*/
|
||||
public void setContentUri(Uri contentUri) {
|
||||
this.contentUri = contentUri;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package fr.free.nrw.commons.category;
|
||||
|
||||
import com.pedrogomez.renderers.ListAdapteeCollection;
|
||||
import com.pedrogomez.renderers.RendererBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CategoriesAdapterFactory {
|
||||
private final CategoryClickedListener listener;
|
||||
|
||||
public CategoriesAdapterFactory(CategoryClickedListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public CategoryRendererAdapter create(List<CategoryItem> placeList) {
|
||||
RendererBuilder<CategoryItem> builder = new RendererBuilder<CategoryItem>()
|
||||
.bind(CategoryItem.class, new CategoriesRenderer(listener));
|
||||
ListAdapteeCollection<CategoryItem> collection = new ListAdapteeCollection<>(
|
||||
placeList != null ? placeList : Collections.<CategoryItem>emptyList());
|
||||
return new CategoryRendererAdapter(builder, collection);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package fr.free.nrw.commons.category;
|
||||
|
||||
import com.pedrogomez.renderers.AdapteeCollection;
|
||||
import com.pedrogomez.renderers.RVRendererAdapter;
|
||||
import com.pedrogomez.renderers.RendererBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CategoryRendererAdapter extends RVRendererAdapter<CategoryItem> {
|
||||
CategoryRendererAdapter(RendererBuilder<CategoryItem> rendererBuilder, AdapteeCollection<CategoryItem> collection) {
|
||||
super(rendererBuilder, collection);
|
||||
}
|
||||
|
||||
protected ArrayList<CategoryItem> allItems() {
|
||||
int itemCount = getItemCount();
|
||||
ArrayList<CategoryItem> items = new ArrayList<>(itemCount);
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
items.add(getItem(i));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
|
@ -120,10 +120,6 @@ public class Contribution extends Media {
|
|||
parcel.writeInt(isMultiple ? 1 : 0);
|
||||
}
|
||||
|
||||
public String getDateCreatedSource() {
|
||||
return dateCreatedSource;
|
||||
}
|
||||
|
||||
public void setDateCreatedSource(String dateCreatedSource) {
|
||||
this.dateCreatedSource = dateCreatedSource;
|
||||
}
|
||||
|
|
@ -241,14 +237,6 @@ public class Contribution extends Media {
|
|||
this.source = source;
|
||||
}
|
||||
|
||||
public void setLocalUri(Uri localUri) {
|
||||
this.localUri = localUri;
|
||||
}
|
||||
|
||||
public void setDecimalCoords(String decimalCoords) {
|
||||
this.decimalCoords = decimalCoords;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String licenseTemplateFor(String license) {
|
||||
switch (license) {
|
||||
|
|
@ -284,7 +272,4 @@ public class Contribution extends Media {
|
|||
this.contentProviderUri = contentProviderUri;
|
||||
}
|
||||
|
||||
public Uri getContentProviderUri() {
|
||||
return contentProviderUri;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
package fr.free.nrw.commons.contributions;
|
||||
|
||||
import static fr.free.nrw.commons.contributions.Contribution.STATE_FAILED;
|
||||
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
|
||||
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.database.DataSetObserver;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -17,12 +12,17 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentManager.OnBackStackChangedListener;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.HandlerService;
|
||||
|
|
@ -56,11 +56,12 @@ import io.reactivex.Observable;
|
|||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.util.ArrayList;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static fr.free.nrw.commons.contributions.Contribution.STATE_FAILED;
|
||||
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
|
||||
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
|
||||
|
||||
public class ContributionsFragment
|
||||
extends CommonsDaggerSupportFragment
|
||||
implements
|
||||
|
|
@ -76,7 +77,6 @@ public class ContributionsFragment
|
|||
@Inject CampaignsPresenter presenter;
|
||||
@Inject LocationServiceManager locationManager;
|
||||
|
||||
private ArrayList<DataSetObserver> observersWaitingForLoad = new ArrayList<>();
|
||||
private UploadService uploadService;
|
||||
private boolean isUploadServiceConnected;
|
||||
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
|
|
@ -371,10 +371,6 @@ public class ContributionsFragment
|
|||
|
||||
}
|
||||
|
||||
public void betaSetUploadCount(int betaUploadCount) {
|
||||
displayUploadCount(betaUploadCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
|||
private static final String[] existsQuery = {COLUMN_FILENAME};
|
||||
private static final String existsSelection = COLUMN_FILENAME + " = ?";
|
||||
private static final ContentValues[] EMPTY = {};
|
||||
private static int COMMIT_THRESHOLD = 10;
|
||||
|
||||
// Arbitrary limit to cap the number of contributions to ever load. This is a maximum built
|
||||
// into the app, rather than the user's setting. Also see Github issue #52.
|
||||
public static final int ABSOLUTE_CONTRIBUTIONS_LOAD_LIMIT = 500;
|
||||
|
||||
@Inject
|
||||
UserClient userClient;
|
||||
|
|
|
|||
|
|
@ -2,20 +2,18 @@ package fr.free.nrw.commons.filepicker;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -25,10 +23,8 @@ import java.util.List;
|
|||
|
||||
import static fr.free.nrw.commons.filepicker.PickedFiles.singleFileList;
|
||||
|
||||
@SuppressWarnings({"unused", "FieldCanBeLocal", "ResultOfMethodCallIgnored"})
|
||||
public class FilePicker implements Constants {
|
||||
|
||||
private static final boolean SHOW_GALLERY_IN_CHOOSER = false;
|
||||
private static final String KEY_PHOTO_URI = "photo_uri";
|
||||
private static final String KEY_VIDEO_URI = "video_uri";
|
||||
private static final String KEY_LAST_CAMERA_PHOTO = "last_photo";
|
||||
|
|
@ -45,23 +41,6 @@ public class FilePicker implements Constants {
|
|||
return uri;
|
||||
}
|
||||
|
||||
private static Uri createCameraVideoFile(@NonNull Context context) throws IOException {
|
||||
File imagePath = PickedFiles.getCameraVideoLocation(context);
|
||||
Uri uri = PickedFiles.getUriToFile(context, imagePath);
|
||||
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
||||
editor.putString(KEY_VIDEO_URI, uri.toString());
|
||||
editor.putString(KEY_LAST_CAMERA_VIDEO, imagePath.toString());
|
||||
editor.apply();
|
||||
return uri;
|
||||
}
|
||||
|
||||
private static Intent createDocumentsIntent(@NonNull Context context, int type) {
|
||||
storeType(context, type);
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType("image/*");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent createGalleryIntent(@NonNull Context context, int type) {
|
||||
storeType(context, type);
|
||||
return plainGalleryPickerIntent()
|
||||
|
|
@ -84,22 +63,6 @@ public class FilePicker implements Constants {
|
|||
return intent;
|
||||
}
|
||||
|
||||
private static Intent createCameraForVideoIntent(@NonNull Context context, int type) {
|
||||
storeType(context, type);
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
|
||||
try {
|
||||
Uri capturedImageUri = createCameraVideoFile(context);
|
||||
//We have to explicitly grant the write permission since Intent.setFlag works only on API Level >=20
|
||||
grantWritePermission(context, intent, capturedImageUri);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static void revokeWritePermission(@NonNull Context context, Uri uri) {
|
||||
context.revokeUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
|
|
@ -112,41 +75,6 @@ public class FilePicker implements Constants {
|
|||
}
|
||||
}
|
||||
|
||||
private static Intent createChooserIntent(@NonNull Context context, @Nullable String chooserTitle, int type) throws IOException {
|
||||
return createChooserIntent(context, chooserTitle, SHOW_GALLERY_IN_CHOOSER, type);
|
||||
}
|
||||
|
||||
private static Intent createChooserIntent(@NonNull Context context, @Nullable String chooserTitle, boolean showGallery, int type) throws IOException {
|
||||
storeType(context, type);
|
||||
|
||||
Uri outputFileUri = createCameraPictureFile(context);
|
||||
List<Intent> cameraIntents = new ArrayList<>();
|
||||
Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
List<ResolveInfo> camList = packageManager.queryIntentActivities(captureIntent, 0);
|
||||
for (ResolveInfo res : camList) {
|
||||
final String packageName = res.activityInfo.packageName;
|
||||
final Intent intent = new Intent(captureIntent);
|
||||
intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
|
||||
intent.setPackage(packageName);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
grantWritePermission(context, intent, outputFileUri);
|
||||
cameraIntents.add(intent);
|
||||
}
|
||||
Intent galleryIntent;
|
||||
|
||||
if (showGallery) {
|
||||
galleryIntent = createGalleryIntent(context, type);
|
||||
} else {
|
||||
galleryIntent = createDocumentsIntent(context, type);
|
||||
}
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(galleryIntent, chooserTitle);
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));
|
||||
|
||||
return chooserIntent;
|
||||
}
|
||||
|
||||
private static void storeType(@NonNull Context context, int type) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putInt(KEY_TYPE, type).apply();
|
||||
}
|
||||
|
|
@ -155,75 +83,6 @@ public class FilePicker implements Constants {
|
|||
return PreferenceManager.getDefaultSharedPreferences(context).getInt(KEY_TYPE, 0);
|
||||
}
|
||||
|
||||
public static void openChooserWithDocuments(Activity activity, @Nullable String chooserTitle, int type) {
|
||||
try {
|
||||
Intent intent = createChooserIntent(activity, chooserTitle, type);
|
||||
activity.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openChooserWithDocuments(Fragment fragment, @Nullable String chooserTitle, int type) {
|
||||
try {
|
||||
Intent intent = createChooserIntent(fragment.getActivity(), chooserTitle, type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openChooserWithDocuments(android.app.Fragment fragment, @Nullable String chooserTitle, int type) {
|
||||
try {
|
||||
Intent intent = createChooserIntent(fragment.getActivity(), chooserTitle, type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openChooserWithGallery(Activity activity, @Nullable String chooserTitle, int type) {
|
||||
try {
|
||||
Intent intent = createChooserIntent(activity, chooserTitle, true, type);
|
||||
activity.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_GALLERY);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openChooserWithGallery(Fragment fragment, @Nullable String chooserTitle, int type) {
|
||||
try {
|
||||
Intent intent = createChooserIntent(fragment.getActivity(), chooserTitle, true, type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_GALLERY);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openChooserWithGallery(android.app.Fragment fragment, @Nullable String chooserTitle, int type) {
|
||||
try {
|
||||
Intent intent = createChooserIntent(fragment.getActivity(), chooserTitle, true, type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_GALLERY);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openDocuments(Activity activity, int type) {
|
||||
Intent intent = createDocumentsIntent(activity, type);
|
||||
activity.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
|
||||
}
|
||||
|
||||
public static void openDocuments(Fragment fragment, int type) {
|
||||
Intent intent = createDocumentsIntent(fragment.getContext(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
|
||||
}
|
||||
|
||||
public static void openDocuments(android.app.Fragment fragment, int type) {
|
||||
Intent intent = createDocumentsIntent(fragment.getActivity(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens default galery or a available galleries picker if there is no default
|
||||
*
|
||||
|
|
@ -234,58 +93,13 @@ public class FilePicker implements Constants {
|
|||
activity.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_GALLERY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens default galery or a available galleries picker if there is no default
|
||||
*
|
||||
* @param type Custom type of your choice, which will be returned with the images
|
||||
*/
|
||||
public static void openGallery(Fragment fragment, int type) {
|
||||
Intent intent = createGalleryIntent(fragment.getContext(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_GALLERY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens default galery or a available galleries picker if there is no default
|
||||
*
|
||||
* @param type Custom type of your choice, which will be returned with the images
|
||||
*/
|
||||
public static void openGallery(android.app.Fragment fragment, int type) {
|
||||
Intent intent = createGalleryIntent(fragment.getActivity(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_GALLERY);
|
||||
}
|
||||
|
||||
public static void openCameraForImage(Activity activity, int type) {
|
||||
Intent intent = createCameraForImageIntent(activity, type);
|
||||
activity.startActivityForResult(intent, RequestCodes.TAKE_PICTURE);
|
||||
}
|
||||
|
||||
public static void openCameraForImage(Fragment fragment, int type) {
|
||||
Intent intent = createCameraForImageIntent(fragment.getActivity(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.TAKE_PICTURE);
|
||||
}
|
||||
|
||||
public static void openCameraForImage(android.app.Fragment fragment, int type) {
|
||||
Intent intent = createCameraForImageIntent(fragment.getActivity(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.TAKE_PICTURE);
|
||||
}
|
||||
|
||||
public static void openCameraForVideo(Activity activity, int type) {
|
||||
Intent intent = createCameraForVideoIntent(activity, type);
|
||||
activity.startActivityForResult(intent, RequestCodes.CAPTURE_VIDEO);
|
||||
}
|
||||
|
||||
public static void openCameraForVideo(Fragment fragment, int type) {
|
||||
Intent intent = createCameraForVideoIntent(fragment.getActivity(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.CAPTURE_VIDEO);
|
||||
}
|
||||
|
||||
public static void openCameraForVideo(android.app.Fragment fragment, int type) {
|
||||
Intent intent = createCameraForVideoIntent(fragment.getActivity(), type);
|
||||
fragment.startActivityForResult(intent, RequestCodes.CAPTURE_VIDEO);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static UploadableFile takenCameraPicture(Context context) throws IOException, URISyntaxException {
|
||||
private static UploadableFile takenCameraPicture(Context context) throws URISyntaxException {
|
||||
String lastCameraPhoto = PreferenceManager.getDefaultSharedPreferences(context).getString(KEY_LAST_CAMERA_PHOTO, null);
|
||||
if (lastCameraPhoto != null) {
|
||||
return new UploadableFile(new File(lastCameraPhoto));
|
||||
|
|
@ -295,7 +109,7 @@ public class FilePicker implements Constants {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
private static UploadableFile takenCameraVideo(Context context) throws IOException, URISyntaxException {
|
||||
private static UploadableFile takenCameraVideo(Context context) throws URISyntaxException {
|
||||
String lastCameraPhoto = PreferenceManager.getDefaultSharedPreferences(context).getString(KEY_LAST_CAMERA_VIDEO, null);
|
||||
if (lastCameraPhoto != null) {
|
||||
return new UploadableFile(new File(lastCameraPhoto));
|
||||
|
|
@ -352,49 +166,12 @@ public class FilePicker implements Constants {
|
|||
return data == null || (data.getData() == null && data.getClipData() == null);
|
||||
}
|
||||
|
||||
public static boolean willHandleActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == RequestCodes.SOURCE_CHOOSER || requestCode == RequestCodes.PICK_PICTURE_FROM_GALLERY || requestCode == RequestCodes.TAKE_PICTURE || requestCode == RequestCodes.PICK_PICTURE_FROM_DOCUMENTS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Intent plainGalleryPickerIntent() {
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType("image/*");
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static boolean canDeviceHandleGallery(@NonNull Context context) {
|
||||
return plainGalleryPickerIntent().resolveActivity(context.getPackageManager()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context context
|
||||
* @return File containing lastly taken (using camera) photo. Returns null if there was no photo taken or it doesn't exist anymore.
|
||||
*/
|
||||
public static File lastlyTakenButCanceledPhoto(@NonNull Context context) {
|
||||
String filePath = PreferenceManager.getDefaultSharedPreferences(context).getString(KEY_LAST_CAMERA_PHOTO, null);
|
||||
if (filePath == null) return null;
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static File lastlyTakenButCanceledVideo(@NonNull Context context) {
|
||||
String filePath = PreferenceManager.getDefaultSharedPreferences(context).getString(KEY_LAST_CAMERA_VIDEO, null);
|
||||
if (filePath == null) return null;
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void onPictureReturnedFromDocuments(Intent data, Activity activity, @NonNull FilePicker.Callbacks callbacks) {
|
||||
try {
|
||||
Uri photoPath = data.getData();
|
||||
|
|
@ -508,20 +285,6 @@ public class FilePicker implements Constants {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to clear configuration. Would likely be used in onDestroy(), onDestroyView()...
|
||||
*
|
||||
* @param context context
|
||||
*/
|
||||
public static void clearConfiguration(@NonNull Context context) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit()
|
||||
.remove(BundleKeys.FOLDER_NAME)
|
||||
.remove(BundleKeys.ALLOW_MULTIPLE)
|
||||
.remove(BundleKeys.COPY_TAKEN_PHOTOS)
|
||||
.remove(BundleKeys.COPY_PICKED_IMAGES)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static FilePickerConfiguration configuration(@NonNull Context context) {
|
||||
return new FilePickerConfiguration(context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,6 @@ public class FilePickerConfiguration implements Constants {
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
public FilePickerConfiguration setImagesFolderName(String folderName) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.edit().putString(BundleKeys.FOLDER_NAME, folderName)
|
||||
.apply();
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilePickerConfiguration setAllowMultiplePickInGallery(boolean allowMultiple) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit()
|
||||
.putBoolean(BundleKeys.ALLOW_MULTIPLE, allowMultiple)
|
||||
|
|
@ -32,13 +25,6 @@ public class FilePickerConfiguration implements Constants {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FilePickerConfiguration setCopyPickedImagesToPublicGalleryAppFolder(boolean copy) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit()
|
||||
.putBoolean(BundleKeys.COPY_PICKED_IMAGES, copy)
|
||||
.apply();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFolderName() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getString(BundleKeys.FOLDER_NAME, DEFAULT_FOLDER_NAME);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,6 @@ public class MimeTypeMapWrapper {
|
|||
"image/heif", "heif",
|
||||
"image/heic", "heic");
|
||||
|
||||
private static final Map<String, String> sExtensionToMimeTypeMap =
|
||||
ImmutableMap.of(
|
||||
"heif", "image/heif",
|
||||
"heic", "image/heic");
|
||||
|
||||
public static String getExtensionFromMimeType(String mimeType) {
|
||||
String result = sMimeTypeToExtensionMap.get(mimeType);
|
||||
if (result != null) {
|
||||
|
|
@ -28,19 +23,4 @@ public class MimeTypeMapWrapper {
|
|||
return sMimeTypeMap.getExtensionFromMimeType(mimeType);
|
||||
}
|
||||
|
||||
public static String getMimeTypeFromExtension(String extension) {
|
||||
String result = sExtensionToMimeTypeMap.get(extension);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
return sMimeTypeMap.getMimeTypeFromExtension(extension);
|
||||
}
|
||||
|
||||
public static boolean hasExtension(String extension) {
|
||||
return sExtensionToMimeTypeMap.containsKey(extension) || sMimeTypeMap.hasExtension(extension);
|
||||
}
|
||||
|
||||
public static boolean hasMimeType(String mimeType) {
|
||||
return sMimeTypeToExtensionMap.containsKey(mimeType) || sMimeTypeMap.hasMimeType(mimeType);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,10 @@ import android.content.Context;
|
|||
import android.media.MediaScannerConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.FileProvider;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
|
@ -100,11 +101,9 @@ class PickedFiles implements Constants {
|
|||
|
||||
MediaScannerConnection.scanFile(context,
|
||||
paths, null,
|
||||
new MediaScannerConnection.OnScanCompletedListener() {
|
||||
public void onScanCompleted(String path, Uri uri) {
|
||||
Timber.d("Scanned " + path + ":");
|
||||
Timber.d("-> uri=%s", uri);
|
||||
}
|
||||
(path, uri) -> {
|
||||
Timber.d("Scanned " + path + ":");
|
||||
Timber.d("-> uri=%s", uri);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -122,11 +121,6 @@ class PickedFiles implements Constants {
|
|||
return File.createTempFile(UUID.randomUUID().toString(), ".jpg", dir);
|
||||
}
|
||||
|
||||
static File getCameraVideoLocation(@NonNull Context context) throws IOException {
|
||||
File dir = tempImageDirectory(context);
|
||||
return File.createTempFile(UUID.randomUUID().toString(), ".mp4", dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* To find out the extension of required object in given uri
|
||||
* Solution by http://stackoverflow.com/a/36514823/1171484
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import timber.log.Timber;
|
||||
|
||||
public class LocationServiceManager implements LocationListener {
|
||||
public static final int LOCATION_REQUEST = 1;
|
||||
|
||||
// Maybe these values can be improved for efficiency
|
||||
private static final long MIN_LOCATION_UPDATE_REQUEST_TIME_IN_MILLIS = 2 * 60 * 100;
|
||||
|
|
@ -93,7 +92,6 @@ public class LocationServiceManager implements LocationListener {
|
|||
// Check whether the new location fix is newer or older
|
||||
long timeDelta = location.getTime() - currentBestLocation.getTime();
|
||||
boolean isSignificantlyNewer = timeDelta > MIN_LOCATION_UPDATE_REQUEST_TIME_IN_MILLIS;
|
||||
boolean isSignificantlyOlder = timeDelta < -MIN_LOCATION_UPDATE_REQUEST_TIME_IN_MILLIS;
|
||||
boolean isNewer = timeDelta > 0;
|
||||
|
||||
// Check whether the new location fix is more or less accurate
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package fr.free.nrw.commons.media;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class MwParseResult {
|
||||
|
|
|
|||
|
|
@ -2,31 +2,26 @@ package fr.free.nrw.commons.mwapi;
|
|||
|
||||
import android.text.TextUtils;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import fr.free.nrw.commons.Media;
|
||||
|
||||
import fr.free.nrw.commons.achievements.FeaturedImages;
|
||||
import fr.free.nrw.commons.achievements.FeedbackResponse;
|
||||
import fr.free.nrw.commons.campaigns.CampaignResponseDTO;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.nearby.Place;
|
||||
import fr.free.nrw.commons.nearby.model.NearbyResponse;
|
||||
import fr.free.nrw.commons.nearby.model.NearbyResultItem;
|
||||
import fr.free.nrw.commons.upload.FileUtils;
|
||||
import fr.free.nrw.commons.utils.CommonsDateUtil;
|
||||
import fr.free.nrw.commons.utils.ConfigUtils;
|
||||
import fr.free.nrw.commons.wikidata.model.GetWikidataEditCountResponse;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import okhttp3.HttpUrl;
|
||||
|
|
@ -35,8 +30,7 @@ import okhttp3.Request;
|
|||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.wikipedia.dataclient.mwapi.MwQueryPage;
|
||||
import org.wikipedia.dataclient.mwapi.MwQueryResponse;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
|
|
@ -166,7 +160,7 @@ public class OkHttpJsonApiClient {
|
|||
try {
|
||||
return gson.fromJson(json, FeedbackResponse.class);
|
||||
} catch (Exception e) {
|
||||
return new FeedbackResponse("", 0, 0, 0, new FeaturedImages(0, 0), 0, "", 0);
|
||||
return new FeedbackResponse(0, 0, 0, new FeaturedImages(0, 0), 0, "");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package fr.free.nrw.commons.nearby.fragments;
|
||||
|
||||
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -9,9 +7,11 @@ import android.util.AttributeSet;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
|
|
@ -26,6 +26,13 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.utils.MapFragmentUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
|
|
@ -41,12 +48,10 @@ import fr.free.nrw.commons.nearby.contract.NearbyParentFragmentContract;
|
|||
import fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter;
|
||||
import fr.free.nrw.commons.utils.LocationUtils;
|
||||
import fr.free.nrw.commons.utils.UiUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
|
||||
|
||||
/**
|
||||
* Support Fragment wrapper around a map view.
|
||||
* <p>
|
||||
|
|
@ -79,15 +84,6 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment
|
|||
private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.004;
|
||||
private static final double ZOOM_LEVEL = 14f;
|
||||
|
||||
/**
|
||||
* Creates a default MapFragment instance
|
||||
*
|
||||
* @return MapFragment created
|
||||
*/
|
||||
public static NearbyMapFragment newInstance() {
|
||||
return new NearbyMapFragment();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a MapFragment instance
|
||||
*
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ public class ImageProcessingService {
|
|||
private final ReadFBMD readFBMD;
|
||||
private final EXIFReader EXIFReader;
|
||||
private final MediaClient mediaClient;
|
||||
private final Context context;
|
||||
|
||||
@Inject
|
||||
public ImageProcessingService(FileUtilsWrapper fileUtilsWrapper,
|
||||
|
|
@ -40,7 +39,6 @@ public class ImageProcessingService {
|
|||
this.readFBMD = readFBMD;
|
||||
this.EXIFReader = EXIFReader;
|
||||
this.mediaClient = mediaClient;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,8 +8,19 @@ import android.content.Intent;
|
|||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.HandlerService;
|
||||
|
|
@ -24,13 +35,6 @@ import fr.free.nrw.commons.utils.CommonsDateUtil;
|
|||
import fr.free.nrw.commons.wikidata.WikidataEditService;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class UploadService extends HandlerService<Contribution> {
|
||||
|
|
@ -42,7 +46,6 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
public static final String ACTION_START_SERVICE = EXTRA_PREFIX + ".upload";
|
||||
public static final String EXTRA_SOURCE = EXTRA_PREFIX + ".source";
|
||||
public static final String EXTRA_FILES = EXTRA_PREFIX + ".files";
|
||||
public static final String EXTRA_CAMPAIGN = EXTRA_PREFIX + ".campaign";
|
||||
|
||||
@Inject WikidataEditService wikidataEditService;
|
||||
@Inject SessionManager sessionManager;
|
||||
|
|
@ -63,7 +66,6 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
// See http://stackoverflow.com/questions/8725909/startforeground-does-not-show-my-notification
|
||||
// Seriously, Android?
|
||||
public static final int NOTIFICATION_UPLOAD_IN_PROGRESS = 1;
|
||||
public static final int NOTIFICATION_UPLOAD_COMPLETE = 2;
|
||||
public static final int NOTIFICATION_UPLOAD_FAILED = 3;
|
||||
|
||||
public UploadService() {
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import fr.free.nrw.commons.category.QueryContinue;
|
||||
|
||||
public class ContinueUtils {
|
||||
|
||||
public static QueryContinue getQueryContinue(Node document) {
|
||||
Element continueElement = (Element) document;
|
||||
return new QueryContinue(continueElement.getAttribute("continue"),
|
||||
continueElement.getAttribute("gcmcontinue"));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
/**
|
||||
* Returns a new instance of proxy with overriden invocationhanlder() returning appropriate values
|
||||
* for different datatypes
|
||||
* See https://stackoverflow.com/questions/52083338/expected-to-unbox-a-string-primitive-type-but-was-returned-null
|
||||
*/
|
||||
public class CustomProxy extends Proxy {
|
||||
protected CustomProxy(InvocationHandler h) {
|
||||
super(h);
|
||||
}
|
||||
|
||||
public static Object newInstance(ClassLoader loader, Class<?>[] interfaces) {
|
||||
return Proxy.newProxyInstance(loader, interfaces, (o, method, objects) -> {
|
||||
if (String.class == method.getReturnType()) {
|
||||
return "";
|
||||
} else if (Integer.class == method.getReturnType()) {
|
||||
return Integer.valueOf(0);
|
||||
} else if (int.class == method.getReturnType()) {
|
||||
return 0;
|
||||
} else if (Boolean.class == method.getReturnType()) {
|
||||
return Boolean.FALSE;
|
||||
} else if (boolean.class == method.getReturnType()) {
|
||||
return false;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package fr.free.nrw.commons.utils;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
|
@ -31,27 +30,6 @@ public class LayoutUtils {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used for keeping aspect radios suggested by material guidelines. See:
|
||||
* https://material.io/design/layout/spacing-methods.html#containers-aspect-ratios
|
||||
* In some cases we don't know exact height, for such cases this method measures
|
||||
* height and sets width by multiplying the width with height.
|
||||
* @param rate Aspect ratios, ie 1 for 1:1. (height * rate = width)
|
||||
* @param view view to change width
|
||||
*/
|
||||
public static void setLayoutWidthAllignedToHeight(double rate, View view) {
|
||||
ViewTreeObserver vto = view.getViewTreeObserver();
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
layoutParams.width = (int) (view.getHeight() * rate);
|
||||
view.setLayoutParams(layoutParams);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static double getScreenWidth(Context context, double rate) {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
|
|
|
|||
|
|
@ -7,25 +7,6 @@ import fr.free.nrw.commons.location.LatLng;
|
|||
|
||||
public class PlaceUtils {
|
||||
|
||||
/**
|
||||
* Converts our defined LatLng to string, to put as String
|
||||
* @param latLng latlang will be converted to string
|
||||
* @return latitude + "/" + longitude
|
||||
*/
|
||||
public static String latLangToString(LatLng latLng) {
|
||||
return latLng.getLatitude()+"/"+latLng.getLongitude();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts latitude + "/" + longitude string to commons LatLng
|
||||
* @param latLngString latitude + "/" + longitude string
|
||||
* @return commons LatLng
|
||||
*/
|
||||
public static LatLng stringToLatLng(String latLngString) {
|
||||
String[] parts = latLngString.split("/");
|
||||
return new LatLng(Double.parseDouble(parts[0]), Double.parseDouble(parts[1]), 0);
|
||||
}
|
||||
|
||||
public static LatLng latLngFromPointString(String pointString) {
|
||||
double latitude;
|
||||
double longitude;
|
||||
|
|
|
|||
|
|
@ -38,17 +38,6 @@ public class UiUtils {
|
|||
return dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts device specific pixels to dp.
|
||||
* @param px pixels
|
||||
* @param context Context to access display metrics
|
||||
* @return dp equivalent to px value
|
||||
*/
|
||||
public static float convertPixelsToDp(float px, Context context) {
|
||||
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||
return px / ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a series of points that create a circle on the map.
|
||||
* Takes the center latitude, center longitude of the circle,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
package fr.free.nrw.commons.wikidata;
|
||||
|
||||
public class WikidataConstants {
|
||||
public static final String WIKIDATA_ENTITY_ID_PREF = "WikiDataEntityId";
|
||||
public static final String WIKIDATA_ITEM_LOCATION = "WikiDataItemLocation";
|
||||
public static final String IS_DIRECT_UPLOAD = "isDirectUpload";
|
||||
public static final String PLACE_OBJECT = "place";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue