-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feature/refractor uploads [WIP] #2887
Merged
ashishkumar468
merged 42 commits into
commons-app:refactor_uploads
from
ashishkumar468:feature/refractor_uploads
May 28, 2019
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
3684710
Fix duplicate param information (#2515)
maskaravivek e90049b
Bug fix issue #2476 (#2526)
ashishkumar468 cf1faf4
Versioning and changelog for v2.10.2 (#2531)
misaochan 27683a7
Bugfix/issue 2580 (#2584)
ashishkumar468 468f0b7
Bug Fix #2585 (#2647)
ashishkumar468 fbf7cd5
Bug Fix issue #2648 (#2678)
ashishkumar468 01f6c99
BugFix issue #2652 (#2706)
ashishkumar468 963072e
BugFix issue #2711 (#2712)
ashishkumar468 6ea1c81
BugFix #2718 (#2719)
ashishkumar468 5fdb6fc
Fix #2791: NPE when nominating for deletion and leaving screen (#2792)
ashishkumar468 314ebd8
Bug Fix issue #2789 (#2790)
ashishkumar468 03e3d05
BugFix #2720 (#2831)
ashishkumar468 70a715d
ui fixes, wip, upload
ashishkumar468 ad8ca71
*Issue #2886, BugFix #2832[wip]
ashishkumar468 fe80c12
* updated interfaces names to follow names suffixed with Contract
ashishkumar468 b5c4210
card view elevation
ashishkumar468 87d7b0d
view pager disabled swipe
ashishkumar468 22ce2e2
bug fix, duplicate image
ashishkumar468 7718cd8
used existing non-swipable view pager
ashishkumar468 3177162
Avoid image view resize with keyboard, added adjustPan and stateVisib…
ashishkumar468 e648119
retain UploadBaseFragment instances on orientation changes
ashishkumar468 cbafd76
* Added test cases for UploadMediaPresenter
ashishkumar468 0a10178
categories presenter test cased wip
ashishkumar468 70ee5ee
Added CategoriesPresenter test
ashishkumar468 07870a5
* Added the logic to show open map (with to be uploaded image's coord…
ashishkumar468 00819a4
codacy suggested changes * added java docs
ashishkumar468 a40a1c3
Added travis_wait fot android-wait-for-emulator
ashishkumar468 3485d3e
Synced with master
ashishkumar468 2f5c83f
ranamed interface onResponseCallback to Callback
ashishkumar468 51943a3
* Added api to delete picture in UploadModel
ashishkumar468 de9d681
* Added tests for UploadPresenter
ashishkumar468 72b0f5e
* Made the upload add descriptions visible when keyboard visible
ashishkumar468 c2e294a
Added JavaDocs, review suggested changes
ashishkumar468 697948c
Merge branch 'master' into feature/refractor_uploads
ashishkumar468 bf9d180
Fix dagger injection
maskaravivek 020938b
Merge pull request #1 from maskaravivek/uploadDagger
ashishkumar468 24f8c46
use DialogUtil to show info in descriptions
ashishkumar468 8ef415a
Merge branch 'feature/refractor_uploads' of https://github.com/ashish…
ashishkumar468 7121ccf
use activity context for DialogUtil
ashishkumar468 f893b8f
Minor changes
maskaravivek 59bac5b
Merge pull request #2 from maskaravivek/minorChanges
ashishkumar468 3286816
resolved merge conflicts with master
ashishkumar468 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add java docs. For class and methods |
||
|
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annotate as Nullable |
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused imports?