-
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
Changes from 32 commits
3684710
e90049b
cf1faf4
27683a7
468f0b7
fbf7cd5
01f6c99
963072e
6ea1c81
5fdb6fc
314ebd8
03e3d05
70a715d
ad8ca71
fe80c12
b5c4210
87d7b0d
22ce2e2
7718cd8
3177162
e648119
cbafd76
0a10178
70ee5ee
07870a5
00819a4
a40a1c3
3485d3e
2f5c83f
51943a3
de9d681
72b0f5e
c2e294a
697948c
bf9d180
020938b
24f8c46
8ef415a
7121ccf
f893b8f
59bac5b
3286816
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package fr.free.nrw.commons.di; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import dagger.Component; | ||
import dagger.android.AndroidInjectionModule; | ||
import dagger.android.AndroidInjector; | ||
|
@@ -15,7 +13,12 @@ | |
import fr.free.nrw.commons.review.ReviewController; | ||
import fr.free.nrw.commons.settings.SettingsFragment; | ||
import fr.free.nrw.commons.upload.FileProcessor; | ||
import fr.free.nrw.commons.upload.UploadModule; | ||
import fr.free.nrw.commons.upload.categories.UploadCategoriesFragment; | ||
import fr.free.nrw.commons.upload.license.MediaLicenseFragment; | ||
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment; | ||
import fr.free.nrw.commons.widget.PicOfDayAppWidget; | ||
import javax.inject.Singleton; | ||
|
||
|
||
@Singleton | ||
|
@@ -27,7 +30,7 @@ | |
ActivityBuilderModule.class, | ||
FragmentBuilderModule.class, | ||
ServiceBuilderModule.class, | ||
ContentProviderBuilderModule.class | ||
ContentProviderBuilderModule.class, UploadModule.class | ||
}) | ||
public interface CommonsApplicationComponent extends AndroidInjector<ApplicationlessInjection> { | ||
void inject(CommonsApplication application); | ||
|
@@ -51,6 +54,12 @@ public interface CommonsApplicationComponent extends AndroidInjector<Application | |
|
||
void inject(PicOfDayAppWidget picOfDayAppWidget); | ||
|
||
void inject(UploadCategoriesFragment uploadCategoriesFragment); | ||
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. No need to declare 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. No need to define the fragments here. Add them in |
||
|
||
void inject(MediaLicenseFragment mediaLicenseFragment); | ||
|
||
void inject(UploadMediaDetailFragment uploadMediaDetailFragment); | ||
|
||
void inject(ContributionViewHolder viewHolder); | ||
|
||
@Component.Builder | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,10 @@ | |
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import io.reactivex.disposables.Disposable; | ||
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. Unused? |
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Represents search screen of this app | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,12 @@ | |
import org.apache.commons.lang3.StringUtils; | ||
import org.wikipedia.util.DateUtil; | ||
import org.wikipedia.util.StringUtil; | ||
import java.io.IOException; | ||
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. Unused? |
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
import timber.log.Timber; | ||
|
||
import static android.view.View.GONE; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,11 +44,15 @@ | |
import fr.free.nrw.commons.utils.NetworkUtils; | ||
import fr.free.nrw.commons.utils.PermissionUtils; | ||
import fr.free.nrw.commons.utils.ViewUtil; | ||
import javax.inject.Inject; | ||
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. Unused? |
||
import javax.inject.Named; | ||
import timber.log.Timber; | ||
|
||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; | ||
import static android.content.Context.DOWNLOAD_SERVICE; | ||
import static fr.free.nrw.commons.Utils.handleWebUrl; | ||
import static android.content.Intent.ACTION_VIEW; | ||
import static android.widget.Toast.LENGTH_SHORT; | ||
|
||
public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment implements ViewPager.OnPageChangeListener { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package fr.free.nrw.commons.repository; | ||
|
||
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; | ||
|
||
@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; | ||
} | ||
|
||
|
||
public List<String> getLicenses() { | ||
return uploadModel.getLicenses(); | ||
} | ||
|
||
public String getFromDefaultKvStore(String key, String defaultValue) { | ||
return defaultKVStore.getString(key, defaultValue); | ||
} | ||
|
||
public void saveInDefaultKvStore(String key, String value) { | ||
defaultKVStore.putString(key, value); | ||
} | ||
|
||
public int getCount() { | ||
return uploadModel.getCount(); | ||
} | ||
|
||
public String getSelectedLicense() { | ||
return uploadModel.getSelectedLicense(); | ||
} | ||
|
||
public void setSelectedLicense(String licenseName) { | ||
uploadModel.setSelectedLicense(licenseName); | ||
} | ||
|
||
public void updateUploadItem(int index, UploadItem uploadItem) { | ||
uploadModel.updateUploadItem(index, uploadItem); | ||
} | ||
|
||
public void saveInDirectKvStore(String key, boolean value) { | ||
defaultKVStore.putBoolean(key, value); | ||
} | ||
|
||
public void cleanUp() { | ||
uploadModel.cleanUp(); | ||
} | ||
|
||
public void deletePicture(String filePath) { | ||
uploadModel.deletePicture(filePath); | ||
} | ||
|
||
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){ | ||
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. Fix formatting. There are formatting issues at other places too. Please check once. |
||
return uploadModel.getItems().get(index-1); | ||
} | ||
return null; //There is no previous item to copy details | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package fr.free.nrw.commons.repository; | ||
|
||
import fr.free.nrw.commons.category.CategoriesModel; | ||
import fr.free.nrw.commons.category.CategoryItem; | ||
import fr.free.nrw.commons.contributions.Contribution; | ||
import fr.free.nrw.commons.filepicker.UploadableFile; | ||
import fr.free.nrw.commons.nearby.Place; | ||
import fr.free.nrw.commons.upload.SimilarImageInterface; | ||
import fr.free.nrw.commons.upload.UploadController; | ||
import fr.free.nrw.commons.upload.UploadModel; | ||
import fr.free.nrw.commons.upload.UploadModel.UploadItem; | ||
import io.reactivex.Observable; | ||
import io.reactivex.Single; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
public class UploadRemoteDataSource { | ||
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 |
||
|
||
private UploadModel uploadModel; | ||
private UploadController uploadController; | ||
private CategoriesModel categoriesModel; | ||
|
||
@Inject | ||
public UploadRemoteDataSource(UploadModel uploadModel, UploadController uploadController, | ||
CategoriesModel categoriesModel) { | ||
this.uploadModel = uploadModel; | ||
this.uploadController = uploadController; | ||
this.categoriesModel = categoriesModel; | ||
} | ||
|
||
public Observable<Contribution> buildContributions() { | ||
return uploadModel.buildContributions(); | ||
} | ||
|
||
public void startUpload(Contribution contribution) { | ||
uploadController.startUpload(contribution); | ||
} | ||
|
||
public List<UploadItem> getUploads() { | ||
return uploadModel.getUploads(); | ||
} | ||
|
||
public void prepareService() { | ||
uploadController.prepareService(); | ||
} | ||
|
||
public void cleanup() { | ||
uploadController.cleanup(); | ||
} | ||
|
||
public List<CategoryItem> getSelectedCategories() { | ||
return categoriesModel.getSelectedCategories(); | ||
} | ||
|
||
public Observable<CategoryItem> searchAll(String query, List<String> imageTitleList) { | ||
return categoriesModel.searchAll(query, imageTitleList); | ||
} | ||
|
||
public Observable<CategoryItem> searchCategories(String query, List<String> imageTitleList) { | ||
return categoriesModel.searchCategories(query, imageTitleList); | ||
} | ||
|
||
public Observable<CategoryItem> defaultCategories(List<String> imageTitleList) { | ||
return categoriesModel.defaultCategories(imageTitleList); | ||
} | ||
|
||
public List<String> getCategoryStringList() { | ||
return categoriesModel.getCategoryStringList(); | ||
} | ||
|
||
public void setSelectedCategories(List<String> categoryStringList) { | ||
uploadModel.setSelectedCategories(categoryStringList); | ||
} | ||
|
||
public void onCategoryClicked(CategoryItem categoryItem) { | ||
categoriesModel.onCategoryItemClicked(categoryItem); | ||
} | ||
|
||
public Comparator<CategoryItem> sortBySimilarity(String query) { | ||
return categoriesModel.sortBySimilarity(query); | ||
} | ||
|
||
public boolean containsYear(String name) { | ||
return categoriesModel.containsYear(name); | ||
} | ||
|
||
public Observable<UploadItem> preProcessImage(UploadableFile uploadableFile, Place place, | ||
String source, SimilarImageInterface similarImageInterface) { | ||
return uploadModel.preProcessImage(uploadableFile,place,source,similarImageInterface); | ||
} | ||
|
||
public Single<Integer> getImageQuality(UploadItem uploadItem, boolean shouldValidateTitle) { | ||
return uploadModel.getImageQuality(uploadItem,shouldValidateTitle); | ||
} | ||
} |
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?