From 0e9d1ca77186ae4a510e5ba54c7fe89942edf4d9 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 24 Jul 2015 11:56:38 +0300 Subject: [PATCH] Notification with buttons --- .../net/osmand/plus/NavigationService.java | 152 ++++++++++-------- .../plus/myplaces/AvailableGPXFragment.java | 141 ++++++++-------- 2 files changed, 157 insertions(+), 136 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index f338d32513..6a40a0c383 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -1,10 +1,6 @@ package net.osmand.plus; -import net.osmand.PlatformUtil; -import net.osmand.access.AccessibleToast; -import net.osmand.plus.osmo.OsMoPlugin; import android.app.AlarmManager; -import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; @@ -27,33 +23,42 @@ import android.support.v7.app.NotificationCompat; import android.util.Log; import android.widget.Toast; +import net.osmand.PlatformUtil; +import net.osmand.access.AccessibleToast; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.osmo.OsMoPlugin; + public class NavigationService extends Service implements LocationListener { public static class NavigationServiceBinder extends Binder { - + } + // global id don't conflict with others private final static int NOTIFICATION_SERVICE_ID = 5; - public final static String OSMAND_STOP_SERVICE_ACTION = "OSMAND_STOP_SERVICE_ACTION"; //$NON-NLS-1$ + public final static String OSMAND_STOP_SERVICE_ACTION = "OSMAND_STOP_SERVICE_ACTION"; //$NON-NLS-1$ + public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION"; public static int USED_BY_NAVIGATION = 1; public static int USED_BY_GPX = 2; public static int USED_BY_LIVE = 4; - public final static String USAGE_INTENT = "SERVICE_USED_BY"; - + public final static String USAGE_INTENT = "SERVICE_USED_BY"; + private NavigationServiceBinder binder = new NavigationServiceBinder(); - + private int serviceOffInterval; private String serviceOffProvider; private int serviceError; - + private OsmandSettings settings; - + private Handler handler; private static WakeLock lockStatic; private PendingIntent pendingIntent; private BroadcastReceiver broadcastReceiver; + private BroadcastReceiver saveBroadcastReceiver; private int usedBy = 0; private OsmAndLocationProvider locationProvider; @@ -61,7 +66,7 @@ public class NavigationService extends Service implements LocationListener { public IBinder onBind(Intent intent) { return binder; } - + protected synchronized static PowerManager.WakeLock getLock(Context context) { if (lockStatic == null) { PowerManager mgr = (PowerManager) context.getSystemService(Context.POWER_SERVICE); @@ -73,29 +78,29 @@ public class NavigationService extends Service implements LocationListener { protected Handler getHandler() { return handler; } - + public int getServiceError() { return serviceError; } - + public int getServiceOffInterval() { return serviceOffInterval; } - + public String getServiceOffProvider() { return serviceOffProvider; } - + public boolean isUsed() { return usedBy != 0; } - + public void addUsageIntent(int usageIntent) { usedBy |= usageIntent; } - + public void stopIfNeeded(Context ctx, int usageIntent) { - if((usedBy & usageIntent) > 0) { + if ((usedBy & usageIntent) > 0) { usedBy -= usageIntent; } @@ -114,7 +119,7 @@ public class NavigationService extends Service implements LocationListener { ctx.stopService(serviceIntent); } } - + @Override public int onStartCommand(Intent intent, int flags, int startId) { handler = new Handler(); @@ -135,13 +140,13 @@ public class NavigationService extends Service implements LocationListener { serviceError = Math.max(serviceError, 30 * 1000); // 3. not more than serviceOffInterval serviceError = Math.min(serviceError, serviceOffInterval); - - + + locationProvider = app.getLocationProvider(); app.setNavigationService(this); - - // requesting - if(isContinuous()){ + + // requesting + if (isContinuous()) { // request location updates LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); try { @@ -155,11 +160,11 @@ public class NavigationService extends Service implements LocationListener { pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(this, OnNavigationServiceAlarmReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 500, serviceOffInterval, pendingIntent); } - + // registering icon at top level // Leave icon visible even for navigation for proper display // if (!startedForNavigation) { - showNotificationInStatusBar(app); + showNotificationInStatusBar(app); // } return START_REDELIVER_INTENT; } @@ -168,35 +173,40 @@ public class NavigationService extends Service implements LocationListener { broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if(settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) { + if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) { settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); } OsMoPlugin plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - if(plugin != null) { - if(plugin.getTracker().isEnabledTracker()) { + if (plugin != null) { + if (plugin.getTracker().isEnabledTracker()) { plugin.getTracker().disableTracker(); } - } + } NavigationService.this.stopSelf(); } }; registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION)); - - - Intent notificationIntent = new Intent(OSMAND_STOP_SERVICE_ACTION); + saveBroadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + final OsmandMonitoringPlugin plugin = OsmandPlugin + .getEnabledPlugin(OsmandMonitoringPlugin.class); + plugin.saveCurrentTrack(); + } + }; + registerReceiver(saveBroadcastReceiver, new IntentFilter(OSMAND_SAVE_SERVICE_ACTION)); //Show currently active wake-up interval int soi = settings.SERVICE_OFF_INTERVAL.get(); - String nt = getString(R.string.service_stop_background_service) + ". " + getString(R.string.gps_wake_up_timer) + ": "; + String nt = getString(R.string.service_stop_background_service) + ". " + getString(R.string.gps_wake_up_timer) + ": "; if (soi == 0) { nt = nt + getString(R.string.int_continuosly); } else if (soi <= 90000) { - nt = nt + Integer.toString(soi/1000) + " " + getString(R.string.int_seconds); + nt = nt + Integer.toString(soi / 1000) + " " + getString(R.string.int_seconds); } else { - nt = nt + Integer.toString(soi/1000/60) + " " + getString(R.string.int_min); + nt = nt + Integer.toString(soi / 1000 / 60) + " " + getString(R.string.int_min); } - PendingIntent broadcast = PendingIntent.getBroadcast(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Notification notification = new Notification(R.drawable.bgs_icon, "", //$NON-NLS-1$ // System.currentTimeMillis()); // @@ -204,35 +214,51 @@ public class NavigationService extends Service implements LocationListener { // broadcast); // notification.flags = Notification.FLAG_NO_CLEAR; // startForeground(NOTIFICATION_SERVICE_ID, notification); - - final Builder noti = new NotificationCompat.Builder( - this).setContentTitle(Version.getAppName(cl)) - .setContentText(getString(R.string.osmand_service)).setSmallIcon(R.drawable.bgs_icon) -// .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, getBaseContext())) - .setContentIntent(broadcast).setOngoing(true); - startForeground(NOTIFICATION_SERVICE_ID, noti.build()); + + String stop = getResources().getString(R.string.shared_string_control_stop); + Intent stopIntent = new Intent(OSMAND_STOP_SERVICE_ACTION); + PendingIntent stopPendingIntent = PendingIntent.getBroadcast(this, 0, stopIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + String pause = getResources().getString(R.string.shared_string_save); + Intent saveIntent = new Intent(OSMAND_SAVE_SERVICE_ACTION); + PendingIntent savePendingIntent = PendingIntent.getBroadcast(this, 0, saveIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + Intent contentIntent = new Intent(this, MapActivity.class); + PendingIntent contentPendingIntent = PendingIntent.getActivity(this, 0, contentIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + + final Builder notificationBuilder = new NotificationCompat.Builder( + this).setContentTitle(Version.getAppName(cl)) + .setContentText(getString(R.string.osmand_service)) + .setSmallIcon(R.drawable.bgs_icon) +// .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, getBaseContext())) + .setContentIntent(contentPendingIntent) + .setOngoing(true) + .addAction(R.drawable.ic_action_rec_stop, stop, stopPendingIntent) + .addAction(R.drawable.ic_action_save, pause, savePendingIntent); + startForeground(NOTIFICATION_SERVICE_ID, notificationBuilder.build()); } - + @Override public void onCreate() { super.onCreate(); // initializing variables } - - private boolean isContinuous(){ + + private boolean isContinuous() { return serviceOffInterval == 0; } - - + + @Override public void onDestroy() { super.onDestroy(); - ((OsmandApplication)getApplication()).setNavigationService(null); + ((OsmandApplication) getApplication()).setNavigationService(null); usedBy = 0; // remove updates LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.removeUpdates(this); - + if (!isContinuous()) { WakeLock lock = getLock(this); if (lock.isHeld()) { @@ -253,15 +279,19 @@ public class NavigationService extends Service implements LocationListener { unregisterReceiver(broadcastReceiver); broadcastReceiver = null; } + if (saveBroadcastReceiver != null) { + unregisterReceiver(saveBroadcastReceiver); + saveBroadcastReceiver = null; + } stopForeground(Boolean.TRUE); } @Override public void onLocationChanged(Location l) { - if(l != null && !settings.MAP_ACTIVITY_ENABLED.get()){ - net.osmand.Location location = OsmAndLocationProvider.convertLocation(l,(OsmandApplication) getApplication()); - if(!isContinuous()){ + if (l != null && !settings.MAP_ACTIVITY_ENABLED.get()) { + net.osmand.Location location = OsmAndLocationProvider.convertLocation(l, (OsmandApplication) getApplication()); + if (!isContinuous()) { // unregister listener and wait next time LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.removeUpdates(this); @@ -272,7 +302,7 @@ public class NavigationService extends Service implements LocationListener { } locationProvider.setLocationFromService(location, isContinuous()); } - + } @Override @@ -281,21 +311,19 @@ public class NavigationService extends Service implements LocationListener { } - @Override public void onProviderEnabled(String provider) { } - @Override public void onStatusChanged(String provider, int status, Bundle extras) { } - + @Override public void onTaskRemoved(Intent rootIntent) { - if (((OsmandApplication) getApplication()).getNavigationService() != null && - ((OsmandApplication) getApplication()).getSettings().DISABLE_RECORDING_ONCE_APP_KILLED.get()) { + if (((OsmandApplication) getApplication()).getNavigationService() != null && + ((OsmandApplication) getApplication()).getSettings().DISABLE_RECORDING_ONCE_APP_KILLED.get()) { OsMoPlugin plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); if (plugin != null) { if (plugin.getTracker().isEnabledTracker()) { @@ -305,6 +333,4 @@ public class NavigationService extends Service implements LocationListener { NavigationService.this.stopSelf(); } } - - } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 7eb2dc3c2d..c7739f4a15 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -1,47 +1,5 @@ package net.osmand.plus.myplaces; -import java.io.File; -import java.text.Collator; -import java.text.DateFormat; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import net.osmand.IndexConstants; -import net.osmand.access.AccessibleToast; -import net.osmand.plus.ContextMenuAdapter; -import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; -import net.osmand.plus.GPXUtilities; -import net.osmand.plus.GPXUtilities.GPXFile; -import net.osmand.plus.GPXUtilities.GPXTrackAnalysis; -import net.osmand.plus.GPXUtilities.WptPt; -import net.osmand.plus.GpxSelectionHelper; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.IconsCache; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.OsmandActionBarActivity; -import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; -import net.osmand.plus.activities.OsmandExpandableListFragment; -import net.osmand.plus.activities.SavingTrackHelper; -import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.dialogs.DirectionsDialogs; -import net.osmand.plus.download.LocalIndexesFragment; -import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.monitoring.OsmandMonitoringPlugin; -import net.osmand.plus.osmedit.OsmEditingPlugin; -import net.osmand.util.Algorithms; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; @@ -75,6 +33,49 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import net.osmand.IndexConstants; +import net.osmand.access.AccessibleToast; +import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; +import net.osmand.plus.GPXUtilities; +import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.GPXUtilities.GPXTrackAnalysis; +import net.osmand.plus.GPXUtilities.WptPt; +import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.OsmandActionBarActivity; +import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; +import net.osmand.plus.activities.OsmandExpandableListFragment; +import net.osmand.plus.activities.SavingTrackHelper; +import net.osmand.plus.activities.TrackActivity; +import net.osmand.plus.dialogs.DirectionsDialogs; +import net.osmand.plus.download.LocalIndexesFragment; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.osmedit.OsmEditingPlugin; +import net.osmand.util.Algorithms; + +import java.io.File; +import java.text.Collator; +import java.text.DateFormat; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + public class AvailableGPXFragment extends OsmandExpandableListFragment { public static final int SEARCH_ID = -1; @@ -115,7 +116,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { public void run() { if (getView() != null && updateEnable) { updateCurrentTrack(getView(), getActivity(), app); - if(selectedGpxHelper.getSelectedCurrentRecordingTrack() != null) { + if (selectedGpxHelper.getSelectedCurrentRecordingTrack() != null) { allGpxAdapter.notifyDataSetChanged(); } startHandler(); @@ -139,7 +140,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { allGpxAdapter.notifyDataSetChanged(); } updateCurrentTrack(); - + updateEnable = true; startHandler(); } @@ -152,14 +153,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { operationTask.cancel(true); } } - + public void updateCurrentTrack() { if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) { return; } updateCurrentTrack(getView(), getActivity(), app); final CheckBox checkbox = (CheckBox) getView().findViewById(R.id.check_local_index); - checkbox.setVisibility(selectionMode && showOnMapMode? View.VISIBLE : View.GONE); + checkbox.setVisibility(selectionMode && showOnMapMode ? View.VISIBLE : View.GONE); if (selectionMode && showOnMapMode) { checkbox.setChecked(selectedItems.contains(currentRecording)); checkbox.setOnClickListener(new View.OnClickListener() { @@ -187,7 +188,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get(); ImageButton stop = ((ImageButton) v.findViewById(R.id.stop)); - if(isRecording) { + if (isRecording) { stop.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_rec_stop)); } else { stop.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_rec_start, R.color.recording_color)); @@ -210,15 +211,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Runnable run = new Runnable() { - @Override - public void run() { - final OsmandMonitoringPlugin plugin = OsmandPlugin - .getEnabledPlugin(OsmandMonitoringPlugin.class); - plugin.saveCurrentTrack(); - } - }; - run.run(); + final OsmandMonitoringPlugin plugin = OsmandPlugin + .getEnabledPlugin(OsmandMonitoringPlugin.class); + plugin.saveCurrentTrack(); } }); if (sth.getPoints() > 0 || sth.getDistance() > 0) { @@ -265,11 +260,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { return v; } - + public static void openTrack(Activity a, final File f) { Intent newIntent = new Intent(a, ((OsmandApplication) a.getApplication()).getAppCustomization().getTrackActivity()); // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - if(f == null) { + if (f == null) { newIntent.putExtra(TrackActivity.CURRENT_RECORDING, true); } else { newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath()); @@ -435,7 +430,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { private void openShowOnMapMode() { enableSelectionMode(true); - showOnMapMode = true; + showOnMapMode = true; selectedItems.clear(); final Set originalSelectedItems = allGpxAdapter.getSelectedGpx(); selectedItems.addAll(originalSelectedItems); @@ -487,7 +482,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } public void openSelectionMode(final int actionResId, int darkIcon, int lightIcon, - final DialogInterface.OnClickListener listener) { + final DialogInterface.OnClickListener listener) { final int actionIconId = !isLightActionBar() ? darkIcon : lightIcon; String value = app.getString(actionResId); if (value.endsWith("...")) { @@ -617,7 +612,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { if (getActivity() != null) { ((OsmandActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(false); } - if (allGpxAdapter.getGroupCount() > 0 && + if (allGpxAdapter.getGroupCount() > 0 && allGpxAdapter.isShowingSelection()) { getExpandableListView().expandGroup(0); } @@ -643,7 +638,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } private void loadGPXFolder(File mapPath, List result, LoadGpxTask loadTask, List progress, - String gpxSubfolder) { + String gpxSubfolder) { for (File gpxFile : listFilesSorted(mapPath)) { if (gpxFile.isDirectory()) { String sub = gpxSubfolder.length() == 0 ? gpxFile.getName() : gpxSubfolder + "/" @@ -682,7 +677,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { public GpxIndexesAdapter(Context ctx) { warningColor = ctx.getResources().getColor(R.color.color_warning); - TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary }); + TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary}); defaultColor = ta.getColor(0, ctx.getResources().getColor(R.color.color_unknown)); ta.recycle(); } @@ -766,7 +761,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { @Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, - View convertView, ViewGroup parent) { + View convertView, ViewGroup parent) { View v = convertView; final GpxInfo child = getChild(groupPosition, childPosition); if (v == null) { @@ -816,9 +811,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { checkItem.setVisibility(View.GONE); } - + final boolean isChecked; - if(child.currentlyRecordingTrack) { + if (child.currentlyRecordingTrack) { isChecked = selectedGpxHelper.getSelectedCurrentRecordingTrack() != null; } else { final SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByName(child.getFileName()); @@ -896,7 +891,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { @Override public String getGroup(int groupPosition) { - if(isSelectedGroup(groupPosition)) { + if (isSelectedGroup(groupPosition)) { return app.getString(R.string.shared_string_selected); } return category.get(getGroupPosition(groupPosition)); @@ -1085,7 +1080,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { protected String doInBackground(GpxInfo... params) { for (GpxInfo info : params) { if (!isCancelled()) { - if(!info.currentlyRecordingTrack) { + if (!info.currentlyRecordingTrack) { info.setGpx(GPXUtilities.loadGPXFile(app, info.file)); } publishProgress(info); @@ -1183,7 +1178,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { if (!selectionMode) { Intent newIntent = new Intent(getActivity(), getMyApplication().getAppCustomization().getTrackActivity()); // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - if(item.currentlyRecordingTrack) { + if (item.currentlyRecordingTrack) { newIntent.putExtra(TrackActivity.CURRENT_RECORDING, true); } else { newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, item.file.getAbsolutePath()); @@ -1298,7 +1293,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } else { viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); } - SelectedGpxFile sgpx = child.currentlyRecordingTrack ? selectedGpxHelper.getSelectedCurrentRecordingTrack() : + SelectedGpxFile sgpx = child.currentlyRecordingTrack ? selectedGpxHelper.getSelectedCurrentRecordingTrack() : selectedGpxHelper.getSelectedFileByName(child.getFileName()); GPXTrackAnalysis analysis = null; if (sgpx != null) { @@ -1314,7 +1309,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { String size = ""; if (child.getSize() >= 0) { if (child.getSize() > 100) { - size = formatMb.format(new Object[] { (float) child.getSize() / (1 << 10) }); + size = formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)}); } else { size = child.getSize() + " kB"; } @@ -1346,14 +1341,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { // if (analysis.totalDistanceMoving != 0) { // distance.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistanceMoving, app)); // } else { - distance.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app)); + distance.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app)); // } if (analysis.isTimeSpecified()) { // if (analysis.isTimeMoving()) { // time.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000)) + ""); // } else { - time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000)) + ""); + time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000)) + ""); // } } else { time.setText("");