com.drismo.gui.monitor
Class MonitorActivityTemplate

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.view.ContextThemeWrapper
              extended by android.app.Activity
                  extended by com.drismo.gui.monitor.MonitorActivityTemplate
All Implemented Interfaces:
android.content.ComponentCallbacks, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback, CalibrationListener, QualityListener
Direct Known Subclasses:
DebugMonitor, MapMonitor, PrimitiveMonitor, QualityMeterMonitor

public abstract class MonitorActivityTemplate
extends android.app.Activity
implements CalibrationListener, QualityListener

This class is a template for creating a custom quality monitor. The derived class must only specify the layout in the abstract method setUpLayout() and control it as wished specified by the abstract method onQualityUpdate(). The rest (i.e. initiation, calibration, etc) is controlled/handled in MonitorActivityTemplate.


Field Summary
private static int CALIBRATION_DIALOG
           
private  CalibrationDialog calibrationDialog
           
private  MonitorController controller
           
private static int NOTIFICATION_MONITORING
           
private static java.lang.String TAG
           
private  android.os.PowerManager.WakeLock wl
           
 
Fields inherited from class android.app.Activity
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_NOT_FOREGROUND, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, TELEPHONY_SERVICE, UI_MODE_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Constructor Summary
MonitorActivityTemplate()
           
 
Method Summary
private  void lockScreenRotation()
          Sets screen rotation as fixed to current rotation setting
 void onBackPressed()
          Stops monitoring when back pressed.
 void onCalibrationCompleted()
          Sets up the layout of the child class and hides the calibration dialog.
 void onCreate(android.os.Bundle savedInstanceState)
          Constructs the required layout (depending if we are monitoring or idle) and instantiates the necessary objects.
 android.app.Dialog onCreateDialog(int id)
          Creates the calibration dialog.
 boolean onCreateOptionsMenu(android.view.Menu menu)
          Creates the menu to switch custom monitors.
 void onOffsetCalculationComplete()
          When roll, pitch and offset is calibrated, instruct the driver to go forward.
 boolean onOptionsItemSelected(android.view.MenuItem item)
          Switches between the different custom monitors, based on the given input.
protected  void onPause()
          Works as intended, but releases the wake lock.
abstract  void onQualityUpdate(int newScore)
          This method must be specified in the child class, and should control the layout based on the input parameter.
protected  void onResume()
          Works as intended, but acquires the wake lock.
protected  void prepareQualityMonitor()
          Prepares the quality monitor by locking the screen, starting calibration and showing the calibration dialog.
 void resetCalibration()
          Cancels calibration and resets layout to calibration-layout.
private  void setUpCalibrationLayout()
          Sets up the calibration preface.
protected abstract  void setUpLayout()
          This method must be specified in the child class, and should work the same way as the method onCreate() in a normal activity.
private  void setUpNotificationIcon()
          Sets up the notification icon in the status bar.
private  void startQualityMonitoring()
          Starts all the processes involving the quality monitoring.
private  void stopQualityMonitoring()
          Stops all the processes involving the quality monitoring.
 
Methods inherited from class android.app.Activity
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchKeyEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, finish, finishActivity, finishActivityFromChild, finishFromChild, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getInstanceCount, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLocalClassName, getMenuInflater, getParent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, getWindow, getWindowManager, hasWindowFocus, isChild, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, onActivityResult, onApplyThemeResource, onAttachedToWindow, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onDestroy, onDetachedFromWindow, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNewIntent, onOptionsMenuClosed, onPanelClosed, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, openContextMenu, openOptionsMenu, overridePendingTransition, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setIntent, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, showDialog, showDialog, startActivity, startActivityForResult, startActivityFromChild, startActivityIfNeeded, startIntentSender, startIntentSenderForResult, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
 
Methods inherited from class android.view.ContextThemeWrapper
attachBaseContext, getTheme, setTheme
 
Methods inherited from class android.content.ContextWrapper
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getWallpaper, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG

private static final java.lang.String TAG
See Also:
Constant Field Values

NOTIFICATION_MONITORING

private static final int NOTIFICATION_MONITORING
See Also:
Constant Field Values

controller

private MonitorController controller

calibrationDialog

private CalibrationDialog calibrationDialog

CALIBRATION_DIALOG

private static final int CALIBRATION_DIALOG
See Also:
Constant Field Values

wl

private android.os.PowerManager.WakeLock wl
Constructor Detail

MonitorActivityTemplate

public MonitorActivityTemplate()
Method Detail

onCreate

public void onCreate(android.os.Bundle savedInstanceState)
Constructs the required layout (depending if we are monitoring or idle) and instantiates the necessary objects.

Overrides:
onCreate in class android.app.Activity
Parameters:
savedInstanceState - Never used. State is handled/controlled by the MonitorController.
See Also:
MonitorController

setUpCalibrationLayout

private void setUpCalibrationLayout()
Sets up the calibration preface.


lockScreenRotation

private void lockScreenRotation()
Sets screen rotation as fixed to current rotation setting


prepareQualityMonitor

protected void prepareQualityMonitor()
Prepares the quality monitor by locking the screen, starting calibration and showing the calibration dialog.


resetCalibration

public void resetCalibration()
Cancels calibration and resets layout to calibration-layout.


onOffsetCalculationComplete

public void onOffsetCalculationComplete()
When roll, pitch and offset is calibrated, instruct the driver to go forward.

Specified by:
onOffsetCalculationComplete in interface CalibrationListener

onCalibrationCompleted

public void onCalibrationCompleted()
Sets up the layout of the child class and hides the calibration dialog. It also starts the quality monitoring. When the Calibration is done calibrating, this method is fired.

Specified by:
onCalibrationCompleted in interface CalibrationListener

startQualityMonitoring

private void startQualityMonitoring()
Starts all the processes involving the quality monitoring.


setUpNotificationIcon

private void setUpNotificationIcon()
Sets up the notification icon in the status bar. Used when initiating quality monitoring.


stopQualityMonitoring

private void stopQualityMonitoring()
Stops all the processes involving the quality monitoring.


onBackPressed

public void onBackPressed()
Stops monitoring when back pressed.

Overrides:
onBackPressed in class android.app.Activity

onResume

protected void onResume()
Works as intended, but acquires the wake lock.

Overrides:
onResume in class android.app.Activity

onPause

protected void onPause()
Works as intended, but releases the wake lock.

Overrides:
onPause in class android.app.Activity

onCreateDialog

public android.app.Dialog onCreateDialog(int id)
Creates the calibration dialog.

Overrides:
onCreateDialog in class android.app.Activity
Parameters:
id - CalibrationDialog id, see CALIBRATION_DIALOG.
Returns:
The calibration dialog.

onCreateOptionsMenu

public boolean onCreateOptionsMenu(android.view.Menu menu)
Creates the menu to switch custom monitors.

Overrides:
onCreateOptionsMenu in class android.app.Activity
Parameters:
menu - Menu to insert into.
Returns:
Always true.

onOptionsItemSelected

public boolean onOptionsItemSelected(android.view.MenuItem item)
Switches between the different custom monitors, based on the given input.

Overrides:
onOptionsItemSelected in class android.app.Activity
Parameters:
item - The selected monitor to view.
Returns:
True if success.
See Also:
MonitorFactory.getMonitorActivityIntent(android.content.Context, int), PrimitiveMonitor, QualityMeterMonitor, MapMonitor

setUpLayout

protected abstract void setUpLayout()
This method must be specified in the child class, and should work the same way as the method onCreate() in a normal activity.


onQualityUpdate

public abstract void onQualityUpdate(int newScore)
This method must be specified in the child class, and should control the layout based on the input parameter.

Specified by:
onQualityUpdate in interface QualityListener
Parameters:
newScore - The new quality score.
See Also:
Quality