Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/translate/TranslateTabContent.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/translate/TranslateTabContent.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/translate/TranslateTabContent.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8573b2177256792b3b71cb97d46dc3a36ffa476a |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/translate/TranslateTabContent.java |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2017 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.translate; |
| + |
| +import android.content.Context; |
| +import android.content.res.ColorStateList; |
| +import android.content.res.TypedArray; |
| +import android.support.v4.widget.TextViewCompat; |
| +import android.util.AttributeSet; |
| +import android.view.View; |
| +import android.widget.FrameLayout; |
| +import android.widget.ProgressBar; |
| +import android.widget.TextView; |
| + |
| +import org.chromium.chrome.R; |
| + |
| +/** |
| + * The content of the tab shown in the TranslateTabLayout. |
| + */ |
| +public class TranslateTabContent extends FrameLayout { |
| + private TextView mTextView; |
| + private ProgressBar mProgressBar; |
| + |
| + /** |
| + * Constructor for inflating from XML. |
| + */ |
| + public TranslateTabContent(Context context, AttributeSet attrs) { |
| + super(context, attrs); |
| + } |
| + |
| + @Override |
| + protected void onFinishInflate() { |
| + super.onFinishInflate(); |
| + |
| + mTextView = (TextView) findViewById(R.id.translate_infobar_tab_text); |
| + mProgressBar = (ProgressBar) findViewById(R.id.translate_infobar_tab_progressbar); |
| + } |
| + |
| + /** |
| + * Set the appearance and color of the title text. |
| + * @param context The context used to render. |
| + * @param colors The color state list of the title text. |
| + * @param attrs The AttributeSet to style the title text. |
| + * @param defStyleAttr Default style attribute to use. |
| + */ |
| + public void setupTextAppearance( |
| + Context context, ColorStateList colors, AttributeSet attrs, int defStyleAttr) { |
| + // Style the textView using the text appearance of TabLayout. |
| + TypedArray a = context.obtainStyledAttributes( |
| + attrs, R.styleable.TabLayout, defStyleAttr, R.style.Widget_Design_TabLayout); |
|
gone
2017/03/29 17:04:10
Can you set these styles in the XML themselves? T
Marti Wong
2017/03/29 23:38:07
Done. Thanks for the advice.
The code is so much
|
| + int tabTextAppearance = a.getResourceId( |
| + R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); |
| + TextViewCompat.setTextAppearance(mTextView, tabTextAppearance); |
| + |
| + // Set text color using tabLayout's ColorStateList. |
|
gone
2017/03/29 17:04:10
{@link TabLayout}
Worth adding a comment about wh
Marti Wong
2017/03/29 23:38:07
Done.
This function is changed to setTextColor
Add
|
| + mTextView.setTextColor(colors); |
| + } |
| + |
| + /** |
| + * Set the title text for this tab. |
| + * @param tabTitle The new title string. |
| + */ |
| + public void setText(CharSequence tabTitle) { |
| + mTextView.setText(tabTitle); |
| + } |
| + |
| + /** Hide progress bar and show text. */ |
| + public void hideProgressBar() { |
| + mProgressBar.setVisibility(View.INVISIBLE); |
| + mTextView.setVisibility(View.VISIBLE); |
| + } |
| + |
| + /** Show progress bar and hide text. */ |
| + public void showProgressBar() { |
| + mTextView.setVisibility(View.INVISIBLE); |
| + mProgressBar.setVisibility(View.VISIBLE); |
| + } |
| +} |