aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2015-05-08 18:52:27 +0200
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2015-10-11 23:56:39 +0200
commitd084c567262e1fb9a43e79aa25d4a08f80a0dd8b (patch)
tree60bffa9453840b48a11b11ef999fe9c9c7d83557 /main
parent8ff62c5f34db48aa15c7252c40fea3381bba0952 (diff)
downloadcgeo-d084c567262e1fb9a43e79aa25d4a08f80a0dd8b.zip
cgeo-d084c567262e1fb9a43e79aa25d4a08f80a0dd8b.tar.gz
cgeo-d084c567262e1fb9a43e79aa25d4a08f80a0dd8b.tar.bz2
remove play services first round
Diffstat (limited to 'main')
-rw-r--r--main/AndroidManifest.xml6
-rw-r--r--main/project.properties2
-rw-r--r--main/src/cgeo/geocaching/CgeoApplication.java3
-rw-r--r--main/src/cgeo/geocaching/playservices/LocationProvider.java160
-rw-r--r--main/src/cgeo/geocaching/sensors/Sensors.java1
-rw-r--r--main/src/cgeo/geocaching/settings/Settings.java118
6 files changed, 30 insertions, 260 deletions
diff --git a/main/AndroidManifest.xml b/main/AndroidManifest.xml
index 372e4b9..f0677b9 100644
--- a/main/AndroidManifest.xml
+++ b/main/AndroidManifest.xml
@@ -41,9 +41,6 @@
android:label="@string/app_name"
android:theme="@style/cgeo"
android:hardwareAccelerated="false">
- <uses-library
- android:name="com.google.android.maps"
- android:required="false" />
<!-- Samsung Multi-Window support -->
<uses-library
@@ -65,9 +62,6 @@
<meta-data
android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAIsvD_aUSDMwWOf9NkwwxZ4kJJI_AG2EaxjSu2jw" />
- <meta-data
- android:name="com.google.android.gms.version"
- android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
diff --git a/main/project.properties b/main/project.properties
index 600d70f..2ce3c6d 100644
--- a/main/project.properties
+++ b/main/project.properties
@@ -17,5 +17,3 @@ android.library.reference.2=../android-support-v7-appcompat
android.library.reference.3=../showcaseview
java.source=1.7
java.target=1.7
-android.library.reference.4=../play-services-base
-android.library.reference.5=../play-services-location
diff --git a/main/src/cgeo/geocaching/CgeoApplication.java b/main/src/cgeo/geocaching/CgeoApplication.java
index d74acea..847b520 100644
--- a/main/src/cgeo/geocaching/CgeoApplication.java
+++ b/main/src/cgeo/geocaching/CgeoApplication.java
@@ -6,9 +6,6 @@ import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.OOMDumpingUncaughtExceptionHandler;
import cgeo.geocaching.utils.RxUtils;
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.GooglePlayServicesUtil;
-
import org.eclipse.jdt.annotation.NonNull;
import android.app.Application;
diff --git a/main/src/cgeo/geocaching/playservices/LocationProvider.java b/main/src/cgeo/geocaching/playservices/LocationProvider.java
deleted file mode 100644
index 027ae29..0000000
--- a/main/src/cgeo/geocaching/playservices/LocationProvider.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package cgeo.geocaching.playservices;
-
-import cgeo.geocaching.sensors.GeoData;
-import cgeo.geocaching.settings.Settings;
-import cgeo.geocaching.utils.Log;
-import cgeo.geocaching.utils.RxUtils;
-
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.location.LocationListener;
-import com.google.android.gms.location.LocationRequest;
-import com.google.android.gms.location.LocationServices;
-
-import rx.Observable;
-import rx.Observable.OnSubscribe;
-import rx.Subscriber;
-import rx.functions.Action0;
-import rx.functions.Func1;
-import rx.observers.Subscribers;
-import rx.subjects.ReplaySubject;
-import rx.subscriptions.Subscriptions;
-
-import android.content.Context;
-import android.location.Location;
-import android.os.Bundle;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class LocationProvider implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
-
- private static final LocationRequest LOCATION_REQUEST =
- LocationRequest.create().setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(2000).setFastestInterval(250);
- private static final LocationRequest LOCATION_REQUEST_LOW_POWER =
- LocationRequest.create().setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY).setInterval(10000).setFastestInterval(5000);
- private static final AtomicInteger mostPreciseCount = new AtomicInteger(0);
- private static final AtomicInteger lowPowerCount = new AtomicInteger(0);
- private static LocationProvider instance = null;
- private static final ReplaySubject<GeoData> subject = ReplaySubject.createWithSize(1);
- private final GoogleApiClient locationClient;
-
- private static synchronized LocationProvider getInstance(final Context context) {
- if (instance == null) {
- instance = new LocationProvider(context);
- }
- return instance;
- }
-
- private synchronized void updateRequest() {
- if (locationClient.isConnected()) {
- if (mostPreciseCount.get() > 0) {
- Log.d("LocationProvider: requesting most precise locations");
- LocationServices.FusedLocationApi.requestLocationUpdates(locationClient, LOCATION_REQUEST, this, RxUtils.looperCallbacksLooper);
- } else if (lowPowerCount.get() > 0) {
- Log.d("LocationProvider: requesting low-power locations");
- LocationServices.FusedLocationApi.requestLocationUpdates(locationClient, LOCATION_REQUEST_LOW_POWER, this, RxUtils.looperCallbacksLooper);
- } else {
- Log.d("LocationProvider: stopping location requests");
- LocationServices.FusedLocationApi.removeLocationUpdates(locationClient, this);
- }
- }
- }
-
- private static Observable<GeoData> get(final Context context, final AtomicInteger reference) {
- final LocationProvider instance = getInstance(context);
- return Observable.create(new OnSubscribe<GeoData>() {
- @Override
- public void call(final Subscriber<? super GeoData> subscriber) {
- if (reference.incrementAndGet() == 1) {
- instance.updateRequest();
- }
- subscriber.add(Subscriptions.create(new Action0() {
- @Override
- public void call() {
- RxUtils.looperCallbacksWorker.schedule(new Action0() {
- @Override
- public void call() {
- if (reference.decrementAndGet() == 0) {
- instance.updateRequest();
- }
- }
- }, 2500, TimeUnit.MILLISECONDS);
- }
- }));
- subscriber.add(subject.subscribe(Subscribers.from(subscriber)));
- }
- });
- }
-
- public static Observable<GeoData> getMostPrecise(final Context context) {
- return get(context, mostPreciseCount).onBackpressureDrop();
- }
-
- public static Observable<GeoData> getLowPower(final Context context) {
- // Low-power location without the last stored location
- final Observable<GeoData> lowPowerObservable = get(context, lowPowerCount).skip(1);
-
- // High-power location without the last stored location
- final Observable<GeoData> highPowerObservable = get(context, mostPreciseCount).skip(1);
-
- // Use either low-power (with a 6 seconds head start) or high-power observables to obtain a location
- // no less precise than 20 meters.
- final Observable<GeoData> untilPreciseEnoughObservable =
- lowPowerObservable.mergeWith(highPowerObservable.delaySubscription(6, TimeUnit.SECONDS))
- .takeUntil(new Func1<GeoData, Boolean>() {
- @Override
- public Boolean call(final GeoData geoData) {
- return geoData.getAccuracy() <= 20;
- }
- });
-
- // After sending the last known location, try to get a precise location then use the low-power mode. If no
- // location information is given for 25 seconds (if the network location is turned off for example), get
- // back to the precise location and try again.
- return subject.first().concatWith(untilPreciseEnoughObservable.concatWith(lowPowerObservable).timeout(25, TimeUnit.SECONDS).retry()).onBackpressureDrop();
- }
-
- /**
- * Build a new geo data provider object.
- * <p/>
- * There is no need to instantiate more than one such object in an application, as observers can be added
- * at will.
- *
- * @param context the context used to retrieve the system services
- */
- private LocationProvider(final Context context) {
- final GeoData initialLocation = GeoData.getInitialLocation(context);
- subject.onNext(initialLocation != null ? initialLocation : GeoData.DUMMY_LOCATION);
- locationClient = new GoogleApiClient.Builder(context)
- .addApi(LocationServices.API)
- .addConnectionCallbacks(this)
- .addOnConnectionFailedListener(this)
- .build();
- locationClient.connect();
- }
-
- @Override
- public void onConnected(final Bundle bundle) {
- updateRequest();
- }
-
- @Override
- public void onConnectionFailed(final ConnectionResult connectionResult) {
- Log.e("cannot connect to Google Play location service: " + connectionResult);
- subject.onError(new RuntimeException("Connection failed: " + connectionResult));
- }
-
- @Override
- public void onLocationChanged(final Location location) {
- if (Settings.useLowPowerMode()) {
- location.setProvider(GeoData.LOW_POWER_PROVIDER);
- }
- subject.onNext(new GeoData(location));
- }
-
- @Override
- public void onConnectionSuspended(final int arg0) {
- // empty
- }
-}
diff --git a/main/src/cgeo/geocaching/sensors/Sensors.java b/main/src/cgeo/geocaching/sensors/Sensors.java
index c3f6ce7..6dc0ec2 100644
--- a/main/src/cgeo/geocaching/sensors/Sensors.java
+++ b/main/src/cgeo/geocaching/sensors/Sensors.java
@@ -1,7 +1,6 @@
package cgeo.geocaching.sensors;
import cgeo.geocaching.CgeoApplication;
-import cgeo.geocaching.playservices.LocationProvider;
import cgeo.geocaching.sensors.GpsStatusProvider.Status;
import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.utils.AngleUtils;
diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java
index c15bc1b..3e05efa 100644
--- a/main/src/cgeo/geocaching/settings/Settings.java
+++ b/main/src/cgeo/geocaching/settings/Settings.java
@@ -12,7 +12,7 @@ import cgeo.geocaching.list.StoredList;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.CGeoMap.MapMode;
import cgeo.geocaching.maps.MapProviderFactory;
-//import cgeo.geocaching.maps.google.v1.GoogleMapProvider;
+import cgeo.geocaching.maps.LivemapStrategy;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
import cgeo.geocaching.maps.interfaces.MapProvider;
import cgeo.geocaching.maps.interfaces.MapSource;
@@ -57,7 +57,7 @@ public class Settings {
private static final char HISTORY_SEPARATOR = ',';
public static final int SHOW_WP_THRESHOLD_DEFAULT = 10;
public static final int SHOW_WP_THRESHOLD_MAX = 50;
-// private static final int MAP_SOURCE_DEFAULT = GoogleMapProvider.GOOGLE_MAP_ID.hashCode();
+ private static final int MAP_SOURCE_DEFAULT = GoogleMapProvider.GOOGLE_MAP_ID.hashCode();
public static final boolean HW_ACCEL_DISABLED_BY_DEFAULT =
Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 ||
@@ -136,63 +136,6 @@ public class Settings {
// migrate from non standard file location and integer based boolean types
final Editor e = sharedPrefs.edit();
-<<<<<<< HEAD
- e.putString(getKey(R.string.pref_temp_twitter_token_secret), old.getString(getKey(R.string.pref_temp_twitter_token_secret), null));
- e.putString(getKey(R.string.pref_temp_twitter_token_public), old.getString(getKey(R.string.pref_temp_twitter_token_public), null));
- e.putBoolean(getKey(R.string.pref_help_shown), old.getInt(getKey(R.string.pref_help_shown), 0) != 0);
- e.putFloat(getKey(R.string.pref_anylongitude), old.getFloat(getKey(R.string.pref_anylongitude), 0));
- e.putFloat(getKey(R.string.pref_anylatitude), old.getFloat(getKey(R.string.pref_anylatitude), 0));
- e.putBoolean(getKey(R.string.pref_offlinemaps), 0 != old.getInt(getKey(R.string.pref_offlinemaps), 1));
- e.putBoolean(getKey(R.string.pref_offlinewpmaps), 0 != old.getInt(getKey(R.string.pref_offlinewpmaps), 0));
- e.putString(getKey(R.string.pref_webDeviceCode), old.getString(getKey(R.string.pref_webDeviceCode), null));
- e.putString(getKey(R.string.pref_webDeviceName), old.getString(getKey(R.string.pref_webDeviceName), null));
- e.putBoolean(getKey(R.string.pref_maplive), old.getInt(getKey(R.string.pref_maplive), 1) != 0);
-// e.putInt(getKey(R.string.pref_mapsource), old.getInt(getKey(R.string.pref_mapsource), MAP_SOURCE_DEFAULT));
- e.putBoolean(getKey(R.string.pref_twitter), 0 != old.getInt(getKey(R.string.pref_twitter), 0));
- e.putBoolean(getKey(R.string.pref_showaddress), 0 != old.getInt(getKey(R.string.pref_showaddress), 1));
- e.putBoolean(getKey(R.string.pref_showcaptcha), old.getBoolean(getKey(R.string.pref_showcaptcha), false));
- e.putBoolean(getKey(R.string.pref_maptrail), old.getInt(getKey(R.string.pref_maptrail), 1) != 0);
- e.putInt(getKey(R.string.pref_lastmapzoom), old.getInt(getKey(R.string.pref_lastmapzoom), 14));
- e.putBoolean(getKey(R.string.pref_livelist), 0 != old.getInt(getKey(R.string.pref_livelist), 1));
- e.putBoolean(getKey(R.string.pref_units), old.getInt(getKey(R.string.pref_units), unitsMetric) == unitsMetric);
- e.putBoolean(getKey(R.string.pref_skin), old.getInt(getKey(R.string.pref_skin), 0) != 0);
- e.putInt(getKey(R.string.pref_lastusedlist), old.getInt(getKey(R.string.pref_lastusedlist), StoredList.STANDARD_LIST_ID));
- e.putString(getKey(R.string.pref_cachetype), old.getString(getKey(R.string.pref_cachetype), CacheType.ALL.id));
- e.putString(getKey(R.string.pref_twitter_token_secret), old.getString(getKey(R.string.pref_twitter_token_secret), null));
- e.putString(getKey(R.string.pref_twitter_token_public), old.getString(getKey(R.string.pref_twitter_token_public), null));
- e.putInt(getKey(R.string.pref_version), old.getInt(getKey(R.string.pref_version), 0));
- e.putBoolean(getKey(R.string.pref_autoloaddesc), 0 != old.getInt(getKey(R.string.pref_autoloaddesc), 1));
- e.putBoolean(getKey(R.string.pref_ratingwanted), old.getBoolean(getKey(R.string.pref_ratingwanted), true));
- e.putBoolean(getKey(R.string.pref_friendlogswanted), old.getBoolean(getKey(R.string.pref_friendlogswanted), true));
- e.putBoolean(getKey(R.string.pref_useenglish), old.getBoolean(getKey(R.string.pref_useenglish), false));
- e.putBoolean(getKey(R.string.pref_usecompass), 0 != old.getInt(getKey(R.string.pref_usecompass), 1));
- e.putBoolean(getKey(R.string.pref_trackautovisit), old.getBoolean(getKey(R.string.pref_trackautovisit), false));
- e.putBoolean(getKey(R.string.pref_sigautoinsert), old.getBoolean(getKey(R.string.pref_sigautoinsert), false));
- e.putBoolean(getKey(R.string.pref_logimages), old.getBoolean(getKey(R.string.pref_logimages), false));
- e.putBoolean(getKey(R.string.pref_excludedisabled), 0 != old.getInt(getKey(R.string.pref_excludedisabled), 0));
- e.putBoolean(getKey(R.string.pref_excludemine), 0 != old.getInt(getKey(R.string.pref_excludemine), 0));
- e.putString(getKey(R.string.pref_mapfile), old.getString(getKey(R.string.pref_mapfile), null));
- e.putString(getKey(R.string.pref_signature), old.getString(getKey(R.string.pref_signature), null));
- e.putString(getKey(R.string.pref_pass_vote), old.getString(getKey(R.string.pref_pass_vote), null));
- e.putString(getKey(R.string.pref_password), old.getString(getKey(R.string.pref_password), null));
- e.putString(getKey(R.string.pref_username), old.getString(getKey(R.string.pref_username), null));
- e.putString(getKey(R.string.pref_memberstatus), old.getString(getKey(R.string.pref_memberstatus), ""));
- e.putInt(getKey(R.string.pref_coordinputformat), old.getInt(getKey(R.string.pref_coordinputformat), CoordInputFormatEnum.DEFAULT_INT_VALUE));
- e.putBoolean(getKey(R.string.pref_log_offline), old.getBoolean(getKey(R.string.pref_log_offline), false));
- e.putBoolean(getKey(R.string.pref_choose_list), old.getBoolean(getKey(R.string.pref_choose_list), true));
- e.putBoolean(getKey(R.string.pref_loaddirectionimg), old.getBoolean(getKey(R.string.pref_loaddirectionimg), true));
- e.putString(getKey(R.string.pref_gccustomdate), old.getString(getKey(R.string.pref_gccustomdate), null));
- e.putInt(getKey(R.string.pref_showwaypointsthreshold), old.getInt(getKey(R.string.pref_showwaypointsthreshold), SHOW_WP_THRESHOLD_DEFAULT));
- e.putString(getKey(R.string.pref_cookiestore), old.getString(getKey(R.string.pref_cookiestore), null));
- e.putBoolean(getKey(R.string.pref_opendetailslastpage), old.getBoolean(getKey(R.string.pref_opendetailslastpage), false));
- e.putInt(getKey(R.string.pref_lastdetailspage), old.getInt(getKey(R.string.pref_lastdetailspage), 1));
- e.putInt(getKey(R.string.pref_defaultNavigationTool), old.getInt(getKey(R.string.pref_defaultNavigationTool), NavigationAppsEnum.COMPASS.id));
- e.putInt(getKey(R.string.pref_defaultNavigationTool2), old.getInt(getKey(R.string.pref_defaultNavigationTool2), NavigationAppsEnum.INTERNAL_MAP.id));
- e.putInt(getKey(R.string.pref_livemapstrategy), old.getInt(getKey(R.string.pref_livemapstrategy), Strategy.AUTO.id));
- e.putBoolean(getKey(R.string.pref_debug), old.getBoolean(getKey(R.string.pref_debug), false));
- e.putBoolean(getKey(R.string.pref_hidelivemaphint), old.getInt(getKey(R.string.pref_hidelivemaphint), 0) != 0);
- e.putInt(getKey(R.string.pref_livemaphintshowcount), old.getInt(getKey(R.string.pref_livemaphintshowcount), 0));
-=======
e.putString(getKey(R.string.pref_temp_twitter_token_secret), prefsV0.getString(getKey(R.string.pref_temp_twitter_token_secret), null));
e.putString(getKey(R.string.pref_temp_twitter_token_public), prefsV0.getString(getKey(R.string.pref_temp_twitter_token_public), null));
e.putBoolean(getKey(R.string.pref_help_shown), prefsV0.getInt(getKey(R.string.pref_help_shown), 0) != 0);
@@ -247,7 +190,6 @@ public class Settings {
e.putInt(getKey(R.string.pref_livemapstrategy), prefsV0.getInt(getKey(R.string.pref_livemapstrategy), LivemapStrategy.AUTO.id));
e.putBoolean(getKey(R.string.pref_debug), prefsV0.getBoolean(getKey(R.string.pref_debug), false));
e.putInt(getKey(R.string.pref_livemaphintshowcount), prefsV0.getInt(getKey(R.string.pref_livemaphintshowcount), 0));
->>>>>>> 59b8b2e26a7fff6072c4d5d96f51035dc900e0bc
e.putInt(getKey(R.string.pref_settingsversion), 1); // mark migrated
e.apply();
@@ -269,9 +211,9 @@ public class Settings {
e.putInt(getKey(R.string.pref_showwaypointsthreshold), wpThreshold);
// KEY_MAP_SOURCE must be string, because it is the key for a ListPreference now
-// final int ms = sharedPrefs.getInt(getKey(R.string.pref_mapsource), MAP_SOURCE_DEFAULT);
+ final int ms = sharedPrefs.getInt(getKey(R.string.pref_mapsource), MAP_SOURCE_DEFAULT);
e.remove(getKey(R.string.pref_mapsource));
-// e.putString(getKey(R.string.pref_mapsource), String.valueOf(ms));
+ e.putString(getKey(R.string.pref_mapsource), String.valueOf(ms));
// navigation tool ids must be string, because ListPreference uses strings as keys
final int dnt1 = sharedPrefs.getInt(getKey(R.string.pref_defaultNavigationTool), NavigationAppsEnum.COMPASS.id);
@@ -749,8 +691,8 @@ public class Settings {
if (mapSource != null) {
return mapSource;
}
-// final int id = getConvertedMapId();
-// mapSource = MapProviderFactory.getMapSource(id);
+ final int id = getConvertedMapId();
+ mapSource = MapProviderFactory.getMapSource(id);
if (mapSource != null) {
// don't use offline maps if the map file is not valid
if (!(mapSource instanceof OfflineMapSource) || isValidMapFile()) {
@@ -774,30 +716,30 @@ public class Settings {
/**
* Convert old preference ids for maps (based on constant values) into new hash based ids.
*/
-// private static int getConvertedMapId() {
-// final int id = Integer.parseInt(getString(R.string.pref_mapsource,
-// String.valueOf(MAP_SOURCE_DEFAULT)));
-// switch (id) {
-// case GOOGLEMAP_BASEID + MAP:
-// return GoogleMapProvider.GOOGLE_MAP_ID.hashCode();
-// case GOOGLEMAP_BASEID + SATELLITE:
-// return GoogleMapProvider.GOOGLE_SATELLITE_ID.hashCode();
-// case MFMAP_BASEID + MAPNIK:
-// return MapsforgeMapProvider.MAPSFORGE_MAPNIK_ID.hashCode();
-// case MFMAP_BASEID + CYCLEMAP:
-// return MapsforgeMapProvider.MAPSFORGE_CYCLEMAP_ID.hashCode();
-// case MFMAP_BASEID + OFFLINE: {
-// final String mapFile = Settings.getMapFile();
-// if (StringUtils.isNotEmpty(mapFile)) {
-// return mapFile.hashCode();
-// }
-// break;
-// }
-// default:
-// break;
-// }
-// return id;
-// }
+ private static int getConvertedMapId() {
+ final int id = Integer.parseInt(getString(R.string.pref_mapsource,
+ String.valueOf(MAP_SOURCE_DEFAULT)));
+ switch (id) {
+ case GOOGLEMAP_BASEID + MAP:
+ return GoogleMapProvider.GOOGLE_MAP_ID.hashCode();
+ case GOOGLEMAP_BASEID + SATELLITE:
+ return GoogleMapProvider.GOOGLE_SATELLITE_ID.hashCode();
+ case MFMAP_BASEID + MAPNIK:
+ return MapsforgeMapProvider.MAPSFORGE_MAPNIK_ID.hashCode();
+ case MFMAP_BASEID + CYCLEMAP:
+ return MapsforgeMapProvider.MAPSFORGE_CYCLEMAP_ID.hashCode();
+ case MFMAP_BASEID + OFFLINE: {
+ final String mapFile = Settings.getMapFile();
+ if (StringUtils.isNotEmpty(mapFile)) {
+ return mapFile.hashCode();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return id;
+ }
public static synchronized void setMapSource(final MapSource newMapSource) {
putString(R.string.pref_mapsource, String.valueOf(newMapSource.getNumericalId()));