increased number of saved tracks to 25, keep track of button states, added some more accessibility element descriptions (#2)

This commit is contained in:
y20k 2016-12-16 22:12:43 +01:00
parent f3909ec3a5
commit 382b094b92
12 changed files with 185 additions and 155 deletions

View file

@ -23,9 +23,9 @@ android {
dependencies { dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.1' compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.0.1' compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:25.0.1' compile 'com.android.support:cardview-v7:25.1.0'
compile 'org.osmdroid:osmdroid-android:5.5:release@aar' compile 'org.osmdroid:osmdroid-android:5.5:release@aar'
compile 'com.google.code.gson:gson:2.8.0' compile 'com.google.code.gson:gson:2.8.0'
} }

View file

@ -69,6 +69,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
/* Main class variables */ /* Main class variables */
private ViewPager mViewPager;
private boolean mTrackerServiceRunning; private boolean mTrackerServiceRunning;
private boolean mCurrentTrackVisible; private boolean mCurrentTrackVisible;
private boolean mPermissionsGranted; private boolean mPermissionsGranted;
@ -81,6 +82,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
private MainActivityMapFragment mMainActivityMapFragment; private MainActivityMapFragment mMainActivityMapFragment;
private MainActivityTrackFragment mMainActivityTrackFragment; private MainActivityTrackFragment mMainActivityTrackFragment;
private BroadcastReceiver mTrackingStoppedReceiver; private BroadcastReceiver mTrackingStoppedReceiver;
private int mFloatingActionButtonState;
private int mSelectedTab; private int mSelectedTab;
@ -183,12 +185,17 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
LogHelper.v(LOG_TAG, "onResume called.");
// TODO loadAppState?
loadAppState(this);
// handle new intents - onNewIntent does not seem to work // handle new intents - onNewIntent does not seem to work
handleIncomingIntent(); handleIncomingIntent();
// if not in onboarding mode: set state of FloatingActionButton // if not in onboarding mode: set state of FloatingActionButton
if (mFloatingActionButton != null) { if (mFloatingActionButton != null) {
LogHelper.v(LOG_TAG, "onResume: setting state of FAB.");
setFloatingActionButtonState(); setFloatingActionButtonState();
} }
} }
@ -241,21 +248,22 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
LogHelper.v(LOG_TAG, "onSaveInstanceState called."); LogHelper.v(LOG_TAG, "onSaveInstanceState called.");
outState.putBoolean(INSTANCE_TRACKING_STATE, mTrackerServiceRunning); outState.putBoolean(INSTANCE_TRACKING_STATE, mTrackerServiceRunning);
outState.putBoolean(INSTANCE_TRACK_VISIBLE, mCurrentTrackVisible);
outState.putBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, mFloatingActionButtonSubMenuVisible);
outState.putInt(INSTANCE_SELECTED_TAB, mSelectedTab); outState.putInt(INSTANCE_SELECTED_TAB, mSelectedTab);
outState.putInt(INSTANCE_FAB_STATE, mFloatingActionButtonState);
outState.putBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, mFloatingActionButtonSubMenuVisible);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@Override @Override
public void onRestoreInstanceState(Bundle savedInstanceState) { public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState); super.onRestoreInstanceState(savedInstanceState);
LogHelper.v(LOG_TAG, "onRestoreInstanceState called."); LogHelper.v(LOG_TAG, "onRestoreInstanceState called.");
mTrackerServiceRunning = savedInstanceState.getBoolean(INSTANCE_TRACKING_STATE, false); mTrackerServiceRunning = savedInstanceState.getBoolean(INSTANCE_TRACKING_STATE, false);
mCurrentTrackVisible = savedInstanceState.getBoolean(INSTANCE_TRACK_VISIBLE, false);
mFloatingActionButtonSubMenuVisible = savedInstanceState.getBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, false);
mSelectedTab = savedInstanceState.getInt(INSTANCE_SELECTED_TAB, 0); mSelectedTab = savedInstanceState.getInt(INSTANCE_SELECTED_TAB, 0);
mFloatingActionButtonState = savedInstanceState.getInt(INSTANCE_FAB_STATE, FAB_STATE_DEFAULT);
mFloatingActionButtonSubMenuVisible = savedInstanceState.getBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, false);
} }
@ -263,10 +271,12 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
private void saveAppState(Context context) { private void saveAppState(Context context) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(INSTANCE_TRACKING_STATE, mTrackerServiceRunning); // mCurrentTrackVisible is handled (= saved) by fragment
editor.putBoolean(INSTANCE_TRACK_VISIBLE, mCurrentTrackVisible);
editor.putBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, mFloatingActionButtonSubMenuVisible); // editor.putBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, mFloatingActionButtonSubMenuVisible);
editor.putInt(INSTANCE_SELECTED_TAB, mSelectedTab); // editor.putBoolean(INSTANCE_TRACKING_STATE, mTrackerServiceRunning);
// editor.putInt(INSTANCE_SELECTED_TAB, mSelectedTab);
editor.apply(); editor.apply();
LogHelper.v(LOG_TAG, "Saving state."); LogHelper.v(LOG_TAG, "Saving state.");
} }
@ -275,10 +285,12 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
/* Loads app state from preferences */ /* Loads app state from preferences */
private void loadAppState(Context context) { private void loadAppState(Context context) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
mTrackerServiceRunning = settings.getBoolean(INSTANCE_TRACKING_STATE, false);
mCurrentTrackVisible = settings.getBoolean(INSTANCE_TRACK_VISIBLE, false); mCurrentTrackVisible = settings.getBoolean(INSTANCE_TRACK_VISIBLE, false);
mFloatingActionButtonSubMenuVisible = settings.getBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, false);
mSelectedTab = settings.getInt(INSTANCE_SELECTED_TAB, 0); // mFloatingActionButtonSubMenuVisible = settings.getBoolean(INSTANCE_FAB_SUB_MENU_VISIBLE, false);
// mTrackerServiceRunning = settings.getBoolean(INSTANCE_TRACKING_STATE, false);
// mSelectedTab = settings.getInt(INSTANCE_SELECTED_TAB, 0);
LogHelper.v(LOG_TAG, "Loading state."); LogHelper.v(LOG_TAG, "Loading state.");
} }
@ -297,7 +309,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter. // Set up the ViewPager with the sections adapter.
ViewPager mViewPager = (ViewPager) findViewById(R.id.container); mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(sectionsPagerAdapter); mViewPager.setAdapter(sectionsPagerAdapter);
mViewPager.setCurrentItem(mSelectedTab); mViewPager.setCurrentItem(mSelectedTab);
@ -308,12 +320,16 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
public void onTabSelected(TabLayout.Tab tab) { public void onTabSelected(TabLayout.Tab tab) {
switch (tab.getPosition()) { switch (tab.getPosition()) {
case FRAGMENT_ID_MAP: case FRAGMENT_ID_MAP:
// show the Floating Action Button
mFloatingActionButton.show(); mFloatingActionButton.show();
break; break;
case FRAGMENT_ID_TRACK: case FRAGMENT_ID_TRACK:
// hide the Floating Action Button - and its sub menu
mFloatingActionButton.hide(); mFloatingActionButton.hide();
showFloatingActionButtonMenu(false);
break; break;
default: default:
// show the Floating Action Button
mFloatingActionButton.show(); mFloatingActionButton.show();
break; break;
} }
@ -375,33 +391,16 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
/* Handles tap on the record button */ /* Handles tap on the record button */
private void handleFloatingActionButtonClick(View view) { private void handleFloatingActionButtonClick(View view) {
if (mTrackerServiceRunning) {
// show snackbar
Snackbar.make(view, R.string.snackbar_message_tracking_stopped, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
// change state switch (mFloatingActionButtonState) {
// --> is handled by broadcast receiver case FAB_STATE_DEFAULT:
// stop tracker service
Intent intent = new Intent(this, TrackerService.class);
intent.setAction(ACTION_STOP);
startService(intent);
} else if (mCurrentTrackVisible) {
// toggle floating action button sub menu
if (!mFloatingActionButtonSubMenuVisible) {
showFloatingActionButtonMenu(true);
} else {
showFloatingActionButtonMenu(false);
}
} else {
// show snackbar // show snackbar
Snackbar.make(view, R.string.snackbar_message_tracking_started, Snackbar.LENGTH_SHORT).setAction("Action", null).show(); Snackbar.make(view, R.string.snackbar_message_tracking_started, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
// change state // change state
mTrackerServiceRunning = true; mTrackerServiceRunning = true;
mCurrentTrackVisible = true; mCurrentTrackVisible = true;
mFloatingActionButtonState = FAB_STATE_RECORDING;
setFloatingActionButtonState(); setFloatingActionButtonState();
// get last location from MainActivity Fragment // get last location from MainActivity Fragment
@ -420,6 +419,32 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
setFloatingActionButtonState(); setFloatingActionButtonState();
} }
break;
case FAB_STATE_RECORDING:
// show snackbar
Snackbar.make(view, R.string.snackbar_message_tracking_stopped, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
// change state
// --> is handled by broadcast receiver
// stop tracker service
Intent intent = new Intent(this, TrackerService.class);
intent.setAction(ACTION_STOP);
startService(intent);
break;
case FAB_STATE_SAVE:
// toggle floating action button sub menu
if (!mFloatingActionButtonSubMenuVisible) {
showFloatingActionButtonMenu(true);
} else {
showFloatingActionButtonMenu(false);
}
break;
} }
// update tracking state in MainActivityMapFragment // update tracking state in MainActivityMapFragment
@ -432,13 +457,15 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
LogHelper.v(LOG_TAG, "User chose SAVE and CLEAR"); LogHelper.v(LOG_TAG, "User chose SAVE and CLEAR");
// clear map and save track // clear map and save track
mMainActivityMapFragment.clearMap(true); // TODO change to true mMainActivityMapFragment.clearMap(true);
mCurrentTrackVisible = false; mCurrentTrackVisible = false;
// // reset current track // TODO ist this still necessary // // reset current track // TODO is this still necessary?
// mMainActivityTrackFragment.refreshTrackView(); // mMainActivityTrackFragment.refreshTrackView();
// TODO change to track tab // display track tab
mSelectedTab = FRAGMENT_ID_TRACK;
mViewPager.setCurrentItem(mSelectedTab);
// dismiss notification // dismiss notification
NotificationHelper.stop(); NotificationHelper.stop();
@ -447,7 +474,10 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
showFloatingActionButtonMenu(false); showFloatingActionButtonMenu(false);
// update Floating Action Button icon // update Floating Action Button icon
mFloatingActionButtonState = FAB_STATE_DEFAULT;
setFloatingActionButtonState(); setFloatingActionButtonState();
Toast.makeText(this, getString(R.string.toast_message_track_save), Toast.LENGTH_LONG).show();
} }
@ -466,18 +496,29 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
showFloatingActionButtonMenu(false); showFloatingActionButtonMenu(false);
// update Floating Action Button icon // update Floating Action Button icon
mFloatingActionButtonState = FAB_STATE_DEFAULT;
setFloatingActionButtonState(); setFloatingActionButtonState();
Toast.makeText(this, getString(R.string.toast_message_track_clear), Toast.LENGTH_LONG).show();
} }
/* Set state of FloatingActionButton */ /* Set state of FloatingActionButton */
private void setFloatingActionButtonState() { private void setFloatingActionButtonState() {
if (mTrackerServiceRunning) {
mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_red_24dp); switch (mFloatingActionButtonState) {
} else if (mCurrentTrackVisible) { case FAB_STATE_DEFAULT:
mFloatingActionButton.setImageResource(R.drawable.ic_save_white_24dp);
} else {
mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp); mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp);
break;
case FAB_STATE_RECORDING:
mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_red_24dp);
break;
case FAB_STATE_SAVE:
mFloatingActionButton.setImageResource(R.drawable.ic_save_white_24dp);
break;
default:
mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp);
break;
} }
} }
@ -501,12 +542,14 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
private void handleIncomingIntent() { private void handleIncomingIntent() {
Intent intent = getIntent(); Intent intent = getIntent();
String intentAction = intent.getAction(); String intentAction = intent.getAction();
switch (intentAction) { switch (intentAction) {
case ACTION_SHOW_MAP: case ACTION_SHOW_MAP:
if (intent.hasExtra(EXTRA_TRACKING_STATE) && mMainActivityMapFragment != null) { if (intent.hasExtra(EXTRA_TRACKING_STATE)) {
mTrackerServiceRunning = intent.getBooleanExtra(EXTRA_TRACKING_STATE, false); mTrackerServiceRunning = intent.getBooleanExtra(EXTRA_TRACKING_STATE, false);
mMainActivityMapFragment.setTrackingState(mTrackerServiceRunning); // mMainActivityMapFragment.setTrackingState(mTrackerServiceRunning);
if (mTrackerServiceRunning) {
mFloatingActionButtonState = FAB_STATE_RECORDING;
}
// prevent multiple reactions to intent // prevent multiple reactions to intent
intent.setAction(ACTION_DEFAULT); intent.setAction(ACTION_DEFAULT);
} }
@ -547,6 +590,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
// change state // change state
mTrackerServiceRunning = false; mTrackerServiceRunning = false;
mFloatingActionButtonState = FAB_STATE_SAVE;
setFloatingActionButtonState(); setFloatingActionButtonState();
// pass tracking state to MainActivityMapFragment // pass tracking state to MainActivityMapFragment

View file

@ -102,15 +102,11 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
// action bar has options menu // action bar has options menu
setHasOptionsMenu(true); setHasOptionsMenu(true);
// restore first start state // restore first start state and tracking state
mFirstStart = true; mFirstStart = true;
if (savedInstanceState != null) {
mFirstStart = savedInstanceState.getBoolean(INSTANCE_FIRST_START, true);
}
// restore tracking and map state
mTrackerServiceRunning = false; mTrackerServiceRunning = false;
if (savedInstanceState != null) { if (savedInstanceState != null) {
mFirstStart = savedInstanceState.getBoolean(INSTANCE_FIRST_START, true);
mTrackerServiceRunning = savedInstanceState.getBoolean(INSTANCE_TRACKING_STATE, false); mTrackerServiceRunning = savedInstanceState.getBoolean(INSTANCE_TRACKING_STATE, false);
} }
@ -140,9 +136,6 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
mCurrentBestLocation.setLongitude(DEFAULT_LONGITUDE); mCurrentBestLocation.setLongitude(DEFAULT_LONGITUDE);
} }
LogHelper.v(LOG_TAG, "!!! TRACK:" + mCurrentBestLocation.getExtras());
// get state of location system setting // get state of location system setting
mLocationSystemSetting = LocationHelper.checkLocationSystemSetting(mActivity); mLocationSystemSetting = LocationHelper.checkLocationSystemSetting(mActivity);
@ -222,6 +215,9 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
// set visibility // set visibility
mFragmentVisible = true; mFragmentVisible = true;
// TODO
handleIncomingIntent();
// center map on current position - if TrackerService is running // center map on current position - if TrackerService is running
if (mTrackerServiceRunning) { if (mTrackerServiceRunning) {
mController.setCenter(convertToGeoPoint(mCurrentBestLocation)); mController.setCenter(convertToGeoPoint(mCurrentBestLocation));
@ -257,6 +253,9 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
// disable content observer for changes in System Settings // disable content observer for changes in System Settings
mActivity.getContentResolver().unregisterContentObserver(mSettingsContentObserver); mActivity.getContentResolver().unregisterContentObserver(mSettingsContentObserver);
// save state of track visibility
saveTrackVisibilityState(mActivity);
} }
@ -344,8 +343,8 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
outState.putBoolean(INSTANCE_FIRST_START, mFirstStart); outState.putBoolean(INSTANCE_FIRST_START, mFirstStart);
outState.putParcelable(INSTANCE_CURRENT_LOCATION, mCurrentBestLocation);
outState.putBoolean(INSTANCE_TRACKING_STATE, mTrackerServiceRunning); outState.putBoolean(INSTANCE_TRACKING_STATE, mTrackerServiceRunning);
outState.putParcelable(INSTANCE_CURRENT_LOCATION, mCurrentBestLocation);
outState.putDouble(INSTANCE_LATITUDE_MAIN_MAP, mMapView.getMapCenter().getLatitude()); outState.putDouble(INSTANCE_LATITUDE_MAIN_MAP, mMapView.getMapCenter().getLatitude());
outState.putDouble(INSTANCE_LONGITUDE_MAIN_MAP, mMapView.getMapCenter().getLongitude()); outState.putDouble(INSTANCE_LONGITUDE_MAIN_MAP, mMapView.getMapCenter().getLongitude());
outState.putInt(INSTANCE_ZOOM_LEVEL_MAIN_MAP, mMapView.getZoomLevel()); outState.putInt(INSTANCE_ZOOM_LEVEL_MAIN_MAP, mMapView.getZoomLevel());
@ -393,21 +392,28 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
// clear map // clear map
if (mTrackOverlay != null) { if (mTrackOverlay != null) {
mMapView.getOverlays().remove(mTrackOverlay); mMapView.getOverlays().remove(mTrackOverlay);
mTrackOverlay = null;
} }
// save track object if requested
if (saveTrack) { if (saveTrack) {
// save track object if requested
SaveTrackAsyncHelper saveTrackAsyncHelper = new SaveTrackAsyncHelper(); SaveTrackAsyncHelper saveTrackAsyncHelper = new SaveTrackAsyncHelper();
saveTrackAsyncHelper.execute(); saveTrackAsyncHelper.execute();
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_save_track), Toast.LENGTH_LONG).show(); Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_save_track), Toast.LENGTH_LONG).show();
} else {
// clear track object
mTrack = null;
} }
// save track state
saveTrackVisibilityState(mActivity);
} }
/* Getter for length of current track */ /* Handles new incoming intents */
public String getCurrentTrackLength() { private void handleIncomingIntent() {
return mTrack.getTrackDistance(); Intent intent = mActivity.getIntent();
// TODO get track from intent if not present
} }
@ -544,20 +550,30 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
} }
/* Saves state of map */ /* Saves state of track visibility to SharedPreferences */
private void saveMaoState(Context context) { private void saveTrackVisibilityState(Context context) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
editor.putInt(PREFS_ZOOM_LEVEL, mMapView.getZoomLevel()); editor.putBoolean(INSTANCE_TRACK_VISIBLE, (mTrackOverlay != null));
editor.apply(); editor.apply();
LogHelper.v(LOG_TAG, "Saving state: track visibility = " + (mTrackOverlay != null));
} }
/* Loads app state from preferences */ // /* Saves state of map */
private void loadMapState(Context context) { // private void saveMaoState(Context context) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); // SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
int zoom = settings.getInt(PREFS_ZOOM_LEVEL, 16); // SharedPreferences.Editor editor = settings.edit();
} // editor.putInt(PREFS_ZOOM_LEVEL, mMapView.getZoomLevel());
// editor.apply();
// }
// /* Loads app state from preferences */
// private void loadMapState(Context context) {
// SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
// int zoom = settings.getInt(PREFS_ZOOM_LEVEL, 16);
// }
/** /**

View file

@ -94,6 +94,7 @@ public class NotificationHelper implements TrackbookKeys {
String contentText = mService.getString(R.string.notification_content_distance) + ": " + track.getTrackDistance() + " | " + String contentText = mService.getString(R.string.notification_content_distance) + ": " + track.getTrackDistance() + " | " +
mService.getString(R.string.notification_content_duration) + " : " + track.getTrackDuration(); mService.getString(R.string.notification_content_duration) + " : " + track.getTrackDuration();
// ACTION: NOTIFICATION TAP // ACTION: NOTIFICATION TAP
Intent tapActionIntent = new Intent(mService, MainActivity.class); Intent tapActionIntent = new Intent(mService, MainActivity.class);
tapActionIntent.setAction(ACTION_SHOW_MAP); tapActionIntent.setAction(ACTION_SHOW_MAP);
@ -106,14 +107,6 @@ public class NotificationHelper implements TrackbookKeys {
// pending intent wrapper for notification tap // pending intent wrapper for notification tap
PendingIntent tapActionPendingIntent = tapActionIntentBuilder.getPendingIntent(10, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent tapActionPendingIntent = tapActionIntentBuilder.getPendingIntent(10, PendingIntent.FLAG_UPDATE_CURRENT);
// ACTION: NOTIFICATION SWIPE
Intent swipeActionIntent = new Intent(mService, MainActivity.class);
swipeActionIntent.setAction(ACTION_SHOW_MAP);
swipeActionIntent.putExtra(EXTRA_CLEAR_MAP, true); // EXTRA_CLEAR_MAP is not (yet) used - map gets cleared by default
// artificial back stack for started Activity (https://developer.android.com/training/notify-user/navigation.html#DirectEntry)
TaskStackBuilder swipeActionIntentBuilder = TaskStackBuilder.create(mService);
swipeActionIntentBuilder.addParentStack(MainActivity.class);
swipeActionIntentBuilder.addNextIntent(swipeActionIntent);
// ACTION: NOTIFICATION BUTTON STOP // ACTION: NOTIFICATION BUTTON STOP
Intent stopActionIntent = new Intent(mService, TrackerService.class); Intent stopActionIntent = new Intent(mService, TrackerService.class);
@ -121,6 +114,7 @@ public class NotificationHelper implements TrackbookKeys {
// pending intent wrapper for notification stop action // pending intent wrapper for notification stop action
PendingIntent stopActionPendingIntent = PendingIntent.getService(mService, 12, stopActionIntent, 0); PendingIntent stopActionPendingIntent = PendingIntent.getService(mService, 12, stopActionIntent, 0);
// construct notification in builder // construct notification in builder
NotificationCompat.Builder builder; NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(mService); builder = new NotificationCompat.Builder(mService);

View file

@ -50,7 +50,7 @@ public class StorageHelper implements TrackbookKeys {
private static final String LOG_TAG = StorageHelper.class.getSimpleName(); private static final String LOG_TAG = StorageHelper.class.getSimpleName();
/* Main class variables */ /* Main class variables */
private final int mMaxTrackFiles = 10; private final int mMaxTrackFiles = 25;
private final String mDirectoryName = "tracks"; private final String mDirectoryName = "tracks";
private final String mFileExtension = ".trackbook"; private final String mFileExtension = ".trackbook";
private final Activity mActivity; private final Activity mActivity;

View file

@ -62,6 +62,7 @@ public interface TrackbookKeys {
String INSTANCE_TRACKING_STATE = "trackingState"; String INSTANCE_TRACKING_STATE = "trackingState";
String INSTANCE_TRACK_VISIBLE = "trackVisible"; String INSTANCE_TRACK_VISIBLE = "trackVisible";
String INSTANCE_SELECTED_TAB = "selectedTab"; String INSTANCE_SELECTED_TAB = "selectedTab";
String INSTANCE_FAB_STATE = "fabState";
String INSTANCE_FAB_SUB_MENU_VISIBLE = "fabSubMenuVisible"; String INSTANCE_FAB_SUB_MENU_VISIBLE = "fabSubMenuVisible";
String INSTANCE_TRACK_MAIN_MAP = "trackMainMap"; String INSTANCE_TRACK_MAIN_MAP = "trackMainMap";
String INSTANCE_LATITUDE_MAIN_MAP = "latitudeMainMap"; String INSTANCE_LATITUDE_MAIN_MAP = "latitudeMainMap";
@ -92,6 +93,10 @@ public interface TrackbookKeys {
int INFOSHEET_CONTENT_ABOUT = 1; int INFOSHEET_CONTENT_ABOUT = 1;
int METRIC = 1; int METRIC = 1;
int IMPERIAL = 2; int IMPERIAL = 2;
int FAB_STATE_DEFAULT = 0;
int FAB_STATE_RECORDING = 1;
int FAB_STATE_SAVE = 2;
double DEFAULT_LATITUDE = 49.41667; // latitude Nordkapp, Norway double DEFAULT_LATITUDE = 49.41667; // latitude Nordkapp, Norway
double DEFAULT_LONGITUDE = 8.67201; // longitude Nordkapp, Norway double DEFAULT_LONGITUDE = 8.67201; // longitude Nordkapp, Norway
} }

View file

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="org.y20k.trackbook.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TrackbookAppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/TrackbookAppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<!-- include MainActivityMapFragment -->
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:name="org.y20k.trackbook.MainActivityMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:layout="@layout/fragment_main_map" />
<include layout="@layout/floating_action_button" />
<!-- <android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/ic_fiber_manual_record_white_24dp"
app:fabSize="auto"/> -->
</android.support.design.widget.CoordinatorLayout>

View file

@ -9,6 +9,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="bottom"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
app:layout_behavior="org.y20k.trackbook.layout.DodgeAbleLayoutBehavior"> app:layout_behavior="org.y20k.trackbook.layout.DodgeAbleLayoutBehavior">
@ -16,9 +17,8 @@
<LinearLayout <LinearLayout
android:id="@+id/fabSubMenu1" android:id="@+id/fabSubMenu1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_weight="1"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="@dimen/fab_margin" android:layout_marginBottom="@dimen/fab_margin"
@ -29,6 +29,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:contentDescription="@string/descr_fab_sub_menu_button_1"
app:cardBackgroundColor="@color/trackbook_white" app:cardBackgroundColor="@color/trackbook_white"
app:cardCornerRadius="4dp" app:cardCornerRadius="4dp"
app:cardElevation="4dp" app:cardElevation="4dp"
@ -50,9 +51,9 @@
android:id="@+id/fabSubMenuButton1" android:id="@+id/fabSubMenuButton1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:contentDescription="@string/descr_fab_sub_menu_button_1"
app:srcCompat="@drawable/ic_save_white_24dp" app:srcCompat="@drawable/ic_save_white_24dp"
app:backgroundTint="#4CAF50" app:backgroundTint="@color/trackbook_green"
app:fabSize="mini" /> app:fabSize="mini" />
</LinearLayout> </LinearLayout>
@ -71,6 +72,7 @@
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/descr_fab_sub_menu_label_2"
app:cardBackgroundColor="@color/trackbook_white" app:cardBackgroundColor="@color/trackbook_white"
app:cardCornerRadius="4dp" app:cardCornerRadius="4dp"
app:cardElevation="4dp" app:cardElevation="4dp"
@ -94,8 +96,8 @@
android:id="@+id/fabSubMenuButton2" android:id="@+id/fabSubMenuButton2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/descr_fab_sub_menu_button_2"
app:srcCompat="@drawable/ic_clear_white_24dp" app:srcCompat="@drawable/ic_clear_white_24dp"
app:backgroundTint="#2196F3"
app:fabSize="mini" /> app:fabSize="mini" />
</LinearLayout> </LinearLayout>
@ -111,6 +113,7 @@
android:id="@+id/fabMainButton" android:id="@+id/fabMainButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/descr_fab_main"
app:srcCompat="@drawable/ic_fiber_manual_record_white_24dp" app:srcCompat="@drawable/ic_fiber_manual_record_white_24dp"
app:fabSize="normal" /> app:fabSize="normal" />

View file

@ -6,8 +6,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
tools:context=".MainActivityMapFragment" tools:context=".MainActivityMapFragment">
tools:showIn="@layout/activity_main_old">
<org.osmdroid.views.MapView android:id="@+id/map" <org.osmdroid.views.MapView android:id="@+id/map"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View file

@ -42,6 +42,9 @@
<string name="toast_message_last_location">Letzte Position:</string> <string name="toast_message_last_location">Letzte Position:</string>
<string name="toast_message_save_track">Aufzeichnung wird gespeichert.</string> <string name="toast_message_save_track">Aufzeichnung wird gespeichert.</string>
<string name="toast_message_last_location_age_one_hour">über eine Stunde</string> <string name="toast_message_last_location_age_one_hour">über eine Stunde</string>
<string name="toast_message_track_clear">Aufzeichnung zurückgesetzt.</string>
<string name="toast_message_track_save">Speichere Aufzeichnung.</string>
<!-- map markers --> <!-- map markers -->
<string name="marker_description_source">Quelle</string> <string name="marker_description_source">Quelle</string>
@ -91,6 +94,11 @@
<!-- descriptions --> <!-- descriptions -->
<string name="descr_map_current_track">Karte der aktuellen Aufzeichnung</string> <string name="descr_map_current_track">Karte der aktuellen Aufzeichnung</string>
<string name="descr_map_last_track">Karte der letzten Aufzeichnung</string> <string name="descr_map_last_track">Karte der letzten Aufzeichnung</string>
<string name="descr_fab_main">Haupt-Aktionsbutton</string>
<string name="descr_fab_sub_menu_label_1">Beschreibung des Speichern-und-Zurücksetzen-Buttons</string>
<string name="descr_fab_sub_menu_button_1">kleiner Speichern-und-Zurücksetzen-Button</string>
<string name="descr_fab_sub_menu_label_2">Beschreibung des Zurücksetzen-Buttons</string>
<string name="descr_fab_sub_menu_button_2">kleiner Zurücksetzen-Button</string>
<string name="descr_statistics_sheet_headline">Überschrift der Statistik-Einblendung</string> <string name="descr_statistics_sheet_headline">Überschrift der Statistik-Einblendung</string>
<string name="descr_statistics_sheet_icon">Icon Balkendiagramm</string> <string name="descr_statistics_sheet_icon">Icon Balkendiagramm</string>
<string name="descr_statistics_sheet_p_distance">Datenpunkt: Distanz</string> <string name="descr_statistics_sheet_p_distance">Datenpunkt: Distanz</string>

View file

@ -10,6 +10,8 @@
<color name="trackbook_blue_dark">#FF12537F</color> <color name="trackbook_blue_dark">#FF12537F</color>
<color name="trackbook_blue_85percent">#D92095F2</color> <color name="trackbook_blue_85percent">#D92095F2</color>
<color name="trackbook_green">#FF4CAF50</color>
<color name="trackbook_white">#FFFFFFFF</color> <color name="trackbook_white">#FFFFFFFF</color>
<color name="trackbook_grey_light">#FF607d8b</color> <color name="trackbook_grey_light">#FF607d8b</color>

View file

@ -43,6 +43,9 @@
<string name="toast_message_last_location">Last location:</string> <string name="toast_message_last_location">Last location:</string>
<string name="toast_message_save_track">Saving current track.</string> <string name="toast_message_save_track">Saving current track.</string>
<string name="toast_message_last_location_age_one_hour">over one hour</string> <string name="toast_message_last_location_age_one_hour">over one hour</string>
<string name="toast_message_track_clear">Current track data removed.</string>
<string name="toast_message_track_save">Saving current track data.</string>
<!-- map markers --> <!-- map markers -->
<string name="marker_description_source">Source</string> <string name="marker_description_source">Source</string>
@ -92,6 +95,11 @@
<!-- descriptions --> <!-- descriptions -->
<string name="descr_map_current_track">Map of the current track</string> <string name="descr_map_current_track">Map of the current track</string>
<string name="descr_map_last_track">Map of the last track</string> <string name="descr_map_last_track">Map of the last track</string>
<string name="descr_fab_main">Main Action Button</string>
<string name="descr_fab_sub_menu_label_1">Label of the Save and Clear button</string>
<string name="descr_fab_sub_menu_button_1">small Save and Clear button</string>
<string name="descr_fab_sub_menu_label_2">Label of the Clear button</string>
<string name="descr_fab_sub_menu_button_2">small Clear button</string>
<string name="descr_statistics_sheet_headline">Headline of the statistics sheet</string> <string name="descr_statistics_sheet_headline">Headline of the statistics sheet</string>
<string name="descr_statistics_sheet_icon">Icon of a bar chart</string> <string name="descr_statistics_sheet_icon">Icon of a bar chart</string>
<string name="descr_statistics_sheet_p_distance">Data point: distance</string> <string name="descr_statistics_sheet_p_distance">Data point: distance</string>