diff --git a/res/layout/feedback.xml b/res/layout/feedback.xml
new file mode 100644
index 00000000..e302b569
--- /dev/null
+++ b/res/layout/feedback.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values-ru/text_strings.xml b/res/values-ru/text_strings.xml
index bd3785bb..1be27645 100644
--- a/res/values-ru/text_strings.xml
+++ b/res/values-ru/text_strings.xml
@@ -173,4 +173,10 @@
Опция уже была куплена!
Покупаем...
+ Отзыв
+ Вы используете Калькулятор++ некоторое время\n
+ и для нас важно узнать ваше мнение о приложении.\n\n
+ Пожалуйста, оцените Калькулятор++ \nна андроид.маркете,\n оставьте комментарий или \nобсудите приложение \nна нашем форуме
+
+
\ No newline at end of file
diff --git a/res/values/text_strings.xml b/res/values/text_strings.xml
index e6264f11..47b2894f 100644
--- a/res/values/text_strings.xml
+++ b/res/values/text_strings.xml
@@ -173,4 +173,10 @@
Ad free option was already purchased!
Purchasing...
+ Feedback
+ You have been using Calculator++ for some time \n
+ and it\'s important for us to know your opinion about application.\n\n
+ Please rate Calculator++ \non android.market,\n leave a comment or \ndiscuss application \non our forum
+
+
\ No newline at end of file
diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
index 590e44ce..80808267 100644
--- a/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
+++ b/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
@@ -13,6 +13,7 @@ import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.text.ClipboardManager;
import android.text.Html;
+import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.util.TypedValue;
import android.view.*;
@@ -37,6 +38,7 @@ import org.solovyev.android.calculator.model.CalculatorEngine;
import org.solovyev.android.calculator.view.AngleUnitsButton;
import org.solovyev.android.calculator.view.NumeralBasesButton;
import org.solovyev.android.history.HistoryDragProcessor;
+import org.solovyev.android.prefs.BooleanPreference;
import org.solovyev.android.prefs.IntegerPreference;
import org.solovyev.android.prefs.Preference;
import org.solovyev.android.view.VibratorContainer;
@@ -62,8 +64,22 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
private static final String APP_VERSION_P_KEY = "application.version";
private static final int APP_VERSION_DEFAULT = -1;
public static final Preference appVersion = new IntegerPreference(APP_VERSION_P_KEY, APP_VERSION_DEFAULT);
+
+ private static final Preference appOpenedCounter = new IntegerPreference(APP_OPENED_COUNTER_P_KEY, APP_OPENED_COUNTER_P_DEFAULT);
+ private static final Preference feedbackWindowShown = new BooleanPreference(FEEDBACK_WINDOW_SHOWN_P_KEY, FEEDBACK_WINDOW_SHOWN_P_DEFAULT);
}
+ @NotNull
+ private static final String APP_OPENED_COUNTER_P_KEY = "app_opened_counter";
+ private static final Integer APP_OPENED_COUNTER_P_DEFAULT = 0;
+
+
+
+
+ @NotNull
+ public static final String FEEDBACK_WINDOW_SHOWN_P_KEY = "feedback_window_shown";
+ public static final boolean FEEDBACK_WINDOW_SHOWN_P_DEFAULT = false;
+
@NotNull
public static final String SHOW_RELEASE_NOTES_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_show_release_notes";
public static final boolean SHOW_RELEASE_NOTES_P_DEFAULT = true;
@@ -387,6 +403,10 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
private synchronized void firstTimeInit(@NotNull SharedPreferences preferences) {
if (!initialized) {
+ final Integer appOpenedCounter = Preferences.appOpenedCounter.getPreference(preferences);
+ if (appOpenedCounter != null) {
+ Preferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1);
+ }
final int savedVersion = Preferences.appVersion.getPreference(preferences);
@@ -394,12 +414,14 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
Preferences.appVersion.putPreference(preferences, appVersion);
+ boolean dialogShown = false;
if (savedVersion == Preferences.APP_VERSION_DEFAULT) {
// new start
final AlertDialog.Builder builder = new AlertDialog.Builder(this).setMessage(R.string.c_first_start_text);
builder.setPositiveButton(android.R.string.ok, null);
builder.setTitle(R.string.c_first_start_text_title);
builder.create().show();
+ dialogShown = true;
} else {
if (savedVersion < appVersion) {
final boolean showReleaseNotes = preferences.getBoolean(SHOW_RELEASE_NOTES_P_KEY, SHOW_RELEASE_NOTES_P_DEFAULT);
@@ -410,11 +432,35 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
builder.setPositiveButton(android.R.string.ok, null);
builder.setTitle(R.string.c_release_notes);
builder.create().show();
+ dialogShown = true;
}
}
}
}
+
+ //Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!");
+ if (!dialogShown) {
+ if ( appOpenedCounter != null && appOpenedCounter > 10 ) {
+ final Boolean feedbackWindowShown = Preferences.feedbackWindowShown.getPreference(preferences);
+ if ( feedbackWindowShown != null && !feedbackWindowShown ) {
+ final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
+ final View view = layoutInflater.inflate(R.layout.feedback, null);
+
+ final TextView feedbackTextView = (TextView) view.findViewById(R.id.feedbackText);
+ feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance());
+
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this).setView(view);
+ builder.setPositiveButton(android.R.string.ok, null);
+ builder.create().show();
+
+ dialogShown = true;
+ Preferences.feedbackWindowShown.putPreference(preferences, true);
+ }
+ }
+ }
+
+
ResourceCache.instance.init(R.id.class, this);
initialized = true;