2012-03-19 16:15:05 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.TypedArray;
|
2012-07-27 17:53:54 -07:00
|
|
|
import android.text.TextUtils;
|
2012-03-19 16:15:05 -07:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2012-07-17 17:54:54 -07:00
|
|
|
public class AboutHomeSection extends LinearLayout {
|
2012-03-19 16:15:05 -07:00
|
|
|
private static final String LOGTAG = "GeckoAboutHomeSection";
|
|
|
|
|
2012-07-19 11:42:56 -07:00
|
|
|
private TextView mTitle;
|
|
|
|
private TextView mSubtitle;
|
2012-03-19 16:15:05 -07:00
|
|
|
private LinearLayout mItemsContainer;
|
2012-07-19 11:42:56 -07:00
|
|
|
private LinkTextView mMoreText;
|
2012-03-19 16:15:05 -07:00
|
|
|
|
|
|
|
public AboutHomeSection(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
|
|
|
|
setOrientation(VERTICAL);
|
|
|
|
|
|
|
|
LayoutInflater.from(context).inflate(R.layout.abouthome_section, this);
|
|
|
|
|
2012-07-19 11:42:56 -07:00
|
|
|
mTitle = (TextView) this.findViewById(R.id.title);
|
|
|
|
mSubtitle = (TextView) this.findViewById(R.id.subtitle);
|
2012-03-19 16:15:05 -07:00
|
|
|
mItemsContainer = (LinearLayout) this.findViewById(R.id.items_container);
|
2012-07-19 11:42:56 -07:00
|
|
|
mMoreText = (LinkTextView) this.findViewById(R.id.more_text);
|
2012-03-19 16:15:05 -07:00
|
|
|
|
|
|
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AboutHomeSection);
|
|
|
|
setTitle(a.getText(R.styleable.AboutHomeSection_title));
|
|
|
|
setSubtitle(a.getText(R.styleable.AboutHomeSection_subtitle));
|
|
|
|
setMoreText(a.getText(R.styleable.AboutHomeSection_more_text));
|
|
|
|
a.recycle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public LinearLayout getItemsContainer() {
|
|
|
|
return mItemsContainer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTitle(CharSequence title) {
|
|
|
|
if (!TextUtils.isEmpty(title)) {
|
|
|
|
mTitle.setText(title);
|
|
|
|
mTitle.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
mTitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSubtitle(CharSequence subtitle) {
|
|
|
|
if (!TextUtils.isEmpty(subtitle)) {
|
|
|
|
mSubtitle.setText(subtitle);
|
|
|
|
mSubtitle.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
mSubtitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMoreText(CharSequence moreText) {
|
|
|
|
if (!TextUtils.isEmpty(moreText)) {
|
|
|
|
mMoreText.setText(moreText);
|
|
|
|
mMoreText.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
mMoreText.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOnMoreTextClickListener(View.OnClickListener listener) {
|
|
|
|
mMoreText.setOnClickListener(listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addItem(View item) {
|
|
|
|
mItemsContainer.addView(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clear() {
|
|
|
|
mItemsContainer.removeAllViews();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void show() {
|
|
|
|
setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void hide() {
|
|
|
|
setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void showMoreText() {
|
|
|
|
mMoreText.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void hideMoreText() {
|
|
|
|
mMoreText.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|