summaryrefslogtreecommitdiff
path: root/java/com/android/contacts/common/util
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-06-19 11:26:01 -0700
committerEric Erfanian <erfanian@google.com>2017-06-19 11:30:45 -0700
commit2f1c7586bcce334ca69022eb8dc6d8965ceb6a05 (patch)
treebf00ada449ee3de31ec983a14e84159200aa18c2 /java/com/android/contacts/common/util
parent3d0ca68e466482971a4cf46576c50cb2bd42bcb5 (diff)
Update AOSP Dialer source from internal google3 repository at
cl/159428781. Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/152373142 (4/06/2017) to cl/159428781 (6/19/2017). This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Our current goal is to do frequent drops (daily if possible) and eventually switched to an automated process. Change-Id: Ie60a84b3936efd0ea3d95d7c86bf96d2b1663030
Diffstat (limited to 'java/com/android/contacts/common/util')
-rw-r--r--java/com/android/contacts/common/util/AccountFilterUtil.java42
-rw-r--r--java/com/android/contacts/common/util/BitmapUtil.java26
-rw-r--r--java/com/android/contacts/common/util/ContactDisplayUtils.java12
-rw-r--r--java/com/android/contacts/common/util/DateUtils.java241
-rw-r--r--java/com/android/contacts/common/util/MaterialColorMapUtils.java8
-rw-r--r--java/com/android/contacts/common/util/NameConverter.java242
-rw-r--r--java/com/android/contacts/common/util/StopWatch.java28
-rw-r--r--java/com/android/contacts/common/util/TelephonyManagerUtils.java9
-rw-r--r--java/com/android/contacts/common/util/TrafficStatsTags.java22
9 files changed, 7 insertions, 623 deletions
diff --git a/java/com/android/contacts/common/util/AccountFilterUtil.java b/java/com/android/contacts/common/util/AccountFilterUtil.java
index 18743c65e..25f937c5e 100644
--- a/java/com/android/contacts/common/util/AccountFilterUtil.java
+++ b/java/com/android/contacts/common/util/AccountFilterUtil.java
@@ -16,35 +16,15 @@
package com.android.contacts.common.util;
-import android.app.Activity;
import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.android.contacts.common.R;
import com.android.contacts.common.list.ContactListFilter;
-import com.android.contacts.common.list.ContactListFilterController;
/** Utility class for account filter manipulation. */
public class AccountFilterUtil {
- public static final String EXTRA_CONTACT_LIST_FILTER = "contactListFilter";
- private static final String TAG = AccountFilterUtil.class.getSimpleName();
-
- /**
- * Find TextView with the id "account_filter_header" and set correct text for the account filter
- * header.
- *
- * @param filterContainer View containing TextView with id "account_filter_header"
- * @return true when header text is set in the call. You may use this for conditionally showing or
- * hiding this entire view.
- */
- public static boolean updateAccountFilterTitleForPeople(
- View filterContainer, ContactListFilter filter, boolean showTitleForAllAccounts) {
- return updateAccountFilterTitle(filterContainer, filter, showTitleForAllAccounts, false);
- }
-
/**
* Similar to {@link #updateAccountFilterTitleForPeople(View, ContactListFilter, boolean,
* boolean)}, but for Phone UI.
@@ -78,8 +58,6 @@ public class AccountFilterUtil {
} else if (filter.filterType == ContactListFilter.FILTER_TYPE_CUSTOM) {
headerTextView.setText(R.string.listCustomView);
textWasSet = true;
- } else {
- Log.w(TAG, "Filter type \"" + filter.filterType + "\" isn't expected.");
}
} else {
if (filter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS) {
@@ -97,29 +75,9 @@ public class AccountFilterUtil {
} else if (filter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
headerTextView.setText(R.string.listSingleContact);
textWasSet = true;
- } else {
- Log.w(TAG, "Filter type \"" + filter.filterType + "\" isn't expected.");
}
}
- } else {
- Log.w(TAG, "Filter is null.");
}
return textWasSet;
}
-
- /** This will update filter via a given ContactListFilterController. */
- public static void handleAccountFilterResult(
- ContactListFilterController filterController, int resultCode, Intent data) {
- if (resultCode == Activity.RESULT_OK) {
- final ContactListFilter filter = data.getParcelableExtra(EXTRA_CONTACT_LIST_FILTER);
- if (filter == null) {
- return;
- }
- if (filter.filterType == ContactListFilter.FILTER_TYPE_CUSTOM) {
- filterController.selectCustomFilter();
- } else {
- filterController.setContactListFilter(filter, true);
- }
- }
- }
}
diff --git a/java/com/android/contacts/common/util/BitmapUtil.java b/java/com/android/contacts/common/util/BitmapUtil.java
index 20f916a3f..51f65f280 100644
--- a/java/com/android/contacts/common/util/BitmapUtil.java
+++ b/java/com/android/contacts/common/util/BitmapUtil.java
@@ -24,8 +24,6 @@ import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
/** Provides static functions to decode bitmaps at the optimal size */
public class BitmapUtil {
@@ -91,30 +89,6 @@ public class BitmapUtil {
}
/**
- * Retrieves a copy of the specified drawable resource, rotated by a specified angle.
- *
- * @param resources The current resources.
- * @param resourceId The resource ID of the drawable to rotate.
- * @param angle The angle of rotation.
- * @return Rotated drawable.
- */
- public static Drawable getRotatedDrawable(
- android.content.res.Resources resources, int resourceId, float angle) {
-
- // Get the original drawable and make a copy which will be rotated.
- Bitmap original = BitmapFactory.decodeResource(resources, resourceId);
- Bitmap rotated =
- Bitmap.createBitmap(original.getWidth(), original.getHeight(), Bitmap.Config.ARGB_8888);
-
- // Perform the rotation.
- Canvas tempCanvas = new Canvas(rotated);
- tempCanvas.rotate(angle, original.getWidth() / 2, original.getHeight() / 2);
- tempCanvas.drawBitmap(original, 0, 0, null);
-
- return new BitmapDrawable(resources, rotated);
- }
-
- /**
* Given an input bitmap, scales it to the given width/height and makes it round.
*
* @param input {@link Bitmap} to scale and crop
diff --git a/java/com/android/contacts/common/util/ContactDisplayUtils.java b/java/com/android/contacts/common/util/ContactDisplayUtils.java
index 1586784db..ff22f2880 100644
--- a/java/com/android/contacts/common/util/ContactDisplayUtils.java
+++ b/java/com/android/contacts/common/util/ContactDisplayUtils.java
@@ -16,21 +16,20 @@
package com.android.contacts.common.util;
-import static android.provider.ContactsContract.CommonDataKinds.Phone;
-
import android.content.Context;
import android.content.res.Resources;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.TtsSpan;
-import android.util.Log;
import android.util.Patterns;
import com.android.contacts.common.R;
import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
import com.android.contacts.common.preference.ContactsPreferences;
+import com.android.dialer.common.LogUtil;
import java.util.Objects;
/** Methods for handling various contact data labels. */
@@ -38,7 +37,6 @@ public class ContactDisplayUtils {
public static final int INTERACTION_CALL = 1;
public static final int INTERACTION_SMS = 2;
- private static final String TAG = ContactDisplayUtils.class.getSimpleName();
/**
* Checks if the given data type is a custom type.
@@ -74,9 +72,9 @@ public class ContactDisplayUtils {
} else {
resId = getPhoneLabelResourceId(type);
if (interactionType != INTERACTION_CALL) {
- Log.e(
- TAG,
- "Un-recognized interaction type: "
+ LogUtil.e(
+ "ContactDisplayUtils.getLabelForCallOrSms",
+ "un-recognized interaction type: "
+ interactionType
+ ". Defaulting to ContactDisplayUtils.INTERACTION_CALL.");
}
diff --git a/java/com/android/contacts/common/util/DateUtils.java b/java/com/android/contacts/common/util/DateUtils.java
index 1935d727a..09d52bce8 100644
--- a/java/com/android/contacts/common/util/DateUtils.java
+++ b/java/com/android/contacts/common/util/DateUtils.java
@@ -16,252 +16,11 @@
package com.android.contacts.common.util;
-import android.content.Context;
-import android.text.format.DateFormat;
import android.text.format.Time;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import java.util.TimeZone;
/** Utility methods for processing dates. */
public class DateUtils {
- public static final TimeZone UTC_TIMEZONE = TimeZone.getTimeZone("UTC");
-
- /**
- * When parsing a date without a year, the system assumes 1970, which wasn't a leap-year. Let's
- * add a one-off hack for that day of the year
- */
- public static final String NO_YEAR_DATE_FEB29TH = "--02-29";
-
- // Variations of ISO 8601 date format. Do not change the order - it does affect the
- // result in ambiguous cases.
- private static final SimpleDateFormat[] DATE_FORMATS = {
- CommonDateUtils.FULL_DATE_FORMAT,
- CommonDateUtils.DATE_AND_TIME_FORMAT,
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US),
- new SimpleDateFormat("yyyyMMdd", Locale.US),
- new SimpleDateFormat("yyyyMMdd'T'HHmmssSSS'Z'", Locale.US),
- new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.US),
- new SimpleDateFormat("yyyyMMdd'T'HHmm'Z'", Locale.US),
- };
-
- static {
- for (SimpleDateFormat format : DATE_FORMATS) {
- format.setLenient(true);
- format.setTimeZone(UTC_TIMEZONE);
- }
- CommonDateUtils.NO_YEAR_DATE_FORMAT.setTimeZone(UTC_TIMEZONE);
- }
-
- /**
- * Parses the supplied string to see if it looks like a date.
- *
- * @param string The string representation of the provided date
- * @param mustContainYear If true, the string is parsed as a date containing a year. If false, the
- * string is parsed into a valid date even if the year field is missing.
- * @return A Calendar object corresponding to the date if the string is successfully parsed. If
- * not, null is returned.
- */
- public static Calendar parseDate(String string, boolean mustContainYear) {
- ParsePosition parsePosition = new ParsePosition(0);
- Date date;
- if (!mustContainYear) {
- final boolean noYearParsed;
- // Unfortunately, we can't parse Feb 29th correctly, so let's handle this day seperately
- if (NO_YEAR_DATE_FEB29TH.equals(string)) {
- return getUtcDate(0, Calendar.FEBRUARY, 29);
- } else {
- synchronized (CommonDateUtils.NO_YEAR_DATE_FORMAT) {
- date = CommonDateUtils.NO_YEAR_DATE_FORMAT.parse(string, parsePosition);
- }
- noYearParsed = parsePosition.getIndex() == string.length();
- }
-
- if (noYearParsed) {
- return getUtcDate(date, true);
- }
- }
- for (int i = 0; i < DATE_FORMATS.length; i++) {
- SimpleDateFormat f = DATE_FORMATS[i];
- synchronized (f) {
- parsePosition.setIndex(0);
- date = f.parse(string, parsePosition);
- if (parsePosition.getIndex() == string.length()) {
- return getUtcDate(date, false);
- }
- }
- }
- return null;
- }
-
- private static final Calendar getUtcDate(Date date, boolean noYear) {
- final Calendar calendar = Calendar.getInstance(UTC_TIMEZONE, Locale.US);
- calendar.setTime(date);
- if (noYear) {
- calendar.set(Calendar.YEAR, 0);
- }
- return calendar;
- }
-
- private static final Calendar getUtcDate(int year, int month, int dayOfMonth) {
- final Calendar calendar = Calendar.getInstance(UTC_TIMEZONE, Locale.US);
- calendar.clear();
- calendar.set(Calendar.YEAR, year);
- calendar.set(Calendar.MONTH, month);
- calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- return calendar;
- }
-
- public static boolean isYearSet(Calendar cal) {
- // use the Calendar.YEAR field to track whether or not the year is set instead of
- // Calendar.isSet() because doing Calendar.get() causes Calendar.isSet() to become
- // true irregardless of what the previous value was
- return cal.get(Calendar.YEAR) > 1;
- }
-
- /**
- * Same as {@link #formatDate(Context context, String string, boolean longForm)}, with longForm
- * set to {@code true} by default.
- *
- * @param context Valid context
- * @param string String representation of a date to parse
- * @return Returns the same date in a cleaned up format. If the supplied string does not look like
- * a date, return it unchanged.
- */
- public static String formatDate(Context context, String string) {
- return formatDate(context, string, true);
- }
-
- /**
- * Parses the supplied string to see if it looks like a date.
- *
- * @param context Valid context
- * @param string String representation of a date to parse
- * @param longForm If true, return the date formatted into its long string representation. If
- * false, return the date formatted using its short form representation (i.e. 12/11/2012)
- * @return Returns the same date in a cleaned up format. If the supplied string does not look like
- * a date, return it unchanged.
- */
- public static String formatDate(Context context, String string, boolean longForm) {
- if (string == null) {
- return null;
- }
-
- string = string.trim();
- if (string.length() == 0) {
- return string;
- }
- final Calendar cal = parseDate(string, false);
-
- // we weren't able to parse the string successfully so just return it unchanged
- if (cal == null) {
- return string;
- }
-
- final boolean isYearSet = isYearSet(cal);
- final java.text.DateFormat outFormat;
- if (!isYearSet) {
- outFormat = getLocalizedDateFormatWithoutYear(context);
- } else {
- outFormat =
- longForm ? DateFormat.getLongDateFormat(context) : DateFormat.getDateFormat(context);
- }
- synchronized (outFormat) {
- outFormat.setTimeZone(UTC_TIMEZONE);
- return outFormat.format(cal.getTime());
- }
- }
-
- public static boolean isMonthBeforeDay(Context context) {
- char[] dateFormatOrder = DateFormat.getDateFormatOrder(context);
- for (int i = 0; i < dateFormatOrder.length; i++) {
- if (dateFormatOrder[i] == 'd') {
- return false;
- }
- if (dateFormatOrder[i] == 'M') {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns a SimpleDateFormat object without the year fields by using a regular expression to
- * eliminate the year in the string pattern. In the rare occurence that the resulting pattern
- * cannot be reconverted into a SimpleDateFormat, it uses the provided context to determine
- * whether the month field should be displayed before the day field, and returns either "MMMM dd"
- * or "dd MMMM" converted into a SimpleDateFormat.
- */
- public static java.text.DateFormat getLocalizedDateFormatWithoutYear(Context context) {
- final String pattern =
- ((SimpleDateFormat) SimpleDateFormat.getDateInstance(java.text.DateFormat.LONG))
- .toPattern();
- // Determine the correct regex pattern for year.
- // Special case handling for Spanish locale by checking for "de"
- final String yearPattern =
- pattern.contains("de") ? "[^Mm]*[Yy]+[^Mm]*" : "[^DdMm]*[Yy]+[^DdMm]*";
- try {
- // Eliminate the substring in pattern that matches the format for that of year
- return new SimpleDateFormat(pattern.replaceAll(yearPattern, ""));
- } catch (IllegalArgumentException e) {
- return new SimpleDateFormat(DateUtils.isMonthBeforeDay(context) ? "MMMM dd" : "dd MMMM");
- }
- }
-
- /**
- * Given a calendar (possibly containing only a day of the year), returns the earliest possible
- * anniversary of the date that is equal to or after the current point in time if the date does
- * not contain a year, or the date converted to the local time zone (if the date contains a year.
- *
- * @param target The date we wish to convert(in the UTC time zone).
- * @return If date does not contain a year (year < 1900), returns the next earliest anniversary
- * that is after the current point in time (in the local time zone). Otherwise, returns the
- * adjusted Date in the local time zone.
- */
- public static Date getNextAnnualDate(Calendar target) {
- final Calendar today = Calendar.getInstance();
- today.setTime(new Date());
-
- // Round the current time to the exact start of today so that when we compare
- // today against the target date, both dates are set to exactly 0000H.
- today.set(Calendar.HOUR_OF_DAY, 0);
- today.set(Calendar.MINUTE, 0);
- today.set(Calendar.SECOND, 0);
- today.set(Calendar.MILLISECOND, 0);
-
- final boolean isYearSet = isYearSet(target);
- final int targetYear = target.get(Calendar.YEAR);
- final int targetMonth = target.get(Calendar.MONTH);
- final int targetDay = target.get(Calendar.DAY_OF_MONTH);
- final boolean isFeb29 = (targetMonth == Calendar.FEBRUARY && targetDay == 29);
- final GregorianCalendar anniversary = new GregorianCalendar();
- // Convert from the UTC date to the local date. Set the year to today's year if the
- // there is no provided year (targetYear < 1900)
- anniversary.set(!isYearSet ? today.get(Calendar.YEAR) : targetYear, targetMonth, targetDay);
- // If the anniversary's date is before the start of today and there is no year set,
- // increment the year by 1 so that the returned date is always equal to or greater than
- // today. If the day is a leap year, keep going until we get the next leap year anniversary
- // Otherwise if there is already a year set, simply return the exact date.
- if (!isYearSet) {
- int anniversaryYear = today.get(Calendar.YEAR);
- if (anniversary.before(today) || (isFeb29 && !anniversary.isLeapYear(anniversaryYear))) {
- // If the target date is not Feb 29, then set the anniversary to the next year.
- // Otherwise, keep going until we find the next leap year (this is not guaranteed
- // to be in 4 years time).
- do {
- anniversaryYear += 1;
- } while (isFeb29 && !anniversary.isLeapYear(anniversaryYear));
- anniversary.set(anniversaryYear, targetMonth, targetDay);
- }
- }
- return anniversary.getTime();
- }
-
/**
* Determine the difference, in days between two dates. Uses similar logic as the {@link
* android.text.format.DateUtils.getRelativeTimeSpanString} method.
diff --git a/java/com/android/contacts/common/util/MaterialColorMapUtils.java b/java/com/android/contacts/common/util/MaterialColorMapUtils.java
index a2d9847ec..bd32faa51 100644
--- a/java/com/android/contacts/common/util/MaterialColorMapUtils.java
+++ b/java/com/android/contacts/common/util/MaterialColorMapUtils.java
@@ -21,7 +21,6 @@ import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Trace;
-import com.android.contacts.common.R;
public class MaterialColorMapUtils {
@@ -35,13 +34,6 @@ public class MaterialColorMapUtils {
resources.obtainTypedArray(com.android.contacts.common.R.array.letter_tile_colors_dark);
}
- public static MaterialPalette getDefaultPrimaryAndSecondaryColors(Resources resources) {
- final int primaryColor = resources.getColor(R.color.quickcontact_default_photo_tint_color);
- final int secondaryColor =
- resources.getColor(R.color.quickcontact_default_photo_tint_color_dark);
- return new MaterialPalette(primaryColor, secondaryColor);
- }
-
/**
* Returns the hue component of a color int.
*
diff --git a/java/com/android/contacts/common/util/NameConverter.java b/java/com/android/contacts/common/util/NameConverter.java
deleted file mode 100644
index ae3275d14..000000000
--- a/java/com/android/contacts/common/util/NameConverter.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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.common.util;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.net.Uri;
-import android.net.Uri.Builder;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.CommonDataKinds.StructuredName;
-import android.text.TextUtils;
-import com.android.contacts.common.model.dataitem.StructuredNameDataItem;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * Utility class for converting between a display name and structured name (and vice-versa), via
- * calls to the contact provider.
- */
-public class NameConverter {
-
- /** The array of fields that comprise a structured name. */
- public static final String[] STRUCTURED_NAME_FIELDS =
- new String[] {
- StructuredName.PREFIX,
- StructuredName.GIVEN_NAME,
- StructuredName.MIDDLE_NAME,
- StructuredName.FAMILY_NAME,
- StructuredName.SUFFIX
- };
-
- /**
- * Converts the given structured name (provided as a map from {@link StructuredName} fields to
- * corresponding values) into a display name string.
- *
- * <p>Note that this operates via a call back to the ContactProvider, but it does not access the
- * database, so it should be safe to call from the UI thread. See ContactsProvider2.completeName()
- * for the underlying method call.
- *
- * @param context Activity context.
- * @param structuredName The structured name map to convert.
- * @return The display name computed from the structured name map.
- */
- public static String structuredNameToDisplayName(
- Context context, Map<String, String> structuredName) {
- Builder builder = ContactsContract.AUTHORITY_URI.buildUpon().appendPath("complete_name");
- for (String key : STRUCTURED_NAME_FIELDS) {
- if (structuredName.containsKey(key)) {
- appendQueryParameter(builder, key, structuredName.get(key));
- }
- }
- return fetchDisplayName(context, builder.build());
- }
-
- /**
- * Converts the given structured name (provided as ContentValues) into a display name string.
- *
- * @param context Activity context.
- * @param values The content values containing values comprising the structured name.
- */
- public static String structuredNameToDisplayName(Context context, ContentValues values) {
- Builder builder = ContactsContract.AUTHORITY_URI.buildUpon().appendPath("complete_name");
- for (String key : STRUCTURED_NAME_FIELDS) {
- if (values.containsKey(key)) {
- appendQueryParameter(builder, key, values.getAsString(key));
- }
- }
- return fetchDisplayName(context, builder.build());
- }
-
- /** Helper method for fetching the display name via the given URI. */
- private static String fetchDisplayName(Context context, Uri uri) {
- String displayName = null;
- Cursor cursor =
- context
- .getContentResolver()
- .query(
- uri,
- new String[] {
- StructuredName.DISPLAY_NAME,
- },
- null,
- null,
- null);
-
- if (cursor != null) {
- try {
- if (cursor.moveToFirst()) {
- displayName = cursor.getString(0);
- }
- } finally {
- cursor.close();
- }
- }
- return displayName;
- }
-
- /**
- * Converts the given display name string into a structured name (as a map from {@link
- * StructuredName} fields to corresponding values).
- *
- * <p>Note that this operates via a call back to the ContactProvider, but it does not access the
- * database, so it should be safe to call from the UI thread.
- *
- * @param context Activity context.
- * @param displayName The display name to convert.
- * @return The structured name map computed from the display name.
- */
- public static Map<String, String> displayNameToStructuredName(
- Context context, String displayName) {
- Map<String, String> structuredName = new TreeMap<String, String>();
- Builder builder = ContactsContract.AUTHORITY_URI.buildUpon().appendPath("complete_name");
-
- appendQueryParameter(builder, StructuredName.DISPLAY_NAME, displayName);
- Cursor cursor =
- context
- .getContentResolver()
- .query(builder.build(), STRUCTURED_NAME_FIELDS, null, null, null);
-
- if (cursor != null) {
- try {
- if (cursor.moveToFirst()) {
- for (int i = 0; i < STRUCTURED_NAME_FIELDS.length; i++) {
- structuredName.put(STRUCTURED_NAME_FIELDS[i], cursor.getString(i));
- }
- }
- } finally {
- cursor.close();
- }
- }
- return structuredName;
- }
-
- /**
- * Converts the given display name string into a structured name (inserting the structured values
- * into a new or existing ContentValues object).
- *
- * <p>Note that this operates via a call back to the ContactProvider, but it does not access the
- * database, so it should be safe to call from the UI thread.
- *
- * @param context Activity context.
- * @param displayName The display name to convert.
- * @param contentValues The content values object to place the structured name values into. If
- * null, a new one will be created and returned.
- * @return The ContentValues object containing the structured name fields derived from the display
- * name.
- */
- public static ContentValues displayNameToStructuredName(
- Context context, String displayName, ContentValues contentValues) {
- if (contentValues == null) {
- contentValues = new ContentValues();
- }
- Map<String, String> mapValues = displayNameToStructuredName(context, displayName);
- for (String key : mapValues.keySet()) {
- contentValues.put(key, mapValues.get(key));
- }
- return contentValues;
- }
-
- private static void appendQueryParameter(Builder builder, String field, String value) {
- if (!TextUtils.isEmpty(value)) {
- builder.appendQueryParameter(field, value);
- }
- }
-
- /**
- * Parses phonetic name and returns parsed data (family, middle, given) as ContentValues. Parsed
- * data should be {@link StructuredName#PHONETIC_FAMILY_NAME}, {@link
- * StructuredName#PHONETIC_MIDDLE_NAME}, and {@link StructuredName#PHONETIC_GIVEN_NAME}. If this
- * method cannot parse given phoneticName, null values will be stored.
- *
- * @param phoneticName Phonetic name to be parsed
- * @param values ContentValues to be used for storing data. If null, new instance will be created.
- * @return ContentValues with parsed data. Those data can be null.
- */
- public static StructuredNameDataItem parsePhoneticName(
- String phoneticName, StructuredNameDataItem item) {
- String family = null;
- String middle = null;
- String given = null;
-
- if (!TextUtils.isEmpty(phoneticName)) {
- String[] strings = phoneticName.split(" ", 3);
- switch (strings.length) {
- case 1:
- family = strings[0];
- break;
- case 2:
- family = strings[0];
- given = strings[1];
- break;
- case 3:
- family = strings[0];
- middle = strings[1];
- given = strings[2];
- break;
- }
- }
-
- if (item == null) {
- item = new StructuredNameDataItem();
- }
- item.setPhoneticFamilyName(family);
- item.setPhoneticMiddleName(middle);
- item.setPhoneticGivenName(given);
- return item;
- }
-
- /** Constructs and returns a phonetic full name from given parts. */
- public static String buildPhoneticName(String family, String middle, String given) {
- if (!TextUtils.isEmpty(family) || !TextUtils.isEmpty(middle) || !TextUtils.isEmpty(given)) {
- StringBuilder sb = new StringBuilder();
- if (!TextUtils.isEmpty(family)) {
- sb.append(family.trim()).append(' ');
- }
- if (!TextUtils.isEmpty(middle)) {
- sb.append(middle.trim()).append(' ');
- }
- if (!TextUtils.isEmpty(given)) {
- sb.append(given.trim()).append(' ');
- }
- sb.setLength(sb.length() - 1); // Yank the last space
- return sb.toString();
- } else {
- return null;
- }
- }
-}
diff --git a/java/com/android/contacts/common/util/StopWatch.java b/java/com/android/contacts/common/util/StopWatch.java
index b944b9867..7986d1081 100644
--- a/java/com/android/contacts/common/util/StopWatch.java
+++ b/java/com/android/contacts/common/util/StopWatch.java
@@ -16,7 +16,7 @@
package com.android.contacts.common.util;
-import android.util.Log;
+import com.android.dialer.common.LogUtil;
import java.util.ArrayList;
/** A {@link StopWatch} records start, laps and stop, and print them to logcat. */
@@ -37,11 +37,6 @@ public class StopWatch {
return new StopWatch(label);
}
- /** Return a dummy instance that does no operations. */
- public static StopWatch getNullStopWatch() {
- return NullStopWatch.INSTANCE;
- }
-
/** Record a lap. */
public void lap(String lapLabel) {
mTimes.add(System.currentTimeMillis());
@@ -76,25 +71,6 @@ public class StopWatch {
sb.append(" ");
last = current;
}
- Log.v(TAG, sb.toString());
- }
-
- private static class NullStopWatch extends StopWatch {
-
- public static final NullStopWatch INSTANCE = new NullStopWatch();
-
- public NullStopWatch() {
- super(null);
- }
-
- @Override
- public void lap(String lapLabel) {
- // noop
- }
-
- @Override
- public void stopAndLog(String TAG, int timeThresholdToLog) {
- // noop
- }
+ LogUtil.v(TAG, sb.toString());
}
}
diff --git a/java/com/android/contacts/common/util/TelephonyManagerUtils.java b/java/com/android/contacts/common/util/TelephonyManagerUtils.java
index b664268ca..e4c2c6373 100644
--- a/java/com/android/contacts/common/util/TelephonyManagerUtils.java
+++ b/java/com/android/contacts/common/util/TelephonyManagerUtils.java
@@ -33,13 +33,4 @@ public class TelephonyManagerUtils {
final String voiceMailLabel = telephonyManager.getVoiceMailAlphaTag();
return voiceMailLabel;
}
-
- /**
- * @param context Current application context.
- * @return True if there is a subscription which supports video calls. False otherwise.
- */
- public static boolean hasVideoCallSubscription(Context context) {
- // TODO: Check the telephony manager's subscriptions to see if any support video calls.
- return true;
- }
}
diff --git a/java/com/android/contacts/common/util/TrafficStatsTags.java b/java/com/android/contacts/common/util/TrafficStatsTags.java
deleted file mode 100644
index b0e7fb583..000000000
--- a/java/com/android/contacts/common/util/TrafficStatsTags.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-package com.android.contacts.common.util;
-
-public class TrafficStatsTags {
-
- public static final int CONTACT_PHOTO_DOWNLOAD_TAG = 0x0001;
- public static final int TAG_MAX = 0x9999;
-}