Loading res/layout/call_detail.xml +159 −146 Original line number Diff line number Diff line Loading @@ -19,9 +19,29 @@ android:id="@+id/call_detail" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:gravity="top" android:visibility="gone" > <!-- The list view is under everything. It contains a first header element which is hidden under the controls UI. When scrolling, the controls move up until the name bar hits the top. --> <ListView android:id="@+id/history" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="@android:color/black" /> <!-- All the controls which are part of the pinned header are in this layout. --> <RelativeLayout android:id="@+id/controls" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" > <FrameLayout android:id="@+id/voicemail_status" Loading Loading @@ -64,6 +84,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/blue_separator" android:background="@android:color/black" > <!-- The voicemail fragment will be put here. --> </LinearLayout> Loading Loading @@ -114,7 +135,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/voicemail_container" android:layout_marginTop="@dimen/call_log_icon_margin" android:background="@android:color/black" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/call_and_sms" Loading Loading @@ -184,13 +205,5 @@ /> </LinearLayout> </FrameLayout> <ListView android:id="@+id/history" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/call_log_icon_margin" android:layout_alignParentLeft="true" android:layout_below="@id/call_and_sms_container" android:background="@android:color/black" /> </RelativeLayout> </RelativeLayout> res/layout/call_detail_history_header.xml 0 → 100644 +61 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- This layout is supposed to match the content of the controls in call_detail.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Contact photo. --> <view class="com.android.contacts.widget.ProportionalLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@id/voicemail_status" ex:ratio="0.5" ex:direction="widthToHeight" > <!-- Proportional layout requires a view in it. --> <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> </view> <!-- Separator line --> <View android:layout_width="match_parent" android:layout_height="1dip" /> <!-- Voicemail controls --> <!-- TODO: Make the height be based on a constant. --> <View android:id="@+id/header_voicemail_container" android:layout_width="match_parent" android:layout_height="142dip" android:layout_marginBottom="@dimen/call_log_icon_margin" /> <!-- Call and SMS --> <View android:id="@+id/header_call_and_sms_container" android:layout_width="match_parent" android:layout_height="@dimen/call_log_list_item_height" /> </LinearLayout> src/com/android/contacts/BackScrollManager.java 0 → 100644 +89 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts; import android.view.View; import android.widget.AbsListView; import android.widget.ListView; /** * Handles scrolling back of a list tied to a header. * <p> * This is used to implement a header that scrolls up with the content of a list to be partially * obscured. */ public class BackScrollManager { /** Defines the header to be scrolled. */ public interface ScrollableHeader { /** Sets the offset by which to scroll. */ public void setOffset(int offset); /** Gets the maximum offset that should be applied to the header. */ public int getMaximumScrollableHeaderOffset(); } private final ScrollableHeader mHeader; private final ListView mListView; private final AbsListView.OnScrollListener mScrollListener = new AbsListView.OnScrollListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem != 0) { // The first item is not shown, the header should be pinned at the top. mHeader.setOffset(mHeader.getMaximumScrollableHeaderOffset()); return; } View firstVisibleItemView = view.getChildAt(firstVisibleItem); if (firstVisibleItemView == null) { return; } // We scroll the header up, but at most pin it to the top of the screen. int offset = Math.min( (int) -view.getChildAt(firstVisibleItem).getY(), mHeader.getMaximumScrollableHeaderOffset()); mHeader.setOffset(offset); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // Nothing to do here. } }; /** * Creates a new instance of a {@link BackScrollManager} that connected the header and the list * view. */ public static void bind(ScrollableHeader header, ListView listView) { BackScrollManager backScrollManager = new BackScrollManager(header, listView); backScrollManager.bind(); } private BackScrollManager(ScrollableHeader header, ListView listView) { mHeader = header; mListView = listView; } private void bind() { mListView.setOnScrollListener(mScrollListener); // We disable the scroll bar because it would otherwise be incorrect because of the hidden // header. mListView.setVerticalScrollBarEnabled(false); } } src/com/android/contacts/CallDetailActivity.java +20 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.contacts; import com.android.contacts.BackScrollManager.ScrollableHeader; import com.android.contacts.calllog.CallDetailHistoryAdapter; import com.android.contacts.calllog.CallTypeHelper; import com.android.contacts.calllog.PhoneNumberHelper; Loading Loading @@ -434,7 +435,25 @@ public class CallDetailActivity extends Activity { ListView historyList = (ListView) findViewById(R.id.history); historyList.setAdapter( new CallDetailHistoryAdapter(CallDetailActivity.this, mInflater, mCallTypeHelper, details)); mCallTypeHelper, details, hasVoicemail(), canPlaceCallsTo)); BackScrollManager.bind( new ScrollableHeader() { private View controls = findViewById(R.id.controls); private View photo = findViewById(R.id.contact_background_sizer); private View nameHeader = findViewById(R.id.photo_text_bar); @Override public void setOffset(int offset) { controls.setY(-offset); } @Override public int getMaximumScrollableHeaderOffset() { // We can scroll the photo out, but we should keep the header. return photo.getHeight() - nameHeader.getHeight(); } }, historyList); loadContactPhotos(photoUri); findViewById(R.id.call_detail).setVisibility(View.VISIBLE); } Loading src/com/android/contacts/calllog/CallDetailHistoryAdapter.java +49 −5 Original line number Diff line number Diff line Loading @@ -32,42 +32,86 @@ import android.widget.TextView; * Adapter for a ListView containing history items from the details of a call. */ public class CallDetailHistoryAdapter extends BaseAdapter { /** The top element is a blank header, which is hidden under the rest of the UI. */ private static final int VIEW_TYPE_HEADER = 0; /** Each history item shows the detail of a call. */ private static final int VIEW_TYPE_HISTORY_ITEM = 1; private final Context mContext; private final LayoutInflater mLayoutInflater; private final CallTypeHelper mCallTypeHelper; private final PhoneCallDetails[] mPhoneCallDetails; /** Whether the voicemail controls are shown. */ private final boolean mShowVoicemail; /** Whether the call and SMS controls are shown. */ private final boolean mShowCallAndSms; public CallDetailHistoryAdapter(Context context, LayoutInflater layoutInflater, CallTypeHelper callTypeHelper, PhoneCallDetails[] phoneCallDetails) { CallTypeHelper callTypeHelper, PhoneCallDetails[] phoneCallDetails, boolean showVoicemail, boolean showCallAndSms) { mContext = context; mLayoutInflater = layoutInflater; mCallTypeHelper = callTypeHelper; mPhoneCallDetails = phoneCallDetails; mShowVoicemail = showVoicemail; mShowCallAndSms = showCallAndSms; } @Override public int getCount() { return mPhoneCallDetails.length; return mPhoneCallDetails.length + 1; } @Override public Object getItem(int position) { return mPhoneCallDetails[position]; if (position == 0) { return null; } return mPhoneCallDetails[position - 1]; } @Override public long getItemId(int position) { return position; if (position == 0) { return -1; } return position - 1; } @Override public int getViewTypeCount() { return 2; } @Override public int getItemViewType(int position) { if (position == 0) { return VIEW_TYPE_HEADER; } return VIEW_TYPE_HISTORY_ITEM; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (position == 0) { final View header = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_header, parent, false) : convertView; // Voicemail controls are only shown in the main UI if there is a voicemail. View voicemailContainer = header.findViewById(R.id.header_voicemail_container); voicemailContainer.setVisibility(mShowVoicemail ? View.VISIBLE : View.GONE); // Call and SMS controls are only shown in the main UI if there is a known number. View callAndSmsContainer = header.findViewById(R.id.header_call_and_sms_container); callAndSmsContainer.setVisibility(mShowCallAndSms ? View.VISIBLE : View.GONE); return header; } // Make sure we have a valid convertView to start with final View result = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false) : convertView; PhoneCallDetails details = mPhoneCallDetails[position]; PhoneCallDetails details = mPhoneCallDetails[position - 1]; CallTypeIconsView callTypeIconView = (CallTypeIconsView) result.findViewById(R.id.call_type_icon); TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text); Loading Loading
res/layout/call_detail.xml +159 −146 Original line number Diff line number Diff line Loading @@ -19,9 +19,29 @@ android:id="@+id/call_detail" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:gravity="top" android:visibility="gone" > <!-- The list view is under everything. It contains a first header element which is hidden under the controls UI. When scrolling, the controls move up until the name bar hits the top. --> <ListView android:id="@+id/history" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="@android:color/black" /> <!-- All the controls which are part of the pinned header are in this layout. --> <RelativeLayout android:id="@+id/controls" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" > <FrameLayout android:id="@+id/voicemail_status" Loading Loading @@ -64,6 +84,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/blue_separator" android:background="@android:color/black" > <!-- The voicemail fragment will be put here. --> </LinearLayout> Loading Loading @@ -114,7 +135,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/voicemail_container" android:layout_marginTop="@dimen/call_log_icon_margin" android:background="@android:color/black" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/call_and_sms" Loading Loading @@ -184,13 +205,5 @@ /> </LinearLayout> </FrameLayout> <ListView android:id="@+id/history" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/call_log_icon_margin" android:layout_alignParentLeft="true" android:layout_below="@id/call_and_sms_container" android:background="@android:color/black" /> </RelativeLayout> </RelativeLayout>
res/layout/call_detail_history_header.xml 0 → 100644 +61 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- This layout is supposed to match the content of the controls in call_detail.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Contact photo. --> <view class="com.android.contacts.widget.ProportionalLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@id/voicemail_status" ex:ratio="0.5" ex:direction="widthToHeight" > <!-- Proportional layout requires a view in it. --> <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> </view> <!-- Separator line --> <View android:layout_width="match_parent" android:layout_height="1dip" /> <!-- Voicemail controls --> <!-- TODO: Make the height be based on a constant. --> <View android:id="@+id/header_voicemail_container" android:layout_width="match_parent" android:layout_height="142dip" android:layout_marginBottom="@dimen/call_log_icon_margin" /> <!-- Call and SMS --> <View android:id="@+id/header_call_and_sms_container" android:layout_width="match_parent" android:layout_height="@dimen/call_log_list_item_height" /> </LinearLayout>
src/com/android/contacts/BackScrollManager.java 0 → 100644 +89 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts; import android.view.View; import android.widget.AbsListView; import android.widget.ListView; /** * Handles scrolling back of a list tied to a header. * <p> * This is used to implement a header that scrolls up with the content of a list to be partially * obscured. */ public class BackScrollManager { /** Defines the header to be scrolled. */ public interface ScrollableHeader { /** Sets the offset by which to scroll. */ public void setOffset(int offset); /** Gets the maximum offset that should be applied to the header. */ public int getMaximumScrollableHeaderOffset(); } private final ScrollableHeader mHeader; private final ListView mListView; private final AbsListView.OnScrollListener mScrollListener = new AbsListView.OnScrollListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem != 0) { // The first item is not shown, the header should be pinned at the top. mHeader.setOffset(mHeader.getMaximumScrollableHeaderOffset()); return; } View firstVisibleItemView = view.getChildAt(firstVisibleItem); if (firstVisibleItemView == null) { return; } // We scroll the header up, but at most pin it to the top of the screen. int offset = Math.min( (int) -view.getChildAt(firstVisibleItem).getY(), mHeader.getMaximumScrollableHeaderOffset()); mHeader.setOffset(offset); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // Nothing to do here. } }; /** * Creates a new instance of a {@link BackScrollManager} that connected the header and the list * view. */ public static void bind(ScrollableHeader header, ListView listView) { BackScrollManager backScrollManager = new BackScrollManager(header, listView); backScrollManager.bind(); } private BackScrollManager(ScrollableHeader header, ListView listView) { mHeader = header; mListView = listView; } private void bind() { mListView.setOnScrollListener(mScrollListener); // We disable the scroll bar because it would otherwise be incorrect because of the hidden // header. mListView.setVerticalScrollBarEnabled(false); } }
src/com/android/contacts/CallDetailActivity.java +20 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.contacts; import com.android.contacts.BackScrollManager.ScrollableHeader; import com.android.contacts.calllog.CallDetailHistoryAdapter; import com.android.contacts.calllog.CallTypeHelper; import com.android.contacts.calllog.PhoneNumberHelper; Loading Loading @@ -434,7 +435,25 @@ public class CallDetailActivity extends Activity { ListView historyList = (ListView) findViewById(R.id.history); historyList.setAdapter( new CallDetailHistoryAdapter(CallDetailActivity.this, mInflater, mCallTypeHelper, details)); mCallTypeHelper, details, hasVoicemail(), canPlaceCallsTo)); BackScrollManager.bind( new ScrollableHeader() { private View controls = findViewById(R.id.controls); private View photo = findViewById(R.id.contact_background_sizer); private View nameHeader = findViewById(R.id.photo_text_bar); @Override public void setOffset(int offset) { controls.setY(-offset); } @Override public int getMaximumScrollableHeaderOffset() { // We can scroll the photo out, but we should keep the header. return photo.getHeight() - nameHeader.getHeight(); } }, historyList); loadContactPhotos(photoUri); findViewById(R.id.call_detail).setVisibility(View.VISIBLE); } Loading
src/com/android/contacts/calllog/CallDetailHistoryAdapter.java +49 −5 Original line number Diff line number Diff line Loading @@ -32,42 +32,86 @@ import android.widget.TextView; * Adapter for a ListView containing history items from the details of a call. */ public class CallDetailHistoryAdapter extends BaseAdapter { /** The top element is a blank header, which is hidden under the rest of the UI. */ private static final int VIEW_TYPE_HEADER = 0; /** Each history item shows the detail of a call. */ private static final int VIEW_TYPE_HISTORY_ITEM = 1; private final Context mContext; private final LayoutInflater mLayoutInflater; private final CallTypeHelper mCallTypeHelper; private final PhoneCallDetails[] mPhoneCallDetails; /** Whether the voicemail controls are shown. */ private final boolean mShowVoicemail; /** Whether the call and SMS controls are shown. */ private final boolean mShowCallAndSms; public CallDetailHistoryAdapter(Context context, LayoutInflater layoutInflater, CallTypeHelper callTypeHelper, PhoneCallDetails[] phoneCallDetails) { CallTypeHelper callTypeHelper, PhoneCallDetails[] phoneCallDetails, boolean showVoicemail, boolean showCallAndSms) { mContext = context; mLayoutInflater = layoutInflater; mCallTypeHelper = callTypeHelper; mPhoneCallDetails = phoneCallDetails; mShowVoicemail = showVoicemail; mShowCallAndSms = showCallAndSms; } @Override public int getCount() { return mPhoneCallDetails.length; return mPhoneCallDetails.length + 1; } @Override public Object getItem(int position) { return mPhoneCallDetails[position]; if (position == 0) { return null; } return mPhoneCallDetails[position - 1]; } @Override public long getItemId(int position) { return position; if (position == 0) { return -1; } return position - 1; } @Override public int getViewTypeCount() { return 2; } @Override public int getItemViewType(int position) { if (position == 0) { return VIEW_TYPE_HEADER; } return VIEW_TYPE_HISTORY_ITEM; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (position == 0) { final View header = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_header, parent, false) : convertView; // Voicemail controls are only shown in the main UI if there is a voicemail. View voicemailContainer = header.findViewById(R.id.header_voicemail_container); voicemailContainer.setVisibility(mShowVoicemail ? View.VISIBLE : View.GONE); // Call and SMS controls are only shown in the main UI if there is a known number. View callAndSmsContainer = header.findViewById(R.id.header_call_and_sms_container); callAndSmsContainer.setVisibility(mShowCallAndSms ? View.VISIBLE : View.GONE); return header; } // Make sure we have a valid convertView to start with final View result = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false) : convertView; PhoneCallDetails details = mPhoneCallDetails[position]; PhoneCallDetails details = mPhoneCallDetails[position - 1]; CallTypeIconsView callTypeIconView = (CallTypeIconsView) result.findViewById(R.id.call_type_icon); TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text); Loading