SetupWizard: Add privacy policy popup
* Also launch cmaccount by default Change-Id: Idf625f4f5c8bdb05a4d0b888846972c11676d12d
This commit is contained in:
parent
716ffa86dc
commit
8913799a97
35
res/layout/terms_webview.xml
Normal file
35
res/layout/terms_webview.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2013 The CyanogenMod Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
@ -18,6 +18,8 @@
|
||||
<string name="app_name">Setup Wizard</string>
|
||||
<string name="product_name" translatable="false">cyanogenmod</string>
|
||||
|
||||
<string name="cm_account_type" translatable="false">com.cyanogenmod.account</string>
|
||||
|
||||
<string name="next">Next</string>
|
||||
<string name="continue_label">Continue</string>
|
||||
<string name="skip">Skip</string>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="android:windowExitTransition">@android:transition/explode</item>
|
||||
<item name="android:colorPrimary">@color/primary</item>
|
||||
<item name="android:colorPrimaryDark">#00000000</item>
|
||||
<item name="android:colorPrimaryDark">@color/primary</item>
|
||||
<item name="android:colorAccent">@color/accent</item>
|
||||
</style>
|
||||
|
||||
|
@ -29,7 +29,6 @@ public class SetupWizardApp extends Application {
|
||||
|
||||
public static final String ACTION_FINISHED = "com.cyanogenmod.setupwizard.SETUP_FINISHED";
|
||||
|
||||
public static final String ACCOUNT_TYPE_CYANOGEN = "com.cyanogen";
|
||||
public static final String ACCOUNT_TYPE_GMS = "com.google";
|
||||
|
||||
public static final String ACTION_SETUP_WIFI = "com.android.net.wifi.SETUP_WIFI_NETWORK";
|
||||
@ -37,6 +36,7 @@ public class SetupWizardApp extends Application {
|
||||
public static final String EXTRA_FIRST_RUN = "firstRun";
|
||||
public static final String EXTRA_ALLOW_SKIP = "allowSkip";
|
||||
public static final String EXTRA_AUTO_FINISH = "wifi_auto_finish_on_connect";
|
||||
public static final String EXTRA_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
|
||||
|
||||
public static final int REQUEST_CODE_SETUP_WIFI = 0;
|
||||
|
||||
|
@ -39,6 +39,7 @@ import android.widget.TextView;
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
|
||||
import com.cyanogenmod.setupwizard.ui.WebViewDialogFragment;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
@ -54,6 +55,7 @@ public class CyanogenServicesPage extends SetupPage {
|
||||
public static final String KEY_REGISTER_WHISPERPUSH = "register";
|
||||
|
||||
public static final String SETTING_METRICS = "settings.cyanogen.allow_metrics";
|
||||
public static final String PRIVACY_POLICY_URI = "https://cyngn.com/legal/privacy-policy";
|
||||
|
||||
public CyanogenServicesPage(Context context, SetupDataCallbacks callbacks) {
|
||||
super(context, callbacks);
|
||||
@ -180,10 +182,11 @@ public class CyanogenServicesPage extends SetupPage {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.primary_dark));
|
||||
if (!SetupWizardUtils.accountExists(getActivity(),
|
||||
SetupWizardApp.ACCOUNT_TYPE_CYANOGEN)) {
|
||||
launchCyanogenAccountSetup(getActivity());
|
||||
final Activity activity = getActivity();
|
||||
activity.getWindow().setStatusBarColor(getResources().getColor(R.color.primary_dark));
|
||||
if (!SetupWizardUtils.accountExists(activity,
|
||||
activity.getString(R.string.cm_account_type))) {
|
||||
launchCyanogenAccountSetup(activity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +198,9 @@ public class CyanogenServicesPage extends SetupPage {
|
||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
//TDB privacy policy
|
||||
WebViewDialogFragment.newInstance()
|
||||
.setUri(PRIVACY_POLICY_URI)
|
||||
.show(getActivity().getFragmentManager(), WebViewDialogFragment.TAG);
|
||||
}
|
||||
};
|
||||
ss.setSpan(clickableSpan,
|
||||
@ -262,8 +267,9 @@ public class CyanogenServicesPage extends SetupPage {
|
||||
private void launchCyanogenAccountSetup(final Activity activity) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
|
||||
bundle.putBoolean(SetupWizardApp.EXTRA_SHOW_BUTTON_BAR, true);
|
||||
AccountManager.get(activity)
|
||||
.addAccount(SetupWizardApp.ACCOUNT_TYPE_CYANOGEN, null, null, bundle,
|
||||
.addAccount(activity.getString(R.string.cm_account_type), null, null, bundle,
|
||||
activity, null, null);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.setupwizard.ui;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
|
||||
public class WebViewDialogFragment extends DialogFragment {
|
||||
|
||||
public static String TAG = WebViewDialogFragment.class.getSimpleName();
|
||||
|
||||
private View mRootView;
|
||||
private WebView mWebView;
|
||||
private String mUri;
|
||||
private Dialog mDialog;
|
||||
|
||||
public static WebViewDialogFragment newInstance() {
|
||||
return new WebViewDialogFragment();
|
||||
}
|
||||
|
||||
public WebViewDialogFragment() {
|
||||
|
||||
}
|
||||
|
||||
public WebViewDialogFragment setUri(String uri) {
|
||||
mUri = uri;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
mRootView = getActivity().getLayoutInflater().inflate(R.layout.terms_webview, null, false);
|
||||
mWebView = (WebView)mRootView.findViewById(R.id.webview);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setUseWideViewPort(true);
|
||||
mWebView.loadUrl(mUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if (mDialog == null) {
|
||||
mDialog =new AlertDialog.Builder(getActivity())
|
||||
.setView(mRootView)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
}
|
||||
return mDialog;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user