diff options
author | Brandon Maxwell <maxwelb@google.com> | 2016-03-10 19:42:44 -0800 |
---|---|---|
committer | Brandon Maxwell <maxwelb@google.com> | 2016-03-11 13:34:35 -0800 |
commit | 17df9323e45ae5984b6df25b788a9cbffb51e8ab (patch) | |
tree | e8a24e607b77c1c21283da024859f84d94bd7123 /src | |
parent | ebfbfa10d95ef21373cf7c112eac52413b11c525 (diff) |
Removing hardcoded database column name
+ We were previously hardcoding the post_dial_digits column name.
This code was written before we had src-N and src-pre-N folders.
+ This CL converts the hard coded column name to follow the pattern
we have for new stuff in the SDK.
+ Additionally, this CL removes an unneeded method which checks the
SDK version, instead using the CompatUtils class.
Bug: 25021389
Change-Id: I017d47f7efd323254e616a64d7ac824c5cfb8902
Diffstat (limited to 'src')
7 files changed, 30 insertions, 42 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index e97f8e235..dfb5190e1 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -16,10 +16,6 @@ package com.android.dialer.calllog; -import com.android.contacts.common.util.PermissionsUtil; - -import com.android.dialer.DialtactsActivity; -import com.android.dialer.database.VoicemailArchiveContract; import com.google.common.annotations.VisibleForTesting; import android.content.Context; @@ -40,7 +36,6 @@ import android.telephony.PhoneNumberUtils; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArrayMap; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.AccessibilityDelegate; @@ -48,15 +43,18 @@ import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import com.android.contacts.common.ContactsUtils; +import com.android.contacts.common.compat.CompatUtils; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.util.PermissionsUtil; +import com.android.dialer.DialtactsActivity; import com.android.dialer.PhoneCallDetails; import com.android.dialer.R; import com.android.dialer.calllog.calllogcache.CallLogCache; import com.android.dialer.contactinfo.ContactInfoCache; import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListener; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; +import com.android.dialer.database.VoicemailArchiveContract; import com.android.dialer.filterednumber.BlockNumberDialogFragment.Callback; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; @@ -492,7 +490,7 @@ public class CallLogAdapter extends GroupingListAdapter int count = getGroupSize(position); final String number = c.getString(CallLogQuery.NUMBER); - final String postDialDigits = PhoneNumberDisplayUtil.canShowPostDial() + final String postDialDigits = CompatUtils.isNCompatible() && mActivityType != ACTIVITY_TYPE_ARCHIVE ? c.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java index 13de0775d..7cb35f514 100644 --- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java +++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java @@ -16,6 +16,8 @@ package com.android.dialer.calllog; +import com.google.common.annotations.VisibleForTesting; + import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; @@ -30,18 +32,16 @@ import android.text.TextUtils; import android.util.Log; import com.android.contacts.common.GeoUtil; +import com.android.contacts.common.compat.CompatUtils; import com.android.contacts.common.util.PermissionsUtil; -import com.android.dialer.DialtactsActivity; import com.android.dialer.PhoneCallDetails; +import com.android.dialer.compat.CallsSdkCompat; import com.android.dialer.database.VoicemailArchiveContract; -import com.android.dialer.util.AppCompatConstants; import com.android.dialer.util.AsyncTaskExecutor; import com.android.dialer.util.AsyncTaskExecutors; import com.android.dialer.util.PhoneNumberUtil; import com.android.dialer.util.TelecomUtil; -import com.google.common.annotations.VisibleForTesting; - import java.util.ArrayList; import java.util.Arrays; @@ -94,8 +94,8 @@ public class CallLogAsyncTaskUtil { static { ArrayList<String> projectionList = new ArrayList<>(); projectionList.addAll(Arrays.asList(CALL_LOG_PROJECTION_INTERNAL)); - if (PhoneNumberDisplayUtil.canShowPostDial()) { - projectionList.add(AppCompatConstants.POST_DIAL_DIGITS); + if (CompatUtils.isNCompatible()) { + projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS); } projectionList.trimToSize(); CALL_LOG_PROJECTION = projectionList.toArray(new String[projectionList.size()]); @@ -113,13 +113,13 @@ public class CallLogAsyncTaskUtil { } public interface CallLogAsyncTaskListener { - public void onDeleteCall(); - public void onDeleteVoicemail(); - public void onGetCallDetails(PhoneCallDetails[] details); + void onDeleteCall(); + void onDeleteVoicemail(); + void onGetCallDetails(PhoneCallDetails[] details); } public interface OnCallLogQueryFinishedListener { - public void onQueryFinished(boolean hasEntry); + void onQueryFinished(boolean hasEntry); } // Try to identify if a call log entry corresponds to a number which was blocked. We match by @@ -185,7 +185,7 @@ public class CallLogAsyncTaskUtil { // Read call log. final String countryIso = cursor.getString(CallDetailQuery.COUNTRY_ISO_COLUMN_INDEX); final String number = cursor.getString(CallDetailQuery.NUMBER_COLUMN_INDEX); - final String postDialDigits = PhoneNumberDisplayUtil.canShowPostDial() + final String postDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallDetailQuery.POST_DIAL_DIGITS) : ""; final int numberPresentation = cursor.getInt(CallDetailQuery.NUMBER_PRESENTATION_COLUMN_INDEX); diff --git a/src/com/android/dialer/calllog/CallLogGroupBuilder.java b/src/com/android/dialer/calllog/CallLogGroupBuilder.java index 950f63471..0931e0644 100644 --- a/src/com/android/dialer/calllog/CallLogGroupBuilder.java +++ b/src/com/android/dialer/calllog/CallLogGroupBuilder.java @@ -16,17 +16,18 @@ package com.android.dialer.calllog; +import com.google.common.annotations.VisibleForTesting; + import android.database.Cursor; import android.telephony.PhoneNumberUtils; -import android.text.format.Time; import android.text.TextUtils; +import android.text.format.Time; +import com.android.contacts.common.compat.CompatUtils; import com.android.contacts.common.util.DateUtils; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.dialer.util.AppCompatConstants; -import com.google.common.annotations.VisibleForTesting; - /** * Groups together calls in the call log. The primary grouping attempts to group together calls * to and from the same number into a single row on the call log. @@ -122,7 +123,7 @@ public class CallLogGroupBuilder { // Instantiate the group values to those of the first call in the cursor. String groupNumber = cursor.getString(CallLogQuery.NUMBER); - String groupPostDialDigits = PhoneNumberDisplayUtil.canShowPostDial() + String groupPostDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; int groupCallType = cursor.getInt(CallLogQuery.CALL_TYPE); String groupAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); @@ -138,7 +139,7 @@ public class CallLogGroupBuilder { while (cursor.moveToNext()) { // Obtain the values for the current call to group. number = cursor.getString(CallLogQuery.NUMBER); - numberPostDialDigits = PhoneNumberDisplayUtil.canShowPostDial() + numberPostDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; callType = cursor.getInt(CallLogQuery.CALL_TYPE); accountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); diff --git a/src/com/android/dialer/calllog/CallLogQuery.java b/src/com/android/dialer/calllog/CallLogQuery.java index 905a4b789..4900354bf 100644 --- a/src/com/android/dialer/calllog/CallLogQuery.java +++ b/src/com/android/dialer/calllog/CallLogQuery.java @@ -16,12 +16,13 @@ package com.android.dialer.calllog; +import com.google.common.collect.Lists; + import android.provider.CallLog.Calls; +import com.android.contacts.common.compat.CompatUtils; +import com.android.dialer.compat.CallsSdkCompat; import com.android.dialer.compat.DialerCompatUtils; -import com.android.dialer.util.AppCompatConstants; - -import com.google.common.collect.Lists; import java.util.List; @@ -89,7 +90,7 @@ public final class CallLogQuery { /** * Only available in versions > M - * Call {@link PhoneNumberDisplayUtil#canShowPostDial()} prior to use + * Call {@link CompatUtils#isNCompatible()} prior to use */ public static int POST_DIAL_DIGITS = -1; @@ -101,8 +102,8 @@ public final class CallLogQuery { projectionList.add(Calls.CACHED_PHOTO_URI); CACHED_PHOTO_URI = projectionList.size() - 1; } - if (PhoneNumberDisplayUtil.canShowPostDial()) { - projectionList.add(AppCompatConstants.POST_DIAL_DIGITS); + if (CompatUtils.isNCompatible()) { + projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS); POST_DIAL_DIGITS = projectionList.size() - 1; } _PROJECTION = projectionList.toArray(new String[projectionList.size()]); diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index ff7a3f6a5..6e84a92f9 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -32,6 +32,7 @@ import android.util.Log; import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.ContactsUtils.UserType; +import com.android.contacts.common.compat.CompatUtils; import com.android.contacts.common.util.Constants; import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.common.util.PhoneNumberHelper; @@ -41,7 +42,6 @@ import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; import com.android.dialer.util.TelecomUtil; import com.android.dialerbind.ObjectFactory; -import com.google.common.annotations.VisibleForTesting; import org.json.JSONException; import org.json.JSONObject; @@ -435,7 +435,7 @@ public class ContactInfoHelper { info.type = c.getInt(CallLogQuery.CACHED_NUMBER_TYPE); info.label = c.getString(CallLogQuery.CACHED_NUMBER_LABEL); String matchedNumber = c.getString(CallLogQuery.CACHED_MATCHED_NUMBER); - String postDialDigits = PhoneNumberDisplayUtil.canShowPostDial() + String postDialDigits = CompatUtils.isNCompatible() ? c.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; info.number = (matchedNumber == null) ? c.getString(CallLogQuery.NUMBER) + postDialDigits : matchedNumber; diff --git a/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java index 09b42e9f6..5b1fc9e3a 100644 --- a/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java +++ b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java @@ -17,7 +17,6 @@ package com.android.dialer.calllog; import android.content.Context; -import android.os.Build; import android.provider.CallLog.Calls; import android.text.TextUtils; @@ -81,13 +80,4 @@ public class PhoneNumberDisplayUtil { return context.getResources().getString(R.string.unknown); } } - - /** - * Returns whether we can expect the post-dial digits to be in the call log. - * - * These digits will be present in versions N+. - */ - public static boolean canShowPostDial() { - return Build.VERSION.SDK_INT > Build.VERSION_CODES.M; - } } diff --git a/src/com/android/dialer/util/AppCompatConstants.java b/src/com/android/dialer/util/AppCompatConstants.java index 0bb78df26..1d52eee1d 100644 --- a/src/com/android/dialer/util/AppCompatConstants.java +++ b/src/com/android/dialer/util/AppCompatConstants.java @@ -27,6 +27,4 @@ public final class AppCompatConstants { public static final int CALLS_REJECTED_TYPE = 5; // Added to android.provider.CallLog.Calls in N+. public static final int CALLS_BLOCKED_TYPE = 6; - // Added to android.provider.CallLog.Calls in N+. - public static final String POST_DIAL_DIGITS = "post_dial_digits"; } |