This commit is contained in:
Sergey Solovyev 2012-02-05 19:41:47 +04:00
parent ba4fe97ccc
commit e68b6ed1a4
4 changed files with 77 additions and 0 deletions

19
res/layout/feedback.xml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="fill_parent"
a:layout_height="fill_parent">
<TextView a:id="@+id/feedbackText"
style="@style/about_style"
a:layout_width="fill_parent"
a:text="@string/c_feedback_text"
a:layout_height="fill_parent"/>
</LinearLayout>

View File

@ -173,4 +173,10 @@
<string name="c_calc_already_purchased">Опция уже была куплена!</string> <string name="c_calc_already_purchased">Опция уже была куплена!</string>
<string name="c_calc_purchasing">Покупаем...</string> <string name="c_calc_purchasing">Покупаем...</string>
<string name="c_feedback_title">Отзыв</string>
<string name="c_feedback_text">Вы используете Калькулятор++ некоторое время\n
и для нас важно узнать ваше мнение о приложении.\n\n
Пожалуйста, оцените Калькулятор++ \nна <a href="https://market.android.com/details?id=org.solovyev.android.calculator">андроид.маркете</a>,\n оставьте комментарий или \nобсудите приложение \nна нашем <a href="http://calculatorpp.com/forum/">форуме</a>
</string>
</resources> </resources>

View File

@ -173,4 +173,10 @@
<string name="c_calc_already_purchased">Ad free option was already purchased!</string> <string name="c_calc_already_purchased">Ad free option was already purchased!</string>
<string name="c_calc_purchasing">Purchasing...</string> <string name="c_calc_purchasing">Purchasing...</string>
<string name="c_feedback_title">Feedback</string>
<string name="c_feedback_text">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 <a href="https://market.android.com/details?id=org.solovyev.android.calculator">android.market</a>,\n leave a comment or \ndiscuss application \non our <a href="http://calculatorpp.com/forum/">forum</a>
</string>
</resources> </resources>

View File

@ -13,6 +13,7 @@ import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log; import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.*; 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.AngleUnitsButton;
import org.solovyev.android.calculator.view.NumeralBasesButton; import org.solovyev.android.calculator.view.NumeralBasesButton;
import org.solovyev.android.history.HistoryDragProcessor; import org.solovyev.android.history.HistoryDragProcessor;
import org.solovyev.android.prefs.BooleanPreference;
import org.solovyev.android.prefs.IntegerPreference; import org.solovyev.android.prefs.IntegerPreference;
import org.solovyev.android.prefs.Preference; import org.solovyev.android.prefs.Preference;
import org.solovyev.android.view.VibratorContainer; 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 String APP_VERSION_P_KEY = "application.version";
private static final int APP_VERSION_DEFAULT = -1; private static final int APP_VERSION_DEFAULT = -1;
public static final Preference<Integer> appVersion = new IntegerPreference(APP_VERSION_P_KEY, APP_VERSION_DEFAULT); public static final Preference<Integer> appVersion = new IntegerPreference(APP_VERSION_P_KEY, APP_VERSION_DEFAULT);
private static final Preference<Integer> appOpenedCounter = new IntegerPreference(APP_OPENED_COUNTER_P_KEY, APP_OPENED_COUNTER_P_DEFAULT);
private static final Preference<Boolean> 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 @NotNull
public static final String SHOW_RELEASE_NOTES_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_show_release_notes"; 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; 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) { private synchronized void firstTimeInit(@NotNull SharedPreferences preferences) {
if (!initialized) { 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); final int savedVersion = Preferences.appVersion.getPreference(preferences);
@ -394,12 +414,14 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
Preferences.appVersion.putPreference(preferences, appVersion); Preferences.appVersion.putPreference(preferences, appVersion);
boolean dialogShown = false;
if (savedVersion == Preferences.APP_VERSION_DEFAULT) { if (savedVersion == Preferences.APP_VERSION_DEFAULT) {
// new start // new start
final AlertDialog.Builder builder = new AlertDialog.Builder(this).setMessage(R.string.c_first_start_text); final AlertDialog.Builder builder = new AlertDialog.Builder(this).setMessage(R.string.c_first_start_text);
builder.setPositiveButton(android.R.string.ok, null); builder.setPositiveButton(android.R.string.ok, null);
builder.setTitle(R.string.c_first_start_text_title); builder.setTitle(R.string.c_first_start_text_title);
builder.create().show(); builder.create().show();
dialogShown = true;
} else { } else {
if (savedVersion < appVersion) { if (savedVersion < appVersion) {
final boolean showReleaseNotes = preferences.getBoolean(SHOW_RELEASE_NOTES_P_KEY, SHOW_RELEASE_NOTES_P_DEFAULT); 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.setPositiveButton(android.R.string.ok, null);
builder.setTitle(R.string.c_release_notes); builder.setTitle(R.string.c_release_notes);
builder.create().show(); 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); ResourceCache.instance.init(R.id.class, this);
initialized = true; initialized = true;