Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/refractor uploads [WIP] (#2887)
* Fix duplicate param information (#2515) * Bug fix issue #2476 (#2526) * Added wikidataEntityID in all db versions, handled db.execSql via method runQuery * Versioning and changelog for v2.10.2 (#2531) * Update changelog.md * Versioning for v2.10.2 * Update changelog.md * Bugfix/issue 2580 (#2584) * Corrected string placedholders in certain string files * Corrected string placedholders in certain string files[Bug fix #2580] * Bug Fix #2585 (#2647) * Bug Fix #2585 * Added null checks on view in SearchImageFragment when updating views from external sources * Disposed the disposables in SearchActivity and SearchImageFragment when no longer in active lifecycle * use FragmentUtils to verify fragment active state * Bug Fix issue #2648 (#2678) * Bug Fix issue #2648 * Handled external storage permission before file download * * Removed redudant check for permission in MediaDetailPagerFragment (Dexter already does that) * Removed duplicate code in PermissionUtil$checkPermissionsAndPerformAction, used the existing function with conditional extra parameters * string name typo correction * BugFix issue #2652 (#2706) * Addded null check on bookmark before operating on it * BugFix issue #2711 (#2712) * Added null checks in OkHttpJsonApiClient$searchImages MwQueryResponse * BugFix #2718 (#2719) * Handled null auth cookies * Fix #2791: NPE when nominating for deletion and leaving screen (#2792) * Bug Fix issue #2789 (#2790) * Handled Illegal State Exception for non existent appropriate view parents in ViewUtils$showShortSnackbar * BugFix #2720 (#2831) BugFix deprecated licenes #2720 * ui fixes, wip, upload * *Issue #2886, BugFix #2832[wip] * updated UploadActivity code * modified ui * Updated UploadPresenterTest * * updated interfaces names to follow names suffixed with Contract * added test cases * card view elevation * view pager disabled swipe * bug fix, duplicate image * used existing non-swipable view pager * Avoid image view resize with keyboard, added adjustPan and stateVisible as softinputMode for UploadActivity * retain UploadBaseFragment instances on orientation changes * * Added test cases for UploadMediaPresenter * Injected io and main thread schedulers * categories presenter test cased wip * Added CategoriesPresenter test * * Added the logic to show open map (with to be uploaded image's coordinates while uploading image) * codacy suggested changes * added java docs * Added travis_wait fot android-wait-for-emulator * ranamed interface onResponseCallback to Callback * * Added api to delete picture in UploadModel * cleanUp in UploadModel. once upload has been initiated * Removed unused methods from UploadModel and the corresponding test class * * Added tests for UploadPresenter * Travis suggested changes * Addded copy previous title and description * * Made the upload add descriptions visible when keyboard visible * add description request focus only when user manually requests it * Added JavaDocs, review suggested changes * Fix dagger injection * use DialogUtil to show info in descriptions * use activity context for DialogUtil * Minor changes
- Loading branch information
1 parent
12883e3
commit a7712f0
Showing
68 changed files
with
3,556 additions
and
1,984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
app/src/main/java/fr/free/nrw/commons/repository/UploadLocalDataSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package fr.free.nrw.commons.repository; | ||
|
||
import androidx.annotation.Nullable; | ||
import fr.free.nrw.commons.kvstore.JsonKvStore; | ||
import fr.free.nrw.commons.upload.UploadModel; | ||
import fr.free.nrw.commons.upload.UploadModel.UploadItem; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
/** | ||
* The Local Data Source for UploadRepository, fetches and returns data from local db/shared prefernces | ||
*/ | ||
|
||
@Singleton | ||
public class UploadLocalDataSource { | ||
|
||
private final UploadModel uploadModel; | ||
private JsonKvStore defaultKVStore; | ||
|
||
@Inject | ||
public UploadLocalDataSource( | ||
@Named("default_preferences") JsonKvStore defaultKVStore, | ||
UploadModel uploadModel) { | ||
this.defaultKVStore = defaultKVStore; | ||
this.uploadModel = uploadModel; | ||
} | ||
|
||
|
||
/** | ||
* Fetches and returns the string list of valid licenses | ||
* | ||
* @return | ||
*/ | ||
public List<String> getLicenses() { | ||
return uploadModel.getLicenses(); | ||
} | ||
|
||
/** | ||
* Returns the number of Upload Items | ||
* | ||
* @return | ||
*/ | ||
public int getCount() { | ||
return uploadModel.getCount(); | ||
} | ||
|
||
/** | ||
* Fetches and return the selected license for the current upload | ||
* | ||
* @return | ||
*/ | ||
public String getSelectedLicense() { | ||
return uploadModel.getSelectedLicense(); | ||
} | ||
|
||
/** | ||
* Set selected license for the current upload | ||
* | ||
* @param licenseName | ||
*/ | ||
public void setSelectedLicense(String licenseName) { | ||
uploadModel.setSelectedLicense(licenseName); | ||
} | ||
|
||
/** | ||
* Updates the current upload item | ||
* | ||
* @param index | ||
* @param uploadItem | ||
*/ | ||
public void updateUploadItem(int index, UploadItem uploadItem) { | ||
uploadModel.updateUploadItem(index, uploadItem); | ||
} | ||
|
||
/** | ||
* upload is halted, cleanup the acquired resources | ||
*/ | ||
public void cleanUp() { | ||
uploadModel.cleanUp(); | ||
} | ||
|
||
/** | ||
* Deletes the upload item at the current index | ||
* | ||
* @param filePath | ||
*/ | ||
public void deletePicture(String filePath) { | ||
uploadModel.deletePicture(filePath); | ||
} | ||
|
||
/** | ||
* Fethces and returns the previous upload item, if any, returns null otherwise | ||
* | ||
* @param index | ||
* @return | ||
*/ | ||
@Nullable | ||
public UploadItem getPreviousUploadItem(int index) { | ||
if (index - 1 >= 0) { | ||
return uploadModel.getItems().get(index - 1); | ||
} | ||
return null; //There is no previous item to copy details | ||
} | ||
|
||
/** | ||
* saves boolean value in default store | ||
* | ||
* @param key | ||
* @param value | ||
*/ | ||
public void saveValue(String key, boolean value) { | ||
defaultKVStore.putBoolean(key, value); | ||
} | ||
|
||
/** | ||
* saves string value in default store | ||
* | ||
* @param key | ||
* @param value | ||
*/ | ||
public void saveValue(String key, String value) { | ||
defaultKVStore.putString(key, value); | ||
} | ||
|
||
/** | ||
* Fetches and returns string value from the default store | ||
* | ||
* @param key | ||
* @param defaultValue | ||
* @return | ||
*/ | ||
public String getValue(String key, String defaultValue) { | ||
return defaultKVStore.getString(key, defaultValue); | ||
} | ||
|
||
/** | ||
* Fetches and returns boolean value from the default store | ||
* | ||
* @param key | ||
* @param defaultValue | ||
* @return | ||
*/ | ||
public boolean getValue(String key, boolean defaultValue) { | ||
return defaultKVStore.getBoolean(key, defaultValue); | ||
} | ||
} |
Oops, something went wrong.