rolling back the rollback (see last commit) - maybe found the culprit "-dontshrink" (see #44)

This commit is contained in:
y20k 2018-11-04 10:13:19 +01:00
parent 9985e9f7a4
commit 67eee7f053
33 changed files with 285 additions and 150 deletions

View file

@ -1,8 +1,9 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion
// buildToolsVersion is optional because the plugin uses a recommended version by default
defaultConfig {
applicationId project.ext.applicationId
@ -14,26 +15,29 @@ android {
vectorDrawables.useSupportLibrary = true
resConfigs "en", "de", "id", "it", "ja", "nb-rNO", "nl"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
// minifyEnabled true
// shrinkResources true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:' + supportLibraryVersion
implementation 'com.android.support:design:' + supportLibraryVersion
implementation 'com.android.support:cardview-v7:' + supportLibraryVersion
implementation 'com.android.support.constraint:constraint-layout:' + constraintLayoutVersion
implementation 'org.osmdroid:osmdroid-android:' + osmdroidVersion
implementation 'com.google.code.gson:gson:' + gsonVersion
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayoutVersion"
implementation "androidx.cardview:cardview:$cardviewVersion"
implementation "com.google.android.material:material:$materialVersion"
implementation "org.osmdroid:osmdroid-android:$osmdroidVersion"
implementation "com.google.code.gson:gson:$gsonVersion"
}

View file

@ -15,3 +15,7 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# this was a test
# https://github.com/y20k/trackbook/commit/a3457db5462d9b4ab50b3c38c5621eb992768b7c
# -dontshrink

View file

@ -34,19 +34,6 @@ import android.os.Environment;
import android.os.IBinder;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.util.SparseArray;
import android.view.MenuItem;
import android.view.View;
@ -54,6 +41,10 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import org.osmdroid.config.Configuration;
import org.y20k.trackbook.helpers.DialogHelper;
import org.y20k.trackbook.helpers.ExportHelper;
@ -68,6 +59,17 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
/**
* MainActivity class
@ -264,9 +266,20 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
if (resultCode == Activity.RESULT_OK) {
// user chose CLEAR
handleStateAfterClear();
LogHelper.v(LOG_TAG, "Save dialog result: CLEAR");
LogHelper.v(LOG_TAG, "Clear map dialog result: CLEAR");
} else if (resultCode == Activity.RESULT_CANCELED){
LogHelper.v(LOG_TAG, "Clear map: User chose CANCEL.");
LogHelper.v(LOG_TAG, "Clear map dialog result: User chose CANCEL.");
}
break;
case RESULT_EMPTY_RECORDING_DIALOG:
if (resultCode == Activity.RESULT_OK) {
// User chose RESUME RECORDING
handleResumeButtonClick((View)mFloatingActionButtonMain);
LogHelper.v(LOG_TAG, "Empty recording dialog result: RESUME");
} else if (resultCode == Activity.RESULT_CANCELED){
// User chose CANCEL - do nothing just hide the sub menu
showFloatingActionButtonMenu(false);
LogHelper.v(LOG_TAG, "Empty recording dialog result: CANCEL");
}
break;
}
@ -339,9 +352,6 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
/* Handles the visual state after a save action */
private void handleStateAfterClear() {
// notify user
Toast.makeText(this, getString(R.string.toast_message_track_clear), Toast.LENGTH_LONG).show();
// dismiss notification
dismissNotification();
@ -584,16 +594,24 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
switch (mFloatingActionButtonState) {
case FAB_STATE_DEFAULT:
mFloatingActionButtonMain.hide(); // workaround todo remove asap
mFloatingActionButtonMain.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp);
if (mSelectedTab == FRAGMENT_ID_MAP) mFloatingActionButtonMain.show(); // workaround todo remove asap
break;
case FAB_STATE_RECORDING:
mFloatingActionButtonMain.hide(); // workaround todo remove asap
mFloatingActionButtonMain.setImageResource(R.drawable.ic_fiber_manual_record_red_24dp);
if (mSelectedTab == FRAGMENT_ID_MAP) mFloatingActionButtonMain.show(); // workaround todo remove asap
break;
case FAB_STATE_SAVE:
mFloatingActionButtonMain.hide(); // workaround todo remove asap
mFloatingActionButtonMain.setImageResource(R.drawable.ic_save_white_24dp);
if (mSelectedTab == FRAGMENT_ID_MAP) mFloatingActionButtonMain.show(); // workaround todo remove asap
break;
default:
mFloatingActionButtonMain.hide(); // workaround todo remove asap
mFloatingActionButtonMain.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp);
if (mSelectedTab == FRAGMENT_ID_MAP) mFloatingActionButtonMain.show(); // workaround todo remove asap
break;
}
}
@ -602,20 +620,20 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
/* Shows (and hides) the sub menu of the floating action button */
private void showFloatingActionButtonMenu(boolean visible) {
if (visible) {
mFloatingActionButtonSubResume.setVisibility(View.VISIBLE);
mFloatingActionButtonSubResume.show();
mFloatingActionButtonSubResumeLabel.setVisibility(View.VISIBLE);
mFloatingActionButtonSubClear.setVisibility(View.VISIBLE);
mFloatingActionButtonSubClear.show();
mFloatingActionButtonSubClearLabel.setVisibility(View.VISIBLE);
mFloatingActionButtonSubSave.setVisibility(View.VISIBLE);
mFloatingActionButtonSubSave.show();
mFloatingActionButtonSubSaveLabel.setVisibility(View.VISIBLE);
mFloatingActionButtonSubMenuVisible = true;
} else {
mFloatingActionButtonSubResume.setVisibility(View.INVISIBLE);
mFloatingActionButtonSubResume.hide();
mFloatingActionButtonSubResumeLabel.setVisibility(View.INVISIBLE);
mFloatingActionButtonSubClear.setVisibility(View.INVISIBLE);
mFloatingActionButtonSubClear.hide();
mFloatingActionButtonSubClearLabel.setVisibility(View.INVISIBLE);
mFloatingActionButtonSubSave.hide();
mFloatingActionButtonSubSaveLabel.setVisibility(View.INVISIBLE);
mFloatingActionButtonSubSave.setVisibility(View.INVISIBLE);
mFloatingActionButtonSubMenuVisible = false;
}
}

View file

@ -31,15 +31,13 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.google.android.material.snackbar.Snackbar;
import org.osmdroid.api.IMapController;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
@ -48,6 +46,7 @@ import org.osmdroid.views.overlay.ItemizedIconOverlay;
import org.osmdroid.views.overlay.compass.CompassOverlay;
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider;
import org.y20k.trackbook.core.Track;
import org.y20k.trackbook.helpers.DialogHelper;
import org.y20k.trackbook.helpers.LocationHelper;
import org.y20k.trackbook.helpers.LogHelper;
import org.y20k.trackbook.helpers.MapHelper;
@ -56,6 +55,12 @@ import org.y20k.trackbook.helpers.TrackbookKeys;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
/**
* MainActivityMapFragment class
@ -124,7 +129,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
if (savedInstanceState != null) {
Location savedLocation = savedInstanceState.getParcelable(INSTANCE_CURRENT_LOCATION);
// check if saved location is still current
if (LocationHelper.isNewLocation(savedLocation)) {
if (LocationHelper.isCurrent(savedLocation)) {
mCurrentBestLocation = savedLocation;
} else {
mCurrentBestLocation = null;
@ -207,7 +212,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
// mark user's location on map
if (mCurrentBestLocation != null && !mTrackerServiceRunning) {
mMyLocationOverlay = MapHelper.createMyLocationOverlay(mActivity, mCurrentBestLocation, LocationHelper.isNewLocation(mCurrentBestLocation));
mMyLocationOverlay = MapHelper.createMyLocationOverlay(mActivity, mCurrentBestLocation, LocationHelper.isCurrent(mCurrentBestLocation), false);
mMapView.getOverlays().add(mMyLocationOverlay);
}
@ -307,18 +312,29 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
switch(requestCode) {
case RESULT_SAVE_DIALOG:
if (resultCode == Activity.RESULT_OK) {
// user chose SAVE - clear map AND save track
// user chose SAVE
if (mTrack.getSize() > 0) {
// Track is not empty - clear map AND save track
clearMap(true);
// FloatingActionButton state is already being handled in MainActivity
((MainActivity)mActivity).onFloatingActionButtonResult(requestCode, resultCode);
LogHelper.v(LOG_TAG, "Save dialog result: SAVE");
} else {
// track is empty
handleEmptyRecordingSaveRequest();
}
} else if (resultCode == Activity.RESULT_CANCELED){
LogHelper.v(LOG_TAG, "Save dialog result: CANCEL");
}
break;
case RESULT_CLEAR_DIALOG:
if (resultCode == Activity.RESULT_OK) {
// User chose CLEAR - clear map, DO NOT save track
// User chose CLEAR
if (mTrack.getSize() > 0) {
// Track is not empty - notify user
Toast.makeText(mActivity, getString(R.string.toast_message_track_clear), Toast.LENGTH_LONG).show();
}
// clear map, DO NOT save track
clearMap(false);
// handle FloatingActionButton state in MainActivity
((MainActivity)mActivity).onFloatingActionButtonResult(requestCode, resultCode);
@ -326,6 +342,10 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
LogHelper.v(LOG_TAG, "Clear dialog result: CANCEL");
}
break;
case RESULT_EMPTY_RECORDING_DIALOG:
// handle FloatingActionButton state and possible Resume-Action in MainActivity
((MainActivity)mActivity).onFloatingActionButtonResult(requestCode, resultCode);
break;
}
}
@ -444,6 +464,21 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
}
/* Handles case when user chose to save recording with zero waypoints */ // todo implement
private void handleEmptyRecordingSaveRequest() {
// prepare empty recording dialog ("Unable to save")
int dialogTitle = R.string.dialog_error_empty_recording_title;
String dialogMessage = getString(R.string.dialog_error_empty_recording_content);
int dialogPositiveButton = R.string.dialog_error_empty_recording_action_resume;
int dialogNegativeButton = R.string.dialog_default_action_cancel;
// show empty recording dialog
DialogFragment dialogFragment = DialogHelper.newInstance(dialogTitle, dialogMessage, dialogPositiveButton, dialogNegativeButton);
dialogFragment.setTargetFragment(this, RESULT_EMPTY_RECORDING_DIALOG);
dialogFragment.show(((AppCompatActivity)mActivity).getSupportFragmentManager(), "EmptyRecordingDialog");
// results of dialog are handled by onActivityResult
}
/* Start preliminary tracking for map */
private void startPreliminaryTracking() {
if (mLocationSystemSetting && !mLocalTrackerRunning) {
@ -508,7 +543,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
mMapView.getOverlays().remove(mMyLocationOverlay);
// only update while not tracking
if (!mTrackerServiceRunning) {
mMyLocationOverlay = MapHelper.createMyLocationOverlay(mActivity, mCurrentBestLocation, LocationHelper.isNewLocation(mCurrentBestLocation));
mMyLocationOverlay = MapHelper.createMyLocationOverlay(mActivity, mCurrentBestLocation, LocationHelper.isCurrent(mCurrentBestLocation), false);
mMapView.getOverlays().add(mMyLocationOverlay);
}
}
@ -518,11 +553,16 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
private void drawTrackOverlay(Track track) {
mMapView.getOverlays().remove(mTrackOverlay);
mTrackOverlay = null;
if (track != null) {
if (track == null || track.getSize() == 0) {
LogHelper.i(LOG_TAG, "Waiting for a track. Showing preliminary location.");
mTrackOverlay = MapHelper.createMyLocationOverlay(mActivity, mCurrentBestLocation, false, mTrackerServiceRunning);
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_acquiring_location), Toast.LENGTH_LONG).show();
} else {
LogHelper.v(LOG_TAG, "Drawing track overlay.");
mTrackOverlay = MapHelper.createTrackOverlay(mActivity, track, mTrackerServiceRunning);
mMapView.getOverlays().add(mTrackOverlay);
}
mMapView.getOverlays().add(mTrackOverlay);
}

View file

@ -24,16 +24,6 @@ import android.content.IntentFilter;
import android.location.Location;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.Group;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@ -45,6 +35,8 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import org.osmdroid.api.IMapController;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
@ -67,6 +59,16 @@ import java.io.File;
import java.text.DateFormat;
import java.util.Locale;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
/**
* MainActivityTrackFragment class

View file

@ -18,11 +18,12 @@ package org.y20k.trackbook;
import android.app.Application;
import android.os.Build;
import android.support.v7.app.AppCompatDelegate;
import org.y20k.trackbook.helpers.LogHelper;
import org.y20k.trackbook.helpers.NightModeHelper;
import androidx.appcompat.app.AppCompatDelegate;
/**
* Trackbook.class

View file

@ -37,8 +37,6 @@ import android.os.CountDownTimer;
import android.os.Handler;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.widget.Toast;
import org.y20k.trackbook.core.Track;
@ -50,6 +48,9 @@ import org.y20k.trackbook.helpers.TrackbookKeys;
import java.util.List;
import androidx.core.app.NotificationCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import static android.hardware.Sensor.TYPE_STEP_COUNTER;
@ -233,7 +234,7 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
// load temp track file
mTrack = storageHelper.loadTrack(FILE_TEMP_TRACK);
// try to mark last waypoint as stopover
int lastWayPoint = mTrack.getWayPoints().size() - 1;
int lastWayPoint = mTrack.getSize() - 1;
if (lastWayPoint >= 0) {
mTrack.getWayPoints().get(lastWayPoint).setIsStopOver(true);
}
@ -394,12 +395,17 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
boolean success = false;
Location previousLocation = null;
int trackSize = mTrack.getWayPoints().size();
int trackSize = mTrack.getSize();
if (trackSize == 0) {
// if accurate AND current
if (LocationHelper.isAccurate(mCurrentBestLocation) && LocationHelper.isCurrent(mCurrentBestLocation)) {
// add first location to track
success = mTrack.addWayPoint(previousLocation, mCurrentBestLocation);
} else {
// just send a broadcast indicating that current location fix not not suited
broadcastTrackUpdate();
}
} else {
// get location of previous WayPoint
previousLocation = mTrack.getWayPointLocation(trackSize - 1);
@ -415,17 +421,20 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
averageSpeed = distance / ((float) timeDifference / ONE_SECOND_IN_NANOSECOND);
}
if (LocationHelper.isNewWayPoint(previousLocation, mCurrentBestLocation, averageSpeed)) {
// if new, add current best location to track
// if accurate AND new
if (LocationHelper.isAccurate(mCurrentBestLocation) && LocationHelper.isNewWayPoint(previousLocation, mCurrentBestLocation, averageSpeed)) {
// add current best location to track
success = mTrack.addWayPoint(previousLocation, mCurrentBestLocation);
}
}
if (success) {
if (mResumedFlag) {
int lastWayPoint = mTrack.getSize() - 2;
if (lastWayPoint >= 0) {
// mark last location as stop over
int lastWayPoint = mTrack.getWayPoints().size() - 2;
mTrack.getWayPoints().get(lastWayPoint).setIsStopOver(true);
}
mResumedFlag = false;
} else {
// update distance, if not resumed

View file

@ -19,7 +19,6 @@ package org.y20k.trackbook.core;
import android.location.Location;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import org.y20k.trackbook.helpers.LocationHelper;
import org.y20k.trackbook.helpers.TrackbookKeys;
@ -29,6 +28,8 @@ import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import androidx.annotation.Nullable;
/**
* Track class
@ -275,7 +276,12 @@ public class Track implements TrackbookKeys, Parcelable {
/* Getter recorded distance */
public Double getTrackDistance() {
return (double) mWayPoints.get(mWayPoints.size()-1).getDistanceToStartingPoint();
int size = mWayPoints.size();
if (size > 0) {
return (double)mWayPoints.get(size - 1).getDistanceToStartingPoint();
} else {
return (double)0f;
}
}

View file

@ -21,8 +21,9 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
/**

View file

@ -20,8 +20,6 @@ package org.y20k.trackbook.helpers;
import android.app.Activity;
import android.content.res.Resources;
import android.database.DataSetObserver;
import android.support.annotation.Nullable;
import android.support.v7.widget.ThemedSpinnerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -35,6 +33,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.ThemedSpinnerAdapter;
/**
* DropdownHelper class
@ -175,8 +176,10 @@ public class DropdownAdapter extends BaseAdapter implements ThemedSpinnerAdapter
// fill list with track bundles
mTrackBundleList = new ArrayList<>();
for (File file : files) {
if (file.getName().endsWith(FILE_TYPE_TRACKBOOK_EXTENSION)) {
mTrackBundleList.add(new TrackBundle(file));
}
}
}

View file

@ -20,7 +20,6 @@ import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.os.Environment;
import android.support.v4.content.FileProvider;
import android.widget.Toast;
import org.y20k.trackbook.R;
@ -37,6 +36,8 @@ import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import androidx.core.content.FileProvider;
/**
* ExportHelper class
*/

View file

@ -22,12 +22,13 @@ import android.location.LocationListener;
import android.location.LocationManager;
import android.os.SystemClock;
import android.provider.Settings;
import android.support.annotation.Nullable;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import androidx.annotation.Nullable;
/**
* LocationHelper class
@ -93,8 +94,8 @@ public final class LocationHelper implements TrackbookKeys {
// check whether the new location fix is newer or older
long timeDelta = location.getElapsedRealtimeNanos() - currentBestLocation.getElapsedRealtimeNanos();
boolean isSignificantlyNewer = timeDelta > TWO_MINUTES_IN_NANOSECONDS;
boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES_IN_NANOSECONDS;
boolean isSignificantlyNewer = timeDelta > ONE_MINUTE_IN_NANOSECONDS;
boolean isSignificantlyOlder = timeDelta < -ONE_MINUTE_IN_NANOSECONDS;
boolean isNewer = timeDelta > 0;
// if it's been more than two minutes since the current location, use the new location because the user has likely moved
@ -125,13 +126,19 @@ public final class LocationHelper implements TrackbookKeys {
}
/* Checks accuracy of given location */
public static boolean isAccurate(Location location) {
return location.getAccuracy() < FIFTY_METER_RADIUS;
}
/* Checks if given location is newer than two minutes */
public static boolean isNewLocation(Location location) {
public static boolean isCurrent(Location location) {
if (location == null) {
return false;
} else {
long locationAge = SystemClock.elapsedRealtimeNanos() - location.getElapsedRealtimeNanos();
return locationAge < TWO_MINUTES_IN_NANOSECONDS;
return locationAge < ONE_MINUTE_IN_NANOSECONDS;
}
}

View file

@ -19,7 +19,6 @@ package org.y20k.trackbook.helpers;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
import org.osmdroid.util.GeoPoint;
@ -34,6 +33,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import androidx.core.content.ContextCompat;
/**
* MapHelper class
*/
@ -44,17 +45,20 @@ public final class MapHelper {
/* Creates icon overlay for current position (used in MainActivity Fragment) */
public static ItemizedIconOverlay createMyLocationOverlay(final Context context, Location currentBestLocation, boolean locationIsNew) {
public static ItemizedIconOverlay createMyLocationOverlay(final Context context, Location currentBestLocation, boolean locationIsNew, boolean trackingActive) {
final ArrayList<OverlayItem> overlayItems = new ArrayList<>();
// create marker
Drawable newMarker;
if (locationIsNew) {
if (locationIsNew && !trackingActive) {
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_my_location_dot_blue_24dp);
} else if (!locationIsNew && trackingActive) {
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_my_location_dot_red_grey_24dp);
} else {
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_my_location_dot_grey_24dp);
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_my_location_dot_blue_grey_24dp);
}
OverlayItem overlayItem = createOverlayItem(context, currentBestLocation);
overlayItem.setMarker(newMarker);
@ -83,13 +87,14 @@ public final class MapHelper {
/* Creates icon overlay for track */
public static ItemizedIconOverlay createTrackOverlay(final Context context, Track track, boolean trackingActive){
WayPoint wayPoint;
final ArrayList<OverlayItem> overlayItems = new ArrayList<>();
boolean currentPosition;
final int trackSize = track.getSize();
final List<WayPoint> wayPoints = track.getWayPoints();
final ArrayList<OverlayItem> overlayItems = new ArrayList<>();
WayPoint wayPoint;
for (int i = 0; i < track.getSize(); i++) {
// get WayPoint and check if it is current position
wayPoint = wayPoints.get(i);
currentPosition = i == trackSize - 1;
@ -112,7 +117,7 @@ public final class MapHelper {
else if (trackingActive && currentPosition) {
if (wayPoint.getIsStopOver()) {
// stop over marker
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_my_location_dot_grey_24dp);
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_my_location_dot_blue_grey_24dp);
} else {
// default marker for this case
newMarker = ContextCompat.getDrawable(context, R.drawable.ic_my_location_dot_red_24dp);

View file

@ -22,9 +22,10 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatDelegate;
import android.view.View;
import androidx.appcompat.app.AppCompatDelegate;
/**
* NightModeHelper class

View file

@ -26,15 +26,16 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Build;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import org.y20k.trackbook.MainActivity;
import org.y20k.trackbook.R;
import org.y20k.trackbook.TrackerService;
import org.y20k.trackbook.core.Track;
import androidx.core.app.NotificationCompat;
import androidx.core.app.TaskStackBuilder;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
/**
* NotificationHelper class

View file

@ -18,8 +18,6 @@ package org.y20k.trackbook.helpers;
import android.content.Context;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.support.v4.os.EnvironmentCompat;
import android.widget.Toast;
import com.google.gson.Gson;
@ -42,6 +40,9 @@ import java.util.Comparator;
import java.util.Date;
import java.util.Locale;
import androidx.annotation.Nullable;
import androidx.core.os.EnvironmentCompat;
/**
* StorageHelper class

View file

@ -75,23 +75,21 @@ public interface TrackbookKeys {
int FRAGMENT_ID_MAP = 0;
int FRAGMENT_ID_TRACKS = 1;
String FRAGMENT_TAG_MAP = "fragmentTagMap";
String FRAGMENT_TAG_TRACKS = "fragmentTagTracks";
/* RESULTS */
int RESULT_SAVE_DIALOG = 1;
int RESULT_CLEAR_DIALOG = 2;
int RESULT_DELETE_DIALOG = 3;
int RESULT_EXPORT_DIALOG = 4;
int RESULT_EMPTY_RECORDING_DIALOG = 5;
/* CONSTANTS */
long ONE_SECOND_IN_NANOSECOND = 1000000000L;
long EIGHT_HOURS_IN_MILLISECONDS = 43200000; // maximum tracking duration
long FIFTEEN_SECONDS_IN_MILLISECONDS = 15000; // timer interval for tracking
long FIVE_MINUTES_IN_NANOSECONDS = 5L * 60000000000L; // determines a stop over
long TWO_MINUTES_IN_NANOSECONDS = 2L * 60000000000L; // defines an old location
long ONE_MINUTE_IN_NANOSECONDS = 1L * 60000000000L; // defines an old location
int MAXIMUM_TRACK_FILES = 25;
int FIFTY_METER_RADIUS = 50;
/* FILE */
String FILE_TYPE_GPX_EXTENSION = ".gpx";

View file

@ -18,11 +18,13 @@
package org.y20k.trackbook.layout;
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.util.AttributeSet;
import android.view.View;
import com.google.android.material.snackbar.Snackbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
/**
* DodgeAbleLayoutBehavior class

View file

@ -22,7 +22,6 @@ package org.y20k.trackbook.layout;
*/
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
@ -32,6 +31,8 @@ import org.y20k.trackbook.helpers.LogHelper;
import java.lang.reflect.Field;
import androidx.viewpager.widget.ViewPager;
public class NonSwipeableViewPager extends ViewPager {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.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"
@ -8,14 +8,14 @@
tools:context="org.y20k.trackbook.MainActivity">
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- BUTTON MY LOCATION -->
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabLocationButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -32,7 +32,7 @@
<!-- SAVE RESUME -->
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabSubMenuButtonSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -47,7 +47,7 @@
app:layout_constraintStart_toStartOf="@+id/fabSubMenuButtonClear"
app:srcCompat="@drawable/ic_save_white_24dp" />
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:id="@+id/fabSubMenuLabelSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -75,11 +75,11 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/fab_button_card_text"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
<!-- BUTTON CLEAR -->
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabSubMenuButtonClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -94,7 +94,7 @@
app:layout_constraintStart_toStartOf="@+id/fabSubMenuButtonResume"
app:srcCompat="@drawable/ic_clear_white_24dp" />
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:id="@+id/fabSubMenuLabelClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -122,11 +122,11 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/fab_button_card_text"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
<!-- BUTTON RESUME -->
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabSubMenuButtonResume"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -141,7 +141,7 @@
app:layout_constraintStart_toStartOf="@+id/fabMainButton"
app:srcCompat="@drawable/ic_fiber_manual_record_white_24dp" />
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:id="@+id/fabSubMenuLabelResume"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -168,11 +168,11 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/fab_button_card_text"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
<!-- MAIN BUTTON -->
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabMainButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -189,7 +189,7 @@
<!-- BOTTOM NAVIGATION -->
<android.support.design.widget.BottomNavigationView
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -214,9 +214,9 @@
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.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"
@ -29,7 +29,7 @@
</RelativeLayout>
<!-- BOTTOM SHEET -->
<android.support.v4.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
android:id="@+id/statistics_sheet"
android:layout_width="@dimen/bottom_sheet_width"
android:layout_height="match_parent"
@ -37,7 +37,7 @@
android:background="@color/statistic_sheet_background_collapsed"
app:behavior_hideable="false"
app:behavior_peekHeight="54dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
@ -48,6 +48,6 @@
</ScrollView>
</android.support.v4.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/track_management_layout"
android:layout_width="@dimen/bottom_sheet_width"
@ -57,4 +57,4 @@
app:srcCompat="@drawable/ic_delete_forever_24dp" />
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/statistics_view"
android:layout_width="match_parent"
@ -7,13 +7,13 @@
android:clickable="true"
android:focusable="true">
<android.support.constraint.Group
<androidx.constraintlayout.widget.Group
android:id="@+id/elevation_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="statistics_p_positive_elevation, statistics_data_positive_elevation, statistics_p_negative_elevation, statistics_data_negative_elevation, statistics_p_max_altitude, statistics_data_max_altitude, statistics_p_min_altitude, statistics_data_min_altitude" />
<android.support.constraint.Group
<androidx.constraintlayout.widget.Group
android:id="@+id/statistics_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -294,4 +294,4 @@
app:layout_constraintStart_toEndOf="@+id/statistics_p_min_altitude"
app:layout_constraintTop_toTopOf="@+id/statistics_p_min_altitude" />
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -45,6 +45,9 @@
<string name="dialog_export_content_overwrite">Datei existiert bereits. Exportieren und überschreiben Sie diese Aufzeichnung als GPX-Strecke.</string>
<string name="dialog_export_action_overwrite">Exportieren und überschreiben</string>
<string name="dialog_share_gpx">GPX-Datei öffnen mit</string>
<string name="dialog_error_empty_recording_title">Speichern nicht möglich</string>
<string name="dialog_error_empty_recording_content">Trackbook hat noch keine Wegpunkte aufgezeichnet.</string>
<string name="dialog_error_empty_recording_action_resume">Aufzeichnung fortsetzen</string>
<!-- toast messages -->
<string name="toast_message_permissions_granted">Berechtigungen erteilt.</string>

View file

@ -45,6 +45,9 @@
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
<string name="dialog_share_gpx">Share GPX file with</string>
<string name="dialog_error_empty_recording_title">Unable to save</string>
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
<!-- toast messages -->
<string name="toast_message_permissions_granted">Permissions granted.</string>

View file

@ -45,6 +45,9 @@
<string name="dialog_export_content_overwrite">Il file esiste già. Esportare e sovrascrivere questa registrazione come traccia GPX.</string>
<string name="dialog_export_action_overwrite">Esporta e sovrascrivi</string>
<string name="dialog_share_gpx">Share GPX file with</string>
<string name="dialog_error_empty_recording_title">Unable to save</string>
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
<!-- toast messages -->
<string name="toast_message_permissions_granted">Permessi acquisiti.</string>

View file

@ -45,6 +45,9 @@
<string name="dialog_export_content_overwrite">ファイルは既に存在します。エクスポートし、GPX トラックとしてこの記録を上書きします。</string>
<string name="dialog_export_action_overwrite">エクスポートして上書き</string>
<string name="dialog_share_gpx">Share GPX file with</string>
<string name="dialog_error_empty_recording_title">Unable to save</string>
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
<!-- toast messages -->
<string name="toast_message_permissions_granted">アクセス許可を付与しました。</string>

View file

@ -45,6 +45,9 @@
<string name="dialog_export_content_overwrite">Fila finnes allerede. Eksporter og overskriv dette opptaket som en GPX-tur.</string>
<string name="dialog_export_action_overwrite">Eksporter og overskriv</string>
<string name="dialog_share_gpx">Share GPX file with</string>
<string name="dialog_error_empty_recording_title">Unable to save</string>
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
<!-- toast messages -->
<string name="toast_message_permissions_granted">Tilgang gitt.</string>

View file

@ -45,6 +45,9 @@
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
<string name="dialog_share_gpx">Share GPX file with</string>
<string name="dialog_error_empty_recording_title">Unable to save</string>
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
<!-- toast messages -->
<string name="toast_message_permissions_granted">Rechten verleend.</string>

View file

@ -45,6 +45,9 @@
<string name="dialog_export_content_overwrite">File already exists. Export and overwrite this recording as GPX track.</string>
<string name="dialog_export_action_overwrite">Export and Overwrite</string>
<string name="dialog_share_gpx">Share GPX file with</string>
<string name="dialog_error_empty_recording_title">Unable to save</string>
<string name="dialog_error_empty_recording_content">Trackbook did not record any waypoints so far.</string>
<string name="dialog_error_empty_recording_action_resume">Resume Recording</string>
<!-- toast messages -->
<string name="toast_message_permissions_granted">Permissions granted.</string>

View file

@ -1,35 +1,42 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
project.ext {
applicationId = 'org.y20k.trackbook'
versionCode = 28
versionName = '1.1.12'
minSdkVersion = 22
compileSdkVersion = 27
targetSdkVersion = 27
buildToolsVersion = '27.0.3'
supportLibraryVersion = '27.1.1'
constraintLayoutVersion = '1.1.0-beta6'
versionCode = 29
versionName = '1.1.13'
osmdroidVersion = '6.0.1'
compileSdkVersion = 28
targetSdkVersion = 27
minSdkVersion = 22
constraintlayoutVersion = '1.1.3'
materialVersion = "1.0.0"
appcompatVersion = '1.0.0'
cardviewVersion = '1.0.0'
osmdroidVersion = '6.0.2'
gsonVersion = '2.8.5'
}
}

View file

@ -16,3 +16,5 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true

View file

@ -1,6 +1,6 @@
#Wed Apr 04 15:52:45 CEST 2018
#Thu Oct 04 08:52:03 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip