/*
 * Copyright (C) 2011 Google Inc.
 *
 * 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.example.google.tv.leftnavbar;

import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;

/**
 * Basic implementation of the ActionBar.Tab type.
 * <p>
 * {@code select()} is left unimplemented so that the entity managing tabs can define the proper
 * selection flow.
 */
abstract class TabImpl extends Tab {

    private final Context mContext;

    private ActionBar.TabListener mCallback;
    private Object mTag;
    private Drawable mIcon;
    private CharSequence mText;
    private int mPosition;
    private View mCustomView;

    public TabImpl(Context context) {
        mContext = context;
    }

    @Override
    public Object getTag() {
        return mTag;
    }

    @Override
    public Tab setTag(Object tag) {
        mTag = tag;
        return this;
    }

    @Override
    public Tab setTabListener(ActionBar.TabListener callback) {
        mCallback = callback;
        return this;
    }

    @Override
    public View getCustomView() {
        return mCustomView;
    }

    @Override
    public Tab setCustomView(View view) {
        mCustomView = view;
        return this;
    }

    @Override
    public Tab setCustomView(int layoutResId) {
        return setCustomView(LayoutInflater.from(mContext).inflate(layoutResId, null));
    }

    @Override
    public Drawable getIcon() {
        return mIcon;
    }

    @Override
    public int getPosition() {
        return mPosition;
    }

    public void setPosition(int position) {
        mPosition = position;
    }

    @Override
    public CharSequence getText() {
        return mText;
    }

    @Override
    public Tab setIcon(Drawable icon) {
        mIcon = icon;
        return this;
    }

    @Override
    public Tab setIcon(int resId) {
        return setIcon(mContext.getResources().getDrawable(resId));
    }

    @Override
    public Tab setText(CharSequence text) {
        mText = text;
        return this;
    }

    @Override
    public Tab setText(int resId) {
        return setText(mContext.getResources().getText(resId));
    }

    //----------------------------------------------------------------------------------------------
    // Non-API.

    public ActionBar.TabListener getCallback() {
        return mCallback;
    }

    boolean hasCustomView() {
        return mCustomView != null;
    }

    @Override
    public String toString() {
        Object source = mTag != null ? mTag : mText;
        return "Tab:" + (source != null ? source.toString() : "<no id>");
    }
}

@@ -1222,24 +1222,70 @@
 ence mText;%0A
+    private CharSequence mContentDescription;%0A
     private 
@@ -2365,32 +2365,139 @@
 n mText;%0A    %7D%0A%0A
+    @Override%0A    public CharSequence getContentDescription() %7B%0A        return mContentDescription;%0A    %7D%0A%0A
     @Override%0A  
@@ -2701,32 +2701,153 @@
 resId));%0A    %7D%0A%0A
+    @Override%0A    public Tab setText(int resId) %7B%0A        return setText(mContext.getResources().getText(resId));%0A    %7D%0A%0A
     @Override%0A  
@@ -2962,36 +2962,50 @@
   public Tab set
-Text
+ContentDescription
 (int resId) %7B%0A  
@@ -3012,36 +3012,50 @@
       return set
-Text
+ContentDescription
 (mContext.getRes
@@ -3083,24 +3083,174 @@
 d));%0A    %7D%0A%0A
+    @Override%0A    public Tab setContentDescription(CharSequence contentDesc) %7B%0A        mContentDescription = contentDesc;%0A        return this;%0A    %7D%0A%0A
     //------

Add required overriden methods to TabImpl