Skip to content

Commit a203523

Browse files
committed
move survey domain and display it only after some time
1 parent 1a0f2a5 commit a203523

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

app/src/main/java/vocabletrainer/heinecke/aron/vocabletrainer/activity/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
5454
if (savedInstanceState != null) {
5555
surveyDialog = (SurveyDialog) getSupportFragmentManager().getFragment(savedInstanceState, SurveyDialog.TAG);
5656
}
57-
if (surveyDialog == null && !SurveyDialog.wasSurveyDisplayed(this)) {
57+
if (surveyDialog == null && SurveyDialog.shouldDisplaySurvey(this)) {
5858
surveyDialog = SurveyDialog.newInstance();
5959
surveyDialog.show(getSupportFragmentManager(), SurveyDialog.TAG);
6060
}

app/src/main/java/vocabletrainer/heinecke/aron/vocabletrainer/dialog/SurveyDialog.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
public class SurveyDialog extends DialogFragment {
3333
public static final String TAG = "SurveyDialog";
3434
private static final String P_KEY_SURVEY_DIALOG_API= "showedAPISurveyDialog";
35+
private static final String P_KEY_SURVEY_DIALOG_API_COUNTER= "APISurveyCounter";
3536
private ProgressBar progressBar;
3637
private Button btnCancel;
3738
private Button btnAccept;
@@ -79,9 +80,17 @@ public void onResume() {
7980
this.setCancelable(false);
8081
}
8182

82-
public static boolean wasSurveyDisplayed(Context context) {
83+
public static boolean shouldDisplaySurvey(Context context) {
8384
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
84-
return settings.getBoolean(P_KEY_SURVEY_DIALOG_API,false);
85+
if (settings.getBoolean(P_KEY_SURVEY_DIALOG_API,false)) {
86+
return false;
87+
}
88+
// wait 10 times till displaying the dialog
89+
int count = settings.getInt(P_KEY_SURVEY_DIALOG_API_COUNTER,10);
90+
if(count > 0) {
91+
settings.edit().putInt(P_KEY_SURVEY_DIALOG_API_COUNTER,count -1).apply();
92+
}
93+
return count == 0;
8594
}
8695

8796
/**

app/src/main/java/vocabletrainer/heinecke/aron/vocabletrainer/lib/ViewModel/SurveyViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SurveyViewModel : ViewModel() {
3838
} else {
3939
// allow tls 1.0
4040
// can't be tested fully due to different device libraries
41-
"https://vct.proctet.net/data/add/api"
41+
"https://stats.vocabletrainer.de/data/add/api"
4242
}
4343
runner = Thread {
4444
val jsonBody: JSONObject

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<string name="Format_Diag_error_Title">Invalid Input</string>
124124

125125
<string name="Survey_Diag_Title">Android Version Survey</string>
126-
<string name="Survey_Diag_Msg" ><html>I\'d like to do a survey about the Android versions on which VAT is running.\nSupporting Android devices pre-v21 has gotten increasingly difficult.\nIf you take part the following Information will be send to <a href="https://vct.proctet.net">https://vct.proctet.net</a> and stored:\n<ul><li>Your Android version</li></ul>\nNothing else will be send, no IP is stored.\nYou can also see the results at above URL.</html></string>
126+
<string name="Survey_Diag_Msg" ><html>I\'d like to do a survey about the Android versions on which VAT is running.\nIf you take part the following Information will be send to <a href="https://stats.vocabletrainer.de">https://stats.vocabletrainer.de</a> and stored:\n<ul><li>Your Android version</li></ul>\nNothing else will be send, no IP is stored.\nYou can also see the results at above URL.</html></string>
127127
<string name="Survey_Diag_Accept">Accept Survey</string>
128128
<string name="Survey_Diag_Decline">Decline</string>
129129
<string name="Survey_Diag_Error_Toast">Error during survey submit!</string>

0 commit comments

Comments
 (0)