public class Template1 extends Activity implements SSCallback
Template2
activity. This class
loads the base layout for Template 1 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 user 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 extends Template2
by allowing the use of a
"floating hand". This hand allows that application to demonstrate
functionality of the application by moving the hand and then simulating
screen presses.
Modifier and Type | Field and Description |
---|---|
private float |
ANIMATION_DISTANCE
The distance the floating hand travels during the press animation.
|
private int |
ANIMATION_LENGTH
The length of the floating hand animation.
|
(package private) int |
density
The current pixel density of the device.
|
(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 |
firstrun
used to to determine if this is the first time the
moveHand(float, float, int) method has been run. |
(package private) LayoutParams |
lp
Current instance of the LayoutParameters for the device.s
|
(package private) int |
maxX
The maximum values for the screen orientation.
|
(package private) int |
maxY
The maximum values for the screen orientation.
|
(package private) ImageView |
nextButton
The ImageView containing the "next button"
|
(package private) ImageView |
pointer
The ImageView containing the "floating hand"
|
(package private) SSJsonReader |
reader
The instance of the
SSJsonReader to be passed to all of the
Fragments incorporated in Template 1. |
private boolean |
secondUse
Indicates if this is the second time the
Think Fragment has been
executed for this template |
(package private) int |
statusBarHeight
the height of the statues bar for the current device.
|
(package private) Stop |
stopFragment
The instance of the
Stop fragment saved so the
ExitUtility cannot be performed when onLongClick(View)
occurs. |
Constructor and Description |
---|
Template1() |
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 xDelta,
float yDelta,
int angle,
java.lang.Runnable r)
Animates the floating hand used in
Template1 to simulate a user
touch. |
void |
animateHand(int xDelta,
int yDelta,
int angle,
java.lang.Runnable r,
boolean b)
Convenience method similar to
animateHand(float, float, int, Runnable) This method takes an
elements absolute position on the screen and translates those values into
percentages which can be used by
animateHand(float, float, int, Runnable) This allows the pointer
to be moved around the screen dynamically in case the object needing to
be "touched" is not allows in the same position. |
void |
animateHandNext()
Convenience method to animate the hand to press the nextbuton.
|
void |
displaySetup()
finds and determines different characteristics of the current display
environment.
|
private int |
getStatusBarHeight()
returns the height of the status bar on the active device
|
void |
handVisible(boolean bool)
Determines the visibility of the "floating hand" used in Template 1
|
void |
move(int i)
Not used in this class.
|
void |
moveHand(float x,
float y,
int angle)
Moves the "floating hand" to this position.
|
void |
nextClickable(boolean clickable)
Makes the next button clickable.
|
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 1 view elements.
|
boolean |
onLongClick(View v)
Called by the Android system when the StaySafe logo has been long
pressed.
|
void |
onNext(View v)
Called when the user presses the next button.
|
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 b)
Not used in this class.
|
void |
stopRoutingTimer()
Not used in this class.
|
private float ANIMATION_DISTANCE
private int ANIMATION_LENGTH
int density
java.lang.String fileName
java.lang.String finalHeaders
java.lang.String finalValues
boolean firstrun
moveHand(float, float, int)
method has been run.LayoutParams lp
int maxX
int maxY
ImageView nextButton
ImageView pointer
SSJsonReader reader
SSJsonReader
to be passed to all of the
Fragments incorporated in Template 1.private boolean secondUse
Think
Fragment has been
executed for this templateint statusBarHeight
Stop stopFragment
Stop
fragment saved so the
ExitUtility
cannot be performed when onLongClick(View)
occurs.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 xDelta, float yDelta, int angle, java.lang.Runnable r)
Template1
to simulate a user
touch. This method call allows a Runnable
to be passed. This
allows the hand animation to act as it actually touched the object at the
coordinates givenanimateHand
in interface SSCallback
xDelta
- The x location the hand should be moved to at as a percentage
of total screen size. No limits are set on the percentage.yDelta
- 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.r
- The runnable that corresponds to the hand "pressing" something
on the screen.public void animateHand(int xDelta, int yDelta, int angle, java.lang.Runnable r, boolean b)
animateHand(float, float, int, Runnable)
This method takes an
elements absolute position on the screen and translates those values into
percentages which can be used by
animateHand(float, float, int, Runnable)
This allows the pointer
to be moved around the screen dynamically in case the object needing to
be "touched" is not allows in the same position.animateHand
in interface SSCallback
xDelta
- The absolute x position the hand should be moved toyDelta
- The absolute y position the hand should be moved toangle
- The angle the hand should be rotated tor
- The runnable that corresponds to the hand "pressing" something
on the screen.b
- fifth variable used to distinguish
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 displaySetup()
private int getStatusBarHeight()
public void handVisible(boolean bool)
handVisible
in interface SSCallback
bool
- hand is visible if true; invisible if false.public void move(int i)
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 nextClickable(boolean clickable)
clickable
- clickable if true; not clickable if false.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 onNext(View v)
v
- The view that cause this method to be executed.public 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 b)
showRouting
in interface SSCallback
b
- visible if true invisible if falsepublic void stopRoutingTimer()
stopRoutingTimer
in interface SSCallback