5454import fr .free .nrw .commons .contributions .Contribution ;
5555import fr .free .nrw .commons .mwapi .MediaWikiApi ;
5656import fr .free .nrw .commons .utils .DialogUtil ;
57- import fr .free .nrw .commons .utils .ImageUtils ;
57+ import fr .free .nrw .commons .utils .StringUtils ;
5858import fr .free .nrw .commons .utils .ViewUtil ;
5959import io .reactivex .Observable ;
6060import io .reactivex .android .schedulers .AndroidSchedulers ;
6161import io .reactivex .disposables .CompositeDisposable ;
6262import io .reactivex .schedulers .Schedulers ;
6363import timber .log .Timber ;
6464
65+ import static fr .free .nrw .commons .utils .ImageUtils .Result ;
66+ import static fr .free .nrw .commons .utils .ImageUtils .getErrorMessageForResult ;
6567import static fr .free .nrw .commons .wikidata .WikidataConstants .WIKIDATA_ENTITY_ID_PREF ;
6668
6769public class UploadActivity extends AuthenticatedActivity implements UploadView , SimilarImageInterface {
@@ -211,15 +213,20 @@ public void updateRightCardContent(boolean gpsPresent) {
211213 }
212214
213215 @ Override
214- public void updateBottomCardContent (int currentStep , int stepCount , UploadModel .UploadItem uploadItem ) {
216+ public void updateBottomCardContent (int currentStep ,
217+ int stepCount ,
218+ UploadModel .UploadItem uploadItem ,
219+ boolean isShowingItem ) {
215220 String cardTitle = getResources ().getString (R .string .step_count , currentStep , stepCount );
216221 String cardSubTitle = getResources ().getString (R .string .image_in_set_label , currentStep );
217222 bottomCardTitle .setText (cardTitle );
218223 bottomCardSubtitle .setText (cardSubTitle );
219224 categoryTitle .setText (cardTitle );
220225 licenseTitle .setText (cardTitle );
221- descriptionsAdapter .setItems (uploadItem .title , uploadItem .descriptions );
222- rvDescriptions .setAdapter (descriptionsAdapter );
226+ if (isShowingItem ) {
227+ descriptionsAdapter .setItems (uploadItem .title , uploadItem .descriptions );
228+ rvDescriptions .setAdapter (descriptionsAdapter );
229+ }
223230 }
224231
225232 @ Override
@@ -339,28 +346,15 @@ public void dismissKeyboard() {
339346 }
340347
341348 @ Override
342- public void showBadPicturePopup (@ ImageUtils .Result int result ) {
343- String errorMessage ;
344- if (result == ImageUtils .IMAGE_DARK )
345- errorMessage = getString (R .string .upload_image_problem_dark );
346- else if (result == ImageUtils .IMAGE_BLURRY )
347- errorMessage = getString (R .string .upload_image_problem_blurry );
348- else if (result == ImageUtils .IMAGE_DUPLICATE )
349- errorMessage = getString (R .string .upload_image_problem_duplicate );
350- else if (result == (ImageUtils .IMAGE_DARK |ImageUtils .IMAGE_BLURRY ))
351- errorMessage = getString (R .string .upload_image_problem_dark_blurry );
352- else if (result == (ImageUtils .IMAGE_DARK |ImageUtils .IMAGE_DUPLICATE ))
353- errorMessage = getString (R .string .upload_image_problem_dark_duplicate );
354- else if (result == (ImageUtils .IMAGE_BLURRY |ImageUtils .IMAGE_DUPLICATE ))
355- errorMessage = getString (R .string .upload_image_problem_blurry_duplicate );
356- else if (result == (ImageUtils .IMAGE_DARK |ImageUtils .IMAGE_BLURRY |ImageUtils .IMAGE_DUPLICATE ))
357- errorMessage = getString (R .string .upload_image_problem_dark_blurry_duplicate );
358- else
349+ public void showBadPicturePopup (@ Result int result ) {
350+ String errorMessageForResult = getErrorMessageForResult (this , result );
351+ if (StringUtils .isNullOrWhiteSpace (errorMessageForResult )) {
359352 return ;
353+ }
360354
361355 DialogUtil .showAlertDialog (this ,
362356 getString (R .string .warning ),
363- errorMessage ,
357+ errorMessageForResult ,
364358 () -> presenter .deletePicture (),
365359 () -> presenter .keepPicture ());
366360 }
@@ -373,7 +367,7 @@ public void showDuplicatePicturePopup() {
373367 null ,
374368 () -> {
375369 presenter .keepPicture ();
376- presenter .handleNext (categoriesModel , false );
370+ presenter .handleNext (descriptionsAdapter . getTitle (), getDescriptions () );
377371 });
378372 }
379373
@@ -384,7 +378,7 @@ public void showNoCategorySelectedWarning() {
384378 getString (R .string .no_go_back ),
385379 getString (R .string .yes_submit ),
386380 null ,
387- () -> presenter .handleNext (categoriesModel , true ));
381+ () -> presenter .handleCategoryNext (categoriesModel , true ));
388382 }
389383
390384 @ Override
@@ -454,10 +448,12 @@ private void configureTopCard() {
454448
455449 private void configureBottomCard () {
456450 bottomCardExpandButton .setOnClickListener (v -> presenter .toggleBottomCardState ());
457- bottomCardAddDescription .setOnClickListener (v -> {
458- descriptionsAdapter .addDescription (new Description ());
459- rvDescriptions .scrollToPosition (descriptionsAdapter .getItemCount () - 1 );
460- });
451+ bottomCardAddDescription .setOnClickListener (v -> addNewDescription ());
452+ }
453+
454+ private void addNewDescription () {
455+ descriptionsAdapter .addDescription (new Description ());
456+ rvDescriptions .scrollToPosition (descriptionsAdapter .getItemCount () - 1 );
461457 }
462458
463459 private void configureRightCard () {
@@ -467,11 +463,15 @@ private void configureRightCard() {
467463
468464 private void configureNavigationButtons () {
469465 // Navigation next / previous for each image as we're collecting title + description
470- next .setOnClickListener (v -> presenter .handleNext (categoriesModel , false ));
466+ next .setOnClickListener (v -> {
467+ setTitleAndDescriptions ();
468+ presenter .handleNext (descriptionsAdapter .getTitle (),
469+ descriptionsAdapter .getDescriptions ());
470+ });
471471 previous .setOnClickListener (v -> presenter .handlePrevious ());
472472
473473 // Next / previous for the category selection currentPage
474- categoryNext .setOnClickListener (v -> presenter .handleNext (categoriesModel , false ));
474+ categoryNext .setOnClickListener (v -> presenter .handleCategoryNext (categoriesModel , false ));
475475 categoryPrevious .setOnClickListener (v -> presenter .handlePrevious ());
476476
477477 // Finally, the previous / submit buttons on the final currentPage of the wizard
@@ -484,6 +484,11 @@ private void configureNavigationButtons() {
484484
485485 }
486486
487+ private void setTitleAndDescriptions () {
488+ List <Description > descriptions = descriptionsAdapter .getDescriptions ();
489+ Timber .d ("Descriptions size is %d are %s" , descriptions .size (), descriptions );
490+ }
491+
487492 private void configureCategories () {
488493 categoriesAdapter = new UploadCategoriesAdapterFactory (categoriesModel ).create (new ArrayList <>());
489494 categoriesList .setLayoutManager (new LinearLayoutManager (this ));
@@ -576,6 +581,7 @@ private void initRecyclerView() {
576581 descriptionsAdapter .setCallback (this ::showInfoAlert );
577582 rvDescriptions .setLayoutManager (new LinearLayoutManager (getApplicationContext ()));
578583 rvDescriptions .setAdapter (descriptionsAdapter );
584+ addNewDescription ();
579585 }
580586
581587
0 commit comments