From 183cb71663320f16149d83eeebaff7795a4b55f2 Mon Sep 17 00:00:00 2001 From: linyuh Date: Wed, 27 Dec 2017 17:02:37 -0800 Subject: Remove field prefixes. Test: Existing tests PiperOrigin-RevId: 180230450 Change-Id: I0b2589cfeeaef81e42a04efa48af24b4e4d0e95f --- .../dialer/smartdial/SmartDialCursorLoader.java | 48 +++++++++++----------- .../smartdial/util/SmartDialNameMatcher.java | 26 ++++++------ .../dialer/smartdial/util/SmartDialPrefix.java | 42 +++++++++---------- 3 files changed, 58 insertions(+), 58 deletions(-) (limited to 'java/com/android/dialer/smartdial') diff --git a/java/com/android/dialer/smartdial/SmartDialCursorLoader.java b/java/com/android/dialer/smartdial/SmartDialCursorLoader.java index f6bc9325a..f2e41b22b 100644 --- a/java/com/android/dialer/smartdial/SmartDialCursorLoader.java +++ b/java/com/android/dialer/smartdial/SmartDialCursorLoader.java @@ -35,18 +35,18 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { private static final String TAG = "SmartDialCursorLoader"; private static final boolean DEBUG = false; - private final Context mContext; + private final Context context; - private Cursor mCursor; + private Cursor cursor; - private String mQuery; - private SmartDialNameMatcher mNameMatcher; + private String query; + private SmartDialNameMatcher nameMatcher; - private boolean mShowEmptyListForNullQuery = true; + private boolean showEmptyListForNullQuery = true; public SmartDialCursorLoader(Context context) { super(context); - mContext = context; + this.context = context; } /** @@ -58,11 +58,11 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { if (DEBUG) { LogUtil.v(TAG, "Configure new query to be " + query); } - mQuery = SmartDialNameMatcher.normalizeNumber(mContext, query); + this.query = SmartDialNameMatcher.normalizeNumber(context, query); /** Constructs a name matcher object for matching names. */ - mNameMatcher = new SmartDialNameMatcher(mQuery); - mNameMatcher.setShouldMatchEmptyQuery(!mShowEmptyListForNullQuery); + nameMatcher = new SmartDialNameMatcher(this.query); + nameMatcher.setShouldMatchEmptyQuery(!showEmptyListForNullQuery); } /** @@ -73,18 +73,18 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { @Override public Cursor loadInBackground() { if (DEBUG) { - LogUtil.v(TAG, "Load in background " + mQuery); + LogUtil.v(TAG, "Load in background " + query); } - if (!PermissionsUtil.hasContactsReadPermissions(mContext)) { + if (!PermissionsUtil.hasContactsReadPermissions(context)) { return new MatrixCursor(PhoneQuery.PROJECTION_PRIMARY); } /** Loads results from the database helper. */ final DialerDatabaseHelper dialerDatabaseHelper = - Database.get(mContext).getDatabaseHelper(mContext); + Database.get(context).getDatabaseHelper(context); final ArrayList allMatches = - dialerDatabaseHelper.getLooseMatches(mQuery, mNameMatcher); + dialerDatabaseHelper.getLooseMatches(query, nameMatcher); if (DEBUG) { LogUtil.v(TAG, "Loaded matches " + allMatches.size()); @@ -115,8 +115,8 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { } /** Hold a reference to the old data so it doesn't get garbage collected. */ - Cursor oldCursor = mCursor; - mCursor = cursor; + Cursor oldCursor = this.cursor; + this.cursor = cursor; if (isStarted()) { /** If the Loader is in a started state, deliver the results to the client. */ @@ -131,11 +131,11 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { @Override protected void onStartLoading() { - if (mCursor != null) { + if (cursor != null) { /** Deliver any previously loaded data immediately. */ - deliverResult(mCursor); + deliverResult(cursor); } - if (mCursor == null) { + if (cursor == null) { /** Force loads every time as our results change with queries. */ forceLoad(); } @@ -153,9 +153,9 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { onStopLoading(); /** Release all previously saved query results. */ - if (mCursor != null) { - releaseResources(mCursor); - mCursor = null; + if (cursor != null) { + releaseResources(cursor); + cursor = null; } } @@ -174,9 +174,9 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { } public void setShowEmptyListForNullQuery(boolean show) { - mShowEmptyListForNullQuery = show; - if (mNameMatcher != null) { - mNameMatcher.setShouldMatchEmptyQuery(!show); + showEmptyListForNullQuery = show; + if (nameMatcher != null) { + nameMatcher.setShouldMatchEmptyQuery(!show); } } } diff --git a/java/com/android/dialer/smartdial/util/SmartDialNameMatcher.java b/java/com/android/dialer/smartdial/util/SmartDialNameMatcher.java index 725c88c57..601962292 100644 --- a/java/com/android/dialer/smartdial/util/SmartDialNameMatcher.java +++ b/java/com/android/dialer/smartdial/util/SmartDialNameMatcher.java @@ -38,14 +38,14 @@ public class SmartDialNameMatcher { // positives private static final int INITIAL_LENGTH_LIMIT = 1; - private final ArrayList mMatchPositions = new ArrayList<>(); - private String mQuery; + private final ArrayList matchPositions = new ArrayList<>(); + private String query; // Controls whether to treat an empty query as a match (with anything). - private boolean mShouldMatchEmptyQuery = false; + private boolean shouldMatchEmptyQuery = false; public SmartDialNameMatcher(String query) { - mQuery = query; + this.query = query; } /** @@ -112,7 +112,7 @@ public class SmartDialNameMatcher { @Nullable public SmartDialMatchPosition matchesNumber(Context context, String phoneNumber, String query) { if (TextUtils.isEmpty(phoneNumber)) { - return mShouldMatchEmptyQuery ? new SmartDialMatchPosition(0, 0) : null; + return shouldMatchEmptyQuery ? new SmartDialMatchPosition(0, 0) : null; } StringBuilder builder = new StringBuilder(); constructEmptyMask(builder, phoneNumber.length()); @@ -148,7 +148,7 @@ public class SmartDialNameMatcher { * with the matching positions otherwise */ public SmartDialMatchPosition matchesNumber(Context context, String phoneNumber) { - return matchesNumber(context, phoneNumber, mQuery); + return matchesNumber(context, phoneNumber, query); } /** @@ -164,7 +164,7 @@ public class SmartDialNameMatcher { private SmartDialMatchPosition matchesNumberWithOffset( Context context, String phoneNumber, String query, int offset) { if (TextUtils.isEmpty(phoneNumber) || TextUtils.isEmpty(query)) { - return mShouldMatchEmptyQuery ? new SmartDialMatchPosition(offset, offset) : null; + return shouldMatchEmptyQuery ? new SmartDialMatchPosition(offset, offset) : null; } int queryAt = 0; int numberAt = offset; @@ -406,25 +406,25 @@ public class SmartDialNameMatcher { * match positions (multiple matches correspond to initial matches). */ public boolean matches(Context context, String displayName) { - mMatchPositions.clear(); - return matchesCombination(context, displayName, mQuery, mMatchPositions); + matchPositions.clear(); + return matchesCombination(context, displayName, query, matchPositions); } public ArrayList getMatchPositions() { // Return a clone of mMatchPositions so that the caller can use it without // worrying about it changing - return new ArrayList<>(mMatchPositions); + return new ArrayList<>(matchPositions); } public String getQuery() { - return mQuery; + return query; } public void setQuery(String query) { - mQuery = query; + this.query = query; } public void setShouldMatchEmptyQuery(boolean matches) { - mShouldMatchEmptyQuery = matches; + shouldMatchEmptyQuery = matches; } } diff --git a/java/com/android/dialer/smartdial/util/SmartDialPrefix.java b/java/com/android/dialer/smartdial/util/SmartDialPrefix.java index 9af411913..7fef8814c 100644 --- a/java/com/android/dialer/smartdial/util/SmartDialPrefix.java +++ b/java/com/android/dialer/smartdial/util/SmartDialPrefix.java @@ -54,38 +54,38 @@ public class SmartDialPrefix { private static final String PREF_USER_SIM_COUNTRY_CODE_DEFAULT = null; - private static String sUserSimCountryCode = PREF_USER_SIM_COUNTRY_CODE_DEFAULT; + private static String userSimCountryCode = PREF_USER_SIM_COUNTRY_CODE_DEFAULT; /** Indicates whether user is in NANP regions. */ - private static boolean sUserInNanpRegion = false; + private static boolean userInNanpRegion = false; /** Set of country names that use NANP code. */ - private static Set sNanpCountries = null; + private static Set nanpCountries = null; /** Set of supported country codes in front of the phone number. */ - private static Set sCountryCodes = null; + private static Set countryCodes = null; - private static boolean sNanpInitialized = false; + private static boolean nanpInitialized = false; /** Initializes the Nanp settings, and finds out whether user is in a NANP region. */ public static void initializeNanpSettings(Context context) { final TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (manager != null) { - sUserSimCountryCode = manager.getSimCountryIso(); + userSimCountryCode = manager.getSimCountryIso(); } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); - if (sUserSimCountryCode != null) { + if (userSimCountryCode != null) { /** Updates shared preferences with the latest country obtained from getSimCountryIso. */ - prefs.edit().putString(PREF_USER_SIM_COUNTRY_CODE, sUserSimCountryCode).apply(); + prefs.edit().putString(PREF_USER_SIM_COUNTRY_CODE, userSimCountryCode).apply(); } else { /** Uses previously stored country code if loading fails. */ - sUserSimCountryCode = + userSimCountryCode = prefs.getString(PREF_USER_SIM_COUNTRY_CODE, PREF_USER_SIM_COUNTRY_CODE_DEFAULT); } /** Queries the NANP country list to find out whether user is in a NANP region. */ - sUserInNanpRegion = isCountryNanp(sUserSimCountryCode); - sNanpInitialized = true; + userInNanpRegion = isCountryNanp(userSimCountryCode); + nanpInitialized = true; } /** @@ -255,7 +255,7 @@ public class SmartDialPrefix { */ if ((normalizedNumber.length() == 11) && (normalizedNumber.charAt(0) == '1') - && (sUserInNanpRegion)) { + && (userInNanpRegion)) { countryCode = "1"; countryCodeOffset = number.indexOf(normalizedNumber.charAt(1)); if (countryCodeOffset == -1) { @@ -265,7 +265,7 @@ public class SmartDialPrefix { } /** If user is in NANP region, finds out whether a number is in NANP format. */ - if (sUserInNanpRegion) { + if (userInNanpRegion) { String areaCode = ""; if (countryCode.equals("") && normalizedNumber.length() == 10) { /** @@ -292,10 +292,10 @@ public class SmartDialPrefix { /** Checkes whether a country code is valid. */ private static boolean isValidCountryCode(String countryCode) { - if (sCountryCodes == null) { - sCountryCodes = initCountryCodes(); + if (countryCodes == null) { + countryCodes = initCountryCodes(); } - return sCountryCodes.contains(countryCode); + return countryCodes.contains(countryCode); } private static Set initCountryCodes() { @@ -531,10 +531,10 @@ public class SmartDialPrefix { if (TextUtils.isEmpty(country)) { return false; } - if (sNanpCountries == null) { - sNanpCountries = initNanpCountries(); + if (nanpCountries == null) { + nanpCountries = initNanpCountries(); } - return sNanpCountries.contains(country.toUpperCase()); + return nanpCountries.contains(country.toUpperCase()); } private static Set initNanpCountries() { @@ -572,13 +572,13 @@ public class SmartDialPrefix { * @return Whether user is in Nanp region. */ public static boolean getUserInNanpRegion() { - return sUserInNanpRegion; + return userInNanpRegion; } /** Explicitly setting the user Nanp to the given boolean */ @VisibleForTesting public static void setUserInNanpRegion(boolean userInNanpRegion) { - sUserInNanpRegion = userInNanpRegion; + SmartDialPrefix.userInNanpRegion = userInNanpRegion; } /** Class to record phone number parsing information. */ -- cgit v1.2.3