Merge change 27188 into eclair
* changes: Fix 2146581: Make tabs work for donut apps Use different tab assets with the original coloring scheme for apps that are not Eclair-aware.
This commit is contained in:
@@ -146,6 +146,9 @@ public class Build {
|
|||||||
* <li> The {@link android.app.Activity} class will now execute back
|
* <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
|
* key presses on the key up instead of key down, to be able to detect
|
||||||
* canceled presses from virtual keys.
|
* 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>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static final int ECLAIR = CUR_DEVELOPMENT;
|
public static final int ECLAIR = CUR_DEVELOPMENT;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.app.LocalActivityManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -28,11 +29,12 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import com.android.internal.R;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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
|
* 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
|
* 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() {
|
public View createIndicatorView() {
|
||||||
|
final Context context = getContext();
|
||||||
LayoutInflater inflater =
|
LayoutInflater inflater =
|
||||||
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
|
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
|
||||||
mTabWidget, // tab widget is the parent
|
mTabWidget, // tab widget is the parent
|
||||||
false); // no inflate params
|
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);
|
final TextView tv = (TextView) tabIndicator.findViewById(R.id.title);
|
||||||
tv.setText(mLabel);
|
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;
|
return tabIndicator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -526,13 +533,12 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
|
|||||||
}
|
}
|
||||||
|
|
||||||
public View createIndicatorView() {
|
public View createIndicatorView() {
|
||||||
|
final Context context = getContext();
|
||||||
LayoutInflater inflater =
|
LayoutInflater inflater =
|
||||||
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
|
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
|
||||||
mTabWidget, // tab widget is the parent
|
mTabWidget, // tab widget is the parent
|
||||||
false); // no inflate params
|
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);
|
final TextView tv = (TextView) tabIndicator.findViewById(R.id.title);
|
||||||
tv.setText(mLabel);
|
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);
|
final ImageView iconView = (ImageView) tabIndicator.findViewById(R.id.icon);
|
||||||
iconView.setImageDrawable(mIcon);
|
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;
|
return tabIndicator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,15 @@
|
|||||||
|
|
||||||
package android.widget;
|
package android.widget;
|
||||||
|
|
||||||
|
import com.android.internal.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -94,10 +98,24 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
|
|||||||
setOrientation(LinearLayout.HORIZONTAL);
|
setOrientation(LinearLayout.HORIZONTAL);
|
||||||
mGroupFlags |= FLAG_USE_CHILD_DRAWING_ORDER;
|
mGroupFlags |= FLAG_USE_CHILD_DRAWING_ORDER;
|
||||||
|
|
||||||
mBottomLeftStrip = mContext.getResources().getDrawable(
|
final Context context = mContext;
|
||||||
com.android.internal.R.drawable.tab_bottom_left);
|
final Resources resources = context.getResources();
|
||||||
mBottomRightStrip = mContext.getResources().getDrawable(
|
|
||||||
com.android.internal.R.drawable.tab_bottom_right);
|
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
|
// Deal with focus, as we don't want the focus to go by default
|
||||||
// to a tab other than the current tab
|
// to a tab other than the current tab
|
||||||
setFocusable(true);
|
setFocusable(true);
|
||||||
|
|||||||
20
core/res/res/color/tab_indicator_text_v4.xml
Normal file
20
core/res/res/color/tab_indicator_text_v4.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||||
|
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_selected="true" android:color="#808080"/>
|
||||||
|
<item android:color="#FFFFFF"/> <!-- not selected -->
|
||||||
|
</selector>
|
||||||
BIN
core/res/res/drawable-hdpi/tab_selected_bar_left_v4.9.png
Normal file
BIN
core/res/res/drawable-hdpi/tab_selected_bar_left_v4.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
core/res/res/drawable-hdpi/tab_selected_bar_right_v4.9.png
Normal file
BIN
core/res/res/drawable-hdpi/tab_selected_bar_right_v4.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
core/res/res/drawable-hdpi/tab_selected_v4.9.png
Normal file
BIN
core/res/res/drawable-hdpi/tab_selected_v4.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
core/res/res/drawable-hdpi/tab_unselected_v4.9.png
Normal file
BIN
core/res/res/drawable-hdpi/tab_unselected_v4.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
21
core/res/res/drawable/tab_bottom_left_v4.xml
Normal file
21
core/res/res/drawable/tab_bottom_left_v4.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||||
|
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true" android:drawable="@drawable/tab_press_bar_left"/>
|
||||||
|
<item android:state_focused="false" android:drawable="@drawable/tab_selected_bar_left_v4"/>
|
||||||
|
<item android:state_focused="true" android:drawable="@drawable/tab_focus_bar_left"/>
|
||||||
|
</selector>
|
||||||
21
core/res/res/drawable/tab_bottom_right_v4.xml
Normal file
21
core/res/res/drawable/tab_bottom_right_v4.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||||
|
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true" android:drawable="@drawable/tab_press_bar_right"/>
|
||||||
|
<item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/tab_selected_bar_right_v4"/>
|
||||||
|
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/tab_focus_bar_right"/>
|
||||||
|
</selector>
|
||||||
28
core/res/res/drawable/tab_indicator_v4.xml
Normal file
28
core/res/res/drawable/tab_indicator_v4.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||||
|
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- Non focused states -->
|
||||||
|
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_v4" />
|
||||||
|
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_v4" />
|
||||||
|
|
||||||
|
<!-- Focused states -->
|
||||||
|
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
|
||||||
|
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
|
||||||
|
|
||||||
|
<!-- Pressed -->
|
||||||
|
<item android:state_pressed="true" android:drawable="@drawable/tab_press" />
|
||||||
|
</selector>
|
||||||
Reference in New Issue
Block a user