diff options
Diffstat (limited to 'main/src')
5 files changed, 29 insertions, 7 deletions
diff --git a/main/src/cgeo/geocaching/DirectionProvider.java b/main/src/cgeo/geocaching/DirectionProvider.java index c1f83ac..37b184a 100644 --- a/main/src/cgeo/geocaching/DirectionProvider.java +++ b/main/src/cgeo/geocaching/DirectionProvider.java @@ -14,7 +14,7 @@ public class DirectionProvider extends MemorySubject<Float> implements SensorEve private final SensorManager sensorManager; - // Previous values signaled to observers to avoid resending the same value when the + // Previous values signaled to observers to avoid re-sending the same value when the // device doesn't change orientation. The orientation is usually given with a 1 degree // precision by Android, so it is not uncommon to obtain exactly the same value several // times. @@ -27,7 +27,8 @@ public class DirectionProvider extends MemorySubject<Float> implements SensorEve @Override protected void onFirstObserver() { - sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); + final Sensor defaultSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); + sensorManager.registerListener(this, defaultSensor, SensorManager.SENSOR_DELAY_NORMAL); } @Override @@ -43,7 +44,7 @@ public class DirectionProvider extends MemorySubject<Float> implements SensorEve * this event leads to the log being flooded with multiple entries _per second_, * which I experienced when running cgeo in a building (with GPS and network being * unreliable). - * + * * See for example https://code.google.com/p/android/issues/detail?id=14792 */ diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java index a60b48d..6d5781f 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java @@ -19,7 +19,11 @@ public class AndroidLevel8Emulation implements AndroidLevel8Interface { @Override public int getRotationOffset(Activity activity) { final Display display = activity.getWindowManager().getDefaultDisplay(); + + // the non deprecated method is available in API 8+ only, so we cannot deal better with this + @SuppressWarnings("deprecation") final int rotation = display.getOrientation(); + if (rotation == Configuration.ORIENTATION_LANDSCAPE) { return 90; } diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index ea51375..97c4b7e 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -119,6 +119,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto private static final String BUNDLE_MAP_SOURCE = "mapSource"; private static final String BUNDLE_MAP_STATE = "mapState"; private static final String BUNDLE_LIVE_ENABLED = "liveEnabled"; + private static final String BUNDLE_TRAIL_HISTORY = "trailHistory"; private Resources res = null; private MapItemFactory mapItemFactory = null; @@ -343,6 +344,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto outState.putInt(BUNDLE_MAP_SOURCE, currentSourceId); outState.putIntArray(BUNDLE_MAP_STATE, currentMapState()); outState.putBoolean(BUNDLE_LIVE_ENABLED, isLiveEnabled); + if (overlayPosition != null) { + outState.putParcelableArrayList(BUNDLE_TRAIL_HISTORY, overlayPosition.getHistory()); + } } @Override @@ -380,11 +384,14 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto mapTitle = res.getString(R.string.map_map); } + ArrayList<Location> trailHistory = null; + // Get fresh map information from the bundle if any if (savedInstanceState != null) { currentSourceId = savedInstanceState.getInt(BUNDLE_MAP_SOURCE, Settings.getMapSource().getNumericalId()); mapStateIntent = savedInstanceState.getIntArray(BUNDLE_MAP_STATE); isLiveEnabled = savedInstanceState.getBoolean(BUNDLE_LIVE_ENABLED, false); + trailHistory = savedInstanceState.getParcelableArrayList(BUNDLE_TRAIL_HISTORY); } else { currentSourceId = Settings.getMapSource().getNumericalId(); } @@ -421,6 +428,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto if (overlayPosition == null) { overlayPosition = mapView.createAddPositionOverlay(activity); + if (trailHistory != null) { + overlayPosition.setHistory(trailHistory); + } } if (overlayScale == null) { diff --git a/main/src/cgeo/geocaching/maps/PositionOverlay.java b/main/src/cgeo/geocaching/maps/PositionOverlay.java index fec67ef..08acd2f 100644 --- a/main/src/cgeo/geocaching/maps/PositionOverlay.java +++ b/main/src/cgeo/geocaching/maps/PositionOverlay.java @@ -22,7 +22,6 @@ import android.graphics.Point; import android.location.Location; import java.util.ArrayList; -import java.util.List; public class PositionOverlay implements GeneralOverlay { private Location coordinates = null; @@ -39,7 +38,7 @@ public class PositionOverlay implements GeneralOverlay { private PaintFlagsDrawFilter setfil = null; private PaintFlagsDrawFilter remfil = null; private Location historyRecent = null; - private List<Location> history = new ArrayList<Location>(); + private ArrayList<Location> history = new ArrayList<Location>(); private Point historyPointN = new Point(); private Point historyPointP = new Point(); private Activity activity; @@ -229,4 +228,12 @@ public class PositionOverlay implements GeneralOverlay { public OverlayImpl getOverlayImpl() { return this.ovlImpl; } + + public ArrayList<Location> getHistory() { + return history; + } + + public void setHistory(ArrayList<Location> inHistory) { + history = inHistory; + } } diff --git a/main/src/cgeo/geocaching/utils/ClipboardUtils.java b/main/src/cgeo/geocaching/utils/ClipboardUtils.java index e6779ad..9343576 100644 --- a/main/src/cgeo/geocaching/utils/ClipboardUtils.java +++ b/main/src/cgeo/geocaching/utils/ClipboardUtils.java @@ -3,7 +3,6 @@ package cgeo.geocaching.utils; import cgeo.geocaching.cgeoapplication; import android.content.Context; -import android.text.ClipboardManager; /** * Clipboard Utilities. Functions to copy data to the Android clipboard. @@ -20,7 +19,8 @@ public final class ClipboardUtils { * The text to place in the clipboard. */ public static void copyToClipboard(final CharSequence text) { - final ClipboardManager clipboard = (ClipboardManager) cgeoapplication.getInstance().getSystemService(Context.CLIPBOARD_SERVICE); + // fully qualified name used here to avoid buggy deprecation warning (of javac) on the import statement + final android.text.ClipboardManager clipboard = (android.text.ClipboardManager) cgeoapplication.getInstance().getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(text); } |
