summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorMike Cleron <mcleron@google.com>2009-09-25 17:53:56 -0700
committerMike Cleron <mcleron@google.com>2009-09-25 17:53:56 -0700
commit7609764295d1b3ec0b53d1ae536ee0280f5e0407 (patch)
treeff0dd8fa4e2f42c183e63024a5f27935a24ae804 /core/java/android
parentfdf53a4628f915203752660aa07049aa22c01b5a (diff)
Fix 2146581: Make tabs work for donut apps
Use different tab assets with the original coloring scheme for apps that are not Eclair-aware.
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/Build.java3
-rw-r--r--core/java/android/widget/TabHost.java26
-rw-r--r--core/java/android/widget/TabWidget.java26
3 files changed, 44 insertions, 11 deletions
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index b4778fee7788..b9f78a10c623 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -146,6 +146,9 @@ public class Build {
* <li> The {@link android.app.Activity} class will now execute back
* key presses on the key up instead of key down, to be able to detect
* canceled presses from virtual keys.
+ * <li> The {@link android.widget.TabWidget} class will use a new color scheme
+ * for tabs. In the new scheme, the foreground tab has a medium gray background
+ * the background tabs have a dark gray background.
* </ul>
*/
public static final int ECLAIR = CUR_DEVELOPMENT;
diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java
index ee3b91e5f782..31920e764e6d 100644
--- a/core/java/android/widget/TabHost.java
+++ b/core/java/android/widget/TabHost.java
@@ -20,6 +20,7 @@ import android.app.LocalActivityManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -28,11 +29,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
-import com.android.internal.R;
import java.util.ArrayList;
import java.util.List;
+import com.android.internal.R;
+
/**
* Container for a tabbed window view. This object holds two children: a set of tab labels that the
* user clicks to select a specific tab, and a FrameLayout object that displays the contents of that
@@ -497,17 +499,22 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
}
public View createIndicatorView() {
+ final Context context = getContext();
LayoutInflater inflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
mTabWidget, // tab widget is the parent
false); // no inflate params
- // TODO: Move this to xml when bug 2068024 is resolved.
- tabIndicator.getBackground().setDither(true);
final TextView tv = (TextView) tabIndicator.findViewById(R.id.title);
tv.setText(mLabel);
+ if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
+ // Donut apps get old color scheme
+ tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4);
+ tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4));
+ }
+
return tabIndicator;
}
}
@@ -526,13 +533,12 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
}
public View createIndicatorView() {
+ final Context context = getContext();
LayoutInflater inflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
mTabWidget, // tab widget is the parent
false); // no inflate params
- // TODO: Move this to xml when bug 2068024 is resolved.
- tabIndicator.getBackground().setDither(true);
final TextView tv = (TextView) tabIndicator.findViewById(R.id.title);
tv.setText(mLabel);
@@ -540,6 +546,12 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
final ImageView iconView = (ImageView) tabIndicator.findViewById(R.id.icon);
iconView.setImageDrawable(mIcon);
+ if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
+ // Donut apps get old color scheme
+ tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4);
+ tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4));
+ }
+
return tabIndicator;
}
}
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index 889f37ff7e5b..2ba6268e4765 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -16,11 +16,15 @@
package android.widget;
+import com.android.internal.R;
+
import android.content.Context;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -94,10 +98,24 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
setOrientation(LinearLayout.HORIZONTAL);
mGroupFlags |= FLAG_USE_CHILD_DRAWING_ORDER;
- mBottomLeftStrip = mContext.getResources().getDrawable(
- com.android.internal.R.drawable.tab_bottom_left);
- mBottomRightStrip = mContext.getResources().getDrawable(
- com.android.internal.R.drawable.tab_bottom_right);
+ final Context context = mContext;
+ final Resources resources = context.getResources();
+
+ if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
+ // Donut apps get old color scheme
+ mBottomLeftStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_left_v4);
+ mBottomRightStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_right_v4);
+ } else {
+ // Use modern color scheme for Eclair and beyond
+ mBottomLeftStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_left);
+ mBottomRightStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_right);
+ }
+
+
// Deal with focus, as we don't want the focus to go by default
// to a tab other than the current tab
setFocusable(true);