From 9c3c2e3e3f8513b335e6f093d8e6098da91510e2 Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Mon, 14 May 2012 15:10:08 +0400 Subject: [PATCH] Notes++ announcement --- calculatorpp/res/layout/notespp_announce.xml | 19 ++++++++ calculatorpp/res/values-ru/text_strings.xml | 4 ++ calculatorpp/res/values/text_strings.xml | 4 ++ .../calculator/CalculatorActivity.java | 44 ++++++++++++------- .../calculator/CalculatorPreferences.java | 1 + 5 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 calculatorpp/res/layout/notespp_announce.xml diff --git a/calculatorpp/res/layout/notespp_announce.xml b/calculatorpp/res/layout/notespp_announce.xml new file mode 100644 index 00000000..1f7eec14 --- /dev/null +++ b/calculatorpp/res/layout/notespp_announce.xml @@ -0,0 +1,19 @@ + + + + + + + + + \ No newline at end of file diff --git a/calculatorpp/res/values-ru/text_strings.xml b/calculatorpp/res/values-ru/text_strings.xml index caabd673..89ba423a 100644 --- a/calculatorpp/res/values-ru/text_strings.xml +++ b/calculatorpp/res/values-ru/text_strings.xml @@ -193,6 +193,10 @@ Пожалуйста, оцените Калькулятор++ \nна Google Play,\n оставьте комментарий или \nобсудите приложение \nна нашем форуме + Хорошие новости - я только что выпустил новое приложение под Андроид под названием Заметки++.\n + Если вы заинтересованы в быстром и удобном способе оставлять заметки пройдите по ссылке и попробуйте Заметки++! + + Единицы измерения углов изменены на \'%s\'! Система счисления изменена на \'%s\'! Перевод величин diff --git a/calculatorpp/res/values/text_strings.xml b/calculatorpp/res/values/text_strings.xml index e3a621ed..233e276d 100644 --- a/calculatorpp/res/values/text_strings.xml +++ b/calculatorpp/res/values/text_strings.xml @@ -193,6 +193,10 @@ Please rate Calculator++ \non Google Play,\n leave a comment or \ndiscuss application \non our forum + Good news - I just released new application for Android called Notes++.\n + If you\'re interesting in fast and easy way of making notes please follow the link and try Notes++! + + Angle units changed to \'%s\'! Numeral base changed to \'%s\'! Conversion tool diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index aa12ef5b..991ea00e 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -43,6 +43,7 @@ import org.solovyev.android.calculator.view.OnDragListenerVibrator; import org.solovyev.android.history.HistoryDragProcessor; import org.solovyev.android.menu.ActivityMenu; import org.solovyev.android.menu.LayoutActivityMenu; +import org.solovyev.android.prefs.Preference; import org.solovyev.android.view.ColorButton; import org.solovyev.android.view.drag.*; import org.solovyev.common.utils.Announcer; @@ -460,24 +461,13 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh //Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!"); if (!dialogShown) { if ( appOpenedCounter != null && appOpenedCounter > 10 ) { - final Boolean feedbackWindowShown = CalculatorPreferences.Gui.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; - CalculatorPreferences.Gui.feedbackWindowShown.putPreference(preferences, true); - } + dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.feedbackWindowShown, R.layout.feedback, R.id.feedbackText); } } + if ( !dialogShown ) { + dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.notesppAnnounceShown, R.layout.notespp_announce, R.id.notespp_announce); + } ResourceCache.instance.init(R.id.class, this); @@ -485,7 +475,29 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh } } - @SuppressWarnings({"UnusedDeclaration"}) + private boolean showSpecialWindow(@NotNull SharedPreferences preferences, @NotNull Preference specialWindowShownPref, int layoutId, int textViewId) { + boolean result = false; + + final Boolean specialWindowShown = specialWindowShownPref.getPreference(preferences); + if ( specialWindowShown != null && !specialWindowShown ) { + final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); + final View view = layoutInflater.inflate(layoutId, null); + + final TextView feedbackTextView = (TextView) view.findViewById(textViewId); + feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance()); + + final AlertDialog.Builder builder = new AlertDialog.Builder(this).setView(view); + builder.setPositiveButton(android.R.string.ok, null); + builder.create().show(); + + result = true; + specialWindowShownPref.putPreference(preferences, true); + } + + return result; + } + + @SuppressWarnings({"UnusedDeclaration"}) public void elementaryButtonClickHandler(@NotNull View v) { throw new UnsupportedOperationException("Not implemented yet!"); } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java index 802d5816..5dd13993 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java @@ -32,6 +32,7 @@ public final class CalculatorPreferences { public static final Preference theme = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Theme.metro_blue_theme, Theme.class); public static final Preference layout = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_layout", Layout.main_calculator, Layout.class); public static final Preference feedbackWindowShown = new BooleanPreference("feedback_window_shown", false); + public static final Preference notesppAnnounceShown = new BooleanPreference("notespp_announce_shown", false); public static final Preference showReleaseNotes = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true); public static final Preference usePrevAsBack = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false); public static final Preference showEqualsButton = new BooleanPreference("showEqualsButton", true);