Remove tab pager and related resources
Bug 30944495
Change-Id: I0b42268bf15704d507fdbacd25a8b1b9accb6cbd
diff --git a/res/color/tab_text_color.xml b/res/color/tab_text_color.xml
deleted file mode 100644
index 5ef1fe3..0000000
--- a/res/color/tab_text_color.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2014 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:color="@color/actionbar_text_color" android:state_selected="true"/>
- <item android:color="@color/actionbar_unselected_text_color" />
-</selector>
\ No newline at end of file
diff --git a/res/drawable-v21/view_pager_tab_background.xml b/res/drawable-v21/view_pager_tab_background.xml
deleted file mode 100644
index b9e0805..0000000
--- a/res/drawable-v21/view_pager_tab_background.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2016 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
- -->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/tab_ripple_color">
- <item android:id="@android:id/mask">
- <color android:color="@android:color/white" />
- </item>
-</ripple>
diff --git a/res/drawable/unread_count_background.xml b/res/drawable/unread_count_background.xml
deleted file mode 100644
index f70f84a..0000000
--- a/res/drawable/unread_count_background.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-<shape
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle">
- <corners android:radius="@dimen/tab_unread_count_background_radius"/>
- <solid android:color="@color/tab_unread_count_background_color" />
-</shape>
diff --git a/res/drawable/view_pager_tab_background.xml b/res/drawable/view_pager_tab_background.xml
deleted file mode 100644
index 9f59845..0000000
--- a/res/drawable/view_pager_tab_background.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2014 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="@color/tab_ripple_color"/>
-</selector>
\ No newline at end of file
diff --git a/res/layout-ldrtl/unread_count_tab.xml b/res/layout-ldrtl/unread_count_tab.xml
deleted file mode 100644
index b23ab57..0000000
--- a/res/layout-ldrtl/unread_count_tab.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-<!-- layoutDirection set to ltr as a workaround to a framework bug (b/22010411) causing view with
- layout_centerInParent inside a RelativeLayout to expand to screen width when RTL is active -->
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/view_pager_tab_background"
- android:layoutDirection="ltr">
- <!-- The tab icon -->
- <ImageView
- android:id="@+id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"/>
- <TextView
- android:id="@+id/count"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/tab_unread_count_background_size"
- android:layout_marginTop="@dimen/tab_unread_count_margin_top"
- android:layout_marginStart="@dimen/tab_unread_count_margin_left"
- android:layout_toStartOf="@id/icon"
- android:paddingLeft="@dimen/tab_unread_count_text_padding"
- android:paddingRight="@dimen/tab_unread_count_text_padding"
- android:background="@drawable/unread_count_background"
- android:fontFamily="sans-serif-medium"
- android:importantForAccessibility="no"
- android:minWidth="@dimen/tab_unread_count_background_size"
- android:textAlignment="center"
- android:textColor="@color/tab_accent_color"
- android:textSize="@dimen/tab_unread_count_text_size"
- android:layoutDirection="locale"/>
-</RelativeLayout>
-
diff --git a/res/layout/people_activity.xml b/res/layout/people_activity.xml
index 9fd1a69..46f0976 100644
--- a/res/layout/people_activity.xml
+++ b/res/layout/people_activity.xml
@@ -25,18 +25,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <!--
- ViewPager for swiping between tabs. We put fragments at runtime.
-
- (Adding them directly as the children of this view is not recommended. ViewPager should
- be treated like a ListView, which doesn't expect children to be added from the layout.)
- -->
- <android.support.v4.view.ViewPager
- android:id="@+id/tab_pager"
- android:layout_height="match_parent"
+ <FrameLayout
+ android:id="@+id/contacts_view"
android:layout_width="match_parent"
- android:layout_below="@id/toolbar_parent"
- />
+ android:layout_height="match_parent"
+ android:layout_below="@id/toolbar_parent">
+ <FrameLayout
+ android:id="@+id/contacts_list_container"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent" />
+ </FrameLayout>
<FrameLayout
android:id="@+id/contacts_unavailable_view"
diff --git a/res/layout/people_activity_tabs_lands.xml b/res/layout/people_activity_tabs_lands.xml
deleted file mode 100644
index 8d7b42b..0000000
--- a/res/layout/people_activity_tabs_lands.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 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.
--->
-
-<com.android.contacts.common.list.ViewPagerTabs
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/lists_pager_header"
- android:layout_width="@dimen/people_activity_landscape_tabs_width"
- android:layout_height="match_parent"
- android:textAllCaps="true"
- android:orientation="horizontal"
- android:layout_gravity="top"
- android:layout_weight="0"
- android:visibility="gone"
- android:textSize="@dimen/people_activity_landscape_tabs_text_size"
- style="@style/ContactsActionBarTabTextStyle" />
diff --git a/res/layout/people_activity_toolbar.xml b/res/layout/people_activity_toolbar.xml
index edca3ba..3599f0c 100644
--- a/res/layout/people_activity_toolbar.xml
+++ b/res/layout/people_activity_toolbar.xml
@@ -36,17 +36,4 @@
style="@style/ContactsToolbarStyle" />
</FrameLayout>
-
- <com.android.contacts.common.list.ViewPagerTabs
- android:id="@+id/lists_pager_header"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:textAllCaps="true"
- android:orientation="horizontal"
- android:layout_gravity="top"
- android:layout_weight="0"
- android:layout_below="@id/toolbar"
- android:visibility="gone"
- style="@style/ContactsActionBarTabTextStyle" />
-
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/unread_count_tab.xml b/res/layout/unread_count_tab.xml
deleted file mode 100644
index 783f1c1..0000000
--- a/res/layout/unread_count_tab.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/view_pager_tab_background">
- <!-- The tab icon -->
- <ImageView
- android:id="@+id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true" />
- <TextView
- android:id="@+id/count"
- android:background="@drawable/unread_count_background"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/tab_unread_count_background_size"
- android:gravity="center"
- android:minWidth="@dimen/tab_unread_count_background_size"
- android:layout_marginStart="@dimen/tab_unread_count_margin_left"
- android:layout_marginTop="@dimen/tab_unread_count_margin_top"
- android:layout_toEndOf="@id/icon"
- android:paddingLeft="@dimen/tab_unread_count_text_padding"
- android:paddingRight="@dimen/tab_unread_count_text_padding"
- android:textAlignment="center"
- android:textSize="@dimen/tab_unread_count_text_size"
- android:textColor="@color/tab_accent_color"
- android:fontFamily="sans-serif-medium"
- android:importantForAccessibility="no" />
-</RelativeLayout>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 6f6f4e1..8dd1ba9 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -28,10 +28,6 @@
<dimen name="contact_browser_list_top_margin">18dp</dimen>
<dimen name="quick_contact_photo_container_height">360dip</dimen>
- <!-- Height of the selection indicator of a tab. -->
- <dimen name="tab_selected_underline_height">3dp</dimen>
- <!-- Size of text in tabs. -->
- <dimen name="tab_text_size">16sp</dimen>
<!-- Because the "join" screen has the vertical scroll bar on right,
we cannot use @dimen/contact_browser_list_header_left_margin as is. -->
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index b89c2c1..baa8498 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -18,5 +18,4 @@
<dimen name="group_editor_side_padding">64dip</dimen>
<dimen name="contact_detail_list_top_padding">32dip</dimen>
<dimen name="detail_contact_photo_size">256dip</dimen>
- <dimen name="people_activity_landscape_tabs_text_size">16dp</dimen>
</resources>
diff --git a/res/values-w470dp/dimens.xml b/res/values-w470dp/dimens.xml
deleted file mode 100644
index 2c04e5d..0000000
--- a/res/values-w470dp/dimens.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 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.
--->
-<resources>
-
- <!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
- 470dp is the height of a "normal" screen. We should leave 240dp for
- the title and menu items -->
- <dimen name="people_activity_landscape_tabs_width">230dip</dimen>
- <!-- The size of the text displayed in the ActionBar tabs in landscape mode.
- Text in the tabs should must be width dependent, otherwise it won't fit in the tabs.
- In portrait mode, the tabs look okay when overflowing their allocated space.
- We have to be more careful in landscape. -->
- <dimen name="people_activity_landscape_tabs_text_size">9dp</dimen>
-
-</resources>
\ No newline at end of file
diff --git a/res/values-w590dp/dimens.xml b/res/values-w590dp/dimens.xml
deleted file mode 100644
index 2fff6ca..0000000
--- a/res/values-w590dp/dimens.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 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.
--->
-<resources>
-
- <!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
- 590dp is almost the height of a "large" screen. We should leave 240dp for
- the title and menu items -->
- <dimen name="people_activity_landscape_tabs_width">350dip</dimen>
- <!-- The size of the text displayed in the ActionBar tabs in landscape mode.
- Text in the tabs should must be width dependent, otherwise it won't fit in the tabs.
- In portrait mode, the tabs look okay when overflowing their allocated space.
- We have to be more careful in landscape. -->
- <dimen name="people_activity_landscape_tabs_text_size">14dp</dimen>
-
-</resources>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0cba8e6..2e7dea3 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -201,11 +201,6 @@
<!-- Darker version of the actionbar color. Used for the status bar and navigation bar colors. -->
<color name="actionbar_background_color_dark">#008aa1</color>
- <color name="tab_ripple_color">@color/tab_accent_color</color>
- <color name="tab_accent_color">#ffffff</color>
- <color name="tab_selected_underline_color">@color/tab_accent_color</color>
- <color name="tab_unread_count_background_color">#700f4b70</color>
-
<!-- Color of the title to the Frequently Contacted section -->
<color name="frequently_contacted_title_color">@color/actionbar_background_color</color>
@@ -218,7 +213,6 @@
<color name="actionbar_text_color_black">#DF000000</color>
<!-- Solid grey for status bar overlay-->
<color name="actionbar_color_grey_solid">#777777</color>
- <color name="actionbar_unselected_text_color">#a6ffffff</color>
<!-- Text color of the search box text as entered by user -->
<color name="searchbox_text_color">#000000</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ab102fe..2eb4b22 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -238,16 +238,6 @@
<dimen name="quickcontact_expanding_button_section_height">48dp</dimen>
<dimen name="quickcontact_expanding_button_section_padding">8dp</dimen>
- <!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
- 426dp is the height of a "small" screen. We should leave 240dp for
- the title and menu items -->
- <dimen name="people_activity_landscape_tabs_width">186dip</dimen>
- <!-- The size of the text displayed in the ActionBar tabs in landscape mode.
- Text in the tabs should must be width dependent, otherwise it won't fit in the tabs.
- In portrait mode, the tabs look okay when overflowing their allocated space.
- We have to be more careful in landscape. -->
- <dimen name="people_activity_landscape_tabs_text_size">8dp</dimen>
-
<!-- Top margin of the text message when provider status is busy -->
<dimen name="update_contact_list_top_margin">188dp</dimen>
@@ -431,17 +421,8 @@
<!-- Offset of bottom margin of the floating action button used when dialpad is up -->
<dimen name="floating_action_button_dialpad_margin_bottom_offset">4dp</dimen>
- <!-- Height of the selection indicator of a tab. -->
- <dimen name="tab_selected_underline_height">2dp</dimen>
<!-- Size of text in tabs. -->
- <dimen name="tab_text_size">14sp</dimen>
<dimen name="tab_elevation">2dp</dimen>
- <dimen name="tab_unread_count_background_size">16dp</dimen>
- <dimen name="tab_unread_count_background_radius">2dp</dimen>
- <dimen name="tab_unread_count_margin_left">10dp</dimen>
- <dimen name="tab_unread_count_margin_top">2dp</dimen>
- <dimen name="tab_unread_count_text_size">12sp</dimen>
- <dimen name="tab_unread_count_text_padding">2dp</dimen>
<!-- Padding around the icon in the search box. -->
<dimen name="search_box_icon_margin">4dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 33fa11e..528a61a 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -41,10 +41,6 @@
<style name="PeopleTheme" parent="@android:style/Theme.Material.Light">
<item name="android:actionBarStyle">@style/ContactsActionBarStyle</item>
- <!-- Style for the tab bar (for the divider between tabs) -->
- <item name="android:actionBarTabBarStyle">@style/ContactsActionBarTabBarStyle</item>
- <!-- Style for the tab bar text (for text on tabs) -->
- <item name="android:actionBarTabTextStyle">@style/ContactsActionBarTabTextStyle</item>
<!-- Drawable for the back button -->
<item name="android:homeAsUpIndicator">@drawable/ic_back_arrow</item>
<!-- Style for the overflow button in the actionbar. -->
@@ -107,12 +103,6 @@
<!-- Styles that require AppCompat compatibility, remember to update both sets -->
<item name="android:actionBarStyle">@style/ContactsActionBarStyleAppCompat</item>
<item name="actionBarStyle">@style/ContactsActionBarStyleAppCompat</item>
- <!-- Style for the tab bar (for the divider between tabs) -->
- <item name="android:actionBarTabBarStyle">@style/ContactsActionBarTabBarStyle</item>
- <item name="actionBarTabBarStyle">@style/ContactsActionBarTabBarStyle</item>
- <!-- Style for the tab bar text (for text on tabs) -->
- <item name="android:actionBarTabTextStyle">@style/ContactsActionBarTabTextStyle</item>
- <item name="actionBarTabTextStyle">@style/ContactsActionBarTabTextStyle</item>
<item name="android:actionButtonStyle">@style/ContactsActionButtonStyle</item>
<item name="actionButtonStyle">@style/ContactsActionButtonStyle</item>
<!-- Drawable for the back button -->
@@ -244,22 +234,6 @@
<item name="android:textColor">@color/actionbar_text_color_black</item>
</style>
- <!-- Styling for the tab bar; handles styling of the divider line. -->
- <style name="ContactsActionBarTabBarStyle"
- parent="@android:style/Widget.Material.ActionBar.TabBar">
- <item name="android:showDividers">none</item>
- </style>
-
- <!-- Text style for tabs. -->
- <style name="ContactsActionBarTabTextStyle"
- parent="android:style/Widget.Material.Light.ActionBar.TabText">
- <item name="android:textColor">@color/tab_text_color</item>
- <item name="android:textSize">@dimen/tab_text_size</item>
- <item name="android:fontFamily">@string/tab_font_family</item>
- <item name="android:elevation">0dp</item>
- <item name="android:textStyle">bold</item>
- </style>
-
<!-- Action bar overflow menu icon. -->
<style name="ContactsActionBarOverflowQP"
parent="Widget.AppCompat.Light.ActionButton.Overflow">
diff --git a/src/com/android/contacts/activities/ActionBarAdapter.java b/src/com/android/contacts/activities/ActionBarAdapter.java
index b896406..129f36b 100644
--- a/src/com/android/contacts/activities/ActionBarAdapter.java
+++ b/src/com/android/contacts/activities/ActionBarAdapter.java
@@ -20,11 +20,8 @@
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
@@ -71,41 +68,26 @@
void onAction(int action);
- /**
- * Called when the user selects a tab. The new tab can be obtained using
- * {@link #getCurrentTab}.
- */
- void onSelectedTabChanged();
-
void onUpButtonPressed();
}
private static final String EXTRA_KEY_SEARCH_MODE = "navBar.searchMode";
private static final String EXTRA_KEY_QUERY = "navBar.query";
- private static final String EXTRA_KEY_SELECTED_TAB = "navBar.selectedTab";
private static final String EXTRA_KEY_SELECTED_MODE = "navBar.selectionMode";
- private static final String PERSISTENT_LAST_TAB = "actionBarAdapter.lastTab";
-
private boolean mSelectionMode;
private boolean mSearchMode;
private String mQueryString;
private EditText mSearchView;
private View mClearSearchView;
- /** The view that represents tabs when we are in portrait mode **/
- private View mPortraitTabs;
- /** The view that represents tabs when we are in landscape mode **/
- private View mLandscapeTabs;
private View mSearchContainer;
private View mSelectionContainer;
- private int mMaxPortraitTabHeight;
private int mMaxToolbarContentInsetStart;
private int mActionBarAnimationDuration;
private final Activity mActivity;
- private final SharedPreferences mPrefs;
private Listener mListener;
@@ -126,29 +108,16 @@
private ValueAnimator mStatusBarAnimator;
- public interface TabState {
- public static int ALL = 0;
-
- public static int COUNT = 1;
- public static int DEFAULT = ALL;
- }
-
- private int mCurrentTab = TabState.DEFAULT;
-
public ActionBarAdapter(Activity activity, Listener listener, ActionBar actionBar,
- View portraitTabs, View landscapeTabs, Toolbar toolbar) {
- this(activity, listener, actionBar, portraitTabs, landscapeTabs, toolbar,
- R.string.hint_findContacts);
+ Toolbar toolbar) {
+ this(activity, listener, actionBar, toolbar, R.string.hint_findContacts);
}
public ActionBarAdapter(Activity activity, Listener listener, ActionBar actionBar,
- View portraitTabs, View landscapeTabs, Toolbar toolbar, int searchHintResId) {
+ Toolbar toolbar, int searchHintResId) {
mActivity = activity;
mListener = listener;
mActionBar = actionBar;
- mPrefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
- mPortraitTabs = portraitTabs;
- mLandscapeTabs = landscapeTabs;
mToolbar = toolbar;
mToolBarFrame = (FrameLayout) mToolbar.getParent();
mMaxToolbarContentInsetStart = mToolbar.getContentInsetStart();
@@ -157,7 +126,6 @@
mActivity.getResources().getInteger(R.integer.action_bar_animation_duration);
setupSearchAndSelectionViews();
- setupTabs(mActivity);
}
public void setShowHomeIcon(boolean showHomeIcon) {
@@ -168,22 +136,10 @@
mShowHomeAsUp = showHomeAsUp;
}
- public EditText getSearchView() {
- return mSearchView;
- }
-
public View getSelectionContainer() {
return mSelectionContainer;
}
- private void setupTabs(Context context) {
- final TypedArray attributeArray = context.obtainStyledAttributes(
- new int[]{android.R.attr.actionBarSize});
- mMaxPortraitTabHeight = attributeArray.getDimensionPixelSize(0, 0);
- // Hide tabs initially
- setPortraitTabHeight(0);
- }
-
private void setupSearchAndSelectionViews() {
final LayoutInflater inflater = (LayoutInflater) mToolbar.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
@@ -238,19 +194,11 @@
if (savedState == null) {
mSearchMode = request.isSearchMode();
mQueryString = request.getQueryString();
- mCurrentTab = loadLastTabPreference();
mSelectionMode = false;
} else {
mSearchMode = savedState.getBoolean(EXTRA_KEY_SEARCH_MODE);
mSelectionMode = savedState.getBoolean(EXTRA_KEY_SELECTED_MODE);
mQueryString = savedState.getString(EXTRA_KEY_QUERY);
-
- // Just set to the field here. The listener will be notified by update().
- mCurrentTab = savedState.getInt(EXTRA_KEY_SELECTED_TAB);
- }
- if (mCurrentTab >= TabState.COUNT || mCurrentTab < 0) {
- // Invalid tab index was saved (b/12938207). Restore the default.
- mCurrentTab = TabState.DEFAULT;
}
// Show tabs or the expanded {@link SearchView}, depending on whether or not we are in
// search mode.
@@ -294,30 +242,6 @@
}
/**
- * Save the current tab selection, and notify the listener.
- */
- public void setCurrentTab(int tab) {
- setCurrentTab(tab, true);
- }
-
- /**
- * Save the current tab selection.
- */
- public void setCurrentTab(int tab, boolean notifyListener) {
- if (tab == mCurrentTab) {
- return;
- }
- mCurrentTab = tab;
-
- if (notifyListener && mListener != null) mListener.onSelectedTabChanged();
- saveLastTabPreference(mCurrentTab);
- }
-
- public int getCurrentTab() {
- return mCurrentTab;
- }
-
- /**
* @return Whether in search mode, i.e. if the search view is visible/expanded.
*
* Note even if the action bar is in search mode, if the query is empty, the search fragment
@@ -472,18 +396,12 @@
// to adding the desired container.
if (skipAnimation || isSwitchingFromSearchToSelection) {
if (isTabHeightChanging || isSwitchingFromSearchToSelection) {
- mToolbar.removeView(mLandscapeTabs);
mToolbar.removeView(mSearchContainer);
mToolBarFrame.removeView(mSelectionContainer);
if (mSelectionMode) {
- setPortraitTabHeight(0);
addSelectionContainer();
} else if (mSearchMode) {
- setPortraitTabHeight(0);
addSearchContainer();
- } else {
- setPortraitTabHeight(mMaxPortraitTabHeight);
- addLandscapeViewPagerTabs();
}
updateDisplayOptions(isSearchModeChanging);
}
@@ -492,25 +410,21 @@
// Handle a switch to/from selection mode, due to UI interaction.
if (isSelectionModeChanging) {
- mToolbar.removeView(mLandscapeTabs);
if (mSelectionMode) {
addSelectionContainer();
mSelectionContainer.setAlpha(0);
mSelectionContainer.animate().alpha(1).setDuration(mActionBarAnimationDuration);
- animateTabHeightChange(mMaxPortraitTabHeight, 0);
updateDisplayOptions(isSearchModeChanging);
} else {
if (mListener != null) {
mListener.onAction(Action.BEGIN_STOPPING_SEARCH_AND_SELECTION_MODE);
}
mSelectionContainer.setAlpha(1);
- animateTabHeightChange(0, mMaxPortraitTabHeight);
mSelectionContainer.animate().alpha(0).setDuration(mActionBarAnimationDuration)
.withEndAction(new Runnable() {
@Override
public void run() {
updateDisplayOptions(isSearchModeChanging);
- addLandscapeViewPagerTabs();
mToolBarFrame.removeView(mSelectionContainer);
}
});
@@ -519,22 +433,18 @@
// Handle a switch to/from search mode, due to UI interaction.
if (isSearchModeChanging) {
- mToolbar.removeView(mLandscapeTabs);
if (mSearchMode) {
addSearchContainer();
mSearchContainer.setAlpha(0);
mSearchContainer.animate().alpha(1).setDuration(mActionBarAnimationDuration);
- animateTabHeightChange(mMaxPortraitTabHeight, 0);
updateDisplayOptions(isSearchModeChanging);
} else {
mSearchContainer.setAlpha(1);
- animateTabHeightChange(0, mMaxPortraitTabHeight);
mSearchContainer.animate().alpha(0).setDuration(mActionBarAnimationDuration)
.withEndAction(new Runnable() {
@Override
public void run() {
updateDisplayOptions(isSearchModeChanging);
- addLandscapeViewPagerTabs();
mToolbar.removeView(mSearchContainer);
}
});
@@ -641,13 +551,6 @@
}
}
- private void addLandscapeViewPagerTabs() {
- if (mLandscapeTabs != null) {
- mToolbar.removeView(mLandscapeTabs);
- mToolbar.addView(mLandscapeTabs);
- }
- }
-
private void addSearchContainer() {
mToolbar.removeView(mSearchContainer);
mToolbar.addView(mSearchContainer);
@@ -682,7 +585,6 @@
}
if (!mSearchMode && !mSelectionMode) {
mListener.onAction(Action.STOP_SEARCH_AND_SELECTION_MODE);
- mListener.onSelectedTabChanged();
}
}
updateDisplayOptionsInner();
@@ -698,7 +600,6 @@
outState.putBoolean(EXTRA_KEY_SEARCH_MODE, mSearchMode);
outState.putBoolean(EXTRA_KEY_SELECTED_MODE, mSelectionMode);
outState.putString(EXTRA_KEY_QUERY, mQueryString);
- outState.putInt(EXTRA_KEY_SELECTED_TAB, mCurrentTab);
}
public void setFocusOnSearchView() {
@@ -713,41 +614,4 @@
imm.showSoftInput(view, 0);
}
}
-
- private void saveLastTabPreference(int tab) {
- mPrefs.edit().putInt(PERSISTENT_LAST_TAB, tab).apply();
- }
-
- private int loadLastTabPreference() {
- try {
- return mPrefs.getInt(PERSISTENT_LAST_TAB, TabState.DEFAULT);
- } catch (IllegalArgumentException e) {
- // Preference is corrupt?
- return TabState.DEFAULT;
- }
- }
-
- private void animateTabHeightChange(int start, int end) {
- if (mPortraitTabs == null) {
- return;
- }
- final ValueAnimator animator = ValueAnimator.ofInt(start, end);
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- int value = (Integer) valueAnimator.getAnimatedValue();
- setPortraitTabHeight(value);
- }
- });
- animator.setDuration(100).start();
- }
-
- private void setPortraitTabHeight(int height) {
- if (mPortraitTabs == null) {
- return;
- }
- ViewGroup.LayoutParams layoutParams = mPortraitTabs.getLayoutParams();
- layoutParams.height = height;
- mPortraitTabs.setLayoutParams(layoutParams);
- }
}
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index 7bb921d..57c460a 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -146,8 +146,7 @@
// Add a shadow under the toolbar.
ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources());
- mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(),
- /* portraitTabs */ null, /* landscapeTabs */ null, mToolbar,
+ mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(), mToolbar,
R.string.enter_contact_name);
mActionBarAdapter.setShowHomeIcon(true);
mActionBarAdapter.setShowHomeAsUp(true);
@@ -436,10 +435,6 @@
}
@Override
- public void onSelectedTabChanged() {
- }
-
- @Override
public void onUpButtonPressed() {
onBackPressed();
}
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 41139d8..8cef3e3 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -34,7 +34,6 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.os.Parcelable;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.ProviderStatus;
@@ -42,11 +41,8 @@
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
-import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.GravityCompat;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.text.TextUtils;
import android.util.Log;
@@ -66,7 +62,6 @@
import com.android.contacts.ContactSaveService;
import com.android.contacts.ContactsDrawerActivity;
import com.android.contacts.R;
-import com.android.contacts.activities.ActionBarAdapter.TabState;
import com.android.contacts.common.Experiments;
import com.android.contacts.common.activity.RequestPermissionsActivity;
import com.android.contacts.common.compat.CompatUtils;
@@ -77,7 +72,6 @@
import com.android.contacts.common.list.DirectoryListLoader;
import com.android.contacts.common.list.ProviderStatusWatcher;
import com.android.contacts.common.list.ProviderStatusWatcher.ProviderStatusListener;
-import com.android.contacts.common.list.ViewPagerTabs;
import com.android.contacts.common.logging.ListEvent;
import com.android.contacts.common.logging.Logger;
import com.android.contacts.common.logging.ScreenEvent.ScreenType;
@@ -127,6 +121,8 @@
private static final String ENABLE_DEBUG_OPTIONS_HIDDEN_CODE = "debug debug!";
+ private static final String TAG_ALL = "contacts-all";
+
private static final int ACTIVITY_REQUEST_CODE_SHARE = 0;
private final DialogManager mDialogManager = new DialogManager(this);
@@ -155,12 +151,7 @@
*/
private DefaultContactBrowseListFragment mAllFragment;
- /** ViewPager for swipe */
- private ViewPager mTabPager;
- private ViewPagerTabs mViewPagerTabs;
- private TabPagerAdapter mTabPagerAdapter;
- private String[] mTabTitles;
- private final TabPagerListener mTabPagerListener = new TabPagerListener();
+ private View mContactsView;
private boolean mEnableDebugMenuOptions;
@@ -386,44 +377,17 @@
final FragmentManager fragmentManager = getFragmentManager();
- // Hide all tabs (the current tab will later be reshown once a tab is selected)
final FragmentTransaction transaction = fragmentManager.beginTransaction();
- mTabTitles = new String[TabState.COUNT];
- mTabTitles[TabState.ALL] = getString(R.string.all_contacts_tab_label);
- mTabPager = getView(R.id.tab_pager);
- mTabPagerAdapter = new TabPagerAdapter();
- mTabPager.setAdapter(mTabPagerAdapter);
- mTabPager.setOnPageChangeListener(mTabPagerListener);
-
- // Configure toolbar and toolbar tabs. If in landscape mode, we configure tabs differently.
- final ViewPagerTabs portraitViewPagerTabs
- = (ViewPagerTabs) findViewById(R.id.lists_pager_header);
- ViewPagerTabs landscapeViewPagerTabs = null;
- if (portraitViewPagerTabs == null) {
- landscapeViewPagerTabs = (ViewPagerTabs) getLayoutInflater().inflate(
- R.layout.people_activity_tabs_lands, mToolbar, /* attachToRoot = */ false);
- mViewPagerTabs = landscapeViewPagerTabs;
- } else {
- mViewPagerTabs = portraitViewPagerTabs;
- }
- mViewPagerTabs.setViewPager(mTabPager);
-
- final String ALL_TAG = "tab-pager-all";
-
- // Create the fragments and add as children of the view pager.
- // The pager adapter will only change the visibility; it'll never create/destroy
- // fragments.
- // However, if it's after screen rotation, the fragments have been re-created by
- // the fragment manager, so first see if there're already the target fragments
- // existing.
mAllFragment = (DefaultContactBrowseListFragment)
- fragmentManager.findFragmentByTag(ALL_TAG);
+ fragmentManager.findFragmentByTag(TAG_ALL);
+
+ mContactsView = getView(R.id.contacts_view);
if (mAllFragment == null) {
mAllFragment = new DefaultContactBrowseListFragment();
mAllFragment.setAnimateOnLoad(true);
- transaction.add(R.id.tab_pager, mAllFragment, ALL_TAG);
+ transaction.add(R.id.contacts_list_container, mAllFragment, TAG_ALL);
}
mAllFragment.setFeatureHighlightCallback(this);
@@ -431,15 +395,14 @@
mAllFragment.setCheckBoxListListener(new CheckBoxListListener());
mAllFragment.setListType(mContactListFilterController.getFilterListType());
- // Hide all fragments for now. We adjust visibility when we get onSelectedTabChanged()
- // from ActionBarAdapter.
+ // Hide all fragments for now. We adjust visibility when we get
+ // onAction(Action.STOP_SEARCH_AND_SELECTION_MODE) from ActionBarAdapter.
transaction.hide(mAllFragment);
transaction.commitAllowingStateLoss();
fragmentManager.executePendingTransactions();
- mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(),
- portraitViewPagerTabs, landscapeViewPagerTabs, mToolbar);
+ mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(), mToolbar);
mActionBarAdapter.initialize(savedState, mRequest);
// Configure floating action button
@@ -515,11 +478,6 @@
// called. See also: onSaveInstanceState
mActionBarAdapter.setListener(this);
mDisableOptionItemSelected = false;
- if (mTabPager != null) {
- mTabPager.setOnPageChangeListener(mTabPagerListener);
- }
- // Current tab may have changed since the last onSaveInstanceState(). Make sure
- // the actual contents match the tab.
updateFragmentsVisibility();
if (Flags.getInstance(this).getBoolean(Experiments.PULL_TO_REFRESH)) {
@@ -558,33 +516,22 @@
ContactListFilter filter = null;
int actionCode = mRequest.getActionCode();
boolean searchMode = mRequest.isSearchMode();
- final int tabToOpen;
switch (actionCode) {
case ContactsRequest.ACTION_ALL_CONTACTS:
filter = createContactsFilter();
- tabToOpen = TabState.ALL;
break;
case ContactsRequest.ACTION_CONTACTS_WITH_PHONES:
filter = ContactListFilter.createFilterWithType(
ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY);
- tabToOpen = TabState.ALL;
break;
case ContactsRequest.ACTION_FREQUENT:
case ContactsRequest.ACTION_STREQUENT:
case ContactsRequest.ACTION_STARRED:
- tabToOpen = TabState.ALL;
- break;
case ContactsRequest.ACTION_VIEW_CONTACT:
- tabToOpen = TabState.ALL;
- break;
default:
- tabToOpen = -1;
break;
}
- if (tabToOpen != -1) {
- mActionBarAdapter.setCurrentTab(tabToOpen);
- }
if (filter != null) {
mContactListFilterController.setContactListFilter(filter, /* persistent */ false);
@@ -718,11 +665,6 @@
}
@Override
- public void onSelectedTabChanged() {
- updateFragmentsVisibility();
- }
-
- @Override
public void onUpButtonPressed() {
onBackPressed();
}
@@ -736,223 +678,13 @@
/**
* Updates the fragment/view visibility according to the current mode, such as
- * {@link ActionBarAdapter#isSearchMode()} and {@link ActionBarAdapter#getCurrentTab()}.
+ * {@link ActionBarAdapter#isSearchMode()}.
*/
private void updateFragmentsVisibility() {
- int tab = mActionBarAdapter.getCurrentTab();
-
- if (mActionBarAdapter.isSearchMode() || mActionBarAdapter.isSelectionMode()) {
- mTabPagerAdapter.setTabsHidden(true);
- } else {
- // No smooth scrolling if quitting from the search/selection mode.
- final boolean wereTabsHidden = mTabPagerAdapter.areTabsHidden()
- || mActionBarAdapter.isSelectionMode();
- mTabPagerAdapter.setTabsHidden(false);
- if (mTabPager.getCurrentItem() != tab) {
- mTabPager.setCurrentItem(tab, !wereTabsHidden);
- }
- }
if (!mActionBarAdapter.isSelectionMode()) {
mAllFragment.displayCheckBoxes(false);
}
invalidateOptionsMenu();
- showEmptyStateForTab(tab);
- }
-
- private void showEmptyStateForTab(int tab) {
- if (mContactsUnavailableFragment != null) {
- switch (getTabPositionForTextDirection(tab)) {
- case TabState.ALL:
- mContactsUnavailableFragment.setTabInfo(R.string.noContacts, TabState.ALL);
- break;
- }
- // When using the mContactsUnavailableFragment the ViewPager doesn't contain two views.
- // Therefore, we have to trick the ViewPagerTabs into thinking we have changed tabs
- // when the mContactsUnavailableFragment changes. Otherwise the tab strip won't move.
- mViewPagerTabs.onPageScrolled(tab, 0, 0);
- }
- }
-
- private class TabPagerListener implements ViewPager.OnPageChangeListener {
-
- // This package-protected constructor is here because of a possible compiler bug.
- // PeopleActivity$1.class should be generated due to the private outer/inner class access
- // needed here. But for some reason, PeopleActivity$1.class is missing.
- // Since $1 class is needed as a jvm work around to get access to the inner class,
- // changing the constructor to package-protected or public will solve the problem.
- // To verify whether $1 class is needed, javap PeopleActivity$TabPagerListener and look for
- // references to PeopleActivity$1.
- //
- // When the constructor is private and PeopleActivity$1.class is missing, proguard will
- // correctly catch this and throw warnings and error out the build on user/userdebug builds.
- //
- // All private inner classes below also need this fix.
- TabPagerListener() {}
-
- @Override
- public void onPageScrollStateChanged(int state) {
- if (!mTabPagerAdapter.areTabsHidden()) {
- mViewPagerTabs.onPageScrollStateChanged(state);
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- if (!mTabPagerAdapter.areTabsHidden()) {
- mViewPagerTabs.onPageScrolled(position, positionOffset, positionOffsetPixels);
- }
- }
-
- @Override
- public void onPageSelected(int position) {
- // Make sure not in the search mode, in which case position != TabState.ordinal().
- if (!mTabPagerAdapter.areTabsHidden()) {
- mActionBarAdapter.setCurrentTab(position, false);
- mViewPagerTabs.onPageSelected(position);
- showEmptyStateForTab(position);
- invalidateOptionsMenu();
- }
- }
- }
-
- /**
- * Adapter for the {@link ViewPager}. Unlike {@link FragmentPagerAdapter},
- * {@link #instantiateItem} returns existing fragments, and {@link #instantiateItem}/
- * {@link #destroyItem} show/hide fragments instead of attaching/detaching.
- *
- * In search mode, we always show the "all" fragment, and disable the swipe. We change the
- * number of items to 1 to disable the swipe.
- *
- * TODO figure out a more straight way to disable swipe.
- */
- private class TabPagerAdapter extends PagerAdapter {
- private final FragmentManager mFragmentManager;
- private FragmentTransaction mCurTransaction = null;
-
- private boolean mAreTabsHiddenInTabPager;
-
- private Fragment mCurrentPrimaryItem;
-
- public TabPagerAdapter() {
- mFragmentManager = getFragmentManager();
- }
-
- public boolean areTabsHidden() {
- return mAreTabsHiddenInTabPager;
- }
-
- public void setTabsHidden(boolean hideTabs) {
- if (hideTabs == mAreTabsHiddenInTabPager) {
- return;
- }
- mAreTabsHiddenInTabPager = hideTabs;
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return mAreTabsHiddenInTabPager ? 1 : TabState.COUNT;
- }
-
- /** Gets called when the number of items changes. */
- @Override
- public int getItemPosition(Object object) {
- if (mAreTabsHiddenInTabPager) {
- if (object == mAllFragment) {
- return 0; // Only 1 page in search mode
- }
- } else {
- if (object == mAllFragment) {
- return getTabPositionForTextDirection(TabState.ALL);
- }
- }
- return POSITION_NONE;
- }
-
- @Override
- public void startUpdate(ViewGroup container) {
- }
-
- private Fragment getFragment(int position) {
- position = getTabPositionForTextDirection(position);
- if (mAreTabsHiddenInTabPager) {
- if (position != 0) {
- // This has only been observed in monkey tests.
- // Let's log this issue, but not crash
- Log.w(TAG, "Request fragment at position=" + position + ", eventhough we " +
- "are in search mode");
- }
- return mAllFragment;
- } else {
- if (position == TabState.ALL) {
- return mAllFragment;
- }
- }
- throw new IllegalArgumentException("position: " + position);
- }
-
- @Override
- public Object instantiateItem(ViewGroup container, int position) {
- if (mCurTransaction == null) {
- mCurTransaction = mFragmentManager.beginTransaction();
- }
- Fragment f = getFragment(position);
- mCurTransaction.show(f);
-
- // Non primary pages are not visible.
- f.setUserVisibleHint(f == mCurrentPrimaryItem);
- return f;
- }
-
- @Override
- public void destroyItem(ViewGroup container, int position, Object object) {
- if (mCurTransaction == null) {
- mCurTransaction = mFragmentManager.beginTransaction();
- }
- mCurTransaction.hide((Fragment) object);
- }
-
- @Override
- public void finishUpdate(ViewGroup container) {
- if (mCurTransaction != null) {
- mCurTransaction.commitAllowingStateLoss();
- mCurTransaction = null;
- mFragmentManager.executePendingTransactions();
- }
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return ((Fragment) object).getView() == view;
- }
-
- @Override
- public void setPrimaryItem(ViewGroup container, int position, Object object) {
- Fragment fragment = (Fragment) object;
- if (mCurrentPrimaryItem != fragment) {
- if (mCurrentPrimaryItem != null) {
- mCurrentPrimaryItem.setUserVisibleHint(false);
- }
- if (fragment != null) {
- fragment.setUserVisibleHint(true);
- }
- mCurrentPrimaryItem = fragment;
- }
- }
-
- @Override
- public Parcelable saveState() {
- return null;
- }
-
- @Override
- public void restoreState(Parcelable state, ClassLoader loader) {
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- return mTabTitles[position];
- }
}
private void setQueryTextToFragment(String query) {
@@ -1034,10 +766,10 @@
// actually at least one real account (not "local" account) on device.
if ((mProviderStatus.equals(ProviderStatus.STATUS_EMPTY) && hasNonLocalAccount())
|| mProviderStatus.equals(ProviderStatus.STATUS_NORMAL)) {
- // Ensure that the mTabPager is visible; we may have made it invisible below.
+ // Ensure that the mContactsView is visible; we may have made it invisible below.
contactsUnavailableView.setVisibility(View.GONE);
- if (mTabPager != null) {
- mTabPager.setVisibility(View.VISIBLE);
+ if (mContactsView != null) {
+ mContactsView.setVisibility(View.VISIBLE);
}
if (mAllFragment != null) {
@@ -1059,14 +791,12 @@
}
mContactsUnavailableFragment.updateStatus(mProviderStatus);
- // Show the contactsUnavailableView, and hide the mTabPager so that we don't
+ // Show the contactsUnavailableView, and hide the mContactsView so that we don't
// see it sliding in underneath the contactsUnavailableView at the edges.
contactsUnavailableView.setVisibility(View.VISIBLE);
- if (mTabPager != null) {
- mTabPager.setVisibility(View.GONE);
+ if (mContactsView != null) {
+ mContactsView.setVisibility(View.GONE);
}
-
- showEmptyStateForTab(mActionBarAdapter.getCurrentTab());
}
invalidateOptionsMenuIfNeeded();
@@ -1482,17 +1212,11 @@
// TODO Figure out a better way to deal with the issue.
mDisableOptionItemSelected = true;
mActionBarAdapter.setListener(null);
- if (mTabPager != null) {
- mTabPager.setOnPageChangeListener(null);
- }
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
- // In our own lifecycle, the focus is saved and restore but later taken away by the
- // ViewPager. As a hack, we force focus on the SearchView if we know that we are searching.
- // This fixes the keyboard going away on screen rotation
if (mActionBarAdapter.isSearchMode()) {
mActionBarAdapter.setFocusOnSearchView();
}
@@ -1537,16 +1261,6 @@
}
}
- /**
- * Returns the tab position adjusted for the text direction.
- */
- private int getTabPositionForTextDirection(int position) {
- if (isRTL()) {
- return TabState.COUNT - 1 - position;
- }
- return position;
- }
-
private void setFilterAndUpdateTitle(ContactListFilter filter) {
setFilterAndUpdateTitle(filter, true);
}
diff --git a/src/com/android/contacts/common/list/ViewPagerTabStrip.java b/src/com/android/contacts/common/list/ViewPagerTabStrip.java
deleted file mode 100644
index c8ae21a..0000000
--- a/src/com/android/contacts/common/list/ViewPagerTabStrip.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2014 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.common.list;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import com.android.contacts.common.R;
-
-public class ViewPagerTabStrip extends LinearLayout {
- private int mSelectedUnderlineThickness;
- private final Paint mSelectedUnderlinePaint;
-
- private int mIndexForSelection;
- private float mSelectionOffset;
-
- public ViewPagerTabStrip(Context context) {
- this(context, null);
- }
-
- public ViewPagerTabStrip(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- final Resources res = context.getResources();
-
- mSelectedUnderlineThickness =
- res.getDimensionPixelSize(R.dimen.tab_selected_underline_height);
- int underlineColor = res.getColor(R.color.tab_selected_underline_color);
- int backgroundColor = res.getColor(R.color.actionbar_background_color);
-
- mSelectedUnderlinePaint = new Paint();
- mSelectedUnderlinePaint.setColor(underlineColor);
-
- setBackgroundColor(backgroundColor);
- setWillNotDraw(false);
- }
-
- /**
- * Notifies this view that view pager has been scrolled. We save the tab index
- * and selection offset for interpolating the position and width of selection
- * underline.
- */
- void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- mIndexForSelection = position;
- mSelectionOffset = positionOffset;
- invalidate();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- int childCount = getChildCount();
-
- // Thick colored underline below the current selection
- if (childCount > 0) {
- View selectedTitle = getChildAt(mIndexForSelection);
-
- if (selectedTitle == null) {
- // The view pager's tab count changed but we weren't notified yet. Ignore this draw
- // pass, when we get a new selection we will update and draw the selection strip in
- // the correct place.
- return;
- }
- int selectedLeft = selectedTitle.getLeft();
- int selectedRight = selectedTitle.getRight();
- final boolean isRtl = isRtl();
- final boolean hasNextTab = isRtl ? mIndexForSelection > 0
- : (mIndexForSelection < (getChildCount() - 1));
- if ((mSelectionOffset > 0.0f) && hasNextTab) {
- // Draw the selection partway between the tabs
- View nextTitle = getChildAt(mIndexForSelection + (isRtl ? -1 : 1));
- int nextLeft = nextTitle.getLeft();
- int nextRight = nextTitle.getRight();
-
- selectedLeft = (int) (mSelectionOffset * nextLeft +
- (1.0f - mSelectionOffset) * selectedLeft);
- selectedRight = (int) (mSelectionOffset * nextRight +
- (1.0f - mSelectionOffset) * selectedRight);
- }
-
- int height = getHeight();
- canvas.drawRect(selectedLeft, height - mSelectedUnderlineThickness,
- selectedRight, height, mSelectedUnderlinePaint);
- }
- }
-
- private boolean isRtl() {
- return getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
- }
-}
\ No newline at end of file
diff --git a/src/com/android/contacts/common/list/ViewPagerTabs.java b/src/com/android/contacts/common/list/ViewPagerTabs.java
deleted file mode 100644
index 48de6af..0000000
--- a/src/com/android/contacts/common/list/ViewPagerTabs.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (C) 2014 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.common.list;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.Outline;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.util.AttributeSet;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewOutlineProvider;
-import android.widget.FrameLayout;
-import android.widget.HorizontalScrollView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.android.contacts.common.R;
-import com.android.contacts.common.compat.CompatUtils;
-
-/**
- * Lightweight implementation of ViewPager tabs. This looks similar to traditional actionBar tabs,
- * but allows for the view containing the tabs to be placed anywhere on screen. Text-related
- * attributes can also be assigned in XML - these will get propogated to the child TextViews
- * automatically.
- */
-public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnPageChangeListener {
-
- ViewPager mPager;
- private ViewPagerTabStrip mTabStrip;
-
- /**
- * Linearlayout that will contain the TextViews serving as tabs. This is the only child
- * of the parent HorizontalScrollView.
- */
- final int mTextStyle;
- final ColorStateList mTextColor;
- final int mTextSize;
- final boolean mTextAllCaps;
- int mPrevSelected = -1;
- int mSidePadding;
-
- private int[] mTabIcons;
- // For displaying the unread count next to the tab icon.
- private int[] mUnreadCounts;
-
- private static final ViewOutlineProvider VIEW_BOUNDS_OUTLINE_PROVIDER;
- static {
- if (CompatUtils.isLollipopCompatible()) {
- VIEW_BOUNDS_OUTLINE_PROVIDER = new ViewOutlineProvider() {
- @Override
- public void getOutline(View view, Outline outline) {
- outline.setRect(0, 0, view.getWidth(), view.getHeight());
- }
- };
- } else {
- VIEW_BOUNDS_OUTLINE_PROVIDER = null;
- }
- }
-
- private static final int TAB_SIDE_PADDING_IN_DPS = 10;
-
- // TODO: This should use <declare-styleable> in the future
- private static final int[] ATTRS = new int[] {
- android.R.attr.textSize,
- android.R.attr.textStyle,
- android.R.attr.textColor,
- android.R.attr.textAllCaps
- };
-
- /**
- * Simulates actionbar tab behavior by showing a toast with the tab title when long clicked.
- */
- private class OnTabLongClickListener implements OnLongClickListener {
- final int mPosition;
-
- public OnTabLongClickListener(int position) {
- mPosition = position;
- }
-
- @Override
- public boolean onLongClick(View v) {
- final int[] screenPos = new int[2];
- getLocationOnScreen(screenPos);
-
- final Context context = getContext();
- final int width = getWidth();
- final int height = getHeight();
- final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
-
- Toast toast = Toast.makeText(context, mPager.getAdapter().getPageTitle(mPosition),
- Toast.LENGTH_SHORT);
-
- // Show the toast under the tab
- toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL,
- (screenPos[0] + width / 2) - screenWidth / 2, screenPos[1] + height);
-
- toast.show();
- return true;
- }
- }
-
- public ViewPagerTabs(Context context) {
- this(context, null);
- }
-
- public ViewPagerTabs(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- setFillViewport(true);
-
- mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);
-
- final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
- mTextSize = a.getDimensionPixelSize(0, 0);
- mTextStyle = a.getInt(1, 0);
- mTextColor = a.getColorStateList(2);
- mTextAllCaps = a.getBoolean(3, false);
-
- mTabStrip = new ViewPagerTabStrip(context);
- addView(mTabStrip,
- new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
- a.recycle();
-
- if (CompatUtils.isLollipopCompatible()) {
- // enable shadow casting from view bounds
- setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
- }
- }
-
- public void setViewPager(ViewPager viewPager) {
- mPager = viewPager;
- addTabs(mPager.getAdapter());
- }
-
- /**
- * Set the tab icons and initialize an array for unread counts the same length as the icon
- * array.
- *
- * @param tabIcons An array representing the tab icons in order.
- */
- public void configureTabIcons(int[] tabIcons) {
- mTabIcons = tabIcons;
- mUnreadCounts = new int[tabIcons.length];
- }
-
- public void setUnreadCount(int count, int position) {
- if (mUnreadCounts == null || position >= mUnreadCounts.length) {
- return;
- }
- mUnreadCounts[position] = count;
- }
-
- private void addTabs(PagerAdapter adapter) {
- mTabStrip.removeAllViews();
-
- final int count = adapter.getCount();
- for (int i = 0; i < count; i++) {
- addTab(adapter.getPageTitle(i), i);
- }
- }
-
- private void addTab(CharSequence tabTitle, final int position) {
- View tabView;
- if (mTabIcons != null && position < mTabIcons.length) {
- View layout = LayoutInflater.from(getContext()).inflate(
- R.layout.unread_count_tab, null);
- View iconView = layout.findViewById(R.id.icon);
- iconView.setBackgroundResource(mTabIcons[position]);
- iconView.setContentDescription(tabTitle);
- TextView textView = (TextView) layout.findViewById(R.id.count);
- if (mUnreadCounts != null && mUnreadCounts[position] > 0) {
- textView.setText(Integer.toString(mUnreadCounts[position]));
- textView.setVisibility(View.VISIBLE);
- iconView.setContentDescription(getResources().getQuantityString(
- R.plurals.tab_title_with_unread_items,
- mUnreadCounts[position],
- tabTitle.toString(),
- mUnreadCounts[position]));
- } else {
- textView.setVisibility(View.INVISIBLE);
- iconView.setContentDescription(tabTitle);
- }
- tabView = layout;
- } else {
- final TextView textView = new TextView(getContext());
- textView.setText(tabTitle);
- textView.setBackgroundResource(R.drawable.view_pager_tab_background);
-
- // Assign various text appearance related attributes to child views.
- if (mTextStyle > 0) {
- textView.setTypeface(textView.getTypeface(), mTextStyle);
- }
- if (mTextSize > 0) {
- textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
- }
- if (mTextColor != null) {
- textView.setTextColor(mTextColor);
- }
- textView.setAllCaps(mTextAllCaps);
- textView.setGravity(Gravity.CENTER);
-
- tabView = textView;
- }
-
- tabView.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mPager.setCurrentItem(getRtlPosition(position));
- }
- });
-
- tabView.setOnLongClickListener(new OnTabLongClickListener(position));
-
- tabView.setPadding(mSidePadding, 0, mSidePadding, 0);
-
- mTabStrip.addView(tabView, position, new LinearLayout.LayoutParams(
- LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1));
-
- // Default to the first child being selected
- if (position == 0) {
- mPrevSelected = 0;
- tabView.setSelected(true);
- }
- }
-
- /**
- * Remove a tab at a certain index.
- *
- * @param index The index of the tab view we wish to remove.
- */
- public void removeTab(int index) {
- View view = mTabStrip.getChildAt(index);
- if (view != null) {
- mTabStrip.removeView(view);
- }
- }
-
- /**
- * Refresh a tab at a certain index by removing it and reconstructing it.
- *
- * @param index The index of the tab view we wish to update.
- */
- public void updateTab(int index) {
- removeTab(index);
-
- if (index < mPager.getAdapter().getCount()) {
- addTab(mPager.getAdapter().getPageTitle(index), index);
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- position = getRtlPosition(position);
- int tabStripChildCount = mTabStrip.getChildCount();
- if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
- return;
- }
-
- mTabStrip.onPageScrolled(position, positionOffset, positionOffsetPixels);
- }
-
- @Override
- public void onPageSelected(int position) {
- position = getRtlPosition(position);
- int tabStripChildCount = mTabStrip.getChildCount();
- if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
- return;
- }
-
- if (mPrevSelected >= 0 && mPrevSelected < tabStripChildCount) {
- mTabStrip.getChildAt(mPrevSelected).setSelected(false);
- }
- final View selectedChild = mTabStrip.getChildAt(position);
- selectedChild.setSelected(true);
-
- // Update scroll position
- final int scrollPos = selectedChild.getLeft() - (getWidth() - selectedChild.getWidth()) / 2;
- smoothScrollTo(scrollPos, 0);
- mPrevSelected = position;
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- }
-
- private int getRtlPosition(int position) {
- if (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
- return mTabStrip.getChildCount() - 1 - position;
- }
- return position;
- }
-}
-
diff --git a/src/com/android/contacts/group/GroupMembersFragment.java b/src/com/android/contacts/group/GroupMembersFragment.java
index d3c828b..2951a21 100644
--- a/src/com/android/contacts/group/GroupMembersFragment.java
+++ b/src/com/android/contacts/group/GroupMembersFragment.java
@@ -392,10 +392,6 @@
}
@Override
- public void onSelectedTabChanged() {
- }
-
- @Override
public void onUpButtonPressed() {
getActivity().onBackPressed();
}
@@ -452,8 +448,7 @@
// be null (i.e. it can be null in onCreateView() of this fragment)
final GroupMembersActivity activity = (GroupMembersActivity) getActivity();
mActionBarAdapter = new ActionBarAdapter(activity, this, activity.getSupportActionBar(),
- /* portraitTabs */ null, /* landscapeTabs */ null, activity.getToolbar(),
- R.string.enter_contact_name);
+ activity.getToolbar(), R.string.enter_contact_name);
mActionBarAdapter.setShowHomeIcon(true);
final ContactsRequest contactsRequest = new ContactsRequest();
contactsRequest.setActionCode(ContactsRequest.ACTION_GROUP);
diff --git a/src/com/android/contacts/list/ContactsUnavailableFragment.java b/src/com/android/contacts/list/ContactsUnavailableFragment.java
index 1b122cc..aa08a32 100644
--- a/src/com/android/contacts/list/ContactsUnavailableFragment.java
+++ b/src/com/android/contacts/list/ContactsUnavailableFragment.java
@@ -33,7 +33,6 @@
import android.widget.TextView;
import com.android.contacts.R;
-import com.android.contacts.activities.ActionBarAdapter.TabState;
import com.android.contacts.common.compat.ProviderStatusCompat;
/**
@@ -50,7 +49,6 @@
private ProgressBar mProgress;
private View mButtonsContainer;
private int mNoContactsMsgResId = -1;
- private int mLastTab = -1;
private OnContactsUnavailableActionListener mListener;
@@ -125,10 +123,6 @@
* Update views in the fragment when provider status is empty.
*/
private void updateViewsForEmptyStatus() {
- setTabInfo(mNoContactsMsgResId, mLastTab);
- if (mLastTab == TabState.ALL) {
- updateButtonVisibilty(View.VISIBLE);
- }
mProgress.setVisibility(View.GONE);
}
@@ -167,29 +161,6 @@
}
}
- /**
- * Set the message to be shown if no data is available for the selected tab
- *
- * @param resId - String resource ID of the message , -1 means view will not be visible
- */
- public void setTabInfo(int resId, int callerTab) {
- mNoContactsMsgResId = resId;
- mLastTab = callerTab;
- if ((mMessageView != null) && (mProviderStatus != null) &&
- mProviderStatus.equals(ProviderStatusCompat.STATUS_EMPTY)) {
- if (resId != -1) {
- mMessageView.setText(mNoContactsMsgResId);
- mMessageView.setGravity(Gravity.CENTER_HORIZONTAL);
- mMessageView.setVisibility(View.VISIBLE);
- if (callerTab == TabState.ALL) {
- updateButtonVisibilty(View.VISIBLE);
- }
- } else {
- mMessageView.setVisibility(View.GONE);
- }
- }
- }
-
private void updateButtonVisibilty(int visibility) {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
mAddAccountButton.setVisibility(visibility);