release notes + welcome window
This commit is contained in:
parent
53caff263c
commit
4a2511b93c
@ -41,11 +41,19 @@
|
|||||||
a:label="@string/c_saved_history"
|
a:label="@string/c_saved_history"
|
||||||
a:configChanges="orientation|keyboardHidden"/>
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
<activity a:name=".AboutActivity"
|
<activity a:name=".about.CalculatorAboutTabActivity"
|
||||||
a:label="@string/c_about"
|
a:label="@string/c_about"
|
||||||
a:configChanges="orientation|keyboardHidden"/>
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
<activity a:name=".help.HelpActivity"
|
<activity a:name=".about.CalculatorAboutActivity"
|
||||||
|
a:label="@string/c_about"
|
||||||
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
|
<activity a:name=".about.CalculatorReleaseNotesActivity"
|
||||||
|
a:label="@string/c_about"
|
||||||
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
|
<activity a:name=".help.CalculatorHelpTabActivity"
|
||||||
a:label="@string/c_help"
|
a:label="@string/c_help"
|
||||||
a:configChanges="orientation|keyboardHidden"/>
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
a:text="×"
|
a:text="×"
|
||||||
c:textUp="^"
|
c:textUp="^"
|
||||||
c:textDown="^2"
|
c:textDown="^2"
|
||||||
|
c:textLeft="PI"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
c:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
|
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
28
res/layout/release_notes.xml
Normal file
28
res/layout/release_notes.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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:orientation="vertical"
|
||||||
|
a:layout_width="fill_parent"
|
||||||
|
a:layout_height="fill_parent"
|
||||||
|
a:background="#ff000000">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
a:id="@+id/releaseNotesTextView"
|
||||||
|
a:layout_height="fill_parent"
|
||||||
|
a:layout_width="fill_parent"
|
||||||
|
a:layout_weight="1"
|
||||||
|
a:gravity="top|left"
|
||||||
|
a:scrollbars="vertical"
|
||||||
|
style="@style/about_style"/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
a:scrollbarFadeDuration="0" is not support in android_1.6_compatibility
|
||||||
|
-->
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -23,4 +23,51 @@
|
|||||||
<a href="http://www.achartengine.org/">AChartEngine</a>
|
<a href="http://www.achartengine.org/">AChartEngine</a>
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes">Замечания к выпуску</string>
|
||||||
|
<string name="c_release_notes_for_title">"Замечания к выпуску версии "</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_4">
|
||||||
|
1. Отклик на нажатие\n
|
||||||
|
2. Две раскладки кнопок\n
|
||||||
|
3. Новые константы\n
|
||||||
|
4. Сообщение об ошибке показывается реже
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_5">
|
||||||
|
1. Экран со всеми доступными функциями\n
|
||||||
|
2. Поддержка десятичного логарифма, факториала, функций сравнения\n
|
||||||
|
3. Настройки отклика
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_6">
|
||||||
|
1. Сохранение констант в два клика (используйте +π кнопку)\n
|
||||||
|
2. Размер результата автоматически масштабируется\n
|
||||||
|
3. Исправлена ошибка с отсутствием результата в Xperia Ray\n
|
||||||
|
4. Исправлена ошибка расчёта двойного факториала\n
|
||||||
|
5. Добавлены градусы (используйте °, например, 30° и результат будет автоматически переведён в радианы)
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_7">
|
||||||
|
1. Поддержка ввода чисел в научной нотации (2.3E2)\n
|
||||||
|
2. Добавлены функции: deg(), rad() для перевода радианов в градусы и наоборот\n
|
||||||
|
3. Добавлена поддержка установки приложения на карту памяти\n
|
||||||
|
4. Добавлена поддержка сохранить целое выражение как константу (например, наберите ln(6t), нажмите +π, введите имя и сохраните)\n
|
||||||
|
5. Исправлена проблема с функцией abs() и комплексным аргументом\n
|
||||||
|
6. Исправлена проблема с отображением результата
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_8">
|
||||||
|
1. Исправлена проблема с i^3\n
|
||||||
|
2. Исправлено падение при использовании большого числа скобочек
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_20">
|
||||||
|
1. Поддержка свайпа влево, вправо\n
|
||||||
|
2. Расширенная история: сохранение, удаление, копирование истории (используйте длинное нажатие)\n
|
||||||
|
3. Добавлен испанский язык\n
|
||||||
|
4. Полная поддержка систем счисления (dec, hex, oct, bin)\n
|
||||||
|
5. !!!: Решение проблемы знака произведения на некоторых устройствах. Если у вас странные символы вместо × - измените знак произведения * в настройках приложения\n
|
||||||
|
6. Исправлено: правильное вычисление двойного факториала, 20x, e^(pi*i)+1 и др.
|
||||||
|
</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -153,4 +153,9 @@
|
|||||||
<string name="c_copy_description">Копироват описание</string>
|
<string name="c_copy_description">Копироват описание</string>
|
||||||
<string name="c_copy_value">Копировать значение</string>
|
<string name="c_copy_value">Копировать значение</string>
|
||||||
|
|
||||||
|
<string name="c_first_start_text">Спасибо за выбор Калькулятора++!</string>
|
||||||
|
|
||||||
|
<string name="c_calc_show_release_notes_title">Показывать замечания к выпуску</string>
|
||||||
|
<string name="c_calc_show_release_notes_summary">Определяет показывать или нет всплывающее окно с замечаниями к выпуску после обновления новой версии</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -24,6 +24,9 @@
|
|||||||
<string name="p_calc_haptic_feedback_key">org.solovyev.android.calculator.CalculatorModel_haptic_feedback</string>
|
<string name="p_calc_haptic_feedback_key">org.solovyev.android.calculator.CalculatorModel_haptic_feedback</string>
|
||||||
<string name="p_calc_haptic_feedback">false</string>
|
<string name="p_calc_haptic_feedback">false</string>
|
||||||
|
|
||||||
|
<string name="p_calc_show_release_notes_key">org.solovyev.android.calculator.CalculatorActivity_show_release_notes</string>
|
||||||
|
<string name="p_calc_show_release_notes">true</string>
|
||||||
|
|
||||||
<string name="p_calc_round_result_key">org.solovyev.android.calculator.CalculatorModel_round_result</string>
|
<string name="p_calc_round_result_key">org.solovyev.android.calculator.CalculatorModel_round_result</string>
|
||||||
<string name="p_calc_round_result">true</string>
|
<string name="p_calc_round_result">true</string>
|
||||||
|
|
||||||
|
@ -23,4 +23,51 @@
|
|||||||
<a href="http://www.achartengine.org/">AChartEngine</a>
|
<a href="http://www.achartengine.org/">AChartEngine</a>
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes">Release notes</string>
|
||||||
|
<string name="c_release_notes_for_title">"Release notes for version "</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_4">
|
||||||
|
1. Haptic feedback\n
|
||||||
|
2. Two layouts: calculator and cellphone\n
|
||||||
|
3. New constants\n
|
||||||
|
4. ERROR message is not so often now
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_5">
|
||||||
|
1. Screen with all functions\n
|
||||||
|
2. Added support for decimal logarithm, factorial, comparison functions\n
|
||||||
|
3. Haptic feedback duration preference
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_6">
|
||||||
|
1. Saving constants in two clicks (use +π button)\n
|
||||||
|
2. Result size is auto adjusted to fill all spare space\n
|
||||||
|
3. Fix for Xperia Ray blank result\n
|
||||||
|
4. Double factorial fix\n
|
||||||
|
5. Degrees added (use °: e.g. 30° and result will be converted into radians)
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_7">
|
||||||
|
1. Support for entering numbers in scientific notation (2.3E2)\n
|
||||||
|
2. Added functions: deg(), rad() to convert from radians to degrees and vice versa\n
|
||||||
|
3. Added support for installing application on sd card\n
|
||||||
|
4. Added possibility to save entire expression as constant (e.g. type ln(6t), press +π button, enter name and save)\n
|
||||||
|
5. Fixed bug with abs() function and complex argument\n
|
||||||
|
6. Fixed bug with displaying result
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_8">
|
||||||
|
1. Fixed bug with i^3\n
|
||||||
|
2. Fixed crash in case of many brackets
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="c_release_notes_for_20">
|
||||||
|
1. New swipe actions (left, right)\n
|
||||||
|
2. Extended history: save, remove, copy, use from history screen (use long click for additional actions)\n
|
||||||
|
3. Added Spanish language\n
|
||||||
|
4. Full numeral base support (dec, hex, oct, bin)\n
|
||||||
|
5. !!!: Fix for multiplication sign on some devices - if you have strange symbols instead of × - go to the settings and change multiplication sign to *\n
|
||||||
|
6. Bug fixes: correct double factorial calculation, 20x fix, e^(pi*i)+1 fix and others
|
||||||
|
</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -153,4 +153,9 @@
|
|||||||
<string name="c_copy_description">Copy description</string>
|
<string name="c_copy_description">Copy description</string>
|
||||||
<string name="c_copy_value">Copy value</string>
|
<string name="c_copy_value">Copy value</string>
|
||||||
|
|
||||||
|
<string name="c_first_start_text">Thank you for choosing Calculator++!</string>
|
||||||
|
|
||||||
|
<string name="c_calc_show_release_notes_title">Show release notes</string>
|
||||||
|
<string name="c_calc_show_release_notes_summary">Defines if release notes popup window should appear after update to the new version</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -86,6 +86,12 @@
|
|||||||
range:steps="10"
|
range:steps="10"
|
||||||
range:boundaries="10;500"/>
|
range:boundaries="10;500"/>
|
||||||
|
|
||||||
|
<android.preference.CheckBoxPreference
|
||||||
|
a:key="@string/p_calc_show_release_notes_key"
|
||||||
|
a:summary="@string/c_calc_show_release_notes_summary"
|
||||||
|
a:title="@string/c_calc_show_release_notes_title"
|
||||||
|
a:defaultValue="true"/>
|
||||||
|
|
||||||
<!-- <org.solovyev.android.view.prefs.FloatRangeSeekBarPreference
|
<!-- <org.solovyev.android.view.prefs.FloatRangeSeekBarPreference
|
||||||
a:key="@string/p_drag_duration_key"
|
a:key="@string/p_drag_duration_key"
|
||||||
a:title="Duration of drag event"
|
a:title="Duration of drag event"
|
||||||
|
@ -15,6 +15,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Vibrator;
|
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.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
@ -26,15 +27,18 @@ import jscl.AngleUnit;
|
|||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.solovyev.android.calculator.about.CalculatorReleaseNotesActivity;
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistory;
|
import org.solovyev.android.calculator.history.CalculatorHistory;
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
||||||
import org.solovyev.android.calculator.math.MathType;
|
import org.solovyev.android.calculator.math.MathType;
|
||||||
import org.solovyev.android.calculator.model.CalculatorEngine;
|
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||||
import org.solovyev.android.view.FontSizeAdjuster;
|
import org.solovyev.android.view.FontSizeAdjuster;
|
||||||
|
import org.solovyev.android.view.prefs.AndroidUtils;
|
||||||
import org.solovyev.android.view.prefs.ResourceCache;
|
import org.solovyev.android.view.prefs.ResourceCache;
|
||||||
import org.solovyev.android.view.widgets.*;
|
import org.solovyev.android.view.widgets.*;
|
||||||
import org.solovyev.common.utils.Announcer;
|
import org.solovyev.common.utils.Announcer;
|
||||||
import org.solovyev.common.utils.Point2d;
|
import org.solovyev.common.utils.Point2d;
|
||||||
|
import org.solovyev.common.utils.StringUtils;
|
||||||
import org.solovyev.common.utils.history.HistoryAction;
|
import org.solovyev.common.utils.history.HistoryAction;
|
||||||
|
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
@ -45,6 +49,13 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
|
|
||||||
private static final int HVGA_WIDTH_PIXELS = 320;
|
private static final int HVGA_WIDTH_PIXELS = 320;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static final String APP_VERSION_P_KEY = "application.version";
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Announcer<DragPreferencesChangeListener> dpclRegister = new Announcer<DragPreferencesChangeListener>(DragPreferencesChangeListener.class);
|
private final Announcer<DragPreferencesChangeListener> dpclRegister = new Announcer<DragPreferencesChangeListener>(DragPreferencesChangeListener.class);
|
||||||
|
|
||||||
@ -348,9 +359,37 @@ 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) {
|
||||||
ResourceCache.instance.init(R.id.class, this);
|
|
||||||
|
|
||||||
|
final int savedVersion = preferences.getInt(APP_VERSION_P_KEY, -1);
|
||||||
|
final int appVersion = AndroidUtils.getAppVersionCode(this, CalculatorActivity.class.getPackage().getName());
|
||||||
|
|
||||||
|
final SharedPreferences.Editor pEditor = preferences.edit();
|
||||||
|
pEditor.putInt(APP_VERSION_P_KEY, appVersion);
|
||||||
|
pEditor.commit();
|
||||||
|
|
||||||
|
if (savedVersion == -1) {
|
||||||
|
// 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.create().show();
|
||||||
|
} else {
|
||||||
|
if (savedVersion < appVersion) {
|
||||||
|
final boolean showReleaseNotes = preferences.getBoolean(SHOW_RELEASE_NOTES_P_KEY, SHOW_RELEASE_NOTES_P_DEFAULT);
|
||||||
|
if (showReleaseNotes) {
|
||||||
|
final String releaseNotes = CalculatorReleaseNotesActivity.getReleaseNotes(this, savedVersion + 1);
|
||||||
|
if (!StringUtils.isEmpty(releaseNotes)) {
|
||||||
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this).setMessage(Html.fromHtml(releaseNotes));
|
||||||
|
builder.setPositiveButton(android.R.string.ok, null);
|
||||||
|
builder.setTitle(R.string.c_release_notes);
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceCache.instance.init(R.id.class, this);
|
||||||
CalculatorEngine.instance.init(this, preferences);
|
CalculatorEngine.instance.init(this, preferences);
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ import jscl.math.Generic;
|
|||||||
import jscl.math.function.Constant;
|
import jscl.math.function.Constant;
|
||||||
import org.achartengine.ChartFactory;
|
import org.achartengine.ChartFactory;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.help.HelpActivity;
|
import org.solovyev.android.calculator.about.CalculatorAboutTabActivity;
|
||||||
|
import org.solovyev.android.calculator.help.CalculatorHelpTabActivity;
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
||||||
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsActivity;
|
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsActivity;
|
||||||
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsActivity;
|
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsActivity;
|
||||||
@ -27,7 +28,7 @@ public class CalculatorActivityLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void showHelp(@NotNull final Context context) {
|
public static void showHelp(@NotNull final Context context) {
|
||||||
context.startActivity(new Intent(context, HelpActivity.class));
|
context.startActivity(new Intent(context, CalculatorHelpTabActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showSettings(@NotNull final Context context) {
|
public static void showSettings(@NotNull final Context context) {
|
||||||
@ -35,7 +36,7 @@ public class CalculatorActivityLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void showAbout(@NotNull final Context context) {
|
public static void showAbout(@NotNull final Context context) {
|
||||||
context.startActivity(new Intent(context, AboutActivity.class));
|
context.startActivity(new Intent(context, CalculatorAboutTabActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showFunctions(@NotNull final Context context) {
|
public static void showFunctions(@NotNull final Context context) {
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||||
* For more information, please, contact se.solovyev@gmail.com
|
* For more information, please, contact se.solovyev@gmail.com
|
||||||
|
* or visit http://se.solovyev.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator.about;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
* Date: 9/16/11
|
* Date: 12/24/11
|
||||||
* Time: 11:52 PM
|
* Time: 11:55 PM
|
||||||
*/
|
*/
|
||||||
public class AboutActivity extends Activity {
|
public class CalculatorAboutActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@ -26,6 +27,5 @@ public class AboutActivity extends Activity {
|
|||||||
|
|
||||||
final TextView about = (TextView) findViewById(R.id.aboutTextView);
|
final TextView about = (TextView) findViewById(R.id.aboutTextView);
|
||||||
about.setMovementMethod(LinkMovementMethod.getInstance());
|
about.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||||
|
* For more information, please, contact se.solovyev@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.calculator.about;
|
||||||
|
|
||||||
|
import android.app.TabActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.TabHost;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.view.prefs.AndroidUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 9/16/11
|
||||||
|
* Time: 11:52 PM
|
||||||
|
*/
|
||||||
|
public class CalculatorAboutTabActivity extends TabActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.tabs);
|
||||||
|
|
||||||
|
final TabHost tabHost = getTabHost();
|
||||||
|
|
||||||
|
AndroidUtils.addTab(this, tabHost, "about", R.string.c_about, CalculatorAboutActivity.class);
|
||||||
|
AndroidUtils.addTab(this, tabHost, "release_notes", R.string.c_release_notes, CalculatorReleaseNotesActivity.class);
|
||||||
|
|
||||||
|
tabHost.setCurrentTab(0);
|
||||||
|
AndroidUtils.centerAndWrapTabsFor(tabHost);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.calculator.about;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.solovyev.android.calculator.CalculatorActivity;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.view.prefs.AndroidUtils;
|
||||||
|
import org.solovyev.android.view.prefs.ResourceCache;
|
||||||
|
import org.solovyev.common.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 12/25/11
|
||||||
|
* Time: 12:00 AM
|
||||||
|
*/
|
||||||
|
public class CalculatorReleaseNotesActivity extends Activity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.release_notes);
|
||||||
|
|
||||||
|
final TextView releaseNotes = (TextView) findViewById(R.id.releaseNotesTextView);
|
||||||
|
releaseNotes.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
|
releaseNotes.setText(Html.fromHtml(getReleaseNotes(this)));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String getReleaseNotes(@NotNull Context context) {
|
||||||
|
return getReleaseNotes(context, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String getReleaseNotes(@NotNull Context context, int minVersion) {
|
||||||
|
final StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
|
final String releaseNotesForTitle = context.getString(R.string.c_release_notes_for_title);
|
||||||
|
final int version = AndroidUtils.getAppVersionCode(context, CalculatorActivity.class.getPackage().getName());
|
||||||
|
|
||||||
|
boolean first = true;
|
||||||
|
for ( int i = version; i >= minVersion; i-- ) {
|
||||||
|
String releaseNotesForVersion = ResourceCache.instance.getCaption("c_release_notes_for_" + i);
|
||||||
|
if (!StringUtils.isEmpty(releaseNotesForVersion)){
|
||||||
|
assert releaseNotesForVersion != null;
|
||||||
|
if ( !first ) {
|
||||||
|
result.append("<br/><br/>");
|
||||||
|
} else {
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
releaseNotesForVersion = releaseNotesForVersion.replace("\n", "<br/>");
|
||||||
|
result.append("<b>").append(releaseNotesForTitle).append(i).append("</b><br/>");
|
||||||
|
result.append(releaseNotesForVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,7 @@ import org.solovyev.android.view.prefs.AndroidUtils;
|
|||||||
* Date: 11/19/11
|
* Date: 11/19/11
|
||||||
* Time: 11:35 AM
|
* Time: 11:35 AM
|
||||||
*/
|
*/
|
||||||
public class HelpActivity extends TabActivity {
|
public class CalculatorHelpTabActivity extends TabActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
@ -6,12 +6,9 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.history;
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.view.prefs.AndroidUtils;
|
import org.solovyev.android.view.prefs.AndroidUtils;
|
||||||
@ -31,26 +28,12 @@ public class CalculatorHistoryActivity extends TabActivity {
|
|||||||
|
|
||||||
final TabHost tabHost = getTabHost();
|
final TabHost tabHost = getTabHost();
|
||||||
|
|
||||||
createTab(tabHost, "saved_history", R.string.c_saved_history, SavedHistoryActivityTab.class);
|
AndroidUtils.addTab(this, tabHost, "saved_history", R.string.c_saved_history, SavedHistoryActivityTab.class);
|
||||||
createTab(tabHost, "history", R.string.c_history, HistoryActivityTab.class);
|
AndroidUtils.addTab(this, tabHost, "history", R.string.c_history, HistoryActivityTab.class);
|
||||||
|
|
||||||
tabHost.setCurrentTab(0);
|
tabHost.setCurrentTab(0);
|
||||||
|
|
||||||
AndroidUtils.centerAndWrapTabsFor(tabHost);
|
AndroidUtils.centerAndWrapTabsFor(tabHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTab(@NotNull TabHost tabHost,
|
|
||||||
@NotNull String tabId,
|
|
||||||
int tabCaptionId,
|
|
||||||
@NotNull Class<? extends Activity> activityClass) {
|
|
||||||
|
|
||||||
TabHost.TabSpec spec;
|
|
||||||
|
|
||||||
final Intent intent = new Intent().setClass(this, activityClass);
|
|
||||||
|
|
||||||
// Initialize a TabSpec for each tab and add it to the TabHost
|
|
||||||
spec = tabHost.newTabSpec(tabId).setIndicator(this.getString(tabCaptionId)).setContent(intent);
|
|
||||||
|
|
||||||
tabHost.addTab(spec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
package org.solovyev.android.view.prefs;
|
package org.solovyev.android.view.prefs;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -52,4 +56,37 @@ public final class AndroidUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addTab(@NotNull Context context,
|
||||||
|
@NotNull TabHost tabHost,
|
||||||
|
@NotNull String tabId,
|
||||||
|
int tabCaptionId,
|
||||||
|
@NotNull Class<? extends Activity> activityClass) {
|
||||||
|
|
||||||
|
TabHost.TabSpec spec;
|
||||||
|
|
||||||
|
final Intent intent = new Intent().setClass(context, activityClass);
|
||||||
|
|
||||||
|
// Initialize a TabSpec for each tab and add it to the TabHost
|
||||||
|
spec = tabHost.newTabSpec(tabId).setIndicator(context.getString(tabCaptionId)).setContent(intent);
|
||||||
|
|
||||||
|
tabHost.addTab(spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param context context
|
||||||
|
* @param appPackageName - full name of the package of an app, 'com.example.app' for example.
|
||||||
|
* @return version number we are currently in
|
||||||
|
*/
|
||||||
|
public static int getAppVersionCode(@NotNull Context context, @NotNull String appPackageName) {
|
||||||
|
try {
|
||||||
|
return context.getPackageManager().getPackageInfo(appPackageName, 0).versionCode;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
// App not installed!
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ package org.solovyev.android.view.prefs;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -84,24 +85,43 @@ public enum ResourceCache {
|
|||||||
if (!initialized(locale)) {
|
if (!initialized(locale)) {
|
||||||
final Map<String, String> captionsByLanguage = new HashMap<String, String>();
|
final Map<String, String> captionsByLanguage = new HashMap<String, String>();
|
||||||
|
|
||||||
for (Field field : resourceClass.getDeclaredFields()) {
|
final Locale defaultLocale = Locale.getDefault();
|
||||||
int modifiers = field.getModifiers();
|
|
||||||
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) {
|
try {
|
||||||
try {
|
if (!defaultLocale.getLanguage().equals(locale.getLanguage())) {
|
||||||
int captionId = field.getInt(resourceClass);
|
updateConfiguration(context, locale);
|
||||||
captionsByLanguage.put(field.getName(), context.getString(captionId));
|
}
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
Log.e(ResourceCache.class.getName(), e.getMessage());
|
for (Field field : resourceClass.getDeclaredFields()) {
|
||||||
} catch (Resources.NotFoundException e) {
|
int modifiers = field.getModifiers();
|
||||||
Log.e(ResourceCache.class.getName(), "Caption with name " + field.getName() + " was not found for " + locale.getLanguage() + " language: " + e.getMessage());
|
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) {
|
||||||
|
try {
|
||||||
|
int captionId = field.getInt(resourceClass);
|
||||||
|
captionsByLanguage.put(field.getName(), context.getString(captionId));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
Log.e(ResourceCache.class.getName(), e.getMessage());
|
||||||
|
} catch (Resources.NotFoundException e) {
|
||||||
|
Log.e(ResourceCache.class.getName(), "Caption with name " + field.getName() + " was not found for " + locale.getLanguage() + " language: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (!defaultLocale.getLanguage().equals(locale.getLanguage())) {
|
||||||
|
updateConfiguration(context, defaultLocale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
captions.put(locale.getLanguage(), captionsByLanguage);
|
captions.put(locale.getLanguage(), captionsByLanguage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updateConfiguration(@NotNull Context context, @NotNull Locale locale) {
|
||||||
|
Locale.setDefault(locale);
|
||||||
|
final Configuration config = new Configuration();
|
||||||
|
config.locale = locale;
|
||||||
|
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean initialized(@NotNull Locale locale) {
|
private boolean initialized(@NotNull Locale locale) {
|
||||||
return captions.containsKey(locale.getLanguage());
|
return captions.containsKey(locale.getLanguage());
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,7 @@ public class CalculatorEngineTest {
|
|||||||
Assert.assertEquals("∞", Expression.valueOf("ln(10)/ln(1)").numeric().toString());
|
Assert.assertEquals("∞", Expression.valueOf("ln(10)/ln(1)").numeric().toString());
|
||||||
|
|
||||||
// logarithm
|
// logarithm
|
||||||
Assert.assertEquals("ln(b)/ln(a)", ((CustomFunction) cm.getFunctionsRegistry().get("log")).getContent());
|
Assert.assertEquals("ln(x)/ln(base)", ((CustomFunction) cm.getFunctionsRegistry().get("log")).getContent());
|
||||||
Assert.assertEquals("∞", cm.evaluate(JsclOperation.numeric, "log(1, 10)").getResult());
|
Assert.assertEquals("∞", cm.evaluate(JsclOperation.numeric, "log(1, 10)").getResult());
|
||||||
Assert.assertEquals("3.322", cm.evaluate(JsclOperation.numeric, "log(2, 10)").getResult());
|
Assert.assertEquals("3.322", cm.evaluate(JsclOperation.numeric, "log(2, 10)").getResult());
|
||||||
Assert.assertEquals("1.431", cm.evaluate(JsclOperation.numeric, "log(5, 10)").getResult());
|
Assert.assertEquals("1.431", cm.evaluate(JsclOperation.numeric, "log(5, 10)").getResult());
|
||||||
|
Loading…
Reference in New Issue
Block a user