diff options
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | res/layout/call_log_list_item.xml | 10 | ||||
-rw-r--r-- | res/values/styles.xml | 2 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 45 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 33 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogFragment.java | 14 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogListItemViews.java | 11 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/ContactInfoHelper.java | 7 | ||||
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteFragment.java | 10 | ||||
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java | 3 | ||||
-rw-r--r-- | src/com/android/dialer/list/RegularSearchFragment.java | 4 | ||||
-rw-r--r-- | src/com/android/dialerbind/ObjectFactory.java (renamed from src/com/android/dialerbind/ServiceFactory.java) | 16 |
12 files changed, 79 insertions, 80 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 542ddd94e..82734b687 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -120,7 +120,7 @@ <activity android:name="com.android.dialer.calllog.CallLogActivity" android:label="@string/call_log_activity_title" - android:theme="@style/CallLogActivityTheme" + android:theme="@style/DialtactsThemeWithActionBarOverlay" android:screenOrientation="portrait" android:icon="@mipmap/ic_launcher_phone"> <intent-filter> @@ -133,7 +133,7 @@ <activity android:name="com.android.dialer.list.AllContactsActivity" android:label="@string/show_all_contacts_title" - android:theme="@style/DialtactsTheme" + android:theme="@style/DialtactsThemeWithActionBarOverlay" android:screenOrientation="portrait"> </activity> diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml index 46e503c25..c49b4b008 100644 --- a/res/layout/call_log_list_item.xml +++ b/res/layout/call_log_list_item.xml @@ -17,9 +17,9 @@ <view xmlns:android="http://schemas.android.com/apk/res/android" class="com.android.dialer.calllog.CallLogListItemView" - android:id="@+id/call_log_list_item" android:layout_width="match_parent" android:layout_height="wrap_content" + android:id="@+id/call_log_list_item" android:orientation="vertical" android:background="@drawable/bottom_border_background" > @@ -140,12 +140,4 @@ android:paddingTop="@dimen/call_log_inner_margin" android:paddingBottom="@dimen/call_log_inner_margin" /> - <View - android:id="@+id/call_log_divider" - android:layout_width="match_parent" - android:layout_height="1px" - android:layout_marginStart="@dimen/call_log_outer_margin" - android:layout_marginEnd="@dimen/call_log_outer_margin" - android:background="#55ffffff" - /> </view> diff --git a/res/values/styles.xml b/res/values/styles.xml index e7dd9f9b0..9b9924468 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -72,7 +72,7 @@ <item name="android:textColorPrimary">#FFFFFF</item> </style> - <style name="CallLogActivityTheme" parent="DialtactsTheme"> + <style name="DialtactsThemeWithActionBarOverlay" parent="DialtactsTheme"> <item name="android:windowActionBarOverlay">true</item> </style> diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index ca7a958b7..468003806 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -20,7 +20,6 @@ import android.animation.Animator; import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; import android.app.Activity; -import android.app.backup.BackupManager; import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentManager.BackStackEntry; @@ -28,20 +27,15 @@ import android.app.FragmentTransaction; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; -import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.CallLog.Calls; -import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; import android.provider.ContactsContract.Intents.UI; -import android.provider.Settings; import android.speech.RecognizerIntent; -import android.support.v4.app.NavUtils; import android.telephony.TelephonyManager; import android.text.Editable; import android.text.TextUtils; @@ -51,24 +45,17 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnFocusChangeListener; -import android.view.ViewConfiguration; import android.view.inputmethod.InputMethodManager; import android.widget.AbsListView.OnScrollListener; import android.widget.EditText; -import android.widget.ImageView; import android.widget.PopupMenu; -import android.widget.SearchView; -import android.widget.SearchView.OnCloseListener; -import android.widget.SearchView.OnQueryTextListener; import android.widget.Toast; import com.android.contacts.common.CallUtil; import com.android.contacts.common.activity.TransactionSafeActivity; import com.android.contacts.common.dialog.ClearFrequentsDialog; import com.android.contacts.common.interactions.ImportExportDialogFragment; -import com.android.contacts.common.list.ContactListItemView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; -import com.android.contacts.common.list.PhoneNumberPickerFragment; import com.android.dialer.calllog.CallLogActivity; import com.android.dialer.database.DialerDatabaseHelper; import com.android.dialer.dialpad.DialpadFragment; @@ -76,8 +63,8 @@ import com.android.dialer.dialpad.SmartDialNameMatcher; import com.android.dialer.dialpad.SmartDialPrefix; import com.android.dialer.interactions.PhoneNumberInteraction; import com.android.dialer.list.AllContactsActivity; -import com.android.dialer.list.PhoneFavoriteFragment; import com.android.dialer.list.OnListFragmentScrolledListener; +import com.android.dialer.list.PhoneFavoriteFragment; import com.android.dialer.list.RegularSearchFragment; import com.android.dialer.list.SearchFragment; import com.android.dialer.list.SmartDialSearchFragment; @@ -161,6 +148,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private boolean mInRegularSearch; /** + * True if the dialpad is only temporarily showing due to being in call + */ + private boolean mInCallDialpadUp; + + /** * True when this activity has been launched for the first time. */ private boolean mFirstLaunch; @@ -312,7 +304,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O super.onResume(); if (mFirstLaunch) { displayFragment(getIntent()); + } else if (!phoneIsInUse() && mInCallDialpadUp) { + hideDialpadFragment(false, true); + mInCallDialpadUp = false; } + mFirstLaunch = false; mDialerDatabaseHelper.startSmartDialUpdateThread(); } @@ -372,8 +368,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } return true; case R.id.menu_call_settings: - final Intent settingsIntent = DialtactsActivity.getCallSettingsIntent(); - startActivity(settingsIntent); + handleMenuSettings(); return true; case R.id.menu_all_contacts: onShowAllContacts(); @@ -382,6 +377,15 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O return false; } + protected void handleMenuSettings() { + openTelephonySetting(this); + } + + public static void openTelephonySetting(Activity activity) { + final Intent settingsIntent = getCallSettingsIntent(); + activity.startActivity(settingsIntent); + } + @Override public void onClick(View view) { switch (view.getId()) { @@ -396,6 +400,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O break; } case R.id.dialpad_button: + // Reset the boolean flag that tracks whether the dialpad was up because + // we were in call. Regardless of whether it was true before, we want to + // show the dialpad because the user has explicitly clicked the dialpad + // button. + mInCallDialpadUp = false; showDialpadFragment(true); break; case R.id.call_history_on_dialpad_button: @@ -408,6 +417,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O case R.id.search_close_button: // Clear the search field if (!TextUtils.isEmpty(mSearchView.getText())) { + mDialpadFragment.clearDialpad(); mSearchView.setText(""); } break; @@ -631,6 +641,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O if (mDialpadFragment != null && (phoneIsInUse() || isDialIntent(intent))) { mDialpadFragment.setStartedFromNewIntent(true); + if (!mDialpadFragment.isVisible()) { + mInCallDialpadUp = true; + } showDialpadFragment(false); } } diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 89e8be519..c0054ba79 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -90,7 +90,7 @@ public class CallLogAdapter extends GroupingListAdapter /** The size of the cache of contact info. */ private static final int CONTACT_INFO_CACHE_SIZE = 100; - private final Context mContext; + protected final Context mContext; private final ContactInfoHelper mContactInfoHelper; private final CallFetcher mCallFetcher; private ViewTreeObserver mViewTreeObserver = null; @@ -448,39 +448,30 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected View newStandAloneView(Context context, ViewGroup parent) { - LayoutInflater inflater = - (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = inflater.inflate(R.layout.call_log_list_item, parent, false); - findAndCacheViews(view); - return view; + return newChildView(context, parent); } @Override - protected void bindStandAloneView(View view, Context context, Cursor cursor) { - bindView(view, cursor, 1); + protected View newGroupView(Context context, ViewGroup parent) { + return newChildView(context, parent); } @Override protected View newChildView(Context context, ViewGroup parent) { - LayoutInflater inflater = - (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.call_log_list_item, parent, false); findAndCacheViews(view); return view; } @Override - protected void bindChildView(View view, Context context, Cursor cursor) { + protected void bindStandAloneView(View view, Context context, Cursor cursor) { bindView(view, cursor, 1); } @Override - protected View newGroupView(Context context, ViewGroup parent) { - LayoutInflater inflater = - (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = inflater.inflate(R.layout.call_log_list_item, parent, false); - findAndCacheViews(view); - return view; + protected void bindChildView(View view, Context context, Cursor cursor) { + bindView(view, cursor, 1); } @Override @@ -509,7 +500,6 @@ public class CallLogAdapter extends GroupingListAdapter // Default case: an item in the call log. views.primaryActionView.setVisibility(View.VISIBLE); - views.bottomDivider.setVisibility(View.VISIBLE); views.listHeaderTextView.setVisibility(View.GONE); final String number = c.getString(CallLogQuery.NUMBER); @@ -593,6 +583,7 @@ public class CallLogAdapter extends GroupingListAdapter final int[] callTypes = getCallTypes(c, count); final String geocode = c.getString(CallLogQuery.GEOCODED_LOCATION); final PhoneCallDetails details; + if (TextUtils.isEmpty(name)) { details = new PhoneCallDetails(number, numberPresentation, formattedNumber, countryIso, geocode, callTypes, date, @@ -623,6 +614,12 @@ public class CallLogAdapter extends GroupingListAdapter mViewTreeObserver = view.getViewTreeObserver(); mViewTreeObserver.addOnPreDrawListener(this); } + + postBindView(views, info); + } + + protected void postBindView(CallLogListItemViews views, ContactInfo info) { + // no-op } /** Checks whether the contact info from the call log matches the one from the contacts db. */ diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index b68503064..d0d34d897 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -30,13 +30,9 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract; import android.telephony.PhoneNumberUtils; -import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; @@ -50,8 +46,8 @@ import com.android.dialer.util.EmptyLoader; import com.android.dialer.voicemail.VoicemailStatusHelper; import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage; import com.android.dialer.voicemail.VoicemailStatusHelperImpl; +import com.android.dialerbind.ObjectFactory; import com.android.internal.telephony.ITelephony; -import com.google.common.annotations.VisibleForTesting; import java.util.List; @@ -234,8 +230,8 @@ public class CallLogFragment extends ListFragment super.onViewCreated(view, savedInstanceState); updateEmptyMessage(mCallTypeFilter); String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); - mAdapter = new CallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), false); + mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper( + getActivity(), currentCountryIso), false, true); setListAdapter(mAdapter); getListView().setItemsCanFocus(true); } @@ -444,10 +440,8 @@ public class CallLogFragment extends ListFragment // seen the new calls yet. // This might be called before onCreate() and thus we need to check null explicitly. if (mKeyguardManager != null && !mKeyguardManager.inKeyguardRestrictedInputMode()) { - // On either of the transitions we reset the new flag and update the notifications. + // On either of the transitions we update the missed call and voicemail notifications. // While exiting we additionally consume all missed calls (by marking them as read). - // This will ensure that they no more appear in the "new" section when we return back. - mCallLogQueryHandler.markNewCallsAsOld(); if (!onEntry) { mCallLogQueryHandler.markMissedCallsAsRead(); } diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java index 0dd4f6344..ed6218f86 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViews.java +++ b/src/com/android/dialer/calllog/CallLogListItemViews.java @@ -40,18 +40,15 @@ public final class CallLogListItemViews { public final PhoneCallDetailsViews phoneCallDetailsViews; /** The text of the header of a section. */ public final TextView listHeaderTextView; - /** The divider to be shown below items. */ - public final View bottomDivider; private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, ImageView secondaryActionView, PhoneCallDetailsViews phoneCallDetailsViews, - TextView listHeaderTextView, View bottomDivider) { + TextView listHeaderTextView) { this.quickContactView = quickContactView; this.primaryActionView = primaryActionView; this.secondaryActionView = secondaryActionView; this.phoneCallDetailsViews = phoneCallDetailsViews; this.listHeaderTextView = listHeaderTextView; - this.bottomDivider = bottomDivider; } public static CallLogListItemViews fromView(View view) { @@ -60,8 +57,7 @@ public final class CallLogListItemViews { view.findViewById(R.id.primary_action_view), (ImageView) view.findViewById(R.id.secondary_action_icon), PhoneCallDetailsViews.fromView(view), - (TextView) view.findViewById(R.id.call_log_header), - view.findViewById(R.id.call_log_divider)); + (TextView) view.findViewById(R.id.call_log_header)); } @NeededForTesting @@ -71,7 +67,6 @@ public final class CallLogListItemViews { new View(context), new ImageView(context), PhoneCallDetailsViews.createForTest(context), - new TextView(context), - new View(context)); + new TextView(context)); } } diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 5d7aa1bef..64484cbed 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -22,18 +22,15 @@ import android.net.Uri; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; -import android.provider.ContactsContract.Directory; import android.provider.ContactsContract.DisplayNameSources; import android.provider.ContactsContract.PhoneLookup; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; -import android.util.Log; import com.android.contacts.common.util.Constants; import com.android.contacts.common.util.UriUtils; import com.android.dialer.service.CachedNumberLookupService; -import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; -import com.android.dialerbind.ServiceFactory; +import com.android.dialerbind.ObjectFactory; import org.json.JSONException; import org.json.JSONObject; @@ -46,7 +43,7 @@ public class ContactInfoHelper { private final String mCurrentCountryIso; private static final CachedNumberLookupService mCachedNumberLookupService = - ServiceFactory.newCachedNumberLookupService(); + ObjectFactory.newCachedNumberLookupService(); public ContactInfoHelper(Context context, String currentCountryIso) { mContext = context; diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java index 00bf9f28e..d7c387e57 100644 --- a/src/com/android/dialer/list/PhoneFavoriteFragment.java +++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java @@ -19,7 +19,6 @@ import android.app.Activity; import android.app.Fragment; import android.app.LoaderManager; import android.content.CursorLoader; -import android.content.Intent; import android.content.Loader; import android.database.Cursor; import android.graphics.Rect; @@ -27,7 +26,6 @@ import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.ViewTreeObserver; import android.view.View.OnClickListener; @@ -35,7 +33,6 @@ import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; -import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TextView; @@ -44,13 +41,12 @@ import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactEntry; import com.android.contacts.common.list.ContactTileView; -import com.android.contacts.common.list.PhoneNumberListAdapter; -import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.calllog.CallLogAdapter; import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.list.PhoneFavoritesTileAdapter.ContactTileRow; +import com.android.dialerbind.ObjectFactory; import java.util.ArrayList; import java.util.HashMap; @@ -191,8 +187,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(), this, 1); final String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); - mCallLogAdapter = new CallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), true); + mCallLogAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, + new ContactInfoHelper(getActivity(), currentCountryIso), true, false); setHasOptionsMenu(true); } diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java index fba55a689..57ae2c147 100644 --- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java @@ -314,6 +314,9 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { @Override public void onBeginDrag(View v) { + // We do this so the underlying ScrollView knows that it won't get + // the chance to intercept events anymore + requestDisallowInterceptTouchEvent(true); } @Override diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java index ccbd3d0dc..2a80b3ebd 100644 --- a/src/com/android/dialer/list/RegularSearchFragment.java +++ b/src/com/android/dialer/list/RegularSearchFragment.java @@ -16,7 +16,7 @@ package com.android.dialer.list; import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.dialerbind.ServiceFactory; +import com.android.dialerbind.ObjectFactory; import com.android.dialer.service.CachedNumberLookupService; public class RegularSearchFragment extends SearchFragment { @@ -24,7 +24,7 @@ public class RegularSearchFragment extends SearchFragment { private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5; private static final CachedNumberLookupService mCachedNumberLookupService = - ServiceFactory.newCachedNumberLookupService(); + ObjectFactory.newCachedNumberLookupService(); public RegularSearchFragment() { configureDirectorySearch(); diff --git a/src/com/android/dialerbind/ServiceFactory.java b/src/com/android/dialerbind/ObjectFactory.java index e53d2e82a..6286c05ba 100644 --- a/src/com/android/dialerbind/ServiceFactory.java +++ b/src/com/android/dialerbind/ObjectFactory.java @@ -16,15 +16,27 @@ package com.android.dialerbind; +import static com.android.dialer.calllog.CallLogAdapter.CallFetcher; + +import android.content.Context; + +import com.android.dialer.calllog.CallLogAdapter; +import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.service.CachedNumberLookupService; /** - * Default static binder for services. + * Default static binding for various objects. */ -public class ServiceFactory { +public class ObjectFactory { public static CachedNumberLookupService newCachedNumberLookupService() { // no-op return null; } + + public static CallLogAdapter newCallLogAdapter(Context context, CallFetcher callFetcher, + ContactInfoHelper contactInfoHelper, boolean useCallAsPrimaryAction, + boolean isCallLog) { + return new CallLogAdapter(context, callFetcher, contactInfoHelper, useCallAsPrimaryAction); + } } |