Skip to content

Commit a7712f0

Browse files
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
1 parent 12883e3 commit a7712f0

File tree

68 files changed

+3556
-1984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3556
-1984
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ dependencies {
6363
testImplementation 'org.robolectric:robolectric:3.7.1'
6464
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
6565
testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
66+
testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5"
67+
testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5"
6668

6769
// Android testing
6870
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@
5050
</activity>
5151
<activity android:name=".WelcomeActivity" />
5252

53-
<activity android:name=".upload.UploadActivity"
53+
<activity
54+
android:name=".upload.UploadActivity"
55+
android:configChanges="orientation|screenSize|keyboard"
5456
android:icon="@mipmap/ic_launcher"
5557
android:label="@string/app_name"
56-
android:configChanges="orientation|screenSize|keyboard">
58+
android:windowSoftInputMode="adjustResize"
59+
>
5760
<intent-filter android:label="@string/intent_share_upload_label">
5861
<action android:name="android.intent.action.SEND" />
5962

app/src/main/java/fr/free/nrw/commons/BasePresenter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
/**
44
* Base presenter, enforcing contracts to atach and detach view
55
*/
6-
public interface BasePresenter {
6+
public interface BasePresenter<T> {
77
/**
88
* Until a view is attached, it is open to listen events from the presenter
99
*/
10-
void onAttachView(MvpView view);
10+
void onAttachView(T view);
1111

1212
/**
1313
* Detaching a view makes sure that the view no more receives events from the presenter

app/src/main/java/fr/free/nrw/commons/Utils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111

1212
import org.wikipedia.dataclient.WikiSite;
1313
import org.wikipedia.page.PageTitle;
14+
import fr.free.nrw.commons.location.LatLng;
15+
import fr.free.nrw.commons.utils.ViewUtil;
1416

1517
import java.util.Locale;
1618
import java.util.regex.Pattern;
1719

1820
import androidx.annotation.NonNull;
1921
import androidx.browser.customtabs.CustomTabsIntent;
2022
import androidx.core.content.ContextCompat;
21-
import fr.free.nrw.commons.location.LatLng;
2223
import fr.free.nrw.commons.settings.Prefs;
23-
import fr.free.nrw.commons.utils.ViewUtil;
2424
import timber.log.Timber;
2525

2626
import static android.widget.Toast.LENGTH_SHORT;

app/src/main/java/fr/free/nrw/commons/campaigns/CampaignsPresenter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* success and error
2929
*/
3030
@Singleton
31-
public class CampaignsPresenter implements BasePresenter {
31+
public class CampaignsPresenter implements BasePresenter<ICampaignsView> {
3232
private final OkHttpJsonApiClient okHttpJsonApiClient;
3333

3434
private ICampaignsView view;
@@ -40,8 +40,9 @@ public CampaignsPresenter(OkHttpJsonApiClient okHttpJsonApiClient) {
4040
this.okHttpJsonApiClient = okHttpJsonApiClient;
4141
}
4242

43-
@Override public void onAttachView(MvpView view) {
44-
this.view = (ICampaignsView) view;
43+
@Override
44+
public void onAttachView(ICampaignsView view) {
45+
this.view = view;
4546
}
4647

4748
@Override public void onDetachView() {

app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import io.reactivex.Observable;
2020
import timber.log.Timber;
2121

22-
public class CategoriesModel implements CategoryClickedListener {
22+
public class CategoriesModel{
2323
private static final int SEARCH_CATS_LIMIT = 25;
2424

2525
private final MediaWikiApi mwApi;
@@ -186,8 +186,7 @@ private Observable<CategoryItem> recentCategories() {
186186
//endregion
187187

188188
//region Category Selection
189-
@Override
190-
public void categoryClicked(CategoryItem item) {
189+
public void onCategoryItemClicked(CategoryItem item) {
191190
if (item.isSelected()) {
192191
selectCategory(item);
193192
updateCategoryCount(item);

app/src/main/java/fr/free/nrw/commons/category/CategoryItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public CategoryItem[] newArray(int i) {
1919
}
2020
};
2121

22-
CategoryItem(String name, boolean selected) {
22+
public CategoryItem(String name, boolean selected) {
2323
this.name = name;
2424
this.selected = selected;
2525
}

app/src/main/java/fr/free/nrw/commons/contributions/ContributionDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ContentValues toContentValues(Contribution contribution) {
100100
cv.put(Table.COLUMN_UPLOADED, contribution.getDateUploaded().getTime());
101101
}
102102
cv.put(Table.COLUMN_LENGTH, contribution.getDataLength());
103-
//This was always meant to store the date created..If somehow date created is not fetched while actually saving the contribution, lets save today's date
103+
//This was always meant to store the date created..If somehow date created is not fetched while actually saving the contribution, lets saveValue today's date
104104
cv.put(Table.COLUMN_TIMESTAMP, contribution.getDateCreated()==null?System.currentTimeMillis():contribution.getDateCreated().getTime());
105105
cv.put(Table.COLUMN_STATE, contribution.getState());
106106
cv.put(Table.COLUMN_TRANSFERRED, contribution.getTransferred());

app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import fr.free.nrw.commons.review.ReviewController;
1616
import fr.free.nrw.commons.settings.SettingsFragment;
1717
import fr.free.nrw.commons.upload.FileProcessor;
18+
import fr.free.nrw.commons.upload.UploadModule;
1819
import fr.free.nrw.commons.widget.PicOfDayAppWidget;
1920

2021

@@ -27,7 +28,7 @@
2728
ActivityBuilderModule.class,
2829
FragmentBuilderModule.class,
2930
ServiceBuilderModule.class,
30-
ContentProviderBuilderModule.class
31+
ContentProviderBuilderModule.class, UploadModule.class
3132
})
3233
public interface CommonsApplicationComponent extends AndroidInjector<ApplicationlessInjection> {
3334
void inject(CommonsApplication application);

app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationModule.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
import com.google.gson.Gson;
1010

11+
import io.reactivex.Scheduler;
12+
import io.reactivex.android.schedulers.AndroidSchedulers;
13+
import io.reactivex.schedulers.Schedulers;
1114
import java.util.ArrayList;
1215
import java.util.HashMap;
1316
import java.util.List;
@@ -36,6 +39,8 @@
3639
@SuppressWarnings({"WeakerAccess", "unused"})
3740
public class CommonsApplicationModule {
3841
private Context applicationContext;
42+
public static final String IO_THREAD="io_thread";
43+
public static final String MAIN_THREAD="main_thread";
3944

4045
public CommonsApplicationModule(Context applicationContext) {
4146
this.applicationContext = applicationContext;
@@ -171,4 +176,16 @@ public WikidataEditListener provideWikidataEditListener() {
171176
public boolean provideIsBetaVariant() {
172177
return ConfigUtils.isBetaFlavour();
173178
}
179+
180+
@Named(IO_THREAD)
181+
@Provides
182+
public Scheduler providesIoThread(){
183+
return Schedulers.io();
184+
}
185+
186+
@Named(MAIN_THREAD)
187+
@Provides
188+
public Scheduler providesMainThread(){
189+
return AndroidSchedulers.mainThread();
190+
}
174191
}

0 commit comments

Comments
 (0)