SetupWizard: Make location page dynamic based on GMS

Change-Id: Ia30791882f049cef632281f21f2d7653536d5818
This commit is contained in:
cretin45 2015-02-10 16:51:28 -08:00
parent 6ea46dd6d8
commit 9cce6c2fcf
3 changed files with 54 additions and 19 deletions

View File

@ -36,16 +36,14 @@
android:layout_height="match_parent"
style="@style/PageContent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:layout_marginBottom="@dimen/summary_margin_bottom"
android:paddingLeft="@dimen/content_margin_left"
android:paddingRight="@dimen/content_margin_right"
style="@style/PageSummaryText"
android:text="@string/backup_data_title" />
style="@style/PageSummaryText" />
<LinearLayout
android:id="@+id/backup"
@ -83,16 +81,6 @@
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_marginBottom="@dimen/summary_margin_bottom"
android:paddingLeft="@dimen/content_margin_left"
android:paddingRight="@dimen/content_margin_right"
style="@style/PageSummaryText"
android:text="@string/location_services_summary" />
<LinearLayout
android:id="@+id/location"
android:orientation="horizontal"

View File

@ -45,14 +45,16 @@
<string name="date_time_summary">Set your time zone and adjust current date and time if needed</string>
<string name="backup_data_title">Back up my data</string>
<string name="backup_data_summary">Back up app data, Wi-Fi passwords, and other settings to Google servers</string>
<string name="backup_data_summary"><b>Back up</b> app data, Wi-Fi passwords, and other settings to Google servers</string>
<string name="location_services_summary">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.</string>
<string name="other_services_summary">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 <xliff:g id="name" example="Privacy Policy">%s</xliff:g>.</string>
<string name="location_services_summary">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.</string>
<string name="location_access_summary"><b>Allow apps that have asked your permission</b> to use your location information. This may include your current location and past locations.</string>
<string name="location_gps" product="tablet"><b>Improve location accuracy</b> by allowing apps to use the GPS on your tablet.</string>
<string name="location_gps" product="default"><b>Improve location accuracy</b> by allowing apps to use the GPS on your phone.</string>
<string name="location_network"><b>Use Google\'s location service</b> to help apps determine your location. This means sending annonymous location data to Google, even when no apps are running.</string>
<string name="location_network"><b>Use Wi-Fi</b> to help apps determine your location.</string>
<string name="location_network_telephony"><b>Use Wi-Fi and mobile networks</b> to help apps determine your location.</string>
<string name="location_network_gms"><b>Use Google\'s location service</b> to help apps determine your location. This means sending anonymous location data to Google, even when no apps are running.</string>
<string name="setup_mobile_data">Turn on mobile data</string>
<string name="setup_mobile_data_no_service">No service</string>

View File

@ -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