Skip to content

Sync master with release #3922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cf73e28
#3624 DateTimeFormat wrong - match pattern returned from servers (#3625)
macgills Apr 8, 2020
c961099
Revert "Fixes: #3179 Make category search non case-sensitive (#3326)"…
sivaraam Apr 10, 2020
05a9aa8
Bugfix/security exception (#3627)
ashishkumar468 Apr 17, 2020
d7c2480
Fixes #3436 and #2881: Media Detail design Overhaul (#3505)
kbhardwaj123 Apr 19, 2020
461249f
Fixes #3639 (Fix Save State implementation of CheckBoxTriState ) (#3686)
ashishkumar468 Apr 26, 2020
63018fc
Add #3723 and #3721 to 2.13 release, fix conflicts
VitalyVPinchuk May 4, 2020
bff9231
Fix NullPointer when clicking on image in MediaDetailFragment (#3730)…
ashishkumar468 May 12, 2020
7417468
Update changelog.md
misaochan May 19, 2020
d97d40f
Versioning for v2.13
misaochan May 19, 2020
d950f72
Merge branch '2.13-release-2' of https://github.com/misaochan/apps-an…
misaochan May 19, 2020
ac3e515
Fixes #3705 (Crash when viewing pic I just uploaded) (#3782)
ashishkumar468 Jun 2, 2020
d02b959
Fixed BookmarkLocationsDao DB migration (#3793)
ashishkumar468 Jun 3, 2020
3e389be
Fixes #3725 (#3795)
ashishkumar468 Jun 4, 2020
78d519f
Handled null CompoundDrawable[2] in etTitle-> UploadMediaDetailsFragm…
ashishkumar468 Jun 23, 2020
e471226
DownSample Upload image to be shown in UploadMediaDetailFragment to h…
ashishkumar468 Jun 24, 2020
e7d9315
Bugfix/p18 uploads (#3869)
ashishkumar468 Jul 14, 2020
aa1d6fe
Fixes #3882 (#3883)
ashishkumar468 Jul 28, 2020
fcc3053
Fixes #3766, Added OPENSTREET attribution (#3889)
ashishkumar468 Aug 11, 2020
87f4796
Versioning and changelog for v2.13.1 (#3908)
misaochan Aug 25, 2020
624d351
Fixes #3914 (#3915)
ashishkumar468 Sep 1, 2020
1ec84d3
resolved merge-conflicts
ashishkumar468 Sep 10, 2020
a277ce1
fixed compile-time error
ashishkumar468 Sep 10, 2020
b0eb11c
fix erros
ashishkumar468 Sep 11, 2020
755179f
delete emptied files
ashishkumar468 Sep 13, 2020
5099411
remove empty file CategoriesModel.java
ashishkumar468 Sep 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Wikimedia Commons for Android

## v2.13.1
- Added OpenStreetMap attribution
- Fixed various crashes
- Fixed SQLite error in Nearby map
- Fixed issue with Nearby uploads not being associated with Wikidata p18

## v2.13.0
- New media details UI, ability to zoom and pan around image
- Added suggestions for a place that needs photos if user uploads a photo that is near one of them
- Modifications and fixes to Nearby filters based on user feedback
- Multiple crash and bug fixes

## v2.12.3
- Fixed issue with EXIF data, including coords, being removed from uploads

Expand Down
15 changes: 9 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ dependencies {
// Utils
implementation 'in.yuvi:http.fluent:1.3'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
implementation ("com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"){
force = true //API 19 support
}
implementation 'com.squareup.okio:okio:2.2.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.3'
Expand All @@ -35,6 +37,7 @@ dependencies {
// UI
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation 'com.github.pedrovgs:renderers:3.3.3'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.2'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v8:0.11.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-scalebar-v9:0.4.0'
Expand All @@ -51,7 +54,7 @@ dependencies {
testImplementation "androidx.paging:paging-common-ktx:$PAGING_VERSION"
implementation "androidx.paging:paging-rxjava2-ktx:$PAGING_VERSION"
implementation "androidx.recyclerview:recyclerview:1.2.0-alpha02"
implementation 'com.squareup.okhttp3:okhttp-ws:3.4.1'
implementation "com.squareup.okhttp3:okhttp-ws:$OKHTTP_VERSION"

// Logging
implementation 'ch.acra:acra-dialog:5.3.0'
Expand All @@ -60,7 +63,7 @@ dependencies {
api('com.github.tony19:logback-android-classic:1.1.1-6') {
exclude group: 'com.google.android', module: 'android'
}
implementation "com.squareup.okhttp3:logging-interceptor:4.5.0"
implementation "com.squareup.okhttp3:logging-interceptor:$OKHTTP_VERSION"

// Dependency injector
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
Expand All @@ -81,7 +84,7 @@ dependencies {
testImplementation 'junit:junit:4.13'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'androidx.test:core:1.2.0'
testImplementation "com.squareup.okhttp3:mockwebserver:4.8.0"
testImplementation "com.squareup.okhttp3:mockwebserver:$OKHTTP_VERSION"
testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5"
testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5"
testImplementation 'org.mockito:mockito-core:2.23.0'
Expand Down Expand Up @@ -139,8 +142,8 @@ android {

defaultConfig {
//applicationId 'fr.free.nrw.commons'
versionCode 561
versionName '2.12.3'
versionCode 775
versionName '2.13.1'
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())

minSdkVersion 19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,44 @@ public static void onDelete(SQLiteDatabase db) {

public static void onUpdate(SQLiteDatabase db, int from, int to) {
Timber.d("bookmarksLocations db is updated from:"+from+", to:"+to);
switch (from) {
case 7: onCreate(db);
case 8: // No change
case 9: // No change
case 10:
try {
db.execSQL("ALTER TABLE bookmarksLocations ADD COLUMN location_pic STRING;");
} catch (SQLiteException exception){
Timber.e(exception);
}
case 11: // No change
case 12:
try {
db.execSQL("ALTER TABLE bookmarksLocations ADD COLUMN location_destroyed STRING;");
}catch (SQLiteException exception){
Timber.e(exception);
}
break;
if (from == to) {
return;
}
if (from < 7) {
// doesn't exist yet
from++;
onUpdate(db, from, to);
return;
}
if (from == 7) {
// table added in version 8
onCreate(db);
from++;
onUpdate(db, from, to);
return;
}
if (from == 8) {
from++;
onUpdate(db, from, to);
return;
}
if (from == 10) {
//This is safe, and can be called clean, as we/I do not remember the appropriate version for this
//We are anyways switching to room, these things won't be necessary then
try {
db.execSQL("ALTER TABLE bookmarksLocations ADD COLUMN location_pic STRING;");
}catch (SQLiteException exception){
Timber.e(exception);//
}
return;
}
if (from == 12) {
try {
db.execSQL(
"ALTER TABLE bookmarksLocations ADD COLUMN location_destroyed STRING;");
} catch (SQLiteException exception) {
Timber.e(exception);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ data class Contribution constructor(
val localUri: Uri? = null,
var dataLength: Long = 0,
var dateCreated: Date? = null,
var dateModified: Date? = null
var dateModified: Date? = null,
var hasInvalidLocation : Int = 0
) : Parcelable {

fun completeWith(media: Media): Contribution {
Expand All @@ -65,6 +66,18 @@ data class Contribution constructor(
wikidataPlace = from(item.place)
)

/**
* Set this true when ImageProcessor has said that the location is invalid
* @param hasInvalidLocation
*/
fun setHasInvalidLocation(hasInvalidLocation: Boolean) {
this.hasInvalidLocation = if (hasInvalidLocation) 1 else 0
}

fun hasInvalidLocation(): Boolean {
return hasInvalidLocation == 1
}

companion object {
const val STATE_COMPLETED = -1
const val STATE_FAILED = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager.OnBackStackChangedListener;
import androidx.fragment.app.FragmentTransaction;

import fr.free.nrw.commons.MediaDataExtractor;
import fr.free.nrw.commons.auth.SessionManager;
import io.reactivex.disposables.Disposable;
import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import butterknife.BindView;
import butterknife.ButterKnife;
import fr.free.nrw.commons.Media;
Expand Down Expand Up @@ -83,6 +92,9 @@ public class ContributionsFragment

@Inject ContributionsPresenter contributionsPresenter;

@Inject
SessionManager sessionManager;

private LatLng curLatLng;

private boolean firstLocationUpdate = true;
Expand Down Expand Up @@ -143,7 +155,14 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,

initFragments();

if (!ConfigUtils.isBetaFlavour()) {
if(shouldShowMediaDetailsFragment){
showMediaDetailPagerFragment();
}else{
showContributionsListFragment();
}

if (!ConfigUtils.isBetaFlavour() && sessionManager.isUserLoggedIn()
&& sessionManager.getCurrentAccount() != null) {
setUploadCount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void initRecyclerView() {
getSpanCount(getResources().getConfiguration().orientation));
rvContributionsList.setLayoutManager(layoutManager);
contributionsListPresenter.setup();
contributionsListPresenter.contributionList.observe(this, adapter::submitList);
contributionsListPresenter.contributionList.observe(this.getViewLifecycleOwner(), adapter::submitList);
rvContributionsList.setAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.view.inputmethod.InputMethodManager;
import androidx.collection.LruCache;
import androidx.room.Room;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import com.google.gson.Gson;
import dagger.Module;
import dagger.Provides;
Expand Down Expand Up @@ -49,6 +51,15 @@ public class CommonsApplicationModule {
private Context applicationContext;
public static final String IO_THREAD="io_thread";
public static final String MAIN_THREAD="main_thread";
private AppDatabase appDatabase;

static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE contribution "
+ " ADD COLUMN hasInvalidLocation INTEGER NOT NULL DEFAULT 0");
}
};

public CommonsApplicationModule(Context applicationContext) {
this.applicationContext = applicationContext;
Expand Down Expand Up @@ -103,11 +114,6 @@ public ContentProviderClient provideCategoryContentProviderClient(Context contex
return context.getContentResolver().acquireContentProviderClient(BuildConfig.CATEGORY_AUTHORITY);
}

/**
* This method is used to provide instance of DepictsContentProviderClient
* @param context context
* @return DepictsContentProviderClient*/

/**
* This method is used to provide instance of RecentSearchContentProviderClient
* which provides content of Recent Searches from database
Expand Down Expand Up @@ -224,9 +230,11 @@ public String provideLoggedInUsername() {
@Provides
@Singleton
public AppDatabase provideAppDataBase() {
return Room.databaseBuilder(applicationContext, AppDatabase.class, "commons_room.db")
appDatabase = Room.databaseBuilder(applicationContext, AppDatabase.class, "commons_room.db")
.addMigrations(MIGRATION_1_2)
.fallbackToDestructiveMigration()
.build();
return appDatabase;
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public HttpLoggingInterceptor provideHttpLoggingInterceptor() {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(message -> {
Timber.tag("OkHttp").v(message);
});
httpLoggingInterceptor.level(BuildConfig.DEBUG ? Level.BODY: Level.BASIC);
httpLoggingInterceptor.setLevel(BuildConfig.DEBUG ? Level.BODY: Level.BASIC);
return httpLoggingInterceptor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static void handleActivityResult(int requestCode, int resultCode, Intent
public static List<UploadableFile> handleExternalImagesPicked(Intent data, Activity activity) {
try {
return getFilesFromGalleryPictures(data, activity);
} catch (IOException e) {
} catch (IOException | SecurityException e) {
e.printStackTrace();
}
return new ArrayList<>();
Expand Down Expand Up @@ -207,7 +207,7 @@ private static void onPictureReturnedFromGallery(Intent data, Activity activity,
}
}

private static List<UploadableFile> getFilesFromGalleryPictures(Intent data, Activity activity) throws IOException {
private static List<UploadableFile> getFilesFromGalleryPictures(Intent data, Activity activity) throws IOException, SecurityException {
List<UploadableFile> files = new ArrayList<>();
ClipData clipData = data.getClipData();
if (clipData == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,15 @@ static void scanCopiedImages(Context context, List<File> copiedImages) {
});
}

static UploadableFile pickedExistingPicture(@NonNull Context context, Uri photoUri) throws IOException {
static UploadableFile pickedExistingPicture(@NonNull Context context, Uri photoUri) throws IOException, SecurityException {// SecurityException for those file providers who share URI but forget to grant necessary permissions
InputStream pictureInputStream = context.getContentResolver().openInputStream(photoUri);
File directory = tempImageDirectory(context);
File photoFile = new File(directory, UUID.randomUUID().toString() + "." + getMimeType(context, photoUri));
photoFile.createNewFile();
writeToFile(pictureInputStream, photoFile);
if (photoFile.createNewFile()) {
writeToFile(pictureInputStream, photoFile);
} else {
throw new IOException("could not create photoFile to write upon");
}
return new UploadableFile(photoUri, photoFile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ public void showImage(int i) {
* The method notify the viewpager that number of items have changed.
*/
public void notifyDataSetChanged(){
adapter.notifyDataSetChanged();
if (null != adapter) {
adapter.notifyDataSetChanged();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
import com.facebook.drawee.interfaces.DraweeController;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.image.ImageInfo;
import com.github.chrisbanes.photoview.PhotoView;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class ZoomableActivity extends AppCompatActivity {
private Uri imageUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class ZoomableDraweeView extends DraweeView<GenericDraweeHierarchy>

private boolean mIsDialtoneEnabled = false;
private boolean mZoomingEnabled = true;
private TransformationListener transformationListener;

private final ControllerListener mControllerListener =
new BaseControllerListener<Object>() {
Expand All @@ -73,9 +74,18 @@ public void onTransformChanged(Matrix transform) {
}

@Override
public void onTransformEnd(Matrix transform) {}
public void onTransformEnd(Matrix transform) {
if (null != transformationListener) {
transformationListener.onTransformationEnd();
}
}
};

public void setTransformationListener(
TransformationListener transformationListener) {
this.transformationListener = transformationListener;
}

private final GestureListenerWrapper mTapListenerWrapper = new GestureListenerWrapper();

public ZoomableDraweeView(Context context, GenericDraweeHierarchy hierarchy) {
Expand Down Expand Up @@ -397,4 +407,11 @@ protected Class<?> getLogTag() {
protected ZoomableController createZoomableController() {
return AnimatedZoomableController.newInstance();
}

/**
* Use this, If someone is willing to listen to scale change
*/
public interface TransformationListener{
void onTransformationEnd();
}
}
Loading