com.drismo.gui
Class ViewArchive

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.ViewArchive
All Implemented Interfaces:
android.content.ComponentCallbacks, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback

public class ViewArchive
extends android.app.Activity

This class gets the timestamp/filename data for all stored trips, and lists them in a ListView. It also supplies a quick action menu for the user to view, rename or delete each trip.

See Also:
QuickAction, QuickActionAdapter

Nested Class Summary
private  class ViewArchive.DeleteAllTrips
          Delete all trip files, while progressbar runs in the foreground.
private  class ViewArchive.DeleteOneTrip
          Delete a trip file, while a ProgressDialog (spinner) runs in the foreground.
private  class ViewArchive.PopulateArchive
          Load the trip files.
private  class ViewArchive.RenameTrip
          Rename a trip file, while a ProgressDialog (spinner) runs in the foreground.
 
Field Summary
private  QuickActionAdapter adapter
           
private  java.lang.String drismoDir
           
private  int PLEASE_WAIT_SPINNER
           
private  java.lang.String[] prevTrips
           
private  java.lang.String[] tripDates
           
private  java.lang.String[] tripDurations
           
 
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
ViewArchive()
           
 
Method Summary
 java.lang.String[] addTripDuration()
          Open and read all trip files, to calculate trip duration based on number of lines multiplied by the update frequency.
 void onCreate(android.os.Bundle savedInstanceState)
          Create a ListView from the archive with all previous trips.
protected  android.app.Dialog onCreateDialog(int id)
          Prepare and show a ProgressDialog with a spinner.
 boolean onCreateOptionsMenu(android.view.Menu menu)
          Creating the menu for this activity from archive_menu.xml.
 boolean onOptionsItemSelected(android.view.MenuItem item)
          If user confirmes the action, run AsyncTask to delete all trip files.
 void renameDialog(java.lang.String oldFile)
          Recursive dialog to rename a file.
 void restartActivity(android.content.Intent intent)
          Finish the current activity, and startMonitoring a new instance immediately.
private  void sortTripsByDate(java.io.File[] sortedTrips)
          Sort trip name array descending by when the files has been created.
 
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, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onDestroy, onDetachedFromWindow, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNewIntent, onOptionsMenuClosed, onPanelClosed, onPause, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onResume, 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

drismoDir

private java.lang.String drismoDir

prevTrips

private java.lang.String[] prevTrips

tripDurations

private java.lang.String[] tripDurations

tripDates

private java.lang.String[] tripDates

adapter

private QuickActionAdapter adapter

PLEASE_WAIT_SPINNER

private final int PLEASE_WAIT_SPINNER
See Also:
Constant Field Values
Constructor Detail

ViewArchive

public ViewArchive()
Method Detail

sortTripsByDate

private void sortTripsByDate(java.io.File[] sortedTrips)
Sort trip name array descending by when the files has been created.

Parameters:
sortedTrips - An array of all trip files.

addTripDuration

public java.lang.String[] addTripDuration()
Open and read all trip files, to calculate trip duration based on number of lines multiplied by the update frequency.

Returns:
Array of strings, displaying readable duration in hours, mins and secs.

onCreate

public void onCreate(android.os.Bundle savedInstanceState)
Create a ListView from the archive with all previous trips. The list will be displayed as clickable titles with timestamp.

Overrides:
onCreate in class android.app.Activity
Parameters:
savedInstanceState - Not beeing used, as onSaveInstanceState(Bundle) is not implemented.

onCreateDialog

protected android.app.Dialog onCreateDialog(int id)
Prepare and show a ProgressDialog with a spinner.

Overrides:
onCreateDialog in class android.app.Activity
Parameters:
id - Determines what text to display on the dialog.
Returns:
The ProgressDialog instance.

onCreateOptionsMenu

public boolean onCreateOptionsMenu(android.view.Menu menu)
Creating the menu for this activity from archive_menu.xml.

Overrides:
onCreateOptionsMenu in class android.app.Activity
Parameters:
menu - The menu to place the items into.
Returns:
True to display the menu.

onOptionsItemSelected

public boolean onOptionsItemSelected(android.view.MenuItem item)
If user confirmes the action, run AsyncTask to delete all trip files.

Overrides:
onOptionsItemSelected in class android.app.Activity
Parameters:
item - The menu item that was selected.
Returns:
True, to end menu processing when the AsyncTask has been executed.
See Also:
ViewArchive.DeleteAllTrips

restartActivity

public void restartActivity(android.content.Intent intent)
Finish the current activity, and startMonitoring a new instance immediately. This will refresh the list when changes has been done to one or more files.

Parameters:
intent - Intent describing what activity to startMonitoring.

renameDialog

public void renameDialog(java.lang.String oldFile)
Recursive dialog to rename a file.

Parameters:
oldFile - Current file name of the file to be renamed.