Replacing Aizy with a standard scrollbar
Change-Id: Ie8626844e194894da6e30205fe5da43d92d793c2
diff --git a/res/layout-xlarge/contact_picker_content.xml b/res/layout-xlarge/contact_picker_content.xml
index 5cc6ac9..68f3015 100644
--- a/res/layout-xlarge/contact_picker_content.xml
+++ b/res/layout-xlarge/contact_picker_content.xml
@@ -14,49 +14,31 @@
limitations under the License.
-->
-<LinearLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="horizontal"
- >
+ android:orientation="vertical">
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="2dip"
+ android:layout_marginTop="1dip"
+ android:layout_marginBottom="1dip"
+ android:background="#7e7e87" />
<view
- class="com.android.contacts.list.ContactListAizyView"
- android:id="@+id/contacts_list_aizy"
- android:layout_width="40dip"
- android:layout_height="match_parent"
- />
-
- <LinearLayout
- android:layout_width="0px"
- android:layout_height="match_parent"
- android:orientation="vertical"
+ class="com.android.contacts.list.ContactEntryListView"
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:fastScrollEnabled="true"
android:layout_weight="1"
- >
+ android:scrollingCache="false" />
- <View
- android:layout_width="match_parent"
- android:layout_height="2dip"
- android:layout_marginTop="1dip"
- android:layout_marginBottom="1dip"
- android:background="#7e7e87"
- />
-
- <view
- class="com.android.contacts.list.ContactEntryListView"
- android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:fastScrollEnabled="true"
- android:layout_weight="1"
- android:scrollingCache="false"
- />
-
- <ViewStub android:id="@+id/footer_stub"
- android:layout="@layout/footer_panel"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
- </LinearLayout>
+ <ViewStub
+ android:id="@+id/footer_stub"
+ android:layout="@layout/footer_panel"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
</LinearLayout>
diff --git a/res/layout-xlarge/contacts_list_content.xml b/res/layout-xlarge/contacts_list_content.xml
index 4e1aa19..b305b15 100644
--- a/res/layout-xlarge/contacts_list_content.xml
+++ b/res/layout-xlarge/contacts_list_content.xml
@@ -19,45 +19,31 @@
android:id="@+id/pinned_header_list_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="horizontal"
+ android:orientation="vertical"
>
- <view
- class="com.android.contacts.list.ContactListAizyView"
- android:id="@+id/contacts_list_aizy"
- android:layout_width="40dip"
- android:layout_height="match_parent"
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="2dip"
+ android:layout_marginTop="1dip"
+ android:layout_marginBottom="1dip"
+ android:background="#7e7e87"
/>
- <LinearLayout
- android:layout_width="0px"
- android:layout_height="match_parent"
- android:orientation="vertical"
+ <view
+ class="com.android.contacts.list.ContactEntryListView"
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:fastScrollEnabled="true"
android:layout_weight="1"
- >
+ android:scrollingCache="false"
+ />
- <View
- android:layout_width="match_parent"
- android:layout_height="2dip"
- android:layout_marginTop="1dip"
- android:layout_marginBottom="1dip"
- android:background="#7e7e87"
- />
+ <ViewStub android:id="@+id/footer_stub"
+ android:layout="@layout/footer_panel"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ />
- <view
- class="com.android.contacts.list.ContactEntryListView"
- android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:fastScrollEnabled="true"
- android:layout_weight="1"
- android:scrollingCache="false"
- />
-
- <ViewStub android:id="@+id/footer_stub"
- android:layout="@layout/footer_panel"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
- </LinearLayout>
</LinearLayout>
diff --git a/res/layout/aizy_popup_window.xml b/res/layout/aizy_popup_window.xml
deleted file mode 100644
index 4b3668f..0000000
--- a/res/layout/aizy_popup_window.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/aizy_preview_width"
- android:layout_height="@dimen/aizy_preview_height"
- android:background="@drawable/aizy_label"
- android:paddingTop="0dip"
- android:id="@+id/caption"
- android:textSize="55sp"
- android:gravity="center"
- android:textColor="#ffffffff" />
diff --git a/res/layout/contact_picker_content.xml b/res/layout/contact_picker_content.xml
index 0e46281..6792f9c 100644
--- a/res/layout/contact_picker_content.xml
+++ b/res/layout/contact_picker_content.xml
@@ -14,40 +14,24 @@
limitations under the License.
-->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/pinned_header_list_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal"
- >
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pinned_header_list_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <LinearLayout
- android:layout_width="0px"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_weight="1"
- >
-
- <view
- class="com.android.contacts.list.ContactEntryListView"
- android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:fastScrollEnabled="true"
- android:layout_weight="1"
- />
-
- <ViewStub android:id="@+id/footer_stub"
- android:layout="@layout/footer_panel"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
- </LinearLayout>
<view
- class="com.android.contacts.list.ContactListAizyView"
- android:id="@+id/contacts_list_aizy"
- android:layout_width="30dip"
- android:layout_height="match_parent"
- />
+ class="com.android.contacts.list.ContactEntryListView"
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:fastScrollEnabled="true"
+ android:layout_weight="1" />
+
+ <ViewStub
+ android:id="@+id/footer_stub"
+ android:layout="@layout/footer_panel"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
</LinearLayout>
diff --git a/res/layout/contacts_list_content.xml b/res/layout/contacts_list_content.xml
index 0e46281..6792f9c 100644
--- a/res/layout/contacts_list_content.xml
+++ b/res/layout/contacts_list_content.xml
@@ -14,40 +14,24 @@
limitations under the License.
-->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/pinned_header_list_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal"
- >
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pinned_header_list_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <LinearLayout
- android:layout_width="0px"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_weight="1"
- >
-
- <view
- class="com.android.contacts.list.ContactEntryListView"
- android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:fastScrollEnabled="true"
- android:layout_weight="1"
- />
-
- <ViewStub android:id="@+id/footer_stub"
- android:layout="@layout/footer_panel"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
- </LinearLayout>
<view
- class="com.android.contacts.list.ContactListAizyView"
- android:id="@+id/contacts_list_aizy"
- android:layout_width="30dip"
- android:layout_height="match_parent"
- />
+ class="com.android.contacts.list.ContactEntryListView"
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:fastScrollEnabled="true"
+ android:layout_weight="1" />
+
+ <ViewStub
+ android:id="@+id/footer_stub"
+ android:layout="@layout/footer_panel"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
</LinearLayout>
diff --git a/res/layout/contacts_list_content_join.xml b/res/layout/contacts_list_content_join.xml
index de285fa..5ad1cbf 100644
--- a/res/layout/contacts_list_content_join.xml
+++ b/res/layout/contacts_list_content_join.xml
@@ -61,27 +61,17 @@
</LinearLayout>
</LinearLayout>
- <LinearLayout
- android:id="@+id/pinned_header_list_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal"
- >
-
- <com.android.contacts.list.ContactListAizyView
- android:id="@+id/contacts_list_aizy"
- android:layout_width="50dip"
- android:layout_height="match_parent"
- />
+ <FrameLayout
+ android:id="@+id/pinned_header_list_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<view
- class="com.android.contacts.list.ContactEntryListView"
+ class="com.android.contacts.list.ContactEntryListView"
android:id="@android:id/list"
- android:layout_width="0px"
+ android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_weight="1"
- android:fastScrollEnabled="true"
- />
- </LinearLayout>
+ android:fastScrollEnabled="true" />
+ </FrameLayout>
</LinearLayout>
diff --git a/res/layout/navigation_bar.xml b/res/layout/navigation_bar.xml
index f3fd9d4..088c192 100644
--- a/res/layout/navigation_bar.xml
+++ b/res/layout/navigation_bar.xml
@@ -81,14 +81,12 @@
</FrameLayout>
</view>
- <view
- class="android.widget.SearchView"
+ <SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxWidth="300dip"
android:iconifiedByDefault="false" />
- />
</LinearLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 81b0bec..845cb2f 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -25,9 +25,6 @@
<color name="translucent_search_background">#cc000000</color>
- <!-- Color used in the Aizy visual scroll control for empty section -->
- <color name="aizy_line_color">#ff689afe</color>
-
<!-- Color used for the letter in the A-Z section header -->
<color name="section_header_text_color">#ff999999</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5f01cbd..c63451a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -29,9 +29,6 @@
<dimen name="photo_action_popup_width">400dip</dimen>
- <dimen name="aizy_preview_width">80dip</dimen>
- <dimen name="aizy_preview_height">80dip</dimen>
-
<!-- Width of the quick contact popup. This size is chosen so that the last icon is clipped
to indicate horizontal scrollability. Also, this size is the same as the widget to make them
aligned -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9f5c822..04d2dd6 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -77,11 +77,6 @@
<item name="android:windowExitAnimation">@anim/search_bar_exit</item>
</style>
- <style name="AizyPreviewPopupAnimation">
- <item name="android:windowEnterAnimation">@anim/aizy_preview_popup_enter</item>
- <item name="android:windowExitAnimation">@anim/aizy_preview_popup_exit</item>
- </style>
-
<style name="DummyAnimation">
<item name="android:windowExitAnimation">@anim/dummy_animation</item>
</style>
diff --git a/src/com/android/contacts/activities/ContactBrowserActivity.java b/src/com/android/contacts/activities/ContactBrowserActivity.java
index eb10575..957c6ab 100644
--- a/src/com/android/contacts/activities/ContactBrowserActivity.java
+++ b/src/com/android/contacts/activities/ContactBrowserActivity.java
@@ -72,7 +72,6 @@
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ImageButton;
import android.widget.ListPopupWindow;
import android.widget.Toast;
@@ -400,7 +399,11 @@
} else {
fragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE);
}
- fragment.setAizyEnabled(!mRequest.isSearchMode());
+ fragment.setVisibleScrollbarEnabled(!mRequest.isSearchMode());
+ fragment.setVerticalScrollbarPosition(
+ mContactContentDisplayed
+ ? View.SCROLLBAR_POSITION_LEFT
+ : View.SCROLLBAR_POSITION_RIGHT);
fragment.setSelectionVisible(mContactContentDisplayed);
fragment.setQuickContactEnabled(!mContactContentDisplayed);
fragment.setFilterEnabled(!mRequest.isSearchMode());
@@ -459,7 +462,11 @@
fragment.setSearchMode(true);
fragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_DEFAULT);
fragment.setDirectoryResultLimit(DEFAULT_DIRECTORY_RESULT_LIMIT);
- fragment.setAizyEnabled(false);
+ fragment.setVisibleScrollbarEnabled(false);
+ fragment.setVerticalScrollbarPosition(
+ mContactContentDisplayed
+ ? View.SCROLLBAR_POSITION_LEFT
+ : View.SCROLLBAR_POSITION_RIGHT);
fragment.setSelectionVisible(true);
fragment.setQuickContactEnabled(!mContactContentDisplayed);
invalidateOptionsMenu();
diff --git a/src/com/android/contacts/list/ContactEntryListFragment.java b/src/com/android/contacts/list/ContactEntryListFragment.java
index 872a9c2..c638682 100644
--- a/src/com/android/contacts/list/ContactEntryListFragment.java
+++ b/src/com/android/contacts/list/ContactEntryListFragment.java
@@ -78,7 +78,7 @@
private static final String KEY_PHOTO_LOADER_ENABLED = "photoLoaderEnabled";
private static final String KEY_QUICK_CONTACT_ENABLED = "quickContactEnabled";
private static final String KEY_SEARCH_MODE = "searchMode";
- private static final String KEY_AIZY_ENABLED = "aizyEnabled";
+ private static final String KEY_VISIBLE_SCROLLBAR_ENABLED = "visibleScrollbarEnabled";
private static final String KEY_QUERY_STRING = "queryString";
private static final String KEY_DIRECTORY_SEARCH_MODE = "directorySearchMode";
private static final String KEY_SELECTION_VISIBLE = "selectionVisible";
@@ -99,7 +99,8 @@
private boolean mPhotoLoaderEnabled;
private boolean mQuickContactEnabled = true;
private boolean mSearchMode;
- private boolean mAizyEnabled;
+ private boolean mVisibleScrollbarEnabled;
+ private int mVerticalScrollbarPosition = View.SCROLLBAR_POSITION_RIGHT;
private String mQueryString;
private int mDirectorySearchMode = DirectoryListLoader.SEARCH_MODE_NONE;
private boolean mSelectionVisible;
@@ -111,7 +112,6 @@
private T mAdapter;
private View mView;
private ListView mListView;
- private ContactListAizyView mAizy;
/**
* Used for keeping track of the scroll state of the list.
@@ -155,6 +155,7 @@
}
};
+
protected abstract View inflateView(LayoutInflater inflater, ViewGroup container);
protected abstract T createListAdapter();
@@ -233,7 +234,7 @@
outState.putBoolean(KEY_PHOTO_LOADER_ENABLED, mPhotoLoaderEnabled);
outState.putBoolean(KEY_QUICK_CONTACT_ENABLED, mQuickContactEnabled);
outState.putBoolean(KEY_SEARCH_MODE, mSearchMode);
- outState.putBoolean(KEY_AIZY_ENABLED, mAizyEnabled);
+ outState.putBoolean(KEY_VISIBLE_SCROLLBAR_ENABLED, mVisibleScrollbarEnabled);
outState.putInt(KEY_DIRECTORY_SEARCH_MODE, mDirectorySearchMode);
outState.putBoolean(KEY_SELECTION_VISIBLE, mSelectionVisible);
outState.putBoolean(KEY_LEGACY_COMPATIBILITY, mLegacyCompatibility);
@@ -263,7 +264,7 @@
mPhotoLoaderEnabled = savedState.getBoolean(KEY_PHOTO_LOADER_ENABLED);
mQuickContactEnabled = savedState.getBoolean(KEY_QUICK_CONTACT_ENABLED);
mSearchMode = savedState.getBoolean(KEY_SEARCH_MODE);
- mAizyEnabled = savedState.getBoolean(KEY_AIZY_ENABLED);
+ mVisibleScrollbarEnabled = savedState.getBoolean(KEY_VISIBLE_SCROLLBAR_ENABLED);
mDirectorySearchMode = savedState.getInt(KEY_DIRECTORY_SEARCH_MODE);
mSelectionVisible = savedState.getBoolean(KEY_SELECTION_VISIBLE);
mLegacyCompatibility = savedState.getBoolean(KEY_LEGACY_COMPATIBILITY);
@@ -431,9 +432,6 @@
protected void onPartitionLoaded(int partitionIndex, Cursor data) {
mAdapter.changeCursor(partitionIndex, data);
showCount(partitionIndex, data);
- if (partitionIndex == mAdapter.getIndexedPartition()) {
- mAizy.setIndexer(mAdapter.getIndexer(), data.getCount());
- }
if (!isLoading()) {
completeRestoreInstanceState();
@@ -495,37 +493,35 @@
if (mAdapter != null) {
mAdapter.setSectionHeaderDisplayEnabled(flag);
}
- configureAizy();
+ configureVerticalScrollbar();
}
public boolean isSectionHeaderDisplayEnabled() {
return mSectionHeaderDisplayEnabled;
}
- public void setAizyEnabled(boolean flag) {
- mAizyEnabled = flag;
- configureAizy();
+ public void setVisibleScrollbarEnabled(boolean flag) {
+ mVisibleScrollbarEnabled = flag;
+ configureVerticalScrollbar();
}
- public boolean isAizyEnabled() {
- return mAizyEnabled;
+ public boolean isVisibleScrollbarEnabled() {
+ return mVisibleScrollbarEnabled;
}
- private void configureAizy() {
- boolean hasAisy = isAizyEnabled() && isSectionHeaderDisplayEnabled();
+ public void setVerticalScrollbarPosition(int position) {
+ this.mVerticalScrollbarPosition = position;
+ }
+
+ private void configureVerticalScrollbar() {
+ boolean hasScrollbar = isVisibleScrollbarEnabled() && isSectionHeaderDisplayEnabled();
if (mListView != null) {
- mListView.setFastScrollEnabled(!hasAisy);
- mListView.setVerticalScrollBarEnabled(!hasAisy);
- }
- if (mAizy != null) {
- if (hasAisy) {
- mAizy.setVisibility(View.VISIBLE);
- } else if (isAizyEnabled()) {
- mAizy.setVisibility(View.INVISIBLE);
- } else {
- mAizy.setVisibility(View.GONE);
- }
+ mListView.setFastScrollEnabled(hasScrollbar);
+ mListView.setFastScrollAlwaysVisible(hasScrollbar);
+ mListView.setScrollBarStyle(
+ hasScrollbar ? View.SCROLLBARS_INSIDE_INSET : View.SCROLLBARS_INSIDE_OVERLAY);
+ mListView.setVerticalScrollbarPosition(mVerticalScrollbarPosition);
}
}
@@ -718,15 +714,7 @@
mListView.setOnCreateContextMenuListener(mContextMenuAdapter);
}
- mAizy = (ContactListAizyView) mView.findViewById(R.id.contacts_list_aizy);
- mAizy.setListener(new ContactListAizyView.Listener() {
- @Override
- public void onScroll(int position) {
- mListView.setSelectionFromTop(position + mListView.getHeaderViewsCount(), 0);
- }
- });
-
- configureAizy();
+ configureVerticalScrollbar();
configurePhotoLoader();
}
@@ -778,11 +766,9 @@
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount) {
- if (isAizyEnabled()) {
- mAizy.listOnScroll(firstVisibleItem);
- }
}
+ @Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == OnScrollListener.SCROLL_STATE_FLING) {
mPhotoLoader.pause();
diff --git a/src/com/android/contacts/list/ContactEntryListView.java b/src/com/android/contacts/list/ContactEntryListView.java
index 7e94e5c..86e33fe 100644
--- a/src/com/android/contacts/list/ContactEntryListView.java
+++ b/src/com/android/contacts/list/ContactEntryListView.java
@@ -21,10 +21,6 @@
import com.android.contacts.widget.TextHighlightingAnimation;
import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.ColorFilter;
-import android.graphics.PixelFormat;
-import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.AbsListView;
import android.widget.ListAdapter;
diff --git a/src/com/android/contacts/list/ContactListAizyView.java b/src/com/android/contacts/list/ContactListAizyView.java
deleted file mode 100644
index e22e1c7..0000000
--- a/src/com/android/contacts/list/ContactListAizyView.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2010 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.list;
-
-import com.android.contacts.R;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.PopupWindow;
-import android.widget.SectionIndexer;
-import android.widget.TextView;
-
-/**
- * A View that displays the sections given by an Indexer and their relative sizes. For
- * English and similar languages, this is an A to Z list (where only the used letters are
- * displayed). As the sections are shown in their relative sizes, this View can be used as a
- * scrollbar.
- */
-public class ContactListAizyView extends View {
- private static final String TAG = "ContactListAizyView";
-
- private SectionIndexer mIndexer;
- private int mItemCount;
- private int[] mSectionPositions;
-
- private Listener mListener;
- private float mPosition;
-
- private int mPreviewPosition;
- private PopupWindow mPreviewPopupWindow;
- private TextView mPreviewPopupTextView;
- private boolean mPreviewPopupVisible;
- private final int[] mWindowOffset = new int[2];
-
- private ResourceValues mResourceValues;
-
- public ContactListAizyView(Context context) {
- super(context);
- }
-
- public ContactListAizyView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public ContactListAizyView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
-
- mResourceValues = new ResourceValues(getContext().getResources());
-
- final LayoutInflater inflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mPreviewPopupWindow = new PopupWindow(
- inflater.inflate(R.layout.aizy_popup_window, null, false),
- mResourceValues.getPreviewWidth(), mResourceValues.getPreviewHeight());
- mPreviewPopupWindow.setAnimationStyle(R.style.AizyPreviewPopupAnimation);
- mPreviewPopupTextView =
- (TextView) mPreviewPopupWindow.getContentView().findViewById(R.id.caption);
- }
-
- public void setIndexer(SectionIndexer indexer, int itemCount) {
- mIndexer = indexer;
- mItemCount = itemCount;
- if (mIndexer == null) {
- mSectionPositions = null;
- return;
- }
-
- // Read the section positions
- final Object[] sections = mIndexer.getSections();
- final int sectionCount = sections.length;
- if (mSectionPositions == null || mSectionPositions.length != sectionCount) {
- mSectionPositions = new int[sectionCount];
- }
- for (int i = 0; i < sectionCount; i++) {
- mSectionPositions[i] = mIndexer.getPositionForSection(i);
- }
-
- }
-
- public void setListener(Listener listener) {
- mListener = listener;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- setMeasuredDimension(resolveSize(0, widthMeasureSpec), resolveSize(0, heightMeasureSpec));
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- if (mIndexer == null) return;
-
- drawLineAndText(canvas);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- getLocationInWindow(mWindowOffset);
-
- final int previewX = mWindowOffset[0] + getWidth();
- final int previewY = (int) event.getY() + mWindowOffset[1]
- - mPreviewPopupWindow.getHeight() / 2;
- final boolean previewPopupVisible =
- event.getActionMasked() == MotionEvent.ACTION_MOVE ||
- event.getActionMasked() == MotionEvent.ACTION_DOWN;
- if (previewPopupVisible != mPreviewPopupVisible) {
- if (previewPopupVisible) {
- mPreviewPopupWindow.showAtLocation(this, Gravity.LEFT | Gravity.TOP,
- previewX, previewY);
- } else {
- mPreviewPopupWindow.dismiss();
- }
- mPreviewPopupVisible = previewPopupVisible;
- } else {
- mPreviewPopupWindow.update(previewX, previewY, -1, -1);
- }
- final float yFactor = (float) getHeight() / mItemCount;
- final int position = Math.max(0, (int) (event.getY() / yFactor));
- if (mIndexer != null) {
- final int index = mIndexer.getSectionForPosition(position);
- final Object[] sections = mIndexer.getSections();
- final String caption =
- (index != -1 && index < sections.length) ? sections[index].toString() : "";
- mPreviewPopupTextView.setText(caption);
- }
-
- if (mListener != null) mListener.onScroll(position);
- mPreviewPosition = position;
-
- super.onTouchEvent(event);
- return true;
- }
-
- private void drawLineAndText(Canvas canvas) {
- final float yFactor = (float) getHeight() / mItemCount;
-
- final Paint paint = new Paint();
-
- paint.setColor(mResourceValues.getLineColor());
- paint.setAntiAlias(true);
-
- // TODO: Decide whether to use this feature and remove this flag
- final boolean useSections = false;
-
- // Draw sections
- final float centerX = getWidth() * 0.5f;
- if (useSections) {
- for (int i = 1; i < mSectionPositions.length; i++) {
- final float y1 = mSectionPositions[i - 1] * yFactor;
- final float y2 = mSectionPositions[i] * yFactor;
- canvas.drawLine(
- centerX, y1 + 1.0f,
- centerX, y2 - 1.0f,
- paint);
- }
- } else {
- canvas.drawLine(
- centerX, 0.0f,
- centerX, getHeight(),
- paint);
- }
-
- // Draw knob
- final Drawable knob = mResourceValues.getKnobDrawable();
- final int w = knob.getIntrinsicWidth();
- final int h = knob.getIntrinsicWidth();
- final float y;
-// if (mPreviewPopupWindow.) {
-// y = mPreviewPosition * yFactor;
-// } else {
- y = mPosition * yFactor;
-// }
- knob.setBounds(
- (int) (centerX - w / 2.0f), (int) (y - h / 2.0f),
- (int) (centerX + w / 2.0f), (int) (y + h / 2.0f));
- knob.draw(canvas);
- }
-
- public void listOnScroll(int firstVisibleItem) {
- mPosition = firstVisibleItem;
- invalidate();
- }
-
- private static class ResourceValues {
- private int mLineColor;
- private Drawable mKnobDrawable;
- private int mPreviewWidth;
- private int mPreviewHeight;
-
- public int getLineColor() {
- return mLineColor;
- }
-
- public Drawable getKnobDrawable() {
- return mKnobDrawable;
- }
-
- public int getPreviewWidth() {
- return mPreviewWidth;
- }
-
- public int getPreviewHeight() {
- return mPreviewHeight;
- }
-
- public ResourceValues(Resources resources) {
- mLineColor = resources.getColor(R.color.aizy_line_color);
- mKnobDrawable = resources.getDrawable(R.drawable.aizy_knob);
- mPreviewWidth = resources.getDimensionPixelSize(R.dimen.aizy_preview_width);
- mPreviewHeight = resources.getDimensionPixelSize(R.dimen.aizy_preview_height);
- }
- }
-
- public interface Listener {
- void onScroll(int position);
- }
-}
\ No newline at end of file
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index 692504c..8f03c56 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -333,7 +333,7 @@
// to the text fields in the middle.
int leftBound = layoutLeftSide(height, topBound, bottomBound, mPaddingLeft);
- int rightBound = layoutRightSide(height, topBound, right);
+ int rightBound = layoutRightSide(height, topBound, width);
// Text lines, centered vertically
rightBound -= mPaddingRight;
diff --git a/src/com/android/contacts/list/ContactPickerFragment.java b/src/com/android/contacts/list/ContactPickerFragment.java
index bce4355..17e3fb9 100644
--- a/src/com/android/contacts/list/ContactPickerFragment.java
+++ b/src/com/android/contacts/list/ContactPickerFragment.java
@@ -46,7 +46,7 @@
public ContactPickerFragment() {
setPhotoLoaderEnabled(true);
setSectionHeaderDisplayEnabled(true);
- setAizyEnabled(true);
+ setVisibleScrollbarEnabled(true);
setQuickContactEnabled(false);
setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_CONTACT_SHORTCUT);
}
diff --git a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
index 3084a66..1d5b7f2 100644
--- a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
@@ -39,7 +39,7 @@
public DefaultContactBrowseListFragment() {
setPhotoLoaderEnabled(true);
setSectionHeaderDisplayEnabled(true);
- setAizyEnabled(true);
+ setVisibleScrollbarEnabled(true);
}
diff --git a/src/com/android/contacts/list/JoinContactListFragment.java b/src/com/android/contacts/list/JoinContactListFragment.java
index cb75868..2b071ad 100644
--- a/src/com/android/contacts/list/JoinContactListFragment.java
+++ b/src/com/android/contacts/list/JoinContactListFragment.java
@@ -76,7 +76,7 @@
break;
}
case JoinContactListAdapter.PARTITION_ALL_CONTACTS: {
- setAizyEnabled(mAllContactsListShown);
+ setVisibleScrollbarEnabled(mAllContactsListShown);
JoinContactListAdapter adapter = getAdapter();
Cursor suggestionsCursor = ((JoinContactLoader)loader).getSuggestionsCursor();
@@ -91,7 +91,7 @@
public JoinContactListFragment() {
setPhotoLoaderEnabled(true);
setSectionHeaderDisplayEnabled(true);
- setAizyEnabled(false);
+ setVisibleScrollbarEnabled(false);
setQuickContactEnabled(false);
}
diff --git a/src/com/android/contacts/list/PhoneNumberPickerFragment.java b/src/com/android/contacts/list/PhoneNumberPickerFragment.java
index 7926431..d3d87cc 100644
--- a/src/com/android/contacts/list/PhoneNumberPickerFragment.java
+++ b/src/com/android/contacts/list/PhoneNumberPickerFragment.java
@@ -77,7 +77,7 @@
@Override
protected void configureAdapter() {
setSectionHeaderDisplayEnabled(!isSearchMode());
- setAizyEnabled(!isSearchMode());
+ setVisibleScrollbarEnabled(!isSearchMode());
super.configureAdapter();
}
diff --git a/src/com/android/contacts/widget/PinnedHeaderListView.java b/src/com/android/contacts/widget/PinnedHeaderListView.java
index 35291bf..6b80cae 100644
--- a/src/com/android/contacts/widget/PinnedHeaderListView.java
+++ b/src/com/android/contacts/widget/PinnedHeaderListView.java
@@ -18,14 +18,12 @@
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
@@ -106,6 +104,8 @@
private int mAnimationDuration = DEFAULT_ANIMATION_DURATION;
private boolean mAnimating;
private long mAnimationTargetTime;
+ private int mHeaderPaddingLeft;
+ private int mHeaderWidth;
public PinnedHeaderListView(Context context) {
this(context, null, com.android.internal.R.attr.listViewStyle);
@@ -121,6 +121,13 @@
super.setOnItemSelectedListener(this);
}
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+ mHeaderPaddingLeft = getPaddingLeft();
+ mHeaderWidth = r - l - mHeaderPaddingLeft - getPaddingRight();
+ }
+
public void setPinnedHeaderAnimationDuration(int duration) {
mAnimationDuration = duration;
}
@@ -376,7 +383,7 @@
*/
public int getPositionAt(int y) {
do {
- int position = pointToPosition(0, y);
+ int position = pointToPosition(getPaddingLeft() + 1, y);
if (position != -1) {
return position;
}
@@ -502,9 +509,9 @@
if (header.visible) {
View view = header.view;
int saveCount = canvas.save();
- canvas.translate(0, header.y);
+ canvas.translate(mHeaderPaddingLeft, header.y);
if (header.state == FADING) {
- mBounds.set(0, 0, view.getWidth(), view.getHeight());
+ mBounds.set(0, 0, mHeaderWidth, view.getHeight());
canvas.saveLayerAlpha(mBounds, header.alpha, Canvas.ALL_SAVE_FLAG);
}
view.draw(canvas);