public class Template3 extends Activity implements SSCallback, OnSSTimerListener
Template2
process for the
user. This activity is run during the 4th, 7th and 10th run of the the
application. This class loads the base layout for Template 3 and then
proceeds to load in fragments for the rest of the application. Furthermore,
this class performs high level actions such as restarting the StaySafe
application, showing errors to the user, allowing the administrative to exit
the application early, saving data and then outputting that data. This
application also creates an instance of the SSJsonReader
class and
the proceeds to pass that instance throughout the run of the application.
This class is responsible for interfacing with the Menu3 Fragment and
determining what screen should be displayed next. This class saves what
screens the user has taken a part of in this session.Modifier and Type | Field and Description |
---|---|
(package private) boolean |
fac
boolean values representing which Template 3 sessions have already been
shown.
|
(package private) ImageView |
factsBtn |
(package private) java.lang.String |
fileName
The filename of the file to be exported.
|
(package private) java.lang.String |
finalHeaders
Strings used to save the output data.
|
(package private) java.lang.String |
finalValues
Strings used to save the output data.
|
(package private) boolean |
maz
boolean values representing which Template 3 sessions have already been
shown.
|
(package private) ImageView |
mazeBtn |
(package private) ImageView |
menuButton |
(package private) ImageView |
nextButton |
(package private) SSJsonReader |
reader
The instance of the
SSJsonReader to be passed to all of the
Fragments incorporated in Template 3. |
(package private) SSTimer |
routingTimer
timer used to display the survey button 5 seconds after the menu button.
|
(package private) Stop |
stopFragment
The instance of the
Stop fragment saved so the
ExitUtility cannot be performed when onLongClick(View)
occurs. |
(package private) ImageView |
surveyButton |
(package private) FragmentTransaction |
transaction
instance of a FragmentTransaction used for all Fragments
|
(package private) int |
type
Value representing which Template 3 session is current running
|
(package private) boolean |
vid
boolean values representing which Template 3 sessions have already been
shown.
|
(package private) ImageView |
videoBtn |
Constructor and Description |
---|
Template3() |
Modifier and Type | Method and Description |
---|---|
void |
addData(java.lang.String key,
java.lang.String value)
Saves key value pairs in order to have them output at the end of the
session.
|
void |
addOutputFile()
Causes all saved items (
finalHeaders and finalValues )
from the session to be compiled and saved in the root:/StaySafe/Data/
directory. |
void |
animateHand(float x,
float y,
int angle,
java.lang.Runnable runnable)
Not used in this class.
|
void |
animateHand(int i,
int j,
int k,
java.lang.Runnable runnable,
boolean b)
Not used in this class.
|
void |
animateHandNext()
Not used in this class.
|
void |
handVisible(boolean b)
Not used in this class.
|
void |
move(int i)
Method called by the
Menu3 screen to change the screen currently
displayed to the user. |
void |
moveHand(float x,
float y,
int angle)
Not used in this class.
|
void |
nextVisible(boolean visible)
Makes the next button visible to the user.
|
void |
onBackPressed()
Method run when back button is pressed.
|
protected void |
onCreate(Bundle savedInstanceState)
Responsible for inflating the Template 3 view elements.
|
boolean |
onLongClick(View v)
Called by the Android system when the StaySafe logo has been long
pressed.
|
void |
onMenu()
Displays the
Menu3 screen to the user. |
void |
onRoute(View v)
Method called by the Android system when a button is pressed.
|
void |
onSurvey()
Displays the
Survey screen to the user. |
void |
onTimerDone(SSTimer me)
Method responsible for displaying the survey button on delay.
|
void |
restart()
Closes the current Activity and loads the
Login Activity to
restart the application. |
void |
showError(java.lang.String error)
Shows an error to the user.
|
void |
showRouting(boolean bool)
called by the fragments associated with the template 3.
|
void |
stopRoutingTimer()
Method responsible for canceling the survey timer delay when the user
changes screen before the timer expires.
|
boolean fac
ImageView factsBtn
java.lang.String fileName
java.lang.String finalHeaders
java.lang.String finalValues
boolean maz
ImageView mazeBtn
ImageView menuButton
ImageView nextButton
SSJsonReader reader
SSJsonReader
to be passed to all of the
Fragments incorporated in Template 3.SSTimer routingTimer
Stop stopFragment
Stop
fragment saved so the
ExitUtility
cannot be performed when onLongClick(View)
occurs.ImageView surveyButton
FragmentTransaction transaction
int type
boolean vid
ImageView videoBtn
public void addData(java.lang.String key, java.lang.String value)
finalHeaders
and finalValues
)
Concatenates two strings, one for the keys and the other for the values.
Provides a means for the fragments to communicate and have data generated
within the Fragment be saved within the activity.addData
in interface SSCallback
key
- The title of the value being passedvalue
- The value associated with the keypublic void addOutputFile()
finalHeaders
and finalValues
)
from the session to be compiled and saved in the root:/StaySafe/Data/
directory.addOutputFile
in interface SSCallback
public void animateHand(float x, float y, int angle, java.lang.Runnable runnable)
animateHand
in interface SSCallback
x
- The x location the hand should be moved to at as a percentage
of total screen size. No limits are set on the percentage.y
- The y location the hand should be moved to as a percentage of
total screen size. No limits are set on the percentage.angle
- The angle the hand show be rotated to during animation.runnable
- The runnable that corresponds to the hand "pressing" something
on the screen.public void animateHand(int i, int j, int k, java.lang.Runnable runnable, boolean b)
animateHand
in interface SSCallback
i
- The absolute x position the hand should be moved toj
- The absolute y position the hand should be moved tok
- The angle the hand should be rotated torunnable
- The runnable that corresponds to the hand "pressing" something
on the screen.b
- fifth variable used to distinguish
SSCallback.animateHand(float, float, int, Runnable)
from this
one. This variable has no affect on the method.public void animateHandNext()
animateHandNext
in interface SSCallback
public void handVisible(boolean b)
handVisible
in interface SSCallback
b
- visible if true invisible if falsepublic void move(int i)
Menu3
screen to change the screen currently
displayed to the user. One of the Video, Game, or Facts screen can be
shown with this method.move
in interface SSCallback
i
- 1 - Video\n 2 - Game\n 3 - Factspublic void moveHand(float x, float y, int angle)
moveHand
in interface SSCallback
x
- The x location the hand should be moved to at as a percentage
of total screen size. No limits are set on the percentage.y
- The y location the hand should be moved to as a percentage of
total screen size. No limits are set on the percentage.angle
- The angle the hand show be rotated to during animation.public void nextVisible(boolean visible)
nextVisible
in interface SSCallback
visible
- If true, the next button will be made visible. If false, the
next button will be made invisible.public void onBackPressed()
protected void onCreate(Bundle savedInstanceState)
Login
screen. All Views are
associated with their ids within the activity. Listeners are assigned.public boolean onLongClick(View v)
ExitUtility
.public void onMenu()
Menu3
screen to the user. Transmits which buttons
should be available to the user.public void onRoute(View v)
v
- The view that has been pressed.public void onSurvey()
Survey
screen to the user.public void onTimerDone(SSTimer me)
onTimerDone
in interface OnSSTimerListener
me
- The instance of SSTimer
who has expiredpublic void restart()
Login
Activity to
restart the application.restart
in interface SSCallback
public void showError(java.lang.String error)
ErrorFragment
showError
in interface SSCallback
error
- The error message to be displayed.public void showRouting(boolean bool)
showRouting
in interface SSCallback
bool
- visible if true invisible if falsepublic void stopRoutingTimer()
stopRoutingTimer
in interface SSCallback