Shift contributions to use Room DB (#3324)

* Part of #3127
* Added Room Dependency
* Shifted ContributionsDao to use RoomDB

* Save and Fetch contributions via RoomDAO

* Bugfixes, fixed test cases, injected schedulers for ContributionsPresenter

* removed stetho

* Fixed ReviewHelperTest cases

* Fixed test cases in DeleteHelperTest

* Fetch all contributions [TODO add pagination to use this, maybe later in a seperate PR]

* Update Schema false in AppDatabase

* removed parameter from fetchControbutions

* Added logs for fetch contributions

* Fixed test case ContributionsPresenter

* Added an autogenerate primary key, submit save contributions on executor

* fixed getItemAtPosition

* MainActivity Config changes +=orientation

* BugFixes
* Make AppDataBase Singleton
* Set _id as autogenerate primary key [replacing the previously used filename, seems like they are not unique]
* Replace Execxutor Utils with Subscribers on Singles in UploadService
* BugFix, Upload Progress

* Remove un-nescessary null check on contributions in ContributionsListAdapter

* removed ContributionsListFragment [not-implemeted]

* Review suggested changes
* removed un-nescessary null checks
* provide ContributionsDao
* Minor bug fixes

* wip

* delete existing contributions table (from the existing db) on upgrade

* remove un-nescessary null checks in test classes

* shifted media to be a local variable in ReviewHelperTest

* removed captured folder

* Dispose composite disposables in UploadService

* replaced size check with isEmpty ContributionsPresenter

* transform saveContributions to a Completable

* Addressed comments in review
* Typo in Contributions
* ReasonBuilderTest (create media object instead of mocking)
* Use global Gson object instead of creating a new one in Converters

* Provide Gson to Converters from the CommonsApplicationComponent

* use static method instead of field instead of static field to provide GSON in Converters

* Modified gitignore to exclude captures/*
This commit is contained in:
Ashish Kumar 2020-03-10 02:43:20 +05:30 committed by GitHub
parent 642ed51c8c
commit 99c6f5f105
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 557 additions and 1296 deletions

View file

@ -6,6 +6,8 @@ import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import org.apache.commons.lang3.StringUtils;
import org.wikipedia.dataclient.mwapi.MwQueryPage;
@ -26,6 +28,7 @@ import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.CommonsDateUtil;
import fr.free.nrw.commons.utils.MediaDataExtractorUtil;
@Entity
public class Media implements Parcelable {
public static final Media EMPTY = new Media("");
@ -42,25 +45,25 @@ public class Media implements Parcelable {
};
// Primary metadata fields
protected Uri localUri;
private String thumbUrl;
protected String imageUrl;
protected String filename;
protected String description; // monolingual description on input...
protected String discussion;
protected long dataLength;
protected Date dateCreated;
protected @Nullable Date dateUploaded;
protected int width;
protected int height;
protected String license;
protected String licenseUrl;
protected String creator;
protected ArrayList<String> categories; // as loaded at runtime?
protected boolean requestedDeletion;
private Map<String, String> descriptions; // multilingual descriptions as loaded
private HashMap<String, Object> tags = new HashMap<>();
private @Nullable LatLng coordinates;
public Uri localUri;
public String thumbUrl;
public String imageUrl;
public String filename;
public String description; // monolingual description on input...
public String discussion;
long dataLength;
public Date dateCreated;
@Nullable public Date dateUploaded;
public int width;
public int height;
public String license;
public String licenseUrl;
public String creator;
public ArrayList<String> categories; // as loaded at runtime?
public boolean requestedDeletion;
public HashMap<String, String> descriptions; // multilingual descriptions as loaded
public HashMap<String, String> tags = new HashMap<>();
@Nullable public LatLng coordinates;
/**
* Provides local constructor
@ -118,7 +121,7 @@ public class Media implements Parcelable {
dateCreated = (Date) in.readSerializable();
dateUploaded = (Date) in.readSerializable();
creator = in.readString();
tags = (HashMap<String, Object>) in.readSerializable();
tags = (HashMap<String, String>) in.readSerializable();
width = in.readInt();
height = in.readInt();
license = in.readString();
@ -218,7 +221,7 @@ public class Media implements Parcelable {
* @param key Media key
* @param value Media value
*/
public void setTag(String key, Object value) {
public void setTag(String key, String value) {
tags.put(key, value);
}