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

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