wizard moved to ACL
This commit is contained in:
parent
8a69bf8b81
commit
8d0c631bfc
@ -34,5 +34,5 @@ und der Quelltext kann auf GitHub gefunden werden.</string>
|
|||||||
<string name="cpp_wizard_onscreen_description">Der Rechner im separaten Fenster ermöglicht es Ihnen zu rechnen, während dem benutzen anderer Apps.</string>
|
<string name="cpp_wizard_onscreen_description">Der Rechner im separaten Fenster ermöglicht es Ihnen zu rechnen, während dem benutzen anderer Apps.</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Rechner im separaten Fenster aktivieren (zweites Symbol erscheint in der Liste der Anwendungen)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Rechner im separaten Fenster aktivieren (zweites Symbol erscheint in der Liste der Anwendungen)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">\"Durchziehen\" Schaltfläche ist eine exklusive Funktion der Calculator++, die schnelle Zugriff auf die sekundären Funktionen bietet</string>
|
<string name="cpp_wizard_dragbutton_description">\"Durchziehen\" Schaltfläche ist eine exklusive Funktion der Calculator++, die schnelle Zugriff auf die sekundären Funktionen bietet</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Wollen Sie den Assistenten wirklich beenden?</string>
|
<string name="acl_wizard_finish_confirmation">Wollen Sie den Assistenten wirklich beenden?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -33,5 +33,5 @@ El resultado no se redondea, y los radianes son la unidad de ángulo predetermin
|
|||||||
<string name="cpp_wizard_onscreen_description">La calculadora en ventana independiente te permite realizar cálculos mientras utilizas otras aplicaciones en tu dispositivo</string>
|
<string name="cpp_wizard_onscreen_description">La calculadora en ventana independiente te permite realizar cálculos mientras utilizas otras aplicaciones en tu dispositivo</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Activar la calculadora en ventana independiente (aparecerá un segundo icono en la lista de aplicaciones)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Activar la calculadora en ventana independiente (aparecerá un segundo icono en la lista de aplicaciones)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">El botón de arrastre es una característica exclusiva de Calculadora ++ que proporciona un acceso rápido a las funciones secundarias</string>
|
<string name="cpp_wizard_dragbutton_description">El botón de arrastre es una característica exclusiva de Calculadora ++ que proporciona un acceso rápido a las funciones secundarias</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">¿Realmente quiere finalizar el asistente?</string>
|
<string name="acl_wizard_finish_confirmation">¿Realmente quiere finalizar el asistente?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -33,5 +33,5 @@ Le résultat n\'est pas arrondi et est affiché en notation scientifique, le rad
|
|||||||
<string name="cpp_wizard_onscreen_description">Avoir la calculatrice ouverte dans une fenêtre séparée vous permet de calculer tout en utilisant les autres applications de votre appareil</string>
|
<string name="cpp_wizard_onscreen_description">Avoir la calculatrice ouverte dans une fenêtre séparée vous permet de calculer tout en utilisant les autres applications de votre appareil</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Activer la calculatrice dans une fenêtre séparée (une deuxième icône apparaîtra dans la liste des applications)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Activer la calculatrice dans une fenêtre séparée (une deuxième icône apparaîtra dans la liste des applications)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">Le glissement sur une touche est une fonctionnalité exclusive à Calculator++ ce qui permet un accès rapide aux fonctions secondaires</string>
|
<string name="cpp_wizard_dragbutton_description">Le glissement sur une touche est une fonctionnalité exclusive à Calculator++ ce qui permet un accès rapide aux fonctions secondaires</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Quitter l\'assistant ?</string>
|
<string name="acl_wizard_finish_confirmation">Quitter l\'assistant ?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -32,5 +32,5 @@ Il risultato non è arrotondato, ed è presentato in notazione scientifica, i ra
|
|||||||
<string name="cpp_wizard_onscreen_description">La calcolatrice in una finestra separata consente di fare calcoli durante l\'utilizzo di altre applicazioni sul dispositivo</string>
|
<string name="cpp_wizard_onscreen_description">La calcolatrice in una finestra separata consente di fare calcoli durante l\'utilizzo di altre applicazioni sul dispositivo</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Abilitare la calcolatrice in una finestra separata (una seconda icona comparirà nell\'elenco applicazioni)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Abilitare la calcolatrice in una finestra separata (una seconda icona comparirà nell\'elenco applicazioni)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">Il trascinamento pulsanti è una funzione esclusiva di Calculator++ che permette un accesso rapido alle funzioni secondarie</string>
|
<string name="cpp_wizard_dragbutton_description">Il trascinamento pulsanti è una funzione esclusiva di Calculator++ che permette un accesso rapido alle funzioni secondarie</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Vuoi veramente terminare la procedura guidata?</string>
|
<string name="acl_wizard_finish_confirmation">Vuoi veramente terminare la procedura guidata?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -32,5 +32,5 @@ Resultaat is niet afgerond en wordt gepresenteerd in de ingenieursnotatie, worde
|
|||||||
<string name="cpp_wizard_onscreen_description">Calculator in afzonderlijk venster kunt u berekeningen uitvoeren tijdens het gebruik van andere apps op uw apparaat </string>
|
<string name="cpp_wizard_onscreen_description">Calculator in afzonderlijk venster kunt u berekeningen uitvoeren tijdens het gebruik van andere apps op uw apparaat </string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Calculator in afzonderlijk venster inschakelen (het tweede pictogram wordt weergegeven in de appslijst) </string>
|
<string name="cpp_wizard_onscreen_checkbox">Calculator in afzonderlijk venster inschakelen (het tweede pictogram wordt weergegeven in de appslijst) </string>
|
||||||
<string name="cpp_wizard_dragbutton_description">De sleepknop is een exclusieve functie van Calculator ++ die snel toegang tot de secundaire functies biedt </string>
|
<string name="cpp_wizard_dragbutton_description">De sleepknop is een exclusieve functie van Calculator ++ die snel toegang tot de secundaire functies biedt </string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Do you really want to finish wizard?</string>
|
<string name="acl_wizard_finish_confirmation">Do you really want to finish wizard?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -34,5 +34,5 @@ Wynik nie jest zaokrąglony i jest przedstawiony w postaci inżynierskiej, a dom
|
|||||||
<string name="cpp_wizard_onscreen_description">Kalkulator w osobnym oknie pozwoli Ci wykonywać obliczenia w trakcie korzystania z innych aplikacji na Twoim urządzeniu</string>
|
<string name="cpp_wizard_onscreen_description">Kalkulator w osobnym oknie pozwoli Ci wykonywać obliczenia w trakcie korzystania z innych aplikacji na Twoim urządzeniu</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Włącz kalkulator w osobnym oknie (pojawi się druga ikona na liście aplikacji)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Włącz kalkulator w osobnym oknie (pojawi się druga ikona na liście aplikacji)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">Przeciąganie po przycisku jest wyjątkowym rozwiązaniem w programie Calculator++, które zapewnia szybki dostęp do alternatywnych funkcji</string>
|
<string name="cpp_wizard_dragbutton_description">Przeciąganie po przycisku jest wyjątkowym rozwiązaniem w programie Calculator++, które zapewnia szybki dostęp do alternatywnych funkcji</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Czy na pewno chcesz zakończyć konfigurację programu?</string>
|
<string name="acl_wizard_finish_confirmation">Czy na pewno chcesz zakończyć konfigurację programu?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -31,5 +31,5 @@
|
|||||||
<string name="cpp_wizard_onscreen_description">A calculadora em janela separada permite que você faça cálculos enquanto estiver usando outros aplicativos no seu dispositivo</string>
|
<string name="cpp_wizard_onscreen_description">A calculadora em janela separada permite que você faça cálculos enquanto estiver usando outros aplicativos no seu dispositivo</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Habilitar a calculadora em janela separada (um segundo ícone aparecerá na lista de aplicativos)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Habilitar a calculadora em janela separada (um segundo ícone aparecerá na lista de aplicativos)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">Drag button é uma funcionalidade exclusiva de Calculator++ que fornece acesso rápido às funções secundárias</string>
|
<string name="cpp_wizard_dragbutton_description">Drag button é uma funcionalidade exclusiva de Calculator++ que fornece acesso rápido às funções secundárias</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Parar a configuração da aplicação?</string>
|
<string name="acl_wizard_finish_confirmation">Parar a configuração da aplicação?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -32,5 +32,5 @@
|
|||||||
<string name="cpp_wizard_onscreen_checkbox">Включить калькулятор в отдельном окне (вторая иконка появится в списке приложений)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Включить калькулятор в отдельном окне (вторая иконка появится в списке приложений)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">Специально разработанные кнопки позволяют быстро и просто использовать дополнительные возможности калькулятора
|
<string name="cpp_wizard_dragbutton_description">Специально разработанные кнопки позволяют быстро и просто использовать дополнительные возможности калькулятора
|
||||||
</string>
|
</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Вы действительно хотите завершить визард?</string>
|
<string name="acl_wizard_finish_confirmation">Вы действительно хотите завершить визард?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -31,5 +31,5 @@
|
|||||||
<string name="cpp_wizard_onscreen_description">Калькулятор в окремому вікні - дає змогу виконувати розрахунки під час використання інших програм на вашому пристрої</string>
|
<string name="cpp_wizard_onscreen_description">Калькулятор в окремому вікні - дає змогу виконувати розрахунки під час використання інших програм на вашому пристрої</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">Увімкнути калькулятор в окремому вікні (додаткова іконка з\'явиться у списку програм)</string>
|
<string name="cpp_wizard_onscreen_checkbox">Увімкнути калькулятор в окремому вікні (додаткова іконка з\'явиться у списку програм)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">Кнопки з розширеними функціями є винятковою рисою Калькулятор++, які забезпечують швидкий доступ до додаткових функцій</string>
|
<string name="cpp_wizard_dragbutton_description">Кнопки з розширеними функціями є винятковою рисою Калькулятор++, які забезпечують швидкий доступ до додаткових функцій</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Ви дійсно бажаєте вийти з майстра?</string>
|
<string name="acl_wizard_finish_confirmation">Ви дійсно бажаєте вийти з майстра?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -31,5 +31,5 @@
|
|||||||
<string name="cpp_wizard_onscreen_description">独立窗口模式的计算器可以让你在使用其他应用程序的同时进行计算。</string>
|
<string name="cpp_wizard_onscreen_description">独立窗口模式的计算器可以让你在使用其他应用程序的同时进行计算。</string>
|
||||||
<string name="cpp_wizard_onscreen_checkbox">启用独立窗口模式的计算器(在应用程序列表中将出现第二个图标)</string>
|
<string name="cpp_wizard_onscreen_checkbox">启用独立窗口模式的计算器(在应用程序列表中将出现第二个图标)</string>
|
||||||
<string name="cpp_wizard_dragbutton_description">拖动按钮是Calculator++的独创亮点,可以让你快速使用辅助功能。</string>
|
<string name="cpp_wizard_dragbutton_description">拖动按钮是Calculator++的独创亮点,可以让你快速使用辅助功能。</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Do you really want to finish wizard?</string>
|
<string name="acl_wizard_finish_confirmation">Do you really want to finish wizard?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -56,4 +56,8 @@
|
|||||||
<item type="id" name="cpp_button_paste"/>
|
<item type="id" name="cpp_button_paste"/>
|
||||||
<item type="id" name="cpp_button_equals"/>
|
<item type="id" name="cpp_button_equals"/>
|
||||||
|
|
||||||
|
<item type="id" name="acl_wizard_prev_button"/>
|
||||||
|
<item type="id" name="acl_wizard_next_button"/>
|
||||||
|
<item type="id" name="acl_wizard_content"/>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -320,4 +320,6 @@
|
|||||||
If you have any problems or questions feel free to contact me directly (contacts are available in
|
If you have any problems or questions feel free to contact me directly (contacts are available in
|
||||||
Main->Menu->About)
|
Main->Menu->About)
|
||||||
</string>
|
</string>
|
||||||
|
<string name="acl_yes">Yes</string>
|
||||||
|
<string name="acl_no">No</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -46,5 +46,5 @@
|
|||||||
<string name="cpp_wizard_dragbutton_description">Drag button is an exclusive feature of Calculator++ which provides
|
<string name="cpp_wizard_dragbutton_description">Drag button is an exclusive feature of Calculator++ which provides
|
||||||
fast access to the secondary functions
|
fast access to the secondary functions
|
||||||
</string>
|
</string>
|
||||||
<string name="cpp_wizard_finish_confirmation">Do you really want to finish wizard?</string>
|
<string name="acl_wizard_finish_confirmation">Do you really want to finish wizard?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013 serso aka se.solovyev
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
* Contact details
|
|
||||||
*
|
|
||||||
* Email: se.solovyev@gmail.com
|
|
||||||
* Site: http://se.solovyev.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: Solovyev_S
|
|
||||||
* Date: 03.10.12
|
|
||||||
* Time: 10:48
|
|
||||||
*/
|
|
||||||
public final class AndroidUtils2 {
|
|
||||||
|
|
||||||
private AndroidUtils2() {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -13,22 +13,23 @@ target=android-17
|
|||||||
android.library.reference.1=../android-app-core
|
android.library.reference.1=../android-app-core
|
||||||
android.library.reference.2=../android-app-widget
|
android.library.reference.2=../android-app-widget
|
||||||
android.library.reference.3=../android-app-onscreen
|
android.library.reference.3=../android-app-onscreen
|
||||||
android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-all_1.1.3-SNAPSHOT
|
android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-all_1.1.11
|
||||||
android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-ads_1.1.3-SNAPSHOT
|
android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-ads_1.1.11
|
||||||
android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-core_1.1.3-SNAPSHOT
|
android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-core_1.1.11
|
||||||
android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-billing_1.1.3-SNAPSHOT
|
android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-billing_1.1.11
|
||||||
android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-db_1.1.3-SNAPSHOT
|
android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-db_1.1.11
|
||||||
android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-security_1.1.3-SNAPSHOT
|
android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-security_1.1.11
|
||||||
android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-http_1.1.3-SNAPSHOT
|
android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-http_1.1.11
|
||||||
android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-lists_1.1.3-SNAPSHOT
|
android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-lists_1.1.11
|
||||||
android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-views_1.1.3-SNAPSHOT
|
android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-views_1.1.11
|
||||||
android.library.reference.13=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.1.3-SNAPSHOT
|
android.library.reference.13=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.1.11
|
||||||
android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-menus_1.1.3-SNAPSHOT
|
android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-menus_1.1.11
|
||||||
android.library.reference.15=gen-external-apklibs/org.solovyev.android_android-common-other_1.1.3-SNAPSHOT
|
android.library.reference.15=gen-external-apklibs/org.solovyev.android_android-common-other_1.1.11
|
||||||
android.library.reference.16=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.1.3-SNAPSHOT
|
android.library.reference.16=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.1.11
|
||||||
android.library.reference.17=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
|
android.library.reference.17=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
|
||||||
android.library.reference.18=gen-external-apklibs/org.solovyev.android_android-common-keyboards_1.1.3-SNAPSHOT
|
android.library.reference.18=gen-external-apklibs/org.solovyev.android_android-common-keyboards_1.1.11
|
||||||
android.library.reference.19=gen-external-apklibs/org.solovyev.android_android-common-app_1.1.3-SNAPSHOT
|
android.library.reference.19=gen-external-apklibs/org.solovyev.android_android-common-app_1.1.11
|
||||||
android.library.reference.20=gen-external-apklibs/org.solovyev.android_android-common-networks_1.1.3-SNAPSHOT
|
android.library.reference.20=gen-external-apklibs/org.solovyev.android_android-common-networks_1.1.11
|
||||||
android.library.reference.21=gen-external-apklibs/org.solovyev.android_android-common-fragments_1.1.3-SNAPSHOT
|
android.library.reference.21=gen-external-apklibs/org.solovyev.android_android-common-fragments_1.1.11
|
||||||
android.library.reference.22=gen-external-apklibs/org.solovyev.android_android-common-tasks_1.1.3-SNAPSHOT
|
android.library.reference.22=gen-external-apklibs/org.solovyev.android_android-common-tasks_1.1.11
|
||||||
|
android.library.reference.23=gen-external-apklibs/org.solovyev.android_android-common-wizard_1.1.11
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
a:orientation="vertical"
|
a:orientation="vertical"
|
||||||
a:id="@+id/wizard_content"
|
a:id="@id/acl_wizard_content"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
a:layout_height="0dp"
|
a:layout_height="0dp"
|
||||||
a:layout_weight="1"
|
a:layout_weight="1"
|
||||||
@ -42,7 +42,7 @@
|
|||||||
a:layout_height="wrap_content">
|
a:layout_height="wrap_content">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
a:id="@+id/wizard_prev_button"
|
a:id="@id/acl_wizard_prev_button"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="wrap_content"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_weight="1"
|
a:layout_weight="1"
|
||||||
@ -52,7 +52,7 @@
|
|||||||
a:text="@string/cpp_wizard_back" />
|
a:text="@string/cpp_wizard_back" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
a:id="@+id/wizard_next_button"
|
a:id="@id/acl_wizard_next_button"
|
||||||
a:layout_height="wrap_content"
|
a:layout_height="wrap_content"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
a:layout_weight="1"
|
a:layout_weight="1"
|
||||||
|
@ -24,7 +24,6 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -33,25 +32,22 @@ import android.preference.PreferenceManager;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.*;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewConfiguration;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
|
|
||||||
import org.solovyev.android.Activities;
|
import org.solovyev.android.Activities;
|
||||||
import org.solovyev.android.Android;
|
import org.solovyev.android.Android;
|
||||||
import org.solovyev.android.Threads;
|
import org.solovyev.android.Threads;
|
||||||
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
|
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
|
||||||
import org.solovyev.android.calculator.plot.CalculatorPlotActivity;
|
import org.solovyev.android.calculator.plot.CalculatorPlotActivity;
|
||||||
import org.solovyev.android.calculator.wizard.CalculatorWizardActivity;
|
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
||||||
import org.solovyev.android.fragments.FragmentUtils;
|
import org.solovyev.android.fragments.FragmentUtils;
|
||||||
import org.solovyev.android.prefs.Preference;
|
import org.solovyev.android.prefs.Preference;
|
||||||
|
import org.solovyev.android.wizard.Wizard;
|
||||||
|
import org.solovyev.android.wizard.WizardUi;
|
||||||
|
import org.solovyev.android.wizard.Wizards;
|
||||||
import org.solovyev.common.Objects;
|
import org.solovyev.common.Objects;
|
||||||
import org.solovyev.common.history.HistoryAction;
|
import org.solovyev.common.history.HistoryAction;
|
||||||
import org.solovyev.common.text.Strings;
|
import org.solovyev.common.text.Strings;
|
||||||
@ -63,9 +59,8 @@ import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
|
|||||||
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.preventScreenFromFading;
|
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.preventScreenFromFading;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizards.FIRST_TIME_WIZARD;
|
import static org.solovyev.android.wizard.WizardUi.continueWizard;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizards.isWizardFinished;
|
import static org.solovyev.android.wizard.WizardUi.startWizard;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizards.isWizardStarted;
|
|
||||||
|
|
||||||
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {
|
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {
|
||||||
|
|
||||||
@ -154,13 +149,15 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
if (!CalculatorApplication.isMonkeyRunner(context)) {
|
if (!CalculatorApplication.isMonkeyRunner(context)) {
|
||||||
|
|
||||||
boolean dialogShown = false;
|
boolean dialogShown = false;
|
||||||
if (isWizardStarted(FIRST_TIME_WIZARD) && !isWizardFinished(FIRST_TIME_WIZARD)) {
|
final Wizards wizards = CalculatorApplication.getInstance().getWizards();
|
||||||
CalculatorWizardActivity.continueWizard(FIRST_TIME_WIZARD, context);
|
final Wizard wizard = wizards.getWizard(CalculatorWizards.FIRST_TIME_WIZARD);
|
||||||
|
if (wizard.isStarted() && !wizard.isFinished()) {
|
||||||
|
continueWizard(wizards, wizard.getName(), context);
|
||||||
dialogShown = true;
|
dialogShown = true;
|
||||||
} else {
|
} else {
|
||||||
if (Objects.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
|
if (Objects.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
|
||||||
// new start
|
// new start
|
||||||
context.startActivity(new Intent(context, CalculatorWizardActivity.class));
|
startWizard(wizards, context);
|
||||||
dialogShown = true;
|
dialogShown = true;
|
||||||
} else {
|
} else {
|
||||||
if (savedVersion < appVersion) {
|
if (savedVersion < appVersion) {
|
||||||
|
@ -44,6 +44,8 @@ import org.solovyev.android.calculator.onscreen.CalculatorOnscreenStartActivity;
|
|||||||
import org.solovyev.android.calculator.plot.AndroidCalculatorPlotter;
|
import org.solovyev.android.calculator.plot.AndroidCalculatorPlotter;
|
||||||
import org.solovyev.android.calculator.plot.CalculatorPlotterImpl;
|
import org.solovyev.android.calculator.plot.CalculatorPlotterImpl;
|
||||||
import org.solovyev.android.calculator.view.EditorTextProcessor;
|
import org.solovyev.android.calculator.view.EditorTextProcessor;
|
||||||
|
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
||||||
|
import org.solovyev.android.wizard.Wizards;
|
||||||
import org.solovyev.common.msg.MessageType;
|
import org.solovyev.common.msg.MessageType;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -98,6 +100,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private final CalculatorBroadcaster broadcaster = new CalculatorBroadcaster(this);
|
private final CalculatorBroadcaster broadcaster = new CalculatorBroadcaster(this);
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private final Wizards wizards = new CalculatorWizards(this);
|
||||||
|
|
||||||
|
private final boolean withAds;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
*
|
||||||
@ -106,10 +113,15 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
**********************************************************************
|
**********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CalculatorApplication() {
|
protected CalculatorApplication(boolean withAds) {
|
||||||
|
this.withAds = withAds;
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CalculatorApplication() {
|
||||||
|
this(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@ -162,6 +174,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
|
|
||||||
BillingDB.init(CalculatorApplication.this);
|
BillingDB.init(CalculatorApplication.this);
|
||||||
|
|
||||||
|
if (withAds) {
|
||||||
AdsController.getInstance().init(this, ADMOB_USER_ID, AD_FREE_PRODUCT_ID, new BillingController.IConfiguration() {
|
AdsController.getInstance().init(this, ADMOB_USER_ID, AD_FREE_PRODUCT_ID, new BillingController.IConfiguration() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -174,6 +187,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
return CalculatorSecurity.getPK();
|
return CalculatorSecurity.getPK();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
BillingController.registerObserver(new DefaultBillingObserver(this, null));
|
BillingController.registerObserver(new DefaultBillingObserver(this, null));
|
||||||
|
|
||||||
@ -229,6 +243,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
return uiHandler;
|
return uiHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public Wizards getWizards() {
|
||||||
|
return wizards;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
*
|
||||||
|
@ -42,15 +42,17 @@ import org.solovyev.android.App;
|
|||||||
import org.solovyev.android.ads.AdsController;
|
import org.solovyev.android.ads.AdsController;
|
||||||
import org.solovyev.android.calculator.*;
|
import org.solovyev.android.calculator.*;
|
||||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||||
|
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
||||||
import org.solovyev.android.msg.AndroidMessage;
|
import org.solovyev.android.msg.AndroidMessage;
|
||||||
import org.solovyev.android.view.VibratorContainer;
|
import org.solovyev.android.view.VibratorContainer;
|
||||||
|
import org.solovyev.android.wizard.WizardUi;
|
||||||
import org.solovyev.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
import org.solovyev.common.msg.MessageType;
|
import org.solovyev.common.msg.MessageType;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.wizard.CalculatorWizardActivity.startWizard;
|
import static org.solovyev.android.calculator.wizard.CalculatorWizards.DEFAULT_WIZARD_FLOW;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizards.DEFAULT_WIZARD_FLOW;
|
import static org.solovyev.android.wizard.WizardUi.startWizard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -79,7 +81,7 @@ public class CalculatorPreferencesActivity extends SherlockPreferenceActivity im
|
|||||||
restartWizardPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
restartWizardPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
startWizard(DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
|
startWizard(CalculatorApplication.getInstance().getWizards(), DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -22,285 +22,29 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.wizard;
|
package org.solovyev.android.calculator.wizard;
|
||||||
|
|
||||||
import android.content.Context;
|
import org.solovyev.android.calculator.CalculatorApplication;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
|
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.wizard.BaseWizardActivity;
|
||||||
|
import org.solovyev.android.wizard.Wizards;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
public final class CalculatorWizardActivity extends BaseWizardActivity {
|
||||||
import static android.view.View.VISIBLE;
|
|
||||||
import static org.solovyev.android.calculator.wizard.Wizards.FLOW;
|
|
||||||
import static org.solovyev.android.calculator.wizard.Wizards.STEP;
|
|
||||||
|
|
||||||
/**
|
@Nonnull
|
||||||
* User: serso
|
private Wizards wizards;
|
||||||
* Date: 6/16/13
|
|
||||||
* Time: 9:07 PM
|
|
||||||
*/
|
|
||||||
public final class CalculatorWizardActivity extends FragmentActivity {
|
|
||||||
|
|
||||||
/*
|
public CalculatorWizardActivity() {
|
||||||
**********************************************************************
|
super(R.layout.cpp_wizard);
|
||||||
*
|
this.wizards = CalculatorApplication.getInstance().getWizards();
|
||||||
* FIELDS
|
|
||||||
*
|
|
||||||
**********************************************************************
|
|
||||||
*/
|
|
||||||
private WizardStep step;
|
|
||||||
|
|
||||||
private WizardFlow flow;
|
|
||||||
|
|
||||||
/*
|
|
||||||
**********************************************************************
|
|
||||||
*
|
|
||||||
* VIEWS
|
|
||||||
*
|
|
||||||
**********************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
private View prevButton;
|
|
||||||
private Button nextButton;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.cpp_wizard);
|
|
||||||
|
|
||||||
prevButton = findViewById(R.id.wizard_prev_button);
|
|
||||||
nextButton = (Button) findViewById(R.id.wizard_next_button);
|
|
||||||
|
|
||||||
String wizardName = getIntent().getStringExtra(FLOW);
|
|
||||||
String stepName = getIntent().getStringExtra(STEP);
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
wizardName = savedInstanceState.getString(FLOW);
|
|
||||||
stepName = savedInstanceState.getString(STEP);
|
|
||||||
}
|
|
||||||
|
|
||||||
flow = Wizards.getWizardFlow(wizardName != null ? wizardName : Wizards.FIRST_TIME_WIZARD);
|
|
||||||
|
|
||||||
WizardStep step = null;
|
|
||||||
if (stepName != null) {
|
|
||||||
step = flow.getStep(stepName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (step == null) {
|
|
||||||
step = flow.getFirstStep();
|
|
||||||
}
|
|
||||||
|
|
||||||
setStep(step);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setStep(@Nonnull WizardStep step) {
|
|
||||||
if (this.step == null || !this.step.equals(step)) {
|
|
||||||
hideFragment();
|
|
||||||
this.step = step;
|
|
||||||
showFragment();
|
|
||||||
|
|
||||||
initTitle();
|
|
||||||
initNextButton();
|
|
||||||
initPrevButton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initTitle() {
|
|
||||||
setTitle(step.getTitleResId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initPrevButton() {
|
|
||||||
final WizardStep prevStep = flow.getPrevStep(step);
|
|
||||||
if (prevStep == null) {
|
|
||||||
prevButton.setVisibility(GONE);
|
|
||||||
prevButton.setOnClickListener(null);
|
|
||||||
} else {
|
|
||||||
prevButton.setVisibility(VISIBLE);
|
|
||||||
prevButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (tryGoPrev()) {
|
|
||||||
setStep(prevStep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initNextButton() {
|
|
||||||
final WizardStep nextStep = flow.getNextStep(step);
|
|
||||||
if (nextStep == null) {
|
|
||||||
nextButton.setText(R.string.cpp_wizard_finish);
|
|
||||||
nextButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (tryGoNext()) {
|
|
||||||
finishFlow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
nextButton.setText(step.getNextButtonTitleResId());
|
|
||||||
nextButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (tryGoNext()) {
|
|
||||||
setStep(nextStep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void finishFlow() {
|
|
||||||
finishFlow(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void finishFlow(boolean forceFinish) {
|
|
||||||
if (flow != null && step != null) {
|
|
||||||
Wizards.saveWizardFinished(flow, step, forceFinish);
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean tryGoPrev() {
|
|
||||||
if (this.step == null) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
final Fragment fragment = getSupportFragmentManager().findFragmentByTag(this.step.getFragmentTag());
|
|
||||||
if (fragment != null) {
|
|
||||||
return this.step.onPrev(fragment);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean tryGoNext() {
|
|
||||||
if (this.step == null) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
final Fragment fragment = getSupportFragmentManager().findFragmentByTag(this.step.getFragmentTag());
|
|
||||||
if (fragment != null) {
|
|
||||||
return this.step.onNext(fragment);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private Fragment showFragment() {
|
public Wizards getWizards() {
|
||||||
final FragmentManager fm = getSupportFragmentManager();
|
return wizards;
|
||||||
final FragmentTransaction ft = fm.beginTransaction();
|
|
||||||
|
|
||||||
Fragment newFragment = fm.findFragmentByTag(this.step.getFragmentTag());
|
|
||||||
|
|
||||||
if (newFragment == null) {
|
|
||||||
newFragment = Fragment.instantiate(this, this.step.getFragmentClass().getName(), this.step.getFragmentArgs());
|
|
||||||
ft.add(R.id.wizard_content, newFragment, this.step.getFragmentTag());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ft.commit();
|
public void setWizards(@Nonnull Wizards wizards) {
|
||||||
fm.executePendingTransactions();
|
this.wizards = wizards;
|
||||||
|
|
||||||
return newFragment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideFragment() {
|
|
||||||
final FragmentManager fm = getSupportFragmentManager();
|
|
||||||
final FragmentTransaction ft = fm.beginTransaction();
|
|
||||||
|
|
||||||
if (this.step != null) {
|
|
||||||
hideFragmentByTag(fm, ft, this.step.getFragmentTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
ft.commit();
|
|
||||||
fm.executePendingTransactions();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hideFragmentByTag(@Nonnull FragmentManager fm, @Nonnull FragmentTransaction ft, @Nonnull String fragmentTag) {
|
|
||||||
final Fragment oldFragment = fm.findFragmentByTag(fragmentTag);
|
|
||||||
if (oldFragment != null) {
|
|
||||||
ft.remove(oldFragment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle out) {
|
|
||||||
super.onSaveInstanceState(out);
|
|
||||||
|
|
||||||
out.putString(FLOW, flow.getName());
|
|
||||||
out.putString(STEP, step.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
if (flow != null && step != null) {
|
|
||||||
Wizards.saveLastWizardStep(flow, step);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
FinishWizardConfirmationDialog.show(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
WizardStep getStep() {
|
|
||||||
return step;
|
|
||||||
}
|
|
||||||
|
|
||||||
WizardFlow getFlow() {
|
|
||||||
return flow;
|
|
||||||
}
|
|
||||||
|
|
||||||
View getPrevButton() {
|
|
||||||
return prevButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
View getNextButton() {
|
|
||||||
return nextButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
**********************************************************************
|
|
||||||
*
|
|
||||||
* STATIC/INNER
|
|
||||||
*
|
|
||||||
**********************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void startWizard(@Nonnull String name, @Nonnull Context context) {
|
|
||||||
context.startActivity(createLaunchIntent(name, context));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void continueWizard(@Nonnull String name, @Nonnull Context context) {
|
|
||||||
final Intent intent = createLaunchIntent(name, context);
|
|
||||||
|
|
||||||
final String step = Wizards.getLastSavedWizardStepName(name);
|
|
||||||
if (step != null) {
|
|
||||||
intent.putExtra(STEP, step);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private static Intent createLaunchIntent(@Nonnull String name, @Nonnull Context context) {
|
|
||||||
final Intent intent = new Intent(context, CalculatorWizardActivity.class);
|
|
||||||
intent.putExtra(FLOW, name);
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
||||||
return intent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,13 @@ import static org.solovyev.android.calculator.wizard.OnScreenCalculatorWizardSte
|
|||||||
* Date: 6/16/13
|
* Date: 6/16/13
|
||||||
* Time: 9:17 PM
|
* Time: 9:17 PM
|
||||||
*/
|
*/
|
||||||
enum WizardStep {
|
enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
|
||||||
|
|
||||||
welcome(WelcomeWizardStep.class, R.string.cpp_wizard_welcome_title, R.string.cpp_wizard_start),
|
welcome(WelcomeWizardStep.class, R.string.cpp_wizard_welcome_title, R.string.cpp_wizard_start),
|
||||||
|
|
||||||
choose_layout(ChooseLayoutWizardStep.class, R.string.cpp_wizard_layout_title) {
|
choose_layout(ChooseLayoutWizardStep.class, R.string.cpp_wizard_layout_title) {
|
||||||
@Override
|
@Override
|
||||||
boolean onNext(@Nonnull Fragment f) {
|
public boolean onNext(@Nonnull Fragment f) {
|
||||||
final ChooseLayoutWizardStep fragment = (ChooseLayoutWizardStep) f;
|
final ChooseLayoutWizardStep fragment = (ChooseLayoutWizardStep) f;
|
||||||
|
|
||||||
final CalculatorLayout layout = fragment.getSelectedLayout();
|
final CalculatorLayout layout = fragment.getSelectedLayout();
|
||||||
@ -60,7 +60,7 @@ enum WizardStep {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
Bundle getFragmentArgs() {
|
public Bundle getFragmentArgs() {
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(LAYOUT, CalculatorLayout.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
|
bundle.putSerializable(LAYOUT, CalculatorLayout.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
|
||||||
return bundle;
|
return bundle;
|
||||||
@ -74,7 +74,7 @@ enum WizardStep {
|
|||||||
|
|
||||||
choose_mode(ChooseModeWizardStep.class, R.string.cpp_wizard_mode_title) {
|
choose_mode(ChooseModeWizardStep.class, R.string.cpp_wizard_mode_title) {
|
||||||
@Override
|
@Override
|
||||||
boolean onNext(@Nonnull Fragment f) {
|
public boolean onNext(@Nonnull Fragment f) {
|
||||||
final ChooseModeWizardStep fragment = (ChooseModeWizardStep) f;
|
final ChooseModeWizardStep fragment = (ChooseModeWizardStep) f;
|
||||||
|
|
||||||
final CalculatorMode mode = fragment.getSelectedMode();
|
final CalculatorMode mode = fragment.getSelectedMode();
|
||||||
@ -85,7 +85,7 @@ enum WizardStep {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
Bundle getFragmentArgs() {
|
public Bundle getFragmentArgs() {
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(MODE, CalculatorMode.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
|
bundle.putSerializable(MODE, CalculatorMode.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
|
||||||
return bundle;
|
return bundle;
|
||||||
@ -94,7 +94,7 @@ enum WizardStep {
|
|||||||
|
|
||||||
on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_title) {
|
on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_title) {
|
||||||
@Override
|
@Override
|
||||||
boolean onNext(@Nonnull Fragment f) {
|
public boolean onNext(@Nonnull Fragment f) {
|
||||||
final OnScreenCalculatorWizardStep fragment = (OnScreenCalculatorWizardStep) f;
|
final OnScreenCalculatorWizardStep fragment = (OnScreenCalculatorWizardStep) f;
|
||||||
|
|
||||||
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled());
|
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled());
|
||||||
@ -104,7 +104,7 @@ enum WizardStep {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
Bundle getFragmentArgs() {
|
public Bundle getFragmentArgs() {
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(ONSCREEN_CALCULATOR_ENABLED, CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences()));
|
bundle.putSerializable(ONSCREEN_CALCULATOR_ENABLED, CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences()));
|
||||||
return bundle;
|
return bundle;
|
||||||
@ -121,49 +121,59 @@ enum WizardStep {
|
|||||||
private final int titleResId;
|
private final int titleResId;
|
||||||
private final int nextButtonTitleResId;
|
private final int nextButtonTitleResId;
|
||||||
|
|
||||||
WizardStep(@Nonnull Class<? extends Fragment> fragmentClass, int titleResId) {
|
CalculatorWizardStep(@Nonnull Class<? extends Fragment> fragmentClass, int titleResId) {
|
||||||
this(fragmentClass, titleResId, R.string.cpp_wizard_next);
|
this(fragmentClass, titleResId, R.string.cpp_wizard_next);
|
||||||
}
|
}
|
||||||
WizardStep(@Nonnull Class<? extends Fragment> fragmentClass, int titleResId, int nextButtonTitleResId) {
|
CalculatorWizardStep(@Nonnull Class<? extends Fragment> fragmentClass, int titleResId, int nextButtonTitleResId) {
|
||||||
this.fragmentClass = fragmentClass;
|
this.fragmentClass = fragmentClass;
|
||||||
this.titleResId = titleResId;
|
this.titleResId = titleResId;
|
||||||
this.nextButtonTitleResId = nextButtonTitleResId;
|
this.nextButtonTitleResId = nextButtonTitleResId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
public String getFragmentTag() {
|
public String getFragmentTag() {
|
||||||
return name();
|
return name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
Class<? extends Fragment> getFragmentClass() {
|
public Class<? extends Fragment> getFragmentClass() {
|
||||||
return fragmentClass;
|
return fragmentClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getTitleResId() {
|
@Override
|
||||||
|
public int getTitleResId() {
|
||||||
return titleResId;
|
return titleResId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNextButtonTitleResId() {
|
@Override
|
||||||
|
public int getNextButtonTitleResId() {
|
||||||
return nextButtonTitleResId;
|
return nextButtonTitleResId;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean onNext(@Nonnull Fragment fragment) {
|
@Override
|
||||||
|
public boolean onNext(@Nonnull Fragment fragment) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean onPrev(@Nonnull Fragment fragment) {
|
@Override
|
||||||
|
public boolean onPrev(@Nonnull Fragment fragment) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
Bundle getFragmentArgs() {
|
public Bundle getFragmentArgs() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name();
|
return name();
|
@ -0,0 +1,75 @@
|
|||||||
|
package org.solovyev.android.calculator.wizard;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import org.solovyev.android.wizard.*;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.last;
|
||||||
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.welcome;
|
||||||
|
|
||||||
|
public class CalculatorWizards implements Wizards {
|
||||||
|
|
||||||
|
public static final String FIRST_TIME_WIZARD = "first-wizard";
|
||||||
|
public static final String DEFAULT_WIZARD_FLOW = "app-wizard";
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
public CalculatorWizards(@Nonnull Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Class<? extends Activity> getActivityClassName() {
|
||||||
|
return CalculatorWizardActivity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Wizard getWizard(@Nullable String name) {
|
||||||
|
if (name == null) {
|
||||||
|
return getWizard(FIRST_TIME_WIZARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FIRST_TIME_WIZARD.equals(name)) {
|
||||||
|
return newBaseWizard(FIRST_TIME_WIZARD, newFirstTimeWizardFlow());
|
||||||
|
} else if (DEFAULT_WIZARD_FLOW.equals(name)) {
|
||||||
|
return newBaseWizard(DEFAULT_WIZARD_FLOW, newDefaultWizardFlow());
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Wizard flow " + name + " is not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private BaseWizard newBaseWizard(@Nonnull String name, @Nonnull WizardFlow flow) {
|
||||||
|
return new BaseWizard(name, context, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
static WizardFlow newDefaultWizardFlow() {
|
||||||
|
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
||||||
|
for (WizardStep wizardStep : CalculatorWizardStep.values()) {
|
||||||
|
if (wizardStep != welcome && wizardStep != last && wizardStep.isVisible()) {
|
||||||
|
wizardSteps.add(wizardStep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ListWizardFlow(wizardSteps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
static WizardFlow newFirstTimeWizardFlow() {
|
||||||
|
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
||||||
|
for (WizardStep wizardStep : CalculatorWizardStep.values()) {
|
||||||
|
if (wizardStep.isVisible()) {
|
||||||
|
wizardSteps.add(wizardStep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ListWizardFlow(wizardSteps);
|
||||||
|
}
|
||||||
|
}
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013 serso aka se.solovyev
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
* Contact details
|
|
||||||
*
|
|
||||||
* Email: se.solovyev@gmail.com
|
|
||||||
* Site: http://se.solovyev.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator.wizard;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import org.solovyev.android.calculator.R;
|
|
||||||
import org.solovyev.android.sherlock.AndroidSherlockUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class FinishWizardConfirmationDialog extends DialogFragment {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
final AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
|
||||||
b.setMessage(R.string.cpp_wizard_finish_confirmation);
|
|
||||||
b.setPositiveButton(R.string.c_yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
((CalculatorWizardActivity) getActivity()).finishFlow(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
b.setNegativeButton(R.string.c_no, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return b.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void show(@Nonnull CalculatorWizardActivity activity) {
|
|
||||||
AndroidSherlockUtils.showDialog(new FinishWizardConfirmationDialog(), FinishWizardConfirmationDialog.class.getSimpleName(), activity.getSupportFragmentManager());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013 serso aka se.solovyev
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
* Contact details
|
|
||||||
*
|
|
||||||
* Email: se.solovyev@gmail.com
|
|
||||||
* Site: http://se.solovyev.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator.wizard;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 6/16/13
|
|
||||||
* Time: 9:30 PM
|
|
||||||
*/
|
|
||||||
public final class ListWizardFlow implements WizardFlow {
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final List<WizardStep> wizardSteps;
|
|
||||||
|
|
||||||
public ListWizardFlow(@Nonnull String name, @Nonnull List<WizardStep> wizardSteps) {
|
|
||||||
this.name = name;
|
|
||||||
this.wizardSteps = wizardSteps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public WizardStep getStep(@Nonnull final String name) {
|
|
||||||
return Iterables.find(wizardSteps, new Predicate<WizardStep>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(@Nullable WizardStep step) {
|
|
||||||
assert step != null;
|
|
||||||
return step.getName().equals(name);
|
|
||||||
}
|
|
||||||
}, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public WizardStep getNextStep(@Nonnull WizardStep step) {
|
|
||||||
final int i = wizardSteps.indexOf(step);
|
|
||||||
if (i >= 0 && i + 1 < wizardSteps.size()) {
|
|
||||||
return wizardSteps.get(i + 1);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public WizardStep getPrevStep(@Nonnull WizardStep step) {
|
|
||||||
final int i = wizardSteps.indexOf(step);
|
|
||||||
if (i >= 1) {
|
|
||||||
return wizardSteps.get(i - 1);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public WizardStep getFirstStep() {
|
|
||||||
return wizardSteps.get(0);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013 serso aka se.solovyev
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
* Contact details
|
|
||||||
*
|
|
||||||
* Email: se.solovyev@gmail.com
|
|
||||||
* Site: http://se.solovyev.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator.wizard;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 6/16/13
|
|
||||||
* Time: 9:22 PM
|
|
||||||
*/
|
|
||||||
public interface WizardFlow {
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
WizardStep getStep(@Nonnull String name);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
WizardStep getNextStep(@Nonnull WizardStep step);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
WizardStep getPrevStep(@Nonnull WizardStep step);
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
WizardStep getFirstStep();
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013 serso aka se.solovyev
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
* Contact details
|
|
||||||
*
|
|
||||||
* Email: se.solovyev@gmail.com
|
|
||||||
* Site: http://se.solovyev.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator.wizard;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorApplication;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.last;
|
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 6/16/13
|
|
||||||
* Time: 9:23 PM
|
|
||||||
*/
|
|
||||||
public final class Wizards {
|
|
||||||
|
|
||||||
public static final String FIRST_TIME_WIZARD = "first-wizard";
|
|
||||||
public static final String DEFAULT_WIZARD_FLOW = "app-wizard";
|
|
||||||
static final String FLOW = "flow";
|
|
||||||
static final String FLOW_FINISHED = "flow_finished";
|
|
||||||
static final String STEP = "step";
|
|
||||||
|
|
||||||
private Wizards() {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public static WizardFlow getWizardFlow(@Nonnull String name) {
|
|
||||||
if (FIRST_TIME_WIZARD.equals(name)) {
|
|
||||||
return newFirstTimeWizardFlow();
|
|
||||||
} else if (DEFAULT_WIZARD_FLOW.equals(name)) {
|
|
||||||
return newDefaultWizardFlow();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Wizard flow " + name + " is not supported");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isWizardFinished(@Nonnull String name) {
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
|
||||||
return preferences.getBoolean(makeFinishedPreferenceKey(name), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isWizardStarted(@Nonnull String name) {
|
|
||||||
return getLastSavedWizardStepName(name) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void saveLastWizardStep(@Nonnull WizardFlow flow, @Nonnull WizardStep step) {
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
|
||||||
final SharedPreferences.Editor editor = preferences.edit();
|
|
||||||
|
|
||||||
editor.putString(makeLastStepPreferenceKey(flow), step.name());
|
|
||||||
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
static String getLastSavedWizardStepName(@Nonnull String name) {
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
|
||||||
|
|
||||||
return preferences.getString(makeLastStepPreferenceKey(name), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void saveWizardFinished(@Nonnull WizardFlow flow, @Nonnull WizardStep step, boolean forceFinish) {
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
|
||||||
final SharedPreferences.Editor editor = preferences.edit();
|
|
||||||
|
|
||||||
editor.putBoolean(makeFinishedPreferenceKey(flow), forceFinish || flow.getNextStep(step) == null);
|
|
||||||
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private static String makeFinishedPreferenceKey(@Nonnull WizardFlow flow) {
|
|
||||||
return makeFinishedPreferenceKey(flow.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private static String makeFinishedPreferenceKey(@Nonnull String flowName) {
|
|
||||||
return FLOW_FINISHED + ":" + flowName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private static String makeLastStepPreferenceKey(@Nonnull WizardFlow flow) {
|
|
||||||
return makeLastStepPreferenceKey(flow.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private static String makeLastStepPreferenceKey(@Nonnull String flowName) {
|
|
||||||
return FLOW + ":" + flowName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
static WizardFlow newDefaultWizardFlow() {
|
|
||||||
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
|
||||||
for (WizardStep wizardStep : WizardStep.values()) {
|
|
||||||
if (wizardStep != welcome && wizardStep != last && wizardStep.isVisible()) {
|
|
||||||
wizardSteps.add(wizardStep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ListWizardFlow(DEFAULT_WIZARD_FLOW, wizardSteps);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
static WizardFlow newFirstTimeWizardFlow() {
|
|
||||||
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
|
||||||
for (WizardStep wizardStep : WizardStep.values()) {
|
|
||||||
if (wizardStep.isVisible()) {
|
|
||||||
wizardSteps.add(wizardStep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ListWizardFlow(FIRST_TIME_WIZARD, wizardSteps);
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,6 +31,10 @@ public class TestCalculatorApplication extends CalculatorApplication {
|
|||||||
|
|
||||||
private static volatile boolean initialized = false;
|
private static volatile boolean initialized = false;
|
||||||
|
|
||||||
|
public TestCalculatorApplication() {
|
||||||
|
super(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
synchronized (TestCalculatorApplication.class) {
|
synchronized (TestCalculatorApplication.class) {
|
||||||
|
@ -34,6 +34,14 @@ import org.robolectric.Robolectric;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.shadows.ShadowActivity;
|
import org.robolectric.shadows.ShadowActivity;
|
||||||
import org.robolectric.util.ActivityController;
|
import org.robolectric.util.ActivityController;
|
||||||
|
import org.solovyev.android.wizard.BaseWizardActivity;
|
||||||
|
import org.solovyev.android.wizard.Wizard;
|
||||||
|
import org.solovyev.android.wizard.WizardUi;
|
||||||
|
import org.solovyev.android.wizard.Wizards;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
@ -42,42 +50,48 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.solovyev.android.calculator.wizard.CalculatorWizardActivity.startWizard;
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.choose_mode;
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.choose_mode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 6/17/13
|
|
||||||
* Time: 9:57 PM
|
|
||||||
*/
|
|
||||||
@RunWith(value = RobolectricTestRunner.class)
|
@RunWith(value = RobolectricTestRunner.class)
|
||||||
public class CalculatorWizardActivityTest {
|
public class CalculatorWizardActivityTest {
|
||||||
|
|
||||||
private ActivityController<CalculatorWizardActivity> controller;
|
private ActivityController<CalculatorWizardActivity> controller;
|
||||||
private CalculatorWizardActivity activity;
|
private CalculatorWizardActivity activity;
|
||||||
|
private Wizards wizards;
|
||||||
|
private Field uiField;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
|
controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
|
||||||
|
activity = controller.get();
|
||||||
|
wizards = new CalculatorWizards(Robolectric.application);
|
||||||
|
activity.setWizards(wizards);
|
||||||
controller.attach();
|
controller.attach();
|
||||||
controller.create();
|
controller.create();
|
||||||
activity = controller.get();
|
|
||||||
|
uiField = BaseWizardActivity.class.getDeclaredField("ui");
|
||||||
|
uiField.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldBeFirstTimeWizardByDefault() throws Exception {
|
public void testShouldBeFirstTimeWizardByDefault() throws Exception {
|
||||||
assertEquals(Wizards.FIRST_TIME_WIZARD, activity.getFlow().getName());
|
assertEquals(CalculatorWizards.FIRST_TIME_WIZARD, getWizardUi().getWizard().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private WizardUi getWizardUi() throws IllegalAccessException {
|
||||||
|
return (WizardUi) uiField.get(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldBeFirstStep() throws Exception {
|
public void testShouldBeFirstStep() throws Exception {
|
||||||
assertNotNull(activity.getStep());
|
assertNotNull(getWizardUi().getStep());
|
||||||
assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
|
assertEquals(getWizardUi().getFlow().getFirstStep(), getWizardUi().getStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldSaveState() throws Exception {
|
public void testShouldSaveState() throws Exception {
|
||||||
activity.setStep(choose_mode);
|
getWizardUi().setStep(choose_mode);
|
||||||
|
|
||||||
final Bundle outState = new Bundle();
|
final Bundle outState = new Bundle();
|
||||||
controller.saveInstanceState(outState);
|
controller.saveInstanceState(outState);
|
||||||
@ -86,22 +100,22 @@ public class CalculatorWizardActivityTest {
|
|||||||
controller.create(outState);
|
controller.create(outState);
|
||||||
|
|
||||||
activity = controller.get();
|
activity = controller.get();
|
||||||
assertNotNull(activity.getFlow());
|
assertNotNull(getWizardUi().getFlow());
|
||||||
assertEquals(Wizards.FIRST_TIME_WIZARD, activity.getFlow().getName());
|
assertEquals(CalculatorWizards.FIRST_TIME_WIZARD, getWizardUi().getWizard().getName());
|
||||||
assertNotNull(activity.getStep());
|
assertNotNull(getWizardUi().getStep());
|
||||||
assertEquals(choose_mode, activity.getStep());
|
assertEquals(choose_mode, getWizardUi().getStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setClass(activity, CalculatorWizardActivity.class);
|
intent.setClass(activity, CalculatorWizardActivity.class);
|
||||||
intent.putExtra(Wizards.FLOW, Wizards.DEFAULT_WIZARD_FLOW);
|
intent.putExtra("flow", CalculatorWizards.DEFAULT_WIZARD_FLOW);
|
||||||
controller = Robolectric.buildActivity(CalculatorWizardActivity.class).withIntent(intent);
|
controller = Robolectric.buildActivity(CalculatorWizardActivity.class).withIntent(intent);
|
||||||
controller.create();
|
controller.create();
|
||||||
activity = controller.get();
|
activity = controller.get();
|
||||||
assertEquals(Wizards.DEFAULT_WIZARD_FLOW, activity.getFlow().getName());
|
assertEquals(CalculatorWizards.DEFAULT_WIZARD_FLOW, getWizardUi().getWizard().getName());
|
||||||
assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
|
assertEquals(getWizardUi().getFlow().getFirstStep(), getWizardUi().getStep());
|
||||||
|
|
||||||
final Bundle outState1 = new Bundle();
|
final Bundle outState1 = new Bundle();
|
||||||
controller.saveInstanceState(outState1);
|
controller.saveInstanceState(outState1);
|
||||||
@ -109,8 +123,8 @@ public class CalculatorWizardActivityTest {
|
|||||||
controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
|
controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
|
||||||
activity = controller.get();
|
activity = controller.get();
|
||||||
controller.create(outState1);
|
controller.create(outState1);
|
||||||
assertEquals(Wizards.DEFAULT_WIZARD_FLOW, activity.getFlow().getName());
|
assertEquals(CalculatorWizards.DEFAULT_WIZARD_FLOW, getWizardUi().getWizard().getName());
|
||||||
assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
|
assertEquals(getWizardUi().getFlow().getFirstStep(), getWizardUi().getStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -118,7 +132,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
controller.start().resume();
|
controller.start().resume();
|
||||||
|
|
||||||
final FragmentManager fm = activity.getSupportFragmentManager();
|
final FragmentManager fm = activity.getSupportFragmentManager();
|
||||||
final Fragment f = fm.findFragmentByTag(WizardStep.welcome.getFragmentTag());
|
final Fragment f = fm.findFragmentByTag(CalculatorWizardStep.welcome.getFragmentTag());
|
||||||
assertNotNull(f);
|
assertNotNull(f);
|
||||||
assertTrue(f.isAdded());
|
assertTrue(f.isAdded());
|
||||||
}
|
}
|
||||||
@ -129,7 +143,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
|
|
||||||
final FragmentManager fm = activity.getSupportFragmentManager();
|
final FragmentManager fm = activity.getSupportFragmentManager();
|
||||||
|
|
||||||
activity.setStep(choose_mode);
|
getWizardUi().setStep(choose_mode);
|
||||||
|
|
||||||
final Fragment f = fm.findFragmentByTag(choose_mode.getFragmentTag());
|
final Fragment f = fm.findFragmentByTag(choose_mode.getFragmentTag());
|
||||||
assertNotNull(f);
|
assertNotNull(f);
|
||||||
@ -138,66 +152,69 @@ public class CalculatorWizardActivityTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetStep() throws Exception {
|
public void testSetStep() throws Exception {
|
||||||
activity.setStep(choose_mode);
|
getWizardUi().setStep(choose_mode);
|
||||||
assertEquals(choose_mode, activity.getStep());
|
assertEquals(choose_mode, getWizardUi().getStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldStartWizardActivityAfterStart() throws Exception {
|
public void testShouldStartWizardActivityAfterStart() throws Exception {
|
||||||
final ShadowActivity shadowActivity = Robolectric.shadowOf(controller.get());
|
final ShadowActivity shadowActivity = Robolectric.shadowOf(controller.get());
|
||||||
startWizard(Wizards.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
|
WizardUi.startWizard(activity.getWizards(), CalculatorWizards.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
|
||||||
assertNotNull(shadowActivity.getNextStartedActivity());
|
assertNotNull(shadowActivity.getNextStartedActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTitleShouldBeSet() throws Exception {
|
public void testTitleShouldBeSet() throws Exception {
|
||||||
activity.setStep(choose_mode);
|
getWizardUi().setStep(choose_mode);
|
||||||
assertEquals(activity.getString(choose_mode.getTitleResId()), activity.getTitle().toString());
|
assertEquals(activity.getString(choose_mode.getTitleResId()), activity.getTitle().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNextButtonShouldBeShownAtTheEnd() throws Exception {
|
public void testNextButtonShouldBeShownAtTheEnd() throws Exception {
|
||||||
setLastStep();
|
setLastStep();
|
||||||
assertEquals(VISIBLE, activity.getPrevButton().getVisibility());
|
assertEquals(VISIBLE, getWizardUi().getPrevButton().getVisibility());
|
||||||
assertEquals(VISIBLE, activity.getNextButton().getVisibility());
|
assertEquals(VISIBLE, getWizardUi().getNextButton().getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLastStep() {
|
private void setLastStep() throws IllegalAccessException {
|
||||||
activity.setStep(WizardStep.values()[WizardStep.values().length - 1]);
|
getWizardUi().setStep(CalculatorWizardStep.values()[CalculatorWizardStep.values().length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPrevButtonShouldNotBeShownAtTheStart() throws Exception {
|
public void testPrevButtonShouldNotBeShownAtTheStart() throws Exception {
|
||||||
setFirstStep();
|
setFirstStep();
|
||||||
assertEquals(VISIBLE, activity.getNextButton().getVisibility());
|
assertEquals(VISIBLE, getWizardUi().getNextButton().getVisibility());
|
||||||
assertEquals(GONE, activity.getPrevButton().getVisibility());
|
assertEquals(GONE, getWizardUi().getPrevButton().getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFirstStep() {
|
private void setFirstStep() throws IllegalAccessException {
|
||||||
activity.setStep(WizardStep.values()[0]);
|
getWizardUi().setStep(CalculatorWizardStep.values()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldSaveLastWizardStateOnPause() throws Exception {
|
public void testShouldSaveLastWizardStateOnPause() throws Exception {
|
||||||
assertNull(Wizards.getLastSavedWizardStepName(activity.getFlow().getName()));
|
final Wizard wizard = wizards.getWizard(getWizardUi().getWizard().getName());
|
||||||
activity.setStep(WizardStep.drag_button);
|
assertNull(wizard.getLastSavedStepName());
|
||||||
|
getWizardUi().setStep(CalculatorWizardStep.drag_button);
|
||||||
activity.onPause();
|
activity.onPause();
|
||||||
assertEquals(WizardStep.drag_button.getName(), Wizards.getLastSavedWizardStepName(activity.getFlow().getName()));
|
assertEquals(CalculatorWizardStep.drag_button.getName(), wizard.getLastSavedStepName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldSaveFinishedIfLastStep() throws Exception {
|
public void testShouldSaveFinishedIfLastStep() throws Exception {
|
||||||
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
|
final Wizard wizard = wizards.getWizard(getWizardUi().getWizard().getName());
|
||||||
|
assertFalse(wizard.isFinished());
|
||||||
setLastStep();
|
setLastStep();
|
||||||
activity.finishFlow();
|
getWizardUi().finishWizard();
|
||||||
assertTrue(Wizards.isWizardFinished(activity.getFlow().getName()));
|
assertTrue(wizard.isFinished());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldNotSaveFinishedIfNotLastStep() throws Exception {
|
public void testShouldNotSaveFinishedIfNotLastStep() throws Exception {
|
||||||
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
|
final Wizard wizard = wizards.getWizard(getWizardUi().getWizard().getName());
|
||||||
|
assertFalse(wizard.isFinished());
|
||||||
setFirstStep();
|
setFirstStep();
|
||||||
activity.finishFlow();
|
getWizardUi().finishWizard();
|
||||||
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
|
assertFalse(wizard.isFinished());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
package org.solovyev.android.calculator.wizard;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.solovyev.android.wizard.Wizard;
|
||||||
|
import org.solovyev.android.wizard.WizardFlow;
|
||||||
|
import org.solovyev.android.wizard.Wizards;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.choose_mode;
|
||||||
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.last;
|
||||||
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.welcome;
|
||||||
|
|
||||||
|
@RunWith(value = RobolectricTestRunner.class)
|
||||||
|
public class CalculatorWizardTest {
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private Wizards wizards;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private Wizard wizard;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private Wizard defaultWizard;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
wizards = new CalculatorWizards(Robolectric.application);
|
||||||
|
wizard = wizards.getWizard(null);
|
||||||
|
defaultWizard = wizards.getWizard(CalculatorWizards.DEFAULT_WIZARD_FLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultFlowShouldNotContainWelcomeAndLastSteps() throws Exception {
|
||||||
|
final WizardFlow flow = defaultWizard.getFlow();
|
||||||
|
assertNull(flow.getStepByName(welcome.getName()));
|
||||||
|
assertNull(flow.getStepByName(last.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFirstTimeFlowShouldContainWelcomeAndLastSteps() throws Exception {
|
||||||
|
final WizardFlow flow = wizard.getFlow();
|
||||||
|
assertNotNull(flow.getStepByName(welcome.getName()));
|
||||||
|
assertNotNull(flow.getStepByName(last.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldThrowExceptionIfUnknownWizard() throws Exception {
|
||||||
|
try {
|
||||||
|
wizards.getWizard("testtesttesttesttest");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldReturnWizard() throws Exception {
|
||||||
|
assertNotNull(wizards.getWizard(CalculatorWizards.FIRST_TIME_WIZARD));
|
||||||
|
assertNotNull(wizards.getWizard(CalculatorWizards.DEFAULT_WIZARD_FLOW));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldSaveWizardIsFinishedWhenNotLastStepAndForce() throws Exception {
|
||||||
|
assertFalse(wizard.isFinished());
|
||||||
|
wizard.saveFinished(CalculatorWizardStep.drag_button, true);
|
||||||
|
|
||||||
|
assertTrue(wizard.isFinished());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldNotSaveWizardIsFinishedWhenNotLastStepAndNotForce() throws Exception {
|
||||||
|
assertFalse(wizard.isFinished());
|
||||||
|
wizard.saveFinished(CalculatorWizardStep.drag_button, false);
|
||||||
|
|
||||||
|
assertFalse(wizard.isFinished());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldSaveWizardIsFinishedWhenLastStep() throws Exception {
|
||||||
|
assertFalse(wizard.isFinished());
|
||||||
|
wizard.saveFinished(CalculatorWizardStep.last, false);
|
||||||
|
|
||||||
|
assertTrue(wizard.isFinished());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldSaveLastWizardStep() throws Exception {
|
||||||
|
assertFalse(wizard.isStarted());
|
||||||
|
assertNull(wizard.getLastSavedStepName());
|
||||||
|
|
||||||
|
wizard.saveLastStep(choose_mode);
|
||||||
|
assertTrue(wizard.isStarted());
|
||||||
|
assertEquals(choose_mode.name(), wizard.getLastSavedStepName());
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,10 @@ import org.robolectric.Robolectric;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.util.ActivityController;
|
import org.robolectric.util.ActivityController;
|
||||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
import org.solovyev.android.calculator.CalculatorPreferences;
|
||||||
|
import org.solovyev.android.wizard.BaseWizardActivity;
|
||||||
|
import org.solovyev.android.wizard.WizardUi;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@ -50,22 +54,31 @@ public class OnScreenCalculatorWizardStepTest {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private ActivityController<CalculatorWizardActivity> controller;
|
private ActivityController<CalculatorWizardActivity> controller;
|
||||||
|
private Field uiField;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
uiField = BaseWizardActivity.class.getDeclaredField("ui");
|
||||||
|
uiField.setAccessible(true);
|
||||||
|
|
||||||
createActivity();
|
createActivity();
|
||||||
setFragment();
|
setFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private WizardUi getWizardUi() throws IllegalAccessException {
|
||||||
|
return (WizardUi) uiField.get(activity);
|
||||||
|
}
|
||||||
|
|
||||||
private void createActivity() {
|
private void createActivity() {
|
||||||
controller = Robolectric.buildActivity(CalculatorWizardActivity.class).create().start().resume();
|
controller = Robolectric.buildActivity(CalculatorWizardActivity.class).create().start().resume();
|
||||||
activity = controller.get();
|
activity = controller.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFragment() {
|
private void setFragment() throws IllegalAccessException {
|
||||||
activity.setStep(WizardStep.on_screen_calculator);
|
getWizardUi().setStep(CalculatorWizardStep.on_screen_calculator);
|
||||||
activity.getSupportFragmentManager().executePendingTransactions();
|
activity.getSupportFragmentManager().executePendingTransactions();
|
||||||
fragment = (OnScreenCalculatorWizardStep) activity.getSupportFragmentManager().findFragmentByTag(WizardStep.on_screen_calculator.getFragmentTag());
|
fragment = (OnScreenCalculatorWizardStep) activity.getSupportFragmentManager().findFragmentByTag(CalculatorWizardStep.on_screen_calculator.getFragmentTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -89,7 +102,7 @@ public class OnScreenCalculatorWizardStepTest {
|
|||||||
testShouldBeEqualsToIconState(false);
|
testShouldBeEqualsToIconState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testShouldBeEqualsToIconState(boolean iconEnabled) {
|
private void testShouldBeEqualsToIconState(boolean iconEnabled) throws IllegalAccessException {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(Robolectric.application);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(Robolectric.application);
|
||||||
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(preferences, iconEnabled);
|
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(preferences, iconEnabled);
|
||||||
createActivity();
|
createActivity();
|
||||||
|
@ -48,9 +48,9 @@ import static org.solovyev.android.calculator.wizard.CalculatorMode.simple;
|
|||||||
import static org.solovyev.android.calculator.wizard.ChooseLayoutWizardStep.LAYOUT;
|
import static org.solovyev.android.calculator.wizard.ChooseLayoutWizardStep.LAYOUT;
|
||||||
import static org.solovyev.android.calculator.wizard.ChooseModeWizardStep.MODE;
|
import static org.solovyev.android.calculator.wizard.ChooseModeWizardStep.MODE;
|
||||||
import static org.solovyev.android.calculator.wizard.OnScreenCalculatorWizardStep.ONSCREEN_CALCULATOR_ENABLED;
|
import static org.solovyev.android.calculator.wizard.OnScreenCalculatorWizardStep.ONSCREEN_CALCULATOR_ENABLED;
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.choose_layout;
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.choose_layout;
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.choose_mode;
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.choose_mode;
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.on_screen_calculator;
|
import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.on_screen_calculator;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class WizardStepTest {
|
public class WizardStepTest {
|
||||||
@ -64,7 +64,7 @@ public class WizardStepTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFragmentsShouldBeInstantiated() throws Exception {
|
public void testFragmentsShouldBeInstantiated() throws Exception {
|
||||||
for (WizardStep wizardStep : WizardStep.values()) {
|
for (CalculatorWizardStep wizardStep : CalculatorWizardStep.values()) {
|
||||||
Fragment.instantiate(Robolectric.application, wizardStep.getFragmentClass().getName());
|
Fragment.instantiate(Robolectric.application, wizardStep.getFragmentClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ public class WizardStepTest {
|
|||||||
final ChooseModeWizardStep modeFragment = mock(ChooseModeWizardStep.class);
|
final ChooseModeWizardStep modeFragment = mock(ChooseModeWizardStep.class);
|
||||||
when(modeFragment.getSelectedMode()).thenReturn(mode);
|
when(modeFragment.getSelectedMode()).thenReturn(mode);
|
||||||
when(modeFragment.getActivity()).thenReturn(activity);
|
when(modeFragment.getActivity()).thenReturn(activity);
|
||||||
WizardStep.choose_mode.onNext(modeFragment);
|
CalculatorWizardStep.choose_mode.onNext(modeFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseLayout(CalculatorLayout layout) {
|
private void chooseLayout(CalculatorLayout layout) {
|
||||||
@ -122,7 +122,7 @@ public class WizardStepTest {
|
|||||||
/* @Config(qualifiers = "large")
|
/* @Config(qualifiers = "large")
|
||||||
@Test
|
@Test
|
||||||
public void testChooseLayoutShouldBeVisibleForTablet() throws Exception {
|
public void testChooseLayoutShouldBeVisibleForTablet() throws Exception {
|
||||||
assertTrue(WizardStep.choose_layout.isVisible());
|
assertTrue(CalculatorWizardStep.choose_layout.isVisible());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@Config(qualifiers = "normal")
|
@Config(qualifiers = "normal")
|
||||||
@ -148,7 +148,7 @@ public class WizardStepTest {
|
|||||||
final OnScreenCalculatorWizardStep f = mock(OnScreenCalculatorWizardStep.class);
|
final OnScreenCalculatorWizardStep f = mock(OnScreenCalculatorWizardStep.class);
|
||||||
when(f.isOnscreenCalculatorEnabled()).thenReturn(onscreenCalculatorEnabled);
|
when(f.isOnscreenCalculatorEnabled()).thenReturn(onscreenCalculatorEnabled);
|
||||||
when(f.getActivity()).thenReturn(activity);
|
when(f.getActivity()).thenReturn(activity);
|
||||||
WizardStep.on_screen_calculator.onNext(f);
|
CalculatorWizardStep.on_screen_calculator.onNext(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
package org.solovyev.android.calculator.wizard;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.choose_mode;
|
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.last;
|
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
|
|
||||||
import static org.solovyev.android.calculator.wizard.Wizards.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 7/11/13
|
|
||||||
* Time: 10:29 AM
|
|
||||||
*/
|
|
||||||
@RunWith(value = RobolectricTestRunner.class)
|
|
||||||
public class WizardsTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultFlowShouldNotContainWelcomeAndLastSteps() throws Exception {
|
|
||||||
final WizardFlow flow = Wizards.newDefaultWizardFlow();
|
|
||||||
assertNull(flow.getStep(welcome.getName()));
|
|
||||||
assertNull(flow.getStep(last.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFirstTimeFlowShouldContainWelcomeAndLastSteps() throws Exception {
|
|
||||||
final WizardFlow flow = Wizards.newFirstTimeWizardFlow();
|
|
||||||
assertNotNull(flow.getStep(welcome.getName()));
|
|
||||||
assertNotNull(flow.getStep(last.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShouldThrowExceptionIfUnknownFlow() throws Exception {
|
|
||||||
try {
|
|
||||||
getWizardFlow("testtesttesttesttest");
|
|
||||||
fail();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// ok
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShouldReturnFlow() throws Exception {
|
|
||||||
assertNotNull(getWizardFlow(FIRST_TIME_WIZARD));
|
|
||||||
assertNotNull(getWizardFlow(DEFAULT_WIZARD_FLOW));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShouldSaveWizardIsFinishedWhenNotLastStepAndForce() throws Exception {
|
|
||||||
assertFalse(isWizardFinished(FIRST_TIME_WIZARD));
|
|
||||||
final WizardFlow flow = getWizardFlow(FIRST_TIME_WIZARD);
|
|
||||||
saveWizardFinished(flow, WizardStep.drag_button, true);
|
|
||||||
|
|
||||||
assertTrue(isWizardFinished(FIRST_TIME_WIZARD));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShouldNotSaveWizardIsFinishedWhenNotLastStepAndNotForce() throws Exception {
|
|
||||||
assertFalse(isWizardFinished(FIRST_TIME_WIZARD));
|
|
||||||
final WizardFlow flow = getWizardFlow(FIRST_TIME_WIZARD);
|
|
||||||
saveWizardFinished(flow, WizardStep.drag_button, false);
|
|
||||||
|
|
||||||
assertFalse(isWizardFinished(FIRST_TIME_WIZARD));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShouldSaveWizardIsFinishedWhenLastStep() throws Exception {
|
|
||||||
assertFalse(isWizardFinished(FIRST_TIME_WIZARD));
|
|
||||||
final WizardFlow flow = getWizardFlow(FIRST_TIME_WIZARD);
|
|
||||||
saveWizardFinished(flow, WizardStep.last, false);
|
|
||||||
|
|
||||||
assertTrue(isWizardFinished(FIRST_TIME_WIZARD));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShouldSaveLastWizardStep() throws Exception {
|
|
||||||
assertFalse(isWizardStarted(FIRST_TIME_WIZARD));
|
|
||||||
assertNull(getLastSavedWizardStepName(FIRST_TIME_WIZARD));
|
|
||||||
|
|
||||||
final WizardFlow flow = getWizardFlow(FIRST_TIME_WIZARD);
|
|
||||||
saveLastWizardStep(flow, choose_mode);
|
|
||||||
assertTrue(isWizardStarted(FIRST_TIME_WIZARD));
|
|
||||||
assertEquals(choose_mode.name(), getLastSavedWizardStepName(FIRST_TIME_WIZARD));
|
|
||||||
}
|
|
||||||
}
|
|
8
pom.xml
8
pom.xml
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<acl.version>1.1.3</acl.version>
|
<acl.version>1.1.11</acl.version>
|
||||||
<jcl.version>1.0.6</jcl.version>
|
<jcl.version>1.0.6</jcl.version>
|
||||||
<jscl.version>1.0.7</jscl.version>
|
<jscl.version>1.0.7</jscl.version>
|
||||||
</properties>
|
</properties>
|
||||||
@ -203,9 +203,9 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.electriccloud</groupId>
|
<groupId>org.solovyev.external.com.electriccloud</groupId>
|
||||||
<artifactId>javac2-maven-plugin</artifactId>
|
<artifactId>org.solovyev.external.javac2-maven-plugin</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.4</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>@Nonnull Instrumentation</id>
|
<id>@Nonnull Instrumentation</id>
|
||||||
|
Loading…
Reference in New Issue
Block a user