org.android.activityminer.app.recording
Class AbstractRecordingActivity<T extends Enum<T> & Dimensions>

Package class diagram package AbstractRecordingActivity
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 org.android.activityminer.app.util.SharedPreferenceChangeAwareActivity
                      extended by org.android.activityminer.app.recording.AbstractRecordingActivity<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2, KeyEvent.Callback, LayoutInflater.Factory, LayoutInflater.Factory2, View.OnCreateContextMenuListener, Window.Callback, SharedPreferenceChangeNotificationReceiver, SharedPreferenceChangeObserver
Direct Known Subclasses:
FilterTestActivity, GenericRecordingActivityForSensorObservations

public abstract class AbstractRecordingActivity<T extends Enum<T> & Dimensions>
extends SharedPreferenceChangeAwareActivity

Abstract base class for sensor data recording activities.


Nested Class Summary
private  class AbstractRecordingActivity.ButtonUpdateTask
          The button update task.
 
Field Summary
private  AbstractRecordingActivity.ButtonUpdateTask buttonUpdateTask
          The button update task ( does alter text if minimum count is reached ).
private  GenericObservableCutoutCreator<T,Double> cutoutCreator
          The cut-out creator.
private  EventObserver<SensorObservationCutout<T,Double>> cutoutObserver
          The observer for the created time series data cut-out.
private  Handler handler
          The handler to post runnable tasks
private  AtomicBoolean isRecording
          Activity flag for recording.
private  AtomicLong minRecordingTime
          The minimum recording time.
private  Button recordingBtn
          The button to toggle recording.
private  ProgressBar recordingProgress
          The progress bar.
private  AtomicLong sampleRate
          The sample rate.
private  ObservableSensorScanner<T,Double> sensorScanner
          The observable sensor scanner.
private  PowerManager.WakeLock wakeLock
          The wake lock for active recording state.
 
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, APP_OPS_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAPTIONING_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
 
Constructor Summary
AbstractRecordingActivity()
          Constructor
 
Method Summary
private  void deactivateSamplingChain()
          Method to deactivate recording components and disconnect any observers.
protected  void doStartRecording()
          Method to start recording.
protected  long doStopRecording(boolean doNotify, boolean wasStoppedByUser, long stopTime)
          Method to stop recording.
protected  void enableRecordingButton(boolean enabled)
          Setter for the enabled state of the recording button.
protected  long getActualObservationTime()
          Getter for the actual observation time
protected abstract  long getCutOutSize()
          Getter for the cut-out window size in milliseconds
protected  SensorObservationCutout<T,Double> getLastCutout()
          Method to access the current not completed cut-out.
protected  long getMinRecordingTime()
          Getter for the minimum recording time in milliseconds
 long getRemainingTimeForMinRecordingLength()
          Getter for the remaining time until the mininimal recording length requirement is fulfilled
protected  long getSampleRate()
          Getter for the sample rate
 boolean isInterestedInLimitViolations()
          Method to test if limit violations should be notified.
 boolean isRecording()
          Getter for the recording state
protected  boolean isRecordingButtonEnabled()
           
protected  boolean onAboutToStartRecording()
          Call-back method for recording start preparation.
 void onBackPressed()
           
 void onConfigurationChanged(Configuration newConfig)
           
protected  void onCreate(Bundle savedInstanceState)
           
 void onDefaultRecordingTimeChange(long minimumRecordingTime)
          The handler for default recording time parameter changes.
protected  void onDestroy()
           
protected abstract  void onNewCutOut(SensorObservationCutout<T,Double> cutOut)
          Event handler for new extracted sensor observation cut-outs
protected  void onPause()
           
protected abstract  ObservableSensorScanner<T,Double> onPrepare()
          Call-back method for load preparation.
protected abstract  void onRecordingStopped(boolean wasStoppedByUser, long stopTime)
          Call-back method for recording stopped post processing.
protected  boolean postDelayed(Runnable r, long delayMillis)
          Does post a runnable task to the internal handler.
private  void prepare()
          Preparation in case of creation or orientation changes.
protected  void removeCallbacks(Runnable r)
          Remove any pending posts of a runnable from the handlers queue.
protected  void setMinRecordingTime(long minRecordingTime)
          Setter for the minimum recording time in milliseconds ( which is limited by the maximum recording time )
protected  void startRecording()
          Does start the recording.
 
Methods inherited from class org.android.activityminer.app.util.SharedPreferenceChangeAwareActivity
getConfiguration, onBetaPreferenceChange, onBWCutOffPreferenceChanged, onBWFilterOrderPreferenceChanged, onClassSelectionChange, onCountDownTimeChange, onCrossValidationParameterKChange, onEvaluationAccuracyThresholdChanged, onFeatureSelection, onGravitationCutOffPreferenceChanged, onKNNClassifierParameterKChange, onKNNClassifierParameterNormalizeChange, onLimitViolation, onLocationDataUsageFlagChange, onMaximumRecordingTimeChange, onMaximumSampleRateChange, onMinCutOffPreferenceChanged, onOverlapSizeChange, onOwnLinAccImplementationUsageFlagChange, onSampleRateChange, onSelectedAccFilterChanged, onSelectedClassifierChange, onWindowSizeChange
 
Methods inherited from class android.app.Activity
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityResult, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onChildTitleChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onNewIntent, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onProvideAssistData, onRestart, onRestoreInstanceState, onResume, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, reportFullyDrawn, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
 
Methods inherited from class android.view.ContextThemeWrapper
applyOverrideConfiguration, attachBaseContext, getResources, getTheme, setTheme
 
Methods inherited from class android.content.ContextWrapper
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wakeLock

private PowerManager.WakeLock wakeLock
The wake lock for active recording state.


sampleRate

private final AtomicLong sampleRate
The sample rate.


minRecordingTime

private final AtomicLong minRecordingTime
The minimum recording time.


isRecording

private final AtomicBoolean isRecording
Activity flag for recording.


recordingProgress

private ProgressBar recordingProgress
The progress bar.


recordingBtn

private Button recordingBtn
The button to toggle recording.


cutoutCreator

private GenericObservableCutoutCreator<T extends Enum<T> & Dimensions,Double> cutoutCreator
The cut-out creator.


sensorScanner

private ObservableSensorScanner<T extends Enum<T> & Dimensions,Double> sensorScanner
The observable sensor scanner.


cutoutObserver

private final EventObserver<SensorObservationCutout<T extends Enum<T> & Dimensions,Double>> cutoutObserver
The observer for the created time series data cut-out.


buttonUpdateTask

private AbstractRecordingActivity.ButtonUpdateTask buttonUpdateTask
The button update task ( does alter text if minimum count is reached ).


handler

private Handler handler
The handler to post runnable tasks

Constructor Detail

AbstractRecordingActivity

public AbstractRecordingActivity()
Constructor

Method Detail

getLastCutout

protected final SensorObservationCutout<T,Double> getLastCutout()
Method to access the current not completed cut-out.

Returns:
the current cut-out if not completed

getSampleRate

protected final long getSampleRate()
Getter for the sample rate

Returns:
the sample rate

isRecording

public final boolean isRecording()
Getter for the recording state

Returns:
the recording state

getActualObservationTime

protected final long getActualObservationTime()
Getter for the actual observation time

Returns:
the actual observation time

setMinRecordingTime

protected void setMinRecordingTime(long minRecordingTime)
Setter for the minimum recording time in milliseconds ( which is limited by the maximum recording time )

Parameters:
minRecordingTime - the minimum recording time to set

getMinRecordingTime

protected long getMinRecordingTime()
Getter for the minimum recording time in milliseconds

Returns:
the minimum recording time in milliseconds

onCreate

protected void onCreate(Bundle savedInstanceState)
Overrides:
onCreate in class SharedPreferenceChangeAwareActivity

getCutOutSize

protected abstract long getCutOutSize()
Getter for the cut-out window size in milliseconds

Returns:
the cut out size

onConfigurationChanged

public void onConfigurationChanged(Configuration newConfig)
Specified by:
onConfigurationChanged in interface ComponentCallbacks
Overrides:
onConfigurationChanged in class Activity

enableRecordingButton

protected final void enableRecordingButton(boolean enabled)
Setter for the enabled state of the recording button.

Parameters:
enabled - enabled state

isRecordingButtonEnabled

protected final boolean isRecordingButtonEnabled()
Returns:
true if recording button is enabled, false otherwise

prepare

private final void prepare()
Preparation in case of creation or orientation changes.


onPrepare

protected abstract ObservableSensorScanner<T,Double> onPrepare()
Call-back method for load preparation. This Method is called every time the GUI is loaded, thus on creation and orientation changes.

Returns:
the observable raw time series data source to use.

onPause

protected void onPause()
Overrides:
onPause in class Activity

onBackPressed

public void onBackPressed()
Overrides:
onBackPressed in class Activity

onDestroy

protected void onDestroy()
Overrides:
onDestroy in class SharedPreferenceChangeAwareActivity

doStartRecording

protected void doStartRecording()
Method to start recording.


startRecording

protected final void startRecording()
Does start the recording.


onAboutToStartRecording

protected boolean onAboutToStartRecording()
Call-back method for recording start preparation.

Returns:
if true recording will be started , otherwise you need to call startRecording() Method by your own as soon as you are ready.

doStopRecording

protected long doStopRecording(boolean doNotify,
                               boolean wasStoppedByUser,
                               long stopTime)
Method to stop recording.

Parameters:
doNotify - if true, the onRecordingStopped(boolean, long) method is called
wasStoppedByUser - flag is recording was stopped manually by the user
stopTime - the stop time
Returns:
the time the recording was stopped in milliseconds

onRecordingStopped

protected abstract void onRecordingStopped(boolean wasStoppedByUser,
                                           long stopTime)
Call-back method for recording stopped post processing.

Parameters:
wasStoppedByUser - flag is recording was stopped manually by the user
stopTime - the time the recording was stopped in milliseconds

deactivateSamplingChain

private final void deactivateSamplingChain()
Method to deactivate recording components and disconnect any observers.


isInterestedInLimitViolations

public final boolean isInterestedInLimitViolations()
Description copied from interface: SharedPreferenceChangeNotificationReceiver
Method to test if limit violations should be notified.

Specified by:
isInterestedInLimitViolations in interface SharedPreferenceChangeNotificationReceiver
Overrides:
isInterestedInLimitViolations in class SharedPreferenceChangeAwareActivity
Returns:
true if interested in notifications, false otherwise

getRemainingTimeForMinRecordingLength

public long getRemainingTimeForMinRecordingLength()
Getter for the remaining time until the mininimal recording length requirement is fulfilled

Returns:
the remaining time until the mininimal recording length requirement is fullfilled

onDefaultRecordingTimeChange

public void onDefaultRecordingTimeChange(long minimumRecordingTime)
Description copied from interface: SharedPreferenceChangeObserver
The handler for default recording time parameter changes.

Specified by:
onDefaultRecordingTimeChange in interface SharedPreferenceChangeObserver
Overrides:
onDefaultRecordingTimeChange in class SharedPreferenceChangeAwareActivity
Parameters:
minimumRecordingTime - the new default recording time in seconds

postDelayed

protected final boolean postDelayed(Runnable r,
                                    long delayMillis)
Does post a runnable task to the internal handler.

Parameters:
r - the runnable to post delayed
delayMillis - the delay in milliseconds
Returns:
the result of the call to the handlers postDelayed method

removeCallbacks

protected final void removeCallbacks(Runnable r)
Remove any pending posts of a runnable from the handlers queue.

Parameters:
r - the runnable

onNewCutOut

protected abstract void onNewCutOut(SensorObservationCutout<T,Double> cutOut)
Event handler for new extracted sensor observation cut-outs

Parameters:
cutOut - the new cut-out