Setting for switching off Google play services.

This commit is contained in:
Dmitry Yunitsky 2014-11-29 10:30:10 +03:00 committed by Alex Zolotarev
parent 751822d526
commit d18143cc28
5 changed files with 23 additions and 4 deletions

View file

@ -6,6 +6,7 @@
<string name="pref_storage_activity" translatable="false">StorageActivity</string>
<string name="pref_yota" translatable="false">Yota</string>
<string name="pref_zoom_btns_enabled" translatable="false">ZoomButtonsEnabled</string>
<string name="pref_play_services" translatable="false">PlayServicesEnabled</string>
<string name="pref_about" translatable="false">AboutMapsWithMe</string>
<string name="pref_rate_app" translatable="false">RateApp</string>
<string name="pref_help" translatable="false">Help</string>

View file

@ -51,6 +51,12 @@
android:summary="@string/pref_zoom_summary"
android:title="@string/pref_zoom_title"/>
<CheckBoxPreference
android:key="@string/pref_play_services"
android:order="5"
android:summary="Use google play services for location"
android:title="Location"/>
<Preference
android:key="@string/pref_yota"
android:order="98"

View file

@ -1152,7 +1152,7 @@ public class MWMActivity extends NvEventQueueActivity
builder.setSpan(new AbsoluteSizeSpan(10, true), info.mDistToTarget.length(), builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mTvRoutingDistance.setText(builder);
builder.setSpan(new AbsoluteSizeSpan(25, true), 0, info.mDistToTarget.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new AbsoluteSizeSpan(15, true), info.mDistToTarget.length(), builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new AbsoluteSizeSpan(14, true), info.mDistToTarget.length(), builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mTvTotalDistance.setText(builder);
mIvTurn.setImageResource(getTurnImageResource(info));
if (LocationState.RoutingInfo.TurnDirection.isLeftTurn(info.mTurnDirection))
@ -1162,8 +1162,8 @@ public class MWMActivity extends NvEventQueueActivity
mTvTotalTime.setText(DateUtils.formatElapsedTime(info.mTotalTimeInSeconds));
builder = new SpannableStringBuilder(info.mDistToTurn).append(" ").append(info.mTurnUnitsSuffix.toUpperCase());
builder.setSpan(new AbsoluteSizeSpan(40, true), 0, info.mDistToTurn.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new AbsoluteSizeSpan(15, true), info.mDistToTurn.length(), builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new AbsoluteSizeSpan(44, true), 0, info.mDistToTurn.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new AbsoluteSizeSpan(11, true), info.mDistToTurn.length(), builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mTvTurnDistance.setText(builder);
}
}

View file

@ -11,6 +11,7 @@ import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.TextUtils;
@ -20,6 +21,7 @@ import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationRequest;
import com.mapswithme.maps.MWMApplication;
import com.mapswithme.maps.R;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.LocationUtils;
import com.mapswithme.util.log.Logger;
@ -118,8 +120,10 @@ public enum LocationService implements
}
}
final MWMApplication application = MWMApplication.get();
if (isLocationTurnedOn &&
GooglePlayServicesUtil.isGooglePlayServicesAvailable(MWMApplication.get().get()) == ConnectionResult.SUCCESS)
GooglePlayServicesUtil.isGooglePlayServicesAvailable(application) == ConnectionResult.SUCCESS &&
PreferenceManager.getDefaultSharedPreferences(application).getBoolean(application.getString(R.string.pref_play_services), false))
{
mLogger.d("Use fused provider.");
mLocationProvider = new GoogleFusedLocationProvider();

View file

@ -26,6 +26,8 @@ import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MWMApplication;
import com.mapswithme.maps.R;
@ -81,6 +83,12 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
enableZoomButtons.setChecked(MWMApplication.get().nativeGetBoolean(ZOOM_BUTTON_ENABLED, true));
enableZoomButtons.setOnPreferenceChangeListener(this);
if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(MWMApplication.get()) != ConnectionResult.SUCCESS)
{
((PreferenceScreen) findPreference(getString(R.string.pref_settings))).
removePreference(findPreference(getString(R.string.pref_play_services)));
}
findPreference(getString(R.string.pref_about)).setOnPreferenceClickListener(this);
findPreference(getString(R.string.pref_rate_app)).setOnPreferenceClickListener(this);
findPreference(getString(R.string.pref_contact)).setOnPreferenceClickListener(this);