Update minitab assets and behavior to match spec.
diff --git a/res/color-finger/tab_indicator_text.xml b/res/color-finger/tab_indicator_text.xml
index 0fe2cd9..50ca824 100644
--- a/res/color-finger/tab_indicator_text.xml
+++ b/res/color-finger/tab_indicator_text.xml
@@ -15,6 +15,6 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_selected="true" android:color="@*android:color/dim_foreground_dark"/>
- <item android:color="@*android:color/dim_foreground_dark_inverse"/> <!-- not selected -->
+ <item android:state_selected="true" android:color="@*android:color/dim_foreground_dark_inverse"/>
+ <item android:color="@*android:color/dim_foreground_dark"/> <!-- not selected -->
</selector>
diff --git a/res/drawable/tab_indicator_bg.xml b/res/drawable-finger/tab_bottom.xml
similarity index 65%
copy from res/drawable/tab_indicator_bg.xml
copy to res/drawable-finger/tab_bottom.xml
index 211372f..96f1a24 100644
--- a/res/drawable/tab_indicator_bg.xml
+++ b/res/drawable-finger/tab_bottom.xml
@@ -15,32 +15,27 @@
-->
<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" />
+ <!--
+ <item android:state_pressed="true" android:drawable="@drawable/tab_pressed_bottom"/>
+ <item android:state_focused="false" android:drawable="@drawable/tab_selected_bottom"/>
+ <item android:state_focused="true" android:drawable="@drawable/tab_focused_bottom"/>
+ -->
+
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
- android:drawable="@drawable/tab_selected" />
+ android:drawable="@drawable/tab_selected_bottom" />
<!-- Focused states -->
<item
android:state_focused="true"
- android:state_selected="false"
- android:state_pressed="false"
- android:drawable="@drawable/tab_focused" />
- <item
- android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
- android:drawable="@drawable/tab_focused_selected" />
+ android:drawable="@drawable/tab_focused_bottom" />
<!-- Pressed -->
<item
android:state_pressed="true"
- android:drawable="@drawable/tab_pressed" />
+ android:drawable="@drawable/tab_pressed_bottom" />
</selector>
\ No newline at end of file
diff --git a/res/drawable/tab_divider.xml b/res/drawable-finger/tab_divider.xml
similarity index 100%
rename from res/drawable/tab_divider.xml
rename to res/drawable-finger/tab_divider.xml
diff --git a/res/drawable/tab_divider_res.9.png b/res/drawable-finger/tab_divider_res.9.png
similarity index 100%
rename from res/drawable/tab_divider_res.9.png
rename to res/drawable-finger/tab_divider_res.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_focused.9.png b/res/drawable-finger/tab_focused.9.png
new file mode 100644
index 0000000..389cefd
--- /dev/null
+++ b/res/drawable-finger/tab_focused.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_focused_bottom.9.png b/res/drawable-finger/tab_focused_bottom.9.png
new file mode 100644
index 0000000..64298be
--- /dev/null
+++ b/res/drawable-finger/tab_focused_bottom.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_focused_dithered.xml b/res/drawable-finger/tab_focused_dithered.xml
new file mode 100644
index 0000000..c842543
--- /dev/null
+++ b/res/drawable-finger/tab_focused_dithered.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/tab_focused"
+ android:dither="true"
+/>
diff --git a/res/drawable/tab_indicator_bg.xml b/res/drawable-finger/tab_indicator_bg.xml
similarity index 75%
rename from res/drawable/tab_indicator_bg.xml
rename to res/drawable-finger/tab_indicator_bg.xml
index 211372f..15ab727 100644
--- a/res/drawable/tab_indicator_bg.xml
+++ b/res/drawable-finger/tab_indicator_bg.xml
@@ -20,27 +20,23 @@
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
- android:drawable="@drawable/tab_unselected" />
+ android:drawable="@drawable/tab_unselected_dithered" />
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
- android:drawable="@drawable/tab_selected" />
+ android:drawable="@drawable/tab_selected_dithered" />
<!-- Focused states -->
<item
android:state_focused="true"
- android:state_selected="false"
- android:state_pressed="false"
- android:drawable="@drawable/tab_focused" />
- <item
- android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
- android:drawable="@drawable/tab_focused_selected" />
+ android:drawable="@drawable/tab_focused_dithered" />
<!-- Pressed -->
<item
android:state_pressed="true"
- android:drawable="@drawable/tab_pressed" />
+ android:drawable="@drawable/tab_pressed_dithered" />
+
</selector>
\ No newline at end of file
diff --git a/res/drawable/tab_left_arrow.png b/res/drawable-finger/tab_left_arrow.png
similarity index 100%
rename from res/drawable/tab_left_arrow.png
rename to res/drawable-finger/tab_left_arrow.png
Binary files differ
diff --git a/res/drawable-finger/tab_pressed.9.png b/res/drawable-finger/tab_pressed.9.png
new file mode 100644
index 0000000..f8c06fb
--- /dev/null
+++ b/res/drawable-finger/tab_pressed.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_pressed_bottom.9.png b/res/drawable-finger/tab_pressed_bottom.9.png
new file mode 100644
index 0000000..1447a4e
--- /dev/null
+++ b/res/drawable-finger/tab_pressed_bottom.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_pressed_dithered.xml b/res/drawable-finger/tab_pressed_dithered.xml
new file mode 100644
index 0000000..2469678
--- /dev/null
+++ b/res/drawable-finger/tab_pressed_dithered.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/tab_pressed"
+ android:dither="true"
+/>
diff --git a/res/drawable/tab_right_arrow.png b/res/drawable-finger/tab_right_arrow.png
similarity index 100%
rename from res/drawable/tab_right_arrow.png
rename to res/drawable-finger/tab_right_arrow.png
Binary files differ
diff --git a/res/drawable-finger/tab_selected.9.png b/res/drawable-finger/tab_selected.9.png
new file mode 100644
index 0000000..4cb9d67
--- /dev/null
+++ b/res/drawable-finger/tab_selected.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_selected_bottom.9.png b/res/drawable-finger/tab_selected_bottom.9.png
new file mode 100644
index 0000000..55d6cad
--- /dev/null
+++ b/res/drawable-finger/tab_selected_bottom.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_selected_dithered.xml b/res/drawable-finger/tab_selected_dithered.xml
new file mode 100644
index 0000000..d1d235c
--- /dev/null
+++ b/res/drawable-finger/tab_selected_dithered.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/tab_selected"
+ android:dither="true"
+/>
diff --git a/res/drawable-finger/tab_unselected.9.png b/res/drawable-finger/tab_unselected.9.png
new file mode 100644
index 0000000..4d4c017
--- /dev/null
+++ b/res/drawable-finger/tab_unselected.9.png
Binary files differ
diff --git a/res/drawable-finger/tab_unselected_dithered.xml b/res/drawable-finger/tab_unselected_dithered.xml
new file mode 100644
index 0000000..32c6509
--- /dev/null
+++ b/res/drawable-finger/tab_unselected_dithered.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/tab_unselected"
+ android:dither="true"
+/>
diff --git a/res/drawable/tab_focused.9.png b/res/drawable/tab_focused.9.png
deleted file mode 100644
index adbf191..0000000
--- a/res/drawable/tab_focused.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/tab_focused_selected.9.png b/res/drawable/tab_focused_selected.9.png
deleted file mode 100644
index 2f18b65..0000000
--- a/res/drawable/tab_focused_selected.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/tab_pressed.9.png b/res/drawable/tab_pressed.9.png
deleted file mode 100644
index cb624ef..0000000
--- a/res/drawable/tab_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/tab_selected.9.png b/res/drawable/tab_selected.9.png
deleted file mode 100644
index 24a389f..0000000
--- a/res/drawable/tab_selected.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/tab_unselected.9.png b/res/drawable/tab_unselected.9.png
deleted file mode 100644
index 4130457..0000000
--- a/res/drawable/tab_unselected.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/tab_widget_bg.9.png b/res/drawable/tab_widget_bg.9.png
deleted file mode 100644
index 39427ee..0000000
--- a/res/drawable/tab_widget_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/layout-finger/all_tab_indicator.xml b/res/layout-finger/all_tab_indicator.xml
index daef9c4..fd5c35f 100644
--- a/res/layout-finger/all_tab_indicator.xml
+++ b/res/layout-finger/all_tab_indicator.xml
@@ -15,7 +15,7 @@
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="120dip"
+ android:layout_width="80dip"
android:layout_height="40dip"
android:background="@+drawable/tab_indicator_bg">
diff --git a/res/layout-finger/contact_card_layout.xml b/res/layout-finger/contact_card_layout.xml
index d32ce6f..899f354 100644
--- a/res/layout-finger/contact_card_layout.xml
+++ b/res/layout-finger/contact_card_layout.xml
@@ -27,8 +27,7 @@
<com.android.contacts.ScrollingTabWidget android:id="@+id/tab_widget"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/tab_widget_bg"/>
+ android:layout_height="wrap_content"/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
diff --git a/res/layout-finger/tab_indicator.xml b/res/layout-finger/tab_indicator.xml
index 68f03fd..119f86e 100644
--- a/res/layout-finger/tab_indicator.xml
+++ b/res/layout-finger/tab_indicator.xml
@@ -15,7 +15,7 @@
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="76dip"
+ android:layout_width="80dip"
android:layout_height="40dip"
android:background="@+drawable/tab_indicator_bg">
diff --git a/res/layout-finger/tab_layout.xml b/res/layout-finger/tab_layout.xml
index f9c7364..23359b7 100644
--- a/res/layout-finger/tab_layout.xml
+++ b/res/layout-finger/tab_layout.xml
@@ -14,16 +14,16 @@
limitations under the License.
-->
-<com.android.contacts.NoDragHorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:scrollbars="none"
android:fadingEdgeLength="0dip">
- <LinearLayout
+ <com.android.contacts.TabStripView
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
-</com.android.contacts.NoDragHorizontalScrollView>
\ No newline at end of file
+</HorizontalScrollView>
\ No newline at end of file
diff --git a/res/layout-finger/tab_left_arrow.xml b/res/layout-finger/tab_left_arrow.xml
index eb29928..58c8b92 100644
--- a/res/layout-finger/tab_left_arrow.xml
+++ b/res/layout-finger/tab_left_arrow.xml
@@ -14,27 +14,14 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="44dip"
- android:layout_height="40dip"
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/arrow"
+ android:layout_width="40dip"
+ android:layout_height="37dip"
android:layout_alignParentLeft="true"
- android:orientation="horizontal">
-
- <ImageView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:background="@drawable/tab_indicator_bg"
- android:id="@+id/arrow"
- android:scaleType="centerInside"
- android:src="@drawable/tab_left_arrow"
- />
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:id="@+id/divider"
- android:src="@drawable/tab_divider"
- />
-
-</LinearLayout>
\ No newline at end of file
+ android:layout_alignParentTop="true"
+ android:layout_weight="1"
+ android:background="@drawable/tab_indicator_bg"
+ android:scaleType="centerInside"
+ android:src="@drawable/tab_left_arrow"
+ />
diff --git a/res/layout-finger/tab_right_arrow.xml b/res/layout-finger/tab_right_arrow.xml
index c40029b..febc7f5 100644
--- a/res/layout-finger/tab_right_arrow.xml
+++ b/res/layout-finger/tab_right_arrow.xml
@@ -14,27 +14,14 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="44dip"
- android:layout_height="40dip"
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/arrow"
+ android:layout_width="40dip"
+ android:layout_height="37dip"
android:layout_alignParentRight="true"
- android:orientation="horizontal">
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:id="@+id/divider"
- android:src="@drawable/tab_divider"
- />
-
- <ImageView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:background="@drawable/tab_indicator_bg"
- android:id="@+id/arrow"
- android:scaleType="centerInside"
- android:src="@drawable/tab_right_arrow"
- />
-
-</LinearLayout>
\ No newline at end of file
+ android:layout_alignParentTop="true"
+ android:layout_weight="1"
+ android:background="@drawable/tab_indicator_bg"
+ android:scaleType="centerInside"
+ android:src="@drawable/tab_right_arrow"
+ />
diff --git a/res/layout/act_edit.xml b/res/layout/act_edit.xml
index 1a9f99c..de62e5e 100644
--- a/res/layout/act_edit.xml
+++ b/res/layout/act_edit.xml
@@ -35,8 +35,7 @@
<com.android.contacts.ScrollingTabWidget
android:id="@+id/tab_widget"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/tab_widget_bg" />
+ android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
diff --git a/src/com/android/contacts/NoDragHorizontalScrollView.java b/src/com/android/contacts/NoDragHorizontalScrollView.java
deleted file mode 100644
index 94d8c13..0000000
--- a/src/com/android/contacts/NoDragHorizontalScrollView.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-package com.android.contacts;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.widget.HorizontalScrollView;
-
-/* Simple extension of {@link HorizontalScrollView} that disallows drag scrolling */
-public class NoDragHorizontalScrollView extends HorizontalScrollView {
-
- public NoDragHorizontalScrollView(Context context) {
- super(context);
- }
-
- public NoDragHorizontalScrollView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public NoDragHorizontalScrollView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- return false;
- }
-
-}
diff --git a/src/com/android/contacts/ScrollingTabWidget.java b/src/com/android/contacts/ScrollingTabWidget.java
index 2f703aa..ddd101b 100644
--- a/src/com/android/contacts/ScrollingTabWidget.java
+++ b/src/com/android/contacts/ScrollingTabWidget.java
@@ -18,8 +18,10 @@
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -27,6 +29,8 @@
import android.view.ViewTreeObserver;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
+import android.widget.HorizontalScrollView;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@@ -41,12 +45,11 @@
private OnTabSelectionChangedListener mSelectionChangedListener;
private int mSelectedTab = 0;
- private LinearLayout mLeftArrowView;
- private LinearLayout mRightArrowView;
- private NoDragHorizontalScrollView mTabsScrollWrapper;
- private LinearLayout mTabsView;
+ private ImageView mLeftArrowView;
+ private ImageView mRightArrowView;
+ private HorizontalScrollView mTabsScrollWrapper;
+ private TabStripView mTabsView;
private LayoutInflater mInflater;
- private Drawable mDividerDrawable;
// Keeps track of the left most visible tab.
private int mLeftMostVisibleTabIndex = 0;
@@ -67,20 +70,17 @@
setFocusable(true);
setOnFocusChangeListener(this);
- onLoseFocus();
-// if (!hasFocus()) {
-// setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
-// }
+ if (!hasFocus()) {
+ setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
+ }
- mLeftArrowView = (LinearLayout) mInflater.inflate(R.layout.tab_left_arrow, this, false);
+ mLeftArrowView = (ImageView) mInflater.inflate(R.layout.tab_left_arrow, this, false);
mLeftArrowView.setOnClickListener(this);
- mRightArrowView = (LinearLayout) mInflater.inflate(R.layout.tab_right_arrow, this, false);
+ mRightArrowView = (ImageView) mInflater.inflate(R.layout.tab_right_arrow, this, false);
mRightArrowView.setOnClickListener(this);
- mTabsScrollWrapper = (NoDragHorizontalScrollView) mInflater.inflate(
+ mTabsScrollWrapper = (HorizontalScrollView) mInflater.inflate(
R.layout.tab_layout, this, false);
- mTabsView = (LinearLayout) mTabsScrollWrapper.findViewById(android.R.id.tabs);
- mDividerDrawable = mContext.getResources().getDrawable(
- R.drawable.tab_divider);
+ mTabsView = (TabStripView) mTabsScrollWrapper.findViewById(android.R.id.tabs);
mLeftArrowView.setVisibility(View.INVISIBLE);
mRightArrowView.setVisibility(View.INVISIBLE);
@@ -140,7 +140,7 @@
* @return the tab indicator view at the given index
*/
public View getChildTabViewAt(int index) {
- return mTabsView.getChildAt(index*2);
+ return mTabsView.getChildAt(index);
}
/**
@@ -149,8 +149,7 @@
* @return the number of tab indicator views.
*/
public int getTabCount() {
- int children = mTabsView.getChildCount();
- return (children + 1) / 2;
+ return mTabsView.getChildCount();
}
public void removeAllTabs() {
@@ -195,9 +194,9 @@
return;
}
- getChildTabViewAt(mSelectedTab).setSelected(false);
+ mTabsView.setSelected(mSelectedTab, false);
mSelectedTab = index;
- getChildTabViewAt(mSelectedTab).setSelected(true);
+ mTabsView.setSelected(mSelectedTab, true);
}
/**
@@ -266,17 +265,6 @@
child.setOnClickListener(new TabClickListener());
child.setOnFocusChangeListener(this);
- // If we already have at least one tab, then add a divider before adding the next tab.
- if (getTabCount() > 0) {
- View divider = new View(mContext);
- final LayoutParams lp = new LayoutParams(
- mDividerDrawable.getIntrinsicWidth(),
- ViewGroup.LayoutParams.FILL_PARENT);
- lp.setMargins(0, 0, 0, 0);
- divider.setLayoutParams(lp);
- divider.setBackgroundDrawable(mDividerDrawable);
- mTabsView.addView(divider);
- }
mTabsView.addView(child);
}
@@ -369,23 +357,8 @@
void onTabSelectionChanged(int tabIndex, boolean clicked);
}
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- boolean handled = super.dispatchKeyEvent(event);
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- switch (event.getKeyCode()) {
- case KeyEvent.KEYCODE_DPAD_LEFT:
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- // If tabs move from left/right events we must update mLeftMostVisibleTabIndex.
- updateLeftMostVisible();
- break;
- }
- }
-
- return handled;
- }
-
public void onClick(View v) {
+ updateLeftMostVisible();
if (v == mRightArrowView && (mLeftMostVisibleTabIndex + 1 < getTabCount())) {
tabScroll(true /* right */);
} else if (v == mLeftArrowView && mLeftMostVisibleTabIndex > 0) {
diff --git a/src/com/android/contacts/TabStripView.java b/src/com/android/contacts/TabStripView.java
new file mode 100644
index 0000000..70878ea
--- /dev/null
+++ b/src/com/android/contacts/TabStripView.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+package com.android.contacts;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Rect;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.HorizontalScrollView;
+import android.widget.LinearLayout;
+
+/** Extension of LinearLayout that takes care of drawing bottom strips over the tab children. */
+public class TabStripView extends LinearLayout {
+
+ private Drawable mBottomLeftStrip;
+ private Drawable mBottomRightStrip;
+ private int mSelectedTabIndex;
+
+ public TabStripView(Context context) {
+ this(context, null);
+ }
+
+ public TabStripView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ private void init() {
+ mBottomLeftStrip = mContext.getResources().getDrawable(
+ R.drawable.tab_bottom);
+ mBottomRightStrip = mContext.getResources().getDrawable(
+ R.drawable.tab_bottom);
+ }
+
+ public void setSelected(int index, boolean selected) {
+ mSelectedTabIndex = index;
+ getChildAt(index).setSelected(selected);
+ }
+
+ @Override
+ public void childDrawableStateChanged(View child) {
+ if (child == getChildAt(mSelectedTabIndex)) {
+ // To make sure that the bottom strip is redrawn
+ invalidate();
+ }
+ super.childDrawableStateChanged(child);
+ }
+
+ @Override
+ public void dispatchDraw(Canvas canvas) {
+ super.dispatchDraw(canvas);
+
+ View selectedChild = getChildAt(mSelectedTabIndex);
+
+ mBottomRightStrip.setState(selectedChild.getDrawableState());
+ mBottomLeftStrip.setState(selectedChild.getDrawableState());
+
+ Rect selBounds = new Rect(); // Bounds of the selected tab indicator
+ selBounds.left = selectedChild.getLeft() - getScrollX();
+ selBounds.right = selectedChild.getRight() - getScrollX();
+ final int myHeight = getHeight();
+ mBottomLeftStrip.setBounds(
+ Math.min(0, selBounds.left
+ - mBottomLeftStrip.getIntrinsicWidth()),
+ myHeight - mBottomLeftStrip.getIntrinsicHeight(),
+ selBounds.left,
+ myHeight);
+ mBottomRightStrip.setBounds(
+ selBounds.right,
+ myHeight - mBottomRightStrip.getIntrinsicHeight(),
+ Math.max(getWidth(),
+ selBounds.right + mBottomRightStrip.getIntrinsicWidth()),
+ myHeight);
+
+ mBottomLeftStrip.draw(canvas);
+ mBottomRightStrip.draw(canvas);
+ }
+
+}