Merge pull request #6995 from osmandapp/TrackerImprovements
Tracker improvements
This commit is contained in:
commit
c600ddfe55
5 changed files with 41 additions and 24 deletions
|
@ -64,25 +64,30 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
if (usedBy and usageIntent > 0) {
|
if (usedBy and usageIntent > 0) {
|
||||||
usedBy -= usageIntent
|
usedBy -= usageIntent
|
||||||
}
|
}
|
||||||
if (usedBy == 0) {
|
when {
|
||||||
shouldCleanupResources = false
|
usedBy == 0 -> {
|
||||||
val serviceIntent = Intent(ctx, TelegramService::class.java)
|
shouldCleanupResources = false
|
||||||
ctx.stopService(serviceIntent)
|
val serviceIntent = Intent(ctx, TelegramService::class.java)
|
||||||
} else if (isUsedByMyLocation(usedBy)) {
|
ctx.stopService(serviceIntent)
|
||||||
val app = app()
|
|
||||||
if (app.settings.sendMyLocInterval >= OFF_INTERVAL_THRESHOLD && serviceOffInterval == 0L) {
|
|
||||||
serviceOffInterval = app.settings.sendMyLocInterval
|
|
||||||
setupServiceErrorInterval()
|
|
||||||
setupAlarm()
|
|
||||||
}
|
}
|
||||||
app.notificationHelper.refreshNotification(NotificationType.LOCATION)
|
isUsedByMyLocation(usedBy) -> {
|
||||||
|
val app = app()
|
||||||
|
if (app.settings.sendMyLocInterval >= OFF_INTERVAL_THRESHOLD && serviceOffInterval == 0L) {
|
||||||
|
serviceOffInterval = app.settings.sendMyLocInterval
|
||||||
|
setupServiceErrorInterval()
|
||||||
|
setupAlarm()
|
||||||
|
}
|
||||||
|
app.notificationHelper.refreshNotification(NotificationType.LOCATION)
|
||||||
|
}
|
||||||
|
isUsedByUsersLocations(usedBy) -> removeLocationUpdates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||||
val app = app()
|
val app = app()
|
||||||
handler = Handler()
|
handler = Handler()
|
||||||
usedBy = intent.getIntExtra(USAGE_INTENT, 0)
|
val usageIntent = intent.getIntExtra(USAGE_INTENT, 0)
|
||||||
|
usedBy = usageIntent or usedBy
|
||||||
|
|
||||||
serviceOffInterval = intent.getLongExtra(USAGE_OFF_INTERVAL, 0)
|
serviceOffInterval = intent.getLongExtra(USAGE_OFF_INTERVAL, 0)
|
||||||
sendLocationInterval = intent.getLongExtra(SEND_LOCATION_INTERVAL, 0)
|
sendLocationInterval = intent.getLongExtra(SEND_LOCATION_INTERVAL, 0)
|
||||||
|
@ -259,10 +264,8 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
Toast.makeText(this, getString(R.string.location_service_no_gps_available), Toast.LENGTH_LONG).show()
|
Toast.makeText(this, getString(R.string.location_service_no_gps_available), Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onProviderEnabled(provider: String) {}
|
override fun onProviderEnabled(provider: String) {}
|
||||||
|
|
||||||
|
|
||||||
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
|
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
|
||||||
|
|
||||||
override fun onTaskRemoved(rootIntent: Intent) {
|
override fun onTaskRemoved(rootIntent: Intent) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ private const val TIMELINE_TAB_POS = 2
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListener, TelegramIncomingMessagesListener {
|
class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListener, TelegramIncomingMessagesListener {
|
||||||
|
|
||||||
private val log = PlatformUtil.getLog(TelegramHelper::class.java)
|
private val log = PlatformUtil.getLog(MainActivity::class.java)
|
||||||
|
|
||||||
private var telegramAuthorizationRequestHandler: TelegramAuthorizationRequestHandler? = null
|
private var telegramAuthorizationRequestHandler: TelegramAuthorizationRequestHandler? = null
|
||||||
private var paused: Boolean = false
|
private var paused: Boolean = false
|
||||||
|
|
|
@ -981,6 +981,8 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e);
|
PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e);
|
||||||
}
|
}
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
|
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
|
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.send_report));
|
||||||
|
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(chooserIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.data.PointDescription;
|
|
||||||
import net.osmand.data.QuadRect;
|
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.data.QuadRect;
|
||||||
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
|
@ -447,7 +447,7 @@ public class TrackActivity extends TabActivity {
|
||||||
result = app.getSavingTrackHelper().getCurrentGpx();
|
result = app.getSavingTrackHelper().getCurrentGpx();
|
||||||
} else {
|
} else {
|
||||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath());
|
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath());
|
||||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null && selectedGpxFile.getGpxFile().modifiedTime == file.lastModified()) {
|
||||||
result = selectedGpxFile.getGpxFile();
|
result = selectedGpxFile.getGpxFile();
|
||||||
} else {
|
} else {
|
||||||
result = GPXUtilities.loadGPXFile(file);
|
result = GPXUtilities.loadGPXFile(file);
|
||||||
|
@ -472,8 +472,16 @@ public class TrackActivity extends TabActivity {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.setSupportProgressBarIndeterminateVisibility(false);
|
activity.setSupportProgressBarIndeterminateVisibility(false);
|
||||||
if (showTemporarily && result != null) {
|
if (result != null) {
|
||||||
app.getSelectedGpxHelper().selectGpxFile(result, false, false);
|
final GpxSelectionHelper helper = app.getSelectedGpxHelper();
|
||||||
|
if (showTemporarily) {
|
||||||
|
helper.selectGpxFile(result, false, false);
|
||||||
|
} else {
|
||||||
|
final SelectedGpxFile selectedGpx = helper.getSelectedFileByPath(result.path);
|
||||||
|
if (selectedGpx != null && result.error == null) {
|
||||||
|
selectedGpx.setGpxFile(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!activity.stopped) {
|
if (!activity.stopped) {
|
||||||
activity.onGPXFileReady(result);
|
activity.onGPXFileReady(result);
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
private Bitmap bigIconBg;
|
private Bitmap bigIconBg;
|
||||||
private Bitmap bigIconBgStale;
|
private Bitmap bigIconBgStale;
|
||||||
private Bitmap bigIconBgSelected;
|
private Bitmap bigIconBgSelected;
|
||||||
|
private Bitmap bigIconBgSelectedStale;
|
||||||
private Bitmap placeholder;
|
private Bitmap placeholder;
|
||||||
|
|
||||||
private int smallIconSize;
|
private int smallIconSize;
|
||||||
|
@ -112,6 +113,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
? R.drawable.map_pin_user_stale_location_night : R.drawable.map_pin_user_stale_location_day);
|
? R.drawable.map_pin_user_stale_location_night : R.drawable.map_pin_user_stale_location_day);
|
||||||
bigIconBgSelected = BitmapFactory.decodeResource(res, night
|
bigIconBgSelected = BitmapFactory.decodeResource(res, night
|
||||||
? R.drawable.map_pin_user_location_selected_night : R.drawable.map_pin_user_location_selected_day);
|
? R.drawable.map_pin_user_location_selected_night : R.drawable.map_pin_user_location_selected_day);
|
||||||
|
bigIconBgSelectedStale = BitmapFactory.decodeResource(res, night
|
||||||
|
? R.drawable.map_pin_user_stale_location_selected_night : R.drawable.map_pin_user_stale_location_selected_day);
|
||||||
placeholder = BitmapFactory.decodeResource(res, R.drawable.img_user_picture);
|
placeholder = BitmapFactory.decodeResource(res, R.drawable.img_user_picture);
|
||||||
|
|
||||||
smallIconSize = AndroidUtils.dpToPx(map, SMALL_ICON_SIZE_DP);
|
smallIconSize = AndroidUtils.dpToPx(map, SMALL_ICON_SIZE_DP);
|
||||||
|
@ -171,7 +174,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
image = placeholder;
|
image = placeholder;
|
||||||
}
|
}
|
||||||
if (selected) {
|
if (selected) {
|
||||||
drawBigIcon(canvas, x, y, image, bigIconBgSelected);
|
Bitmap bg = isStale(point) ? bigIconBgSelectedStale : bigIconBgSelected;
|
||||||
|
drawBigIcon(canvas, x, y, image, bg);
|
||||||
} else if (pointsType == PointsType.STANDARD) {
|
} else if (pointsType == PointsType.STANDARD) {
|
||||||
int radius = getRadiusPoi(tb);
|
int radius = getRadiusPoi(tb);
|
||||||
float density = tb.getDensity();
|
float density = tb.getDensity();
|
||||||
|
|
Loading…
Reference in a new issue