Skip to content

Commit

Permalink
Fixes commons-app#3412 Add option to not show the dialog again
Browse files Browse the repository at this point in the history
  • Loading branch information
yashk2000 committed Feb 15, 2020
1 parent 75d4891 commit 07834f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -315,7 +317,8 @@ private void setAchievementsUploadCount(Achievements achievements, int uploadCou
* @param uploadCount
*/
private void setUploadProgress(int uploadCount){
if (uploadCount==0){
SharedPreferences prefs = this.getSharedPreferences(getString(R.string.achievements_activity), Context.MODE_PRIVATE);
if (uploadCount==0 && !prefs.getBoolean(getString(R.string.no_contributions_dialog), false)){
setZeroAchievements();
}else {

Expand All @@ -331,6 +334,12 @@ private void setZeroAchievements() {
AlertDialog.Builder builder=new AlertDialog.Builder(this)
.setMessage(getString(R.string.no_achievements_yet))
.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
})
.setNegativeButton(getString(R.string.no_show), (dialog, which) -> {
SharedPreferences prefs = this.getSharedPreferences(getString(R.string.achievements_activity), Context.MODE_PRIVATE);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(getString(R.string.no_contributions_dialog), true);
edit.apply();
});
AlertDialog dialog = builder.create();
dialog.show();
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -591,4 +591,7 @@ Upload your first media by tapping on the add button.</string>

<string name="upload_nearby_place_found_title">Nearby Place Found</string>
<string name="upload_nearby_place_found_description">Is this a photo of Place %1$s?</string>
<string name="achievements_activity">Achievements Activity</string>
<string name="no_show">Don\'t show again</string>
<string name="no_contributions_dialog">Show no contributions dialog</string>
</resources>

0 comments on commit 07834f1

Please sign in to comment.