Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/AutoSigninFirstRunInfobar.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutoSigninFirstRunInfobar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutoSigninFirstRunInfobar.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..21e37066a5047ce4312c5186651886598dd63e65 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutoSigninFirstRunInfobar.java |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.infobar; |
| + |
| +import android.text.Spannable; |
| +import android.text.SpannableString; |
| +import android.text.method.LinkMovementMethod; |
| +import android.text.style.ClickableSpan; |
| +import android.view.View; |
| +import android.widget.TextView; |
| + |
| +import org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.chrome.R; |
| + |
| +/** |
| + * The Auto Sign-in first run experience infobar is shown instead of usual Auto sign-in snackbar |
|
gone
2015/11/03 18:38:59
nit: Standardize on a capitalization:
Auto Sign-in
melandory
2015/11/03 21:43:27
Done.
|
| + * when user first time faces the auto sign-in feature. It contains information about which account |
| + * was used for signing in and text which explains the feature. |
| + */ |
| +public class AutoSigninFirstRunInfobar extends ConfirmInfoBar { |
| + String mExplanation; |
|
gone
2015/11/03 18:38:59
why are these package private?
melandory
2015/11/03 21:43:27
Done.
|
| + int mExplanationLinkStart; |
| + int mExplanationLinkEnd; |
| + |
| + @CalledByNative |
| + private static InfoBar show(String message, String primaryButtonText, String explanation, |
| + int explanationLinkStart, int explanationLinkEnd) { |
| + return new AutoSigninFirstRunInfobar( |
| + message, primaryButtonText, explanation, explanationLinkStart, explanationLinkEnd); |
| + } |
| + |
| + private AutoSigninFirstRunInfobar(String message, String primaryButtonText, String explanation, |
| + int explanationLinkStart, int explanationLinkEnd) { |
| + super(null, R.drawable.account_management_no_picture, null, message, null, |
| + primaryButtonText, null); |
| + mExplanation = explanation; |
| + mExplanationLinkStart = explanationLinkStart; |
| + mExplanationLinkEnd = explanationLinkEnd; |
| + } |
| + |
| + /** |
| + * Adds text, which explains the auto sign-in feature. |
| + */ |
| + @Override |
| + public void createContent(InfoBarLayout layout) { |
| + super.createContent(layout); |
| + SpannableString explanation = new SpannableString(mExplanation); |
| + if (mExplanationLinkEnd != mExplanationLinkStart && mExplanationLinkEnd != 0) { |
| + explanation.setSpan(new ClickableSpan() { |
| + @Override |
| + public void onClick(View view) { |
| + onLinkClicked(); |
| + } |
| + }, mExplanationLinkStart, mExplanationLinkEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| + } |
| + // TODO(melandory): Implement correct (as in mocks) margin for the first run |
| + // experience text. |
| + TextView firstRunExperienceMessageView = new TextView(getContext()); |
| + firstRunExperienceMessageView.setText(explanation, TextView.BufferType.SPANNABLE); |
| + firstRunExperienceMessageView.setMovementMethod(LinkMovementMethod.getInstance()); |
| + layout.setCustomContent(firstRunExperienceMessageView); |
| + } |
| +} |