From 9cce6c2fcfbd01c0f741b40ce66ed34736d33995 Mon Sep 17 00:00:00 2001 From: cretin45 Date: Tue, 10 Feb 2015 16:51:28 -0800 Subject: [PATCH] SetupWizard: Make location page dynamic based on GMS Change-Id: Ia30791882f049cef632281f21f2d7653536d5818 --- res/layout/location_settings.xml | 16 +------ res/values/strings.xml | 10 ++-- .../setupwizard/setup/OtherSettingsPage.java | 47 ++++++++++++++++++- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/res/layout/location_settings.xml b/res/layout/location_settings.xml index 7da919f..07142e3 100644 --- a/res/layout/location_settings.xml +++ b/res/layout/location_settings.xml @@ -36,16 +36,14 @@ android:layout_height="match_parent" style="@style/PageContent"> - + style="@style/PageSummaryText" /> - - Set your time zone and adjust current date and time if needed - Back up my data - Back up app data, Wi-Fi passwords, and other settings to Google servers + Back up app data, Wi-Fi passwords, and other settings to Google servers - Location services allows Maps and other apps to gather and use data such as your approximate location. For example, Maps may use your approximate location to locate nearby coffee shops. + These services put Google to work you, and you can turn them on or off at any time. Data will be used in accordance with Google\'s %s. + Location services allows system and third party apps to gather and use data such as your approximate location. For example, an app may use your approximate location to locate nearby coffee shops. Allow apps that have asked your permission to use your location information. This may include your current location and past locations. Improve location accuracy by allowing apps to use the GPS on your tablet. Improve location accuracy by allowing apps to use the GPS on your phone. - Use Google\'s location service to help apps determine your location. This means sending annonymous location data to Google, even when no apps are running. + Use Wi-Fi to help apps determine your location. + Use Wi-Fi and mobile networks to help apps determine your location. + Use Google\'s location service to help apps determine your location. This means sending anonymous location data to Google, even when no apps are running. Turn on mobile data No service diff --git a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java index 7d72fdc..9f85aea 100644 --- a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java @@ -28,11 +28,18 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; import android.view.View; import android.widget.CheckBox; +import android.widget.TextView; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.WebViewDialogFragment; +import com.cyanogenmod.setupwizard.util.SetupWizardUtils; import java.util.Observable; import java.util.Observer; @@ -41,6 +48,8 @@ public class OtherSettingsPage extends SetupPage { private static final String TAG = "OtherSettingsPage"; + private static final String PRIVACY_POLICY_URI = "https://www.google.com/intl/en/policies/privacy/?fg=1"; + public OtherSettingsPage(Context context, SetupDataCallbacks callbacks) { super(context, callbacks); } @@ -65,7 +74,11 @@ public class OtherSettingsPage extends SetupPage { @Override public int getTitleResId() { - return R.string.setup_other; + if (SetupWizardUtils.hasGMS(mContext)) { + return R.string.setup_other; + } else { + return R.string.setup_location; + } } public static class OtherSettingsFragment extends SetupPageFragment { @@ -131,8 +144,32 @@ public class OtherSettingsPage extends SetupPage { @Override protected void initializePage() { + final boolean hasGms = SetupWizardUtils.hasGMS(getActivity()); + final boolean hasTelephony = SetupWizardUtils.hasTelephony(getActivity()); + TextView summaryView = (TextView) mRootView.findViewById(android.R.id.summary); + if (hasGms) { + String privacy_policy = getString(R.string.services_privacy_policy); + String otherSummary = getString(R.string.other_services_summary, privacy_policy); + SpannableString ss = new SpannableString(otherSummary); + ClickableSpan clickableSpan = new ClickableSpan() { + @Override + public void onClick(View textView) { + WebViewDialogFragment.newInstance() + .setUri(PRIVACY_POLICY_URI) + .show(getActivity().getFragmentManager(), WebViewDialogFragment.TAG); + } + }; + ss.setSpan(clickableSpan, + otherSummary.length() - privacy_policy.length() - 1, + otherSummary.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + summaryView.setMovementMethod(LinkMovementMethod.getInstance()); + summaryView.setText(ss); + } else { + summaryView.setText(R.string.location_services_summary); + } mBackupRow = mRootView.findViewById(R.id.backup); mBackupRow.setOnClickListener(mBackupClickListener); + mBackupRow.setVisibility(hasGms ? View.VISIBLE : View.GONE); mBackup = (CheckBox) mRootView.findViewById(R.id.backup_checkbox); mLocationRow = mRootView.findViewById(R.id.location); mLocationRow.setOnClickListener(mLocationClickListener); @@ -143,6 +180,14 @@ public class OtherSettingsPage extends SetupPage { mNetworkRow = mRootView.findViewById(R.id.network); mNetworkRow.setOnClickListener(mNetworkClickListener); mNetwork = (CheckBox) mRootView.findViewById(R.id.network_checkbox); + TextView networkSummary = (TextView) mRootView.findViewById(R.id.network_summary); + if (hasGms) { + networkSummary.setText(R.string.location_network_gms); + } else if (hasTelephony) { + networkSummary.setText(R.string.location_network_telephony); + } else { + networkSummary.setText(R.string.location_network); + } } @Override