Fixed 4728 : Suggest User to turn on camera location (#4735)

* Dialog can't be dismissed

* Dialog can't be dismissed

* Suggest users to turn on camera location

* Added safety pattern

* Title removed

* Changed constant
This commit is contained in:
Ayan Sarkar 2021-12-22 18:45:58 +05:30 committed by GitHub
parent d8bfd1ffc5
commit 8a2c30120d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package fr.free.nrw.commons.upload;
import static fr.free.nrw.commons.contributions.ContributionController.ACTION_INTERNAL_UPLOADS;
import static fr.free.nrw.commons.upload.UploadPresenter.COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES;
import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;
import android.Manifest;
@ -469,7 +470,18 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
vpUpload.setCurrentItem(index + 1, false);
fragments.get(index + 1).onBecameVisible();
} else {
presenter.handleSubmit();
if(defaultKvStore.getInt(COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES, 0) >= 10){
DialogUtil.showAlertDialog(this,
"",
getString(R.string.location_message),
getString(R.string.ok),
() -> {
defaultKvStore.putInt(COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES, 0);
presenter.handleSubmit();
}, false);
} else {
presenter.handleSubmit();
}
}
}

View file

@ -32,6 +32,9 @@ public class UploadPresenter implements UploadContract.UserActionListener {
private UploadContract.View view = DUMMY;
private CompositeDisposable compositeDisposable;
public static final String COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES
= "number_of_consecutive_uploads_without_coordinates";
@Inject
UploadPresenter(UploadRepository uploadRepository,
@ -69,6 +72,16 @@ public class UploadPresenter implements UploadContract.UserActionListener {
@Override
public void onNext(Contribution contribution) {
if(contribution.getDecimalCoords() == null){
final int recentCount
= defaultKvStore.getInt(
COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES, 0);
defaultKvStore.putInt(
COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES, recentCount + 1);
} else {
defaultKvStore.putInt(
COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES, 0);
}
repository.prepareMedia(contribution);
contribution.setState(Contribution.STATE_QUEUED);
repository.saveContribution(contribution);

View file

@ -678,4 +678,5 @@ Upload your first media by tapping on the add button.</string>
<string name="advanced_query_info_text">You can customize the Nearby query. If you get errors, reset and apply.</string>
<string name="apply">Apply</string>
<string name="reset">Reset</string>
<string name="location_message">Location data helps Wiki editors find your picture, making it much more useful.\nYour recent uploads have no location.\nWe suggest you turn on location in your camera app\'s settings.\nThank you for uploading!</string>
</resources>