OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.firstrun; |
| 6 |
| 7 import android.content.Context; |
| 8 import android.os.Bundle; |
| 9 import android.text.method.LinkMovementMethod; |
| 10 import android.text.style.ClickableSpan; |
| 11 import android.view.LayoutInflater; |
| 12 import android.view.View; |
| 13 import android.view.View.OnClickListener; |
| 14 import android.view.ViewGroup; |
| 15 import android.widget.Button; |
| 16 import android.widget.CheckBox; |
| 17 import android.widget.TextView; |
| 18 |
| 19 import org.chromium.base.ApiCompatibilityUtils; |
| 20 import org.chromium.chrome.R; |
| 21 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 22 import org.chromium.ui.text.SpanApplier; |
| 23 import org.chromium.ui.text.SpanApplier.SpanInfo; |
| 24 |
| 25 /** |
| 26 * The First Run Experience fragment that allows the user to accept Terms of Ser
vice ("ToS") and |
| 27 * Privacy Notice, and to opt-in to the usage statistics and crash reports colle
ction ("UMA", |
| 28 * User Metrics Analysis) as defined in the Chrome Privacy Notice. |
| 29 */ |
| 30 public class ToSAndUMAFirstRunFragment extends FirstRunPage { |
| 31 private Button mAcceptButton; |
| 32 private CheckBox mSendReportCheckBox; |
| 33 private TextView mTosAndPrivacy; |
| 34 |
| 35 @Override |
| 36 public View onCreateView( |
| 37 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceSt
ate) { |
| 38 return inflater.inflate(R.layout.fre_tosanduma, container, false); |
| 39 } |
| 40 |
| 41 @Override |
| 42 public void onViewCreated(View view, Bundle savedInstanceState) { |
| 43 super.onViewCreated(view, savedInstanceState); |
| 44 |
| 45 mAcceptButton = (Button) view.findViewById(R.id.terms_accept); |
| 46 mSendReportCheckBox = (CheckBox) view.findViewById(R.id.send_report_chec
kbox); |
| 47 mTosAndPrivacy = (TextView) view.findViewById(R.id.tos_and_privacy); |
| 48 |
| 49 mAcceptButton.setOnClickListener(new OnClickListener() { |
| 50 @Override |
| 51 public void onClick(View v) { |
| 52 getPageDelegate().acceptTermsOfService(mSendReportCheckBox.isChe
cked()); |
| 53 } |
| 54 }); |
| 55 |
| 56 int paddingStart = getResources().getDimensionPixelSize(R.dimen.fre_tos_
checkbox_padding); |
| 57 ApiCompatibilityUtils.setPaddingRelative(mSendReportCheckBox, |
| 58 ApiCompatibilityUtils.getPaddingStart(mSendReportCheckBox) + pad
dingStart, |
| 59 mSendReportCheckBox.getPaddingTop(), |
| 60 ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox), |
| 61 mSendReportCheckBox.getPaddingBottom()); |
| 62 |
| 63 mSendReportCheckBox.setChecked(!getPageDelegate().isNeverUploadCrashDump
()); |
| 64 |
| 65 mTosAndPrivacy.setMovementMethod(LinkMovementMethod.getInstance()); |
| 66 |
| 67 ClickableSpan clickableTermsSpan = new ClickableSpan() { |
| 68 @Override |
| 69 public void onClick(View widget) { |
| 70 getPageDelegate().showEmbedContentViewActivity(R.string.terms_of
_service_title, |
| 71 R.string.chrome_terms_of_service_url); |
| 72 } |
| 73 }; |
| 74 |
| 75 ClickableSpan clickablePrivacySpan = new ClickableSpan() { |
| 76 @Override |
| 77 public void onClick(View widget) { |
| 78 getPageDelegate().showEmbedContentViewActivity(R.string.privacy_
notice_title, |
| 79 R.string.chrome_privacy_notice_url); |
| 80 } |
| 81 }; |
| 82 mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos
_and_privacy), |
| 83 new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan), |
| 84 new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan))); |
| 85 } |
| 86 |
| 87 @Override |
| 88 public boolean shouldSkipPageOnResume(Context appContext) { |
| 89 return PrefServiceBridge.getInstance().isFirstRunEulaAccepted(); |
| 90 } |
| 91 } |
OLD | NEW |