diff options
44 files changed, 839 insertions, 355 deletions
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java b/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java index 744c0de74..641be854a 100644 --- a/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java +++ b/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java @@ -21,7 +21,7 @@ import android.content.Context; import android.content.Intent; import android.support.v4.util.Pair; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import me.leolin.shortcutbadger.ShortcutBadger; /** @@ -30,7 +30,7 @@ import me.leolin.shortcutbadger.ShortcutBadger; */ public class MissedCallNotificationReceiver extends BroadcastReceiver { - //TODO: Use compat class for these methods. + // TODO: Use compat class for these methods. public static final String ACTION_SHOW_MISSED_CALLS_NOTIFICATION = "android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION"; @@ -53,7 +53,9 @@ public class MissedCallNotificationReceiver extends BroadcastReceiver { PendingResult pendingResult = goAsync(); - DialerExecutors.createNonUiTaskBuilder(context, MissedCallNotifier.getInstance(context)) + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(MissedCallNotifier.getInstance(context)) .onSuccess( output -> { LogUtil.i( diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index 9d8b04036..33fcba002 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -38,7 +38,7 @@ import com.android.dialer.app.voicemail.error.VoicemailStatus; import com.android.dialer.app.voicemail.error.VoicemailStatusWorker; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.util.PermissionsUtil; @@ -79,8 +79,9 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { super.onActivityCreated(savedInstanceState); mPreSyncVoicemailStatusCheckExecutor = - DialerExecutors.createUiTaskBuilder( - getContext(), + DialerExecutorComponent.get(getContext()) + .dialerExecutorFactory() + .createUiTaskBuilder( getActivity().getFragmentManager(), "fetchVoicemailStatus", new VoicemailStatusWorker()) diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java index fd0be5f54..e3279ce26 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java @@ -31,7 +31,7 @@ import com.android.dialer.blocking.FilteredNumbersUtil; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.notification.DialerNotificationManager; import com.android.dialer.phonenumbercache.ContactInfo; import com.android.dialer.telecom.TelecomUtil; @@ -184,7 +184,9 @@ class VisualVoicemailUpdateTask implements Worker<VisualVoicemailUpdateTask.Inpu context, CallLogNotificationsQueryHelper.getInstance(context), new FilteredNumberAsyncQueryHandler(context)); - DialerExecutors.createNonUiTaskBuilder(context, new VisualVoicemailUpdateTask()) + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new VisualVoicemailUpdateTask()) .onSuccess( output -> { LogUtil.i("VisualVoicemailUpdateTask.scheduleTask", "update successful"); diff --git a/java/com/android/dialer/app/list/RegularSearchFragment.java b/java/com/android/dialer/app/list/RegularSearchFragment.java index ca19432ed..48f77dcdc 100644 --- a/java/com/android/dialer/app/list/RegularSearchFragment.java +++ b/java/com/android/dialer/app/list/RegularSearchFragment.java @@ -32,7 +32,7 @@ import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor; import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.phonenumbercache.CachedNumberLookupService; import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo; import com.android.dialer.phonenumbercache.PhoneNumberCache; @@ -66,8 +66,9 @@ public class RegularSearchFragment extends SearchFragment super.onCreate(savedState); addContactTask = - DialerExecutors.createUiTaskBuilder( - getContext(), + DialerExecutorComponent.get(getContext()) + .dialerExecutorFactory() + .createUiTaskBuilder( getFragmentManager(), "RegularSearchFragment.addContact", new AddContactWorker(getContext().getApplicationContext())) diff --git a/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java b/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java index 2d21bd641..10afe479f 100644 --- a/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java +++ b/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java @@ -51,7 +51,7 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.AsyncTaskExecutor; import com.android.dialer.common.concurrent.AsyncTaskExecutors; import com.android.dialer.common.concurrent.DialerExecutor; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.constants.Constants; import com.android.dialer.logging.DialerImpression; @@ -220,11 +220,10 @@ public class VoicemailPlaybackPresenter mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); } shareVoicemailExecutor = - DialerExecutors.createUiTaskBuilder( - mContext, - mActivity.getFragmentManager(), - "shareVoicemail", - new ShareVoicemailWorker()) + DialerExecutorComponent.get(mContext) + .dialerExecutorFactory() + .createUiTaskBuilder( + mActivity.getFragmentManager(), "shareVoicemail", new ShareVoicemailWorker()) .onSuccess( output -> { if (output == null) { diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java index 9244f6934..c3721a7a8 100644 --- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java +++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java @@ -89,7 +89,11 @@ public final class ConcreteCreator { new Constraints( context, configProvider.getString("assisted_dialing_csv_country_codes", "")); return new AssistedDialingMediatorImpl( - new LocationDetector(telephonyManager), new NumberTransformer(constraints)); + new LocationDetector( + telephonyManager, + PreferenceManager.getDefaultSharedPreferences(context) + .getString(context.getString(R.string.assisted_dialing_setting_cc_key), null)), + new NumberTransformer(constraints)); } /** Returns a boolean indicating whether or not the assisted dialing feature is enabled. */ diff --git a/java/com/android/dialer/assisteddialing/LocationDetector.java b/java/com/android/dialer/assisteddialing/LocationDetector.java index 684068912..8e7535c1b 100644 --- a/java/com/android/dialer/assisteddialing/LocationDetector.java +++ b/java/com/android/dialer/assisteddialing/LocationDetector.java @@ -19,7 +19,9 @@ package com.android.dialer.assisteddialing; import android.annotation.TargetApi; import android.os.Build.VERSION_CODES; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.telephony.TelephonyManager; +import android.text.TextUtils; import com.android.dialer.common.LogUtil; import java.util.Locale; import java.util.Optional; @@ -32,12 +34,16 @@ import java.util.Optional; final class LocationDetector { private final TelephonyManager telephonyManager; + private final String userProvidedHomeCountry; - public LocationDetector(@NonNull TelephonyManager telephonyManager) { + public LocationDetector( + @NonNull TelephonyManager telephonyManager, @Nullable String userProvidedHomeCountry) { if (telephonyManager == null) { throw new NullPointerException("Provided TelephonyManager was null"); } + this.telephonyManager = telephonyManager; + this.userProvidedHomeCountry = userProvidedHomeCountry; } // TODO(erfanian): confirm this is based on ISO 3166-1 alpha-2. libphonenumber expects Unicode's @@ -50,8 +56,16 @@ final class LocationDetector { @SuppressWarnings("AndroidApiChecker") // Use of optional @TargetApi(VERSION_CODES.N) public Optional<String> getUpperCaseUserHomeCountry() { + + if (!TextUtils.isEmpty(userProvidedHomeCountry)) { + LogUtil.i( + "LocationDetector.getUpperCaseUserRoamingCountry", "user provided home country code"); + return Optional.of(userProvidedHomeCountry.toUpperCase(Locale.US)); + } + String simCountryIso = telephonyManager.getSimCountryIso(); if (simCountryIso != null) { + LogUtil.i("LocationDetector.getUpperCaseUserRoamingCountry", "using sim country iso"); return Optional.of(telephonyManager.getSimCountryIso().toUpperCase(Locale.US)); } LogUtil.i("LocationDetector.getUpperCaseUserHomeCountry", "user home country was null"); diff --git a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java index 8847448cd..a70844fbd 100644 --- a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java +++ b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java @@ -16,7 +16,10 @@ package com.android.dialer.assisteddialing.ui; import android.os.Bundle; +import android.preference.ListPreference; +import android.preference.Preference; import android.preference.PreferenceFragment; +import android.text.TextUtils; /** The setting for Assisted Dialing */ public class AssistedDialingSettingFragment extends PreferenceFragment { @@ -27,5 +30,20 @@ public class AssistedDialingSettingFragment extends PreferenceFragment { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.assisted_dialing_setting); + ListPreference countryChooserPref = + (ListPreference) + findPreference(getContext().getString(R.string.assisted_dialing_setting_cc_key)); + + if (!TextUtils.isEmpty(countryChooserPref.getEntry())) { + countryChooserPref.setSummary(countryChooserPref.getEntry()); + } + countryChooserPref.setOnPreferenceChangeListener(this::updateListSummary); + } + + boolean updateListSummary(Preference pref, Object newValue) { + ListPreference listPref = (ListPreference) pref; + CharSequence[] entries = listPref.getEntries(); + listPref.setSummary(entries[listPref.findIndexOfValue(newValue.toString())]); + return true; } } diff --git a/java/com/android/dialer/assisteddialing/ui/res/values/string.xml b/java/com/android/dialer/assisteddialing/ui/res/values/string.xml index cd159bfd5..3b40817ed 100644 --- a/java/com/android/dialer/assisteddialing/ui/res/values/string.xml +++ b/java/com/android/dialer/assisteddialing/ui/res/values/string.xml @@ -15,7 +15,7 @@ ~ limitations under the License --> -<resources> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- Label for a setting enabling assisted dialing [CHAR LIMIT=40]--> <string name="assisted_dialing_setting_title">Assisted dialing</string> @@ -24,4 +24,511 @@ <!-- Key for the assisted dialing setting toggle--> <string name="assisted_dialing_setting_toggle_key" translatable="false">assisted_dialing_setting_toggle_key</string> + + <!-- Key for the assisted dialing home country setting--> + <string name="assisted_dialing_setting_cc_key" translatable="false">assisted_dialing_setting_cc_key</string> + + <!-- Indicates the default state for the home country selector--> + <string name="assisted_dialing_setting_cc_default_summary">Automatically detected</string> + + <!-- Category title for the country code picker in assisted dialing [CHAR LIMIT=40]--> + <string name="assisted_dialing_setting_cc_category_title">Home country</string> + + <!-- Label for the country code picker in assisted dialing [CHAR LIMIT=40]--> + <string name="assisted_dialing_setting_cc_title">Default home country</string> + + <!-- Composed from https://www.iso.org/obp/ui/#search and + https://github.com/googlei18n/libphonenumber/blob/master/javascript/i18n/phonenumbers/metadata.js#L34 --> + <!-- Excluding ['Antarctica', 'Bouvet Island', 'French Southern Territories (the)', 'Heard Island and McDonald Islands', 'Pitcairn', 'South Georgia and the South Sandwich Islands', 'United States Minor Outlying Islands (the)'] --> + <!-- Options for the country codes used in assisted dialing. DO NOT TRANSLATE NUMBERS. [CHAR LIMIT=40] --> + <string-array name="assisted_dialing_cc_entries"> + <item>@string/assisted_dialing_setting_cc_default_summary</item> + <item>Afghanistan <xliff:g>(+93)</xliff:g></item> + <item>Åland Islands <xliff:g>(+358)</xliff:g></item> + <item>Albania <xliff:g>(+355)</xliff:g></item> + <item>Algeria <xliff:g>(+213)</xliff:g></item> + <item>American Samoa <xliff:g>(+1)</xliff:g></item> + <item>Andorra <xliff:g>(+376)</xliff:g></item> + <item>Angola <xliff:g>(+244)</xliff:g></item> + <item>Anguilla <xliff:g>(+1)</xliff:g></item> + <item>Antigua and Barbuda <xliff:g>(+1)</xliff:g></item> + <item>Argentina <xliff:g>(+54)</xliff:g></item> + <item>Armenia <xliff:g>(+374)</xliff:g></item> + <item>Aruba <xliff:g>(+297)</xliff:g></item> + <item>Australia <xliff:g>(+61)</xliff:g></item> + <item>Austria <xliff:g>(+43)</xliff:g></item> + <item>Azerbaijan <xliff:g>(+994)</xliff:g></item> + <item>Bahamas <xliff:g>(+1)</xliff:g></item> + <item>Bahrain <xliff:g>(+973)</xliff:g></item> + <item>Bangladesh <xliff:g>(+880)</xliff:g></item> + <item>Barbados <xliff:g>(+1)</xliff:g></item> + <item>Belarus <xliff:g>(+375)</xliff:g></item> + <item>Belgium <xliff:g>(+32)</xliff:g></item> + <item>Belize <xliff:g>(+501)</xliff:g></item> + <item>Benin <xliff:g>(+229)</xliff:g></item> + <item>Bermuda <xliff:g>(+1)</xliff:g></item> + <item>Bhutan <xliff:g>(+975)</xliff:g></item> + <item>Bolivia <xliff:g>(+591)</xliff:g></item> + <item>Caribbean Netherlands <xliff:g>(+599)</xliff:g></item> + <item>Bosnia and Herzegovina <xliff:g>(+387)</xliff:g></item> + <item>Botswana <xliff:g>(+267)</xliff:g></item> + <item>Brazil <xliff:g>(+55)</xliff:g></item> + <item>British Indian Ocean Territory <xliff:g>(+246)</xliff:g></item> + <item>Brunei <xliff:g>(+673)</xliff:g></item> + <item>Bulgaria <xliff:g>(+359)</xliff:g></item> + <item>Burkina Faso <xliff:g>(+226)</xliff:g></item> + <item>Burundi <xliff:g>(+257)</xliff:g></item> + <item>Cabo Verde <xliff:g>(+238)</xliff:g></item> + <item>Cambodia <xliff:g>(+855)</xliff:g></item> + <item>Cameroon <xliff:g>(+237)</xliff:g></item> + <item>Canada <xliff:g>(+1)</xliff:g></item> + <item>Cayman Islands <xliff:g>(+1)</xliff:g></item> + <item>Central African Republic <xliff:g>(+236)</xliff:g></item> + <item>Chad <xliff:g>(+235)</xliff:g></item> + <item>Chile <xliff:g>(+56)</xliff:g></item> + <item>China <xliff:g>(+86)</xliff:g></item> + <item>Christmas Island <xliff:g>(+61)</xliff:g></item> + <item>Cocos (Keeling) Islands <xliff:g>(+61)</xliff:g></item> + <item>Colombia <xliff:g>(+57)</xliff:g></item> + <item>Comoros <xliff:g>(+269)</xliff:g></item> + <item>Democratic Republic of the Congo <xliff:g>(+243)</xliff:g></item> + <item>Congo <xliff:g>(+242)</xliff:g></item> + <item>Cook Islands <xliff:g>(+682)</xliff:g></item> + <item>Costa Rica <xliff:g>(+506)</xliff:g></item> + <item>Côte d\'Ivoire <xliff:g>(+225)</xliff:g></item> + <item>Croatia <xliff:g>(+385)</xliff:g></item> + <item>Cuba <xliff:g>(+53)</xliff:g></item> + <item>Curaçao <xliff:g>(+599)</xliff:g></item> + <item>Cyprus <xliff:g>(+357)</xliff:g></item> + <item>Czechia <xliff:g>(+420)</xliff:g></item> + <item>Denmark <xliff:g>(+45)</xliff:g></item> + <item>Djibouti <xliff:g>(+253)</xliff:g></item> + <item>Dominica <xliff:g>(+1)</xliff:g></item> + <item>Dominican Republic <xliff:g>(+1)</xliff:g></item> + <item>Ecuador <xliff:g>(+593)</xliff:g></item> + <item>Egypt <xliff:g>(+20)</xliff:g></item> + <item>El Salvador <xliff:g>(+503)</xliff:g></item> + <item>Equatorial Guinea <xliff:g>(+240)</xliff:g></item> + <item>Eritrea <xliff:g>(+291)</xliff:g></item> + <item>Estonia <xliff:g>(+372)</xliff:g></item> + <item>Ethiopia <xliff:g>(+251)</xliff:g></item> + <item>Falkland Islands (Islas Malvinas) <xliff:g>(+500)</xliff:g></item> + <item>Faroe Islands <xliff:g>(+298)</xliff:g></item> + <item>Fiji <xliff:g>(+679)</xliff:g></item> + <item>Finland <xliff:g>(+358)</xliff:g></item> + <item>France <xliff:g>(+33)</xliff:g></item> + <item>French Guiana <xliff:g>(+594)</xliff:g></item> + <item>French Polynesia <xliff:g>(+689)</xliff:g></item> + <item>Gabon <xliff:g>(+241)</xliff:g></item> + <item>Gambia <xliff:g>(+220)</xliff:g></item> + <item>Georgia <xliff:g>(+995)</xliff:g></item> + <item>Germany <xliff:g>(+49)</xliff:g></item> + <item>Ghana <xliff:g>(+233)</xliff:g></item> + <item>Gibraltar <xliff:g>(+350)</xliff:g></item> + <item>Greece <xliff:g>(+30)</xliff:g></item> + <item>Greenland <xliff:g>(+299)</xliff:g></item> + <item>Grenada <xliff:g>(+1)</xliff:g></item> + <item>Guadeloupe <xliff:g>(+590)</xliff:g></item> + <item>Guam <xliff:g>(+1)</xliff:g></item> + <item>Guatemala <xliff:g>(+502)</xliff:g></item> + <item>Guernsey <xliff:g>(+44)</xliff:g></item> + <item>Guinea <xliff:g>(+224)</xliff:g></item> + <item>Guinea-Bissau <xliff:g>(+245)</xliff:g></item> + <item>Guyana <xliff:g>(+592)</xliff:g></item> + <item>Haiti <xliff:g>(+509)</xliff:g></item> + <item>Holy See <xliff:g>(+39)</xliff:g></item> + <item>Honduras <xliff:g>(+504)</xliff:g></item> + <item>Hong Kong <xliff:g>(+852)</xliff:g></item> + <item>Hungary <xliff:g>(+36)</xliff:g></item> + <item>Iceland <xliff:g>(+354)</xliff:g></item> + <item>India <xliff:g>(+91)</xliff:g></item> + <item>Indonesia <xliff:g>(+62)</xliff:g></item> + <item>Iran <xliff:g>(+98)</xliff:g></item> + <item>Iraq <xliff:g>(+964)</xliff:g></item> + <item>Ireland <xliff:g>(+353)</xliff:g></item> + <item>Isle of Man <xliff:g>(+44)</xliff:g></item> + <item>Israel <xliff:g>(+972)</xliff:g></item> + <item>Italy <xliff:g>(+39)</xliff:g></item> + <item>Jamaica <xliff:g>(+1)</xliff:g></item> + <item>Japan <xliff:g>(+81)</xliff:g></item> + <item>Jersey <xliff:g>(+44)</xliff:g></item> + <item>Jordan <xliff:g>(+962)</xliff:g></item> + <item>Kazakhstan <xliff:g>(+7)</xliff:g></item> + <item>Kenya <xliff:g>(+254)</xliff:g></item> + <item>Kiribati <xliff:g>(+686)</xliff:g></item> + <item>North Korea <xliff:g>(+850)</xliff:g></item> + <item>South Korea <xliff:g>(+82)</xliff:g></item> + <item>Kuwait <xliff:g>(+965)</xliff:g></item> + <item>Kyrgyzstan <xliff:g>(+996)</xliff:g></item> + <item>Laos <xliff:g>(+856)</xliff:g></item> + <item>Latvia <xliff:g>(+371)</xliff:g></item> + <item>Lebanon <xliff:g>(+961)</xliff:g></item> + <item>Lesotho <xliff:g>(+266)</xliff:g></item> + <item>Liberia <xliff:g>(+231)</xliff:g></item> + <item>Libya <xliff:g>(+218)</xliff:g></item> + <item>Liechtenstein <xliff:g>(+423)</xliff:g></item> + <item>Lithuania <xliff:g>(+370)</xliff:g></item> + <item>Luxembourg <xliff:g>(+352)</xliff:g></item> + <item>Macao <xliff:g>(+853)</xliff:g></item> + <item>Macedonia (FYROM) <xliff:g>(+389)</xliff:g></item> + <item>Madagascar <xliff:g>(+261)</xliff:g></item> + <item>Malawi <xliff:g>(+265)</xliff:g></item> + <item>Malaysia <xliff:g>(+60)</xliff:g></item> + <item>Maldives <xliff:g>(+960)</xliff:g></item> + <item>Mali <xliff:g>(+223)</xliff:g></item> + <item>Malta <xliff:g>(+356)</xliff:g></item> + <item>Marshall Islands <xliff:g>(+692)</xliff:g></item> + <item>Martinique <xliff:g>(+596)</xliff:g></item> + <item>Mauritania <xliff:g>(+222)</xliff:g></item> + <item>Mauritius <xliff:g>(+230)</xliff:g></item> + <item>Mayotte <xliff:g>(+262)</xliff:g></item> + <item>Mexico <xliff:g>(+52)</xliff:g></item> + <item>Micronesia <xliff:g>(+691)</xliff:g></item> + <item>Moldova <xliff:g>(+373)</xliff:g></item> + <item>Monaco <xliff:g>(+377)</xliff:g></item> + <item>Mongolia <xliff:g>(+976)</xliff:g></item> + <item>Montenegro <xliff:g>(+382)</xliff:g></item> + <item>Montserrat <xliff:g>(+1)</xliff:g></item> + <item>Morocco <xliff:g>(+212)</xliff:g></item> + <item>Mozambique <xliff:g>(+258)</xliff:g></item> + <item>Myanmar <xliff:g>(+95)</xliff:g></item> + <item>Namibia <xliff:g>(+264)</xliff:g></item> + <item>Nauru <xliff:g>(+674)</xliff:g></item> + <item>Nepal <xliff:g>(+977)</xliff:g></item> + <item>Netherlands <xliff:g>(+31)</xliff:g></item> + <item>New Caledonia <xliff:g>(+687)</xliff:g></item> + <item>New Zealand <xliff:g>(+64)</xliff:g></item> + <item>Nicaragua <xliff:g>(+505)</xliff:g></item> + <item>Niger <xliff:g>(+227)</xliff:g></item> + <item>Nigeria <xliff:g>(+234)</xliff:g></item> + <item>Niue <xliff:g>(+683)</xliff:g></item> + <item>Norfolk Island <xliff:g>(+672)</xliff:g></item> + <item>Northern Mariana Islands <xliff:g>(+1)</xliff:g></item> + <item>Norway <xliff:g>(+47)</xliff:g></item> + <item>Oman <xliff:g>(+968)</xliff:g></item> + <item>Pakistan <xliff:g>(+92)</xliff:g></item> + <item>Palau <xliff:g>(+680)</xliff:g></item> + <item>Palestine <xliff:g>(+970)</xliff:g></item> + <item>Panama <xliff:g>(+507)</xliff:g></item> + <item>Papua New Guinea <xliff:g>(+675)</xliff:g></item> + <item>Paraguay <xliff:g>(+595)</xliff:g></item> + <item>Peru <xliff:g>(+51)</xliff:g></item> + <item>Philippines <xliff:g>(+63)</xliff:g></item> + <item>Poland <xliff:g>(+48)</xliff:g></item> + <item>Portugal <xliff:g>(+351)</xliff:g></item> + <item>Puerto Rico <xliff:g>(+1)</xliff:g></item> + <item>Qatar <xliff:g>(+974)</xliff:g></item> + <item>Réunion <xliff:g>(+262)</xliff:g></item> + <item>Romania <xliff:g>(+40)</xliff:g></item> + <item>Russian <xliff:g>(+7)</xliff:g></item> + <item>Rwanda <xliff:g>(+250)</xliff:g></item> + <item>St. Barthélemy <xliff:g>(+590)</xliff:g></item> + <item>St. Helena <xliff:g>(+290)</xliff:g></item> + <item>St. Kitts and Nevis <xliff:g>(+1)</xliff:g></item> + <item>St. Lucia <xliff:g>(+1)</xliff:g></item> + <item>St. Martin <xliff:g>(+590)</xliff:g></item> + <item>St. Pierre and Miquelon <xliff:g>(+508)</xliff:g></item> + <item>St. Vincent and the Grenadines <xliff:g>(+1)</xliff:g></item> + <item>Samoa <xliff:g>(+685)</xliff:g></item> + <item>San Marino <xliff:g>(+378)</xliff:g></item> + <item>Sao Tome and Principe <xliff:g>(+239)</xliff:g></item> + <item>Saudi Arabia <xliff:g>(+966)</xliff:g></item> + <item>Senegal <xliff:g>(+221)</xliff:g></item> + <item>Serbia <xliff:g>(+381)</xliff:g></item> + <item>Seychelles <xliff:g>(+248)</xliff:g></item> + <item>Sierra Leone <xliff:g>(+232)</xliff:g></item> + <item>Singapore <xliff:g>(+65)</xliff:g></item> + <item>Sint Maarten <xliff:g>(+1)</xliff:g></item> + <item>Slovakia <xliff:g>(+421)</xliff:g></item> + <item>Slovenia <xliff:g>(+386)</xliff:g></item> + <item>Solomon Islands <xliff:g>(+677)</xliff:g></item> + <item>Somalia <xliff:g>(+252)</xliff:g></item> + <item>South Africa <xliff:g>(+27)</xliff:g></item> + <item>South Sudan <xliff:g>(+211)</xliff:g></item> + <item>Spain <xliff:g>(+34)</xliff:g></item> + <item>Sri Lanka <xliff:g>(+94)</xliff:g></item> + <item>Sudan <xliff:g>(+249)</xliff:g></item> + <item>Suriname <xliff:g>(+597)</xliff:g></item> + <item>Svalbard and Jan Mayen <xliff:g>(+47)</xliff:g></item> + <item>Swaziland <xliff:g>(+268)</xliff:g></item> + <item>Sweden <xliff:g>(+46)</xliff:g></item> + <item>Switzerland <xliff:g>(+41)</xliff:g></item> + <item>Syria <xliff:g>(+963)</xliff:g></item> + <item>Taiwan <xliff:g>(+886)</xliff:g></item> + <item>Tajikistan <xliff:g>(+992)</xliff:g></item> + <item>Tanzania <xliff:g>(+255)</xliff:g></item> + <item>Thailand <xliff:g>(+66)</xliff:g></item> + <item>Timor-Leste <xliff:g>(+670)</xliff:g></item> + <item>Togo <xliff:g>(+228)</xliff:g></item> + <item>Tokelau <xliff:g>(+690)</xliff:g></item> + <item>Tonga <xliff:g>(+676)</xliff:g></item> + <item>Trinidad and Tobago <xliff:g>(+1)</xliff:g></item> + <item>Tunisia <xliff:g>(+216)</xliff:g></item> + <item>Turkey <xliff:g>(+90)</xliff:g></item> + <item>Turkmenistan <xliff:g>(+993)</xliff:g></item> + <item>Turks and Caicos Islands <xliff:g>(+1)</xliff:g></item> + <item>Tuvalu <xliff:g>(+688)</xliff:g></item> + <item>Uganda <xliff:g>(+256)</xliff:g></item> + <item>Ukraine <xliff:g>(+380)</xliff:g></item> + <item>United Arab Emirates <xliff:g>(+971)</xliff:g></item> + <item>United Kingdom <xliff:g>(+44)</xliff:g></item> + <item>United States <xliff:g>(+1)</xliff:g></item> + <item>Uruguay <xliff:g>(+598)</xliff:g></item> + <item>Uzbekistan <xliff:g>(+998)</xliff:g></item> + <item>Vanuatu <xliff:g>(+678)</xliff:g></item> + <item>Venezuela <xliff:g>(+58)</xliff:g></item> + <item>Viet Nam <xliff:g>(+84)</xliff:g></item> + <item>Virgin Islands (British) <xliff:g>(+1)</xliff:g></item> + <item>Virgin Islands (U.S.) <xliff:g>(+1)</xliff:g></item> + <item>Wallis and Futuna <xliff:g>(+681)</xliff:g></item> + <item>Western Sahara <xliff:g>(+212)</xliff:g></item> + <item>Yemen <xliff:g>(+967)</xliff:g></item> + <item>Zambia <xliff:g>(+260)</xliff:g></item> + <item>Zimbabwe <xliff:g>(+263)</xliff:g></item> + </string-array> + <string-array name="assisted_dialing_cc_values" translatable="false"> + <item></item> + <item>AF</item> + <item>AX</item> + <item>AL</item> + <item>DZ</item> + <item>AS</item> + <item>AD</item> + <item>AO</item> + <item>AI</item> + <item>AG</item> + <item>AR</item> + <item>AM</item> + <item>AW</item> + <item>AU</item> + <item>AT</item> + <item>AZ</item> + <item>BS</item> + <item>BH</item> + <item>BD</item> + <item>BB</item> + <item>BY</item> + <item>BE</item> + <item>BZ</item> + <item>BJ</item> + <item>BM</item> + <item>BT</item> + <item>BO</item> + <item>BQ</item> + <item>BA</item> + <item>BW</item> + <item>BR</item> + <item>IO</item> + <item>BN</item> + <item>BG</item> + <item>BF</item> + <item>BI</item> + <item>CV</item> + <item>KH</item> + <item>CM</item> + <item>CA</item> + <item>KY</item> + <item>CF</item> + <item>TD</item> + <item>CL</item> + <item>CN</item> + <item>CX</item> + <item>CC</item> + <item>CO</item> + <item>KM</item> + <item>CD</item> + <item>CG</item> + <item>CK</item> + <item>CR</item> + <item>CI</item> + <item>HR</item> + <item>CU</item> + <item>CW</item> + <item>CY</item> + <item>CZ</item> + <item>DK</item> + <item>DJ</item> + <item>DM</item> + <item>DO</item> + <item>EC</item> + <item>EG</item> + <item>SV</item> + <item>GQ</item> + <item>ER</item> + <item>EE</item> + <item>ET</item> + <item>FK</item> + <item>FO</item> + <item>FJ</item> + <item>FI</item> + <item>FR</item> + <item>GF</item> + <item>PF</item> + <item>GA</item> + <item>GM</item> + <item>GE</item> + <item>DE</item> + <item>GH</item> + <item>GI</item> + <item>GR</item> + <item>GL</item> + <item>GD</item> + <item>GP</item> + <item>GU</item> + <item>GT</item> + <item>GG</item> + <item>GN</item> + <item>GW</item> + <item>GY</item> + <item>HT</item> + <item>VA</item> + <item>HN</item> + <item>HK</item> + <item>HU</item> + <item>IS</item> + <item>IN</item> + <item>ID</item> + <item>IR</item> + <item>IQ</item> + <item>IE</item> + <item>IM</item> + <item>IL</item> + <item>IT</item> + <item>JM</item> + <item>JP</item> + <item>JE</item> + <item>JO</item> + <item>KZ</item> + <item>KE</item> + <item>KI</item> + <item>KP</item> + <item>KR</item> + <item>KW</item> + <item>KG</item> + <item>LA</item> + <item>LV</item> + <item>LB</item> + <item>LS</item> + <item>LR</item> + <item>LY</item> + <item>LI</item> + <item>LT</item> + <item>LU</item> + <item>MO</item> + <item>MK</item> + <item>MG</item> + <item>MW</item> + <item>MY</item> + <item>MV</item> + <item>ML</item> + <item>MT</item> + <item>MH</item> + <item>MQ</item> + <item>MR</item> + <item>MU</item> + <item>YT</item> + <item>MX</item> + <item>FM</item> + <item>MD</item> + <item>MC</item> + <item>MN</item> + <item>ME</item> + <item>MS</item> + <item>MA</item> + <item>MZ</item> + <item>MM</item> + <item>NA</item> + <item>NR</item> + <item>NP</item> + <item>NL</item> + <item>NC</item> + <item>NZ</item> + <item>NI</item> + <item>NE</item> + <item>NG</item> + <item>NU</item> + <item>NF</item> + <item>MP</item> + <item>NO</item> + <item>OM</item> + <item>PK</item> + <item>PW</item> + <item>PS</item> + <item>PA</item> + <item>PG</item> + <item>PY</item> + <item>PE</item> + <item>PH</item> + <item>PL</item> + <item>PT</item> + <item>PR</item> + <item>QA</item> + <item>RE</item> + <item>RO</item> + <item>RU</item> + <item>RW</item> + <item>BL</item> + <item>SH</item> + <item>KN</item> + <item>LC</item> + <item>MF</item> + <item>PM</item> + <item>VC</item> + <item>WS</item> + <item>SM</item> + <item>ST</item> + <item>SA</item> + <item>SN</item> + <item>RS</item> + <item>SC</item> + <item>SL</item> + <item>SG</item> + <item>SX</item> + <item>SK</item> + <item>SI</item> + <item>SB</item> + <item>SO</item> + <item>ZA</item> + <item>SS</item> + <item>ES</item> + <item>LK</item> + <item>SD</item> + <item>SR</item> + <item>SJ</item> + <item>SZ</item> + <item>SE</item> + <item>CH</item> + <item>SY</item> + <item>TW</item> + <item>TJ</item> + <item>TZ</item> + <item>TH</item> + <item>TL</item> + <item>TG</item> + <item>TK</item> + <item>TO</item> + <item>TT</item> + <item>TN</item> + <item>TR</item> + <item>TM</item> + <item>TC</item> + <item>TV</item> + <item>UG</item> + <item>UA</item> + <item>AE</item> + <item>GB</item> + <item>US</item> + <item>UY</item> + <item>UZ</item> + <item>VU</item> + <item>VE</item> + <item>VN</item> + <item>VG</item> + <item>VI</item> + <item>WF</item> + <item>EH</item> + <item>YE</item> + <item>ZM</item> + <item>ZW</item> + </string-array> </resources>
\ No newline at end of file diff --git a/java/com/android/dialer/assisteddialing/ui/res/xml/assisted_dialing_setting.xml b/java/com/android/dialer/assisteddialing/ui/res/xml/assisted_dialing_setting.xml index 806edfcf9..c1706b2ed 100644 --- a/java/com/android/dialer/assisteddialing/ui/res/xml/assisted_dialing_setting.xml +++ b/java/com/android/dialer/assisteddialing/ui/res/xml/assisted_dialing_setting.xml @@ -17,10 +17,22 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - <SwitchPreference - android:defaultValue="true" - android:key="@string/assisted_dialing_setting_toggle_key" - android:title="@string/assisted_dialing_setting_title" - android:summary="@string/assisted_dialing_setting_summary" /> + <SwitchPreference + android:defaultValue="true" + android:key="@string/assisted_dialing_setting_toggle_key" + android:summary="@string/assisted_dialing_setting_summary" + android:title="@string/assisted_dialing_setting_title"/> + + <PreferenceCategory + android:title="@string/assisted_dialing_setting_cc_category_title"> + <ListPreference + android:dependency="@string/assisted_dialing_setting_toggle_key" + android:defaultValue="" + android:entries="@array/assisted_dialing_cc_entries" + android:entryValues="@array/assisted_dialing_cc_values" + android:key="@string/assisted_dialing_setting_cc_key" + android:summary="@string/assisted_dialing_setting_cc_default_summary" + android:title="@string/assisted_dialing_setting_cc_title"/> + </PreferenceCategory> </PreferenceScreen> diff --git a/java/com/android/dialer/callcomposer/CallComposerActivity.java b/java/com/android/dialer/callcomposer/CallComposerActivity.java index eedf0735c..cd0c74124 100644 --- a/java/com/android/dialer/callcomposer/CallComposerActivity.java +++ b/java/com/android/dialer/callcomposer/CallComposerActivity.java @@ -58,7 +58,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.UiUtil; import com.android.dialer.common.concurrent.DialerExecutor; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.constants.Constants; @@ -223,8 +223,9 @@ public class CallComposerActivity extends AppCompatActivity setMediaIconSelected(currentIndex); copyAndResizeExecutor = - DialerExecutors.createUiTaskBuilder( - getApplicationContext(), + DialerExecutorComponent.get(getApplicationContext()) + .dialerExecutorFactory() + .createUiTaskBuilder( getFragmentManager(), "copyAndResizeImageToSend", new CopyAndResizeImageWorker(this.getApplicationContext())) diff --git a/java/com/android/dialer/callcomposer/camera/CameraManager.java b/java/com/android/dialer/callcomposer/camera/CameraManager.java index 9a9577f6f..b850a193f 100644 --- a/java/com/android/dialer/callcomposer/camera/CameraManager.java +++ b/java/com/android/dialer/callcomposer/camera/CameraManager.java @@ -35,7 +35,7 @@ import com.android.dialer.callcomposer.camera.camerafocus.FocusOverlayManager; import com.android.dialer.callcomposer.camera.camerafocus.RenderOverlay; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -468,8 +468,9 @@ public class CameraManager implements FocusOverlayManager.Listener { } LogUtil.i( "CameraManager.onPictureTaken", "taken picture size: " + bytes.length + " bytes"); - DialerExecutors.createNonUiTaskBuilder( - mCameraPreview.getContext(), + DialerExecutorComponent.get(mCameraPreview.getContext()) + .dialerExecutorFactory() + .createNonUiTaskBuilder( new ImagePersistWorker( width, height, heightPercent, bytes, mCameraPreview.getContext())) .onSuccess( diff --git a/java/com/android/dialer/calllog/CallLogFramework.java b/java/com/android/dialer/calllog/CallLogFramework.java index 788e56b93..e4bb4c89a 100644 --- a/java/com/android/dialer/calllog/CallLogFramework.java +++ b/java/com/android/dialer/calllog/CallLogFramework.java @@ -18,7 +18,6 @@ package com.android.dialer.calllog; import android.content.Context; import android.content.SharedPreferences; -import android.preference.PreferenceManager; import android.support.annotation.MainThread; import android.support.annotation.Nullable; import com.android.dialer.buildtype.BuildType; @@ -26,6 +25,7 @@ import com.android.dialer.calllog.datasources.CallLogDataSource; import com.android.dialer.calllog.datasources.DataSources; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; +import com.android.dialer.storage.Unencrypted; import javax.inject.Inject; import javax.inject.Singleton; @@ -41,12 +41,14 @@ public final class CallLogFramework implements CallLogDataSource.ContentObserver static final String PREF_FORCE_REBUILD = "callLogFrameworkForceRebuild"; private final DataSources dataSources; + private final SharedPreferences sharedPreferences; @Nullable private CallLogUi ui; @Inject - CallLogFramework(DataSources dataSources) { + CallLogFramework(DataSources dataSources, @Unencrypted SharedPreferences sharedPreferences) { this.dataSources = dataSources; + this.sharedPreferences = sharedPreferences; } /** Registers the content observers for all data sources. */ @@ -99,7 +101,6 @@ public final class CallLogFramework implements CallLogDataSource.ContentObserver Assert.isMainThread(); LogUtil.enterBlock("CallLogFramework.markDirtyAndNotify"); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext); sharedPreferences.edit().putBoolean(PREF_FORCE_REBUILD, true).apply(); if (ui != null) { diff --git a/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java b/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java index 273246649..72f73cdaf 100644 --- a/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java +++ b/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java @@ -22,7 +22,6 @@ import android.content.OperationApplicationException; import android.content.SharedPreferences; import android.os.Build; import android.os.RemoteException; -import android.preference.PreferenceManager; import android.support.annotation.WorkerThread; import com.android.dialer.calllog.database.CallLogDatabaseComponent; import com.android.dialer.calllog.datasources.CallLogDataSource; @@ -32,6 +31,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.inject.ApplicationContext; +import com.android.dialer.storage.Unencrypted; import javax.inject.Inject; /** @@ -43,11 +43,16 @@ public class RefreshAnnotatedCallLogWorker implements Worker<Boolean, Void> { private final Context appContext; private final DataSources dataSources; + private final SharedPreferences sharedPreferences; @Inject - RefreshAnnotatedCallLogWorker(@ApplicationContext Context appContext, DataSources dataSources) { + RefreshAnnotatedCallLogWorker( + @ApplicationContext Context appContext, + DataSources dataSources, + @Unencrypted SharedPreferences sharedPreferences) { this.appContext = appContext; this.dataSources = dataSources; + this.sharedPreferences = sharedPreferences; } @Override @@ -71,7 +76,6 @@ public class RefreshAnnotatedCallLogWorker implements Worker<Boolean, Void> { long startTime = System.currentTimeMillis(); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext); // Default to true. If the pref doesn't exist, the annotated call log hasn't been created and // we just skip isDirty checks and force a rebuild. boolean forceRebuildPrefValue = @@ -171,8 +175,6 @@ public class RefreshAnnotatedCallLogWorker implements Worker<Boolean, Void> { dataSourceName, System.currentTimeMillis() - startTime); } - - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext); sharedPreferences.edit().putBoolean(CallLogFramework.PREF_FORCE_REBUILD, false).apply(); } diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java index 1fe3507e0..5ca160778 100644 --- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java +++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java @@ -25,7 +25,6 @@ import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.os.Handler; -import android.preference.PreferenceManager; import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; @@ -48,6 +47,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.phonenumberproto.DialerPhoneNumberUtil; +import com.android.dialer.storage.StorageComponent; import com.android.dialer.theme.R; import com.android.dialer.util.PermissionsUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil; @@ -107,7 +107,8 @@ public class SystemCallLogDataSource implements CallLogDataSource { * * Just return false unless the table has never been written to. */ - return !PreferenceManager.getDefaultSharedPreferences(appContext) + return !StorageComponent.get(appContext) + .unencryptedSharedPrefs() .contains(PREF_LAST_TIMESTAMP_PROCESSED); } @@ -142,7 +143,8 @@ public class SystemCallLogDataSource implements CallLogDataSource { public void onSuccessfulFill(Context appContext) { // If a fill operation was a no-op, lastTimestampProcessed could still be null. if (lastTimestampProcessed != null) { - PreferenceManager.getDefaultSharedPreferences(appContext) + StorageComponent.get(appContext) + .unencryptedSharedPrefs() .edit() .putLong(PREF_LAST_TIMESTAMP_PROCESSED, lastTimestampProcessed) .apply(); @@ -190,7 +192,8 @@ public class SystemCallLogDataSource implements CallLogDataSource { private void handleInsertsAndUpdates( Context appContext, CallLogMutations mutations, Set<Long> existingAnnotatedCallLogIds) { long previousTimestampProcessed = - PreferenceManager.getDefaultSharedPreferences(appContext) + StorageComponent.get(appContext) + .unencryptedSharedPrefs() .getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L); DialerPhoneNumberUtil dialerPhoneNumberUtil = diff --git a/java/com/android/dialer/common/concurrent/DialerExecutor.java b/java/com/android/dialer/common/concurrent/DialerExecutor.java index 0414581d4..3ee06445f 100644 --- a/java/com/android/dialer/common/concurrent/DialerExecutor.java +++ b/java/com/android/dialer/common/concurrent/DialerExecutor.java @@ -25,7 +25,95 @@ import java.util.concurrent.ExecutorService; /** * Provides a consistent interface for doing background work in either UI or non-UI contexts. * - * <p>See {@link DialerExecutors} for usage examples. + * <p>You may create an executor from a UI component (activity or fragment) or a non-UI component. + * Using this class provides a number of benefits: + * + * <ul> + * <li>Ensures that UI tasks keep running across configuration changes by using a headless + * fragment. + * <li>Forces exceptions to crash the application, unless the user implements their own onFailure + * method. + * <li>Checks for dead UI components which can be encountered if a UI task runs longer than its + * UI. If a dead UI component is encountered, onSuccess/onFailure are not called (because they + * can't be) but a message is logged. + * <li>Helps prevent memory leaks in UI tasks by ensuring that callbacks are nulled out when the + * headless fragment is detached. + * <li>UI and non-UI threads are shared across the application and run at reasonable priorities + * </ul> + * + * <p>Executors accept a single input and output parameter which should be immutable data objects. + * If you don't require an input or output, use Void and null as needed. + * + * <p>You may optionally specify onSuccess and onFailure listeners; the default behavior on success + * is a no-op and the default behavior on failure is to crash the application. + * + * <p>To use an executor from a UI component, you must create it in your onCreate method and then + * use it from anywhere: + * + * <pre><code> + * + * public class MyActivity extends Activity { + * + * private final DialerExecutor<MyInputType> myExecutor; + * + * public void onCreate(Bundle state) { + * super.onCreate(bundle); + * + * // Must be called in onCreate; don't use non-static or anonymous inner classes for worker! + * myExecutor = DialerExecutorComponent.get(context).dialerExecutorFactory() + * .createUiTaskBuilder(fragmentManager, taskId, worker) + * .onSuccess(this::onSuccess) // Lambdas, anonymous, or non-static inner classes all fine + * .onFailure(this::onFailure) // Lambdas, anonymous, or non-static inner classes all fine + * .build(); + * ); + * } + * + * private static class MyWorker implements Worker<MyInputType, MyOutputType> { + * MyOutputType doInBackground(MyInputType input) { ... } + * } + * private void onSuccess(MyOutputType output) { ... } + * private void onFailure(Throwable throwable) { ... } + * + * private void userDidSomething() { myExecutor.executeParallel(input); } + * } + * </code></pre> + * + * <p>Usage for non-UI tasks is the same, except that tasks can be created from anywhere instead of + * in onCreate. Non-UI tasks use low-priority threads separate from the UI task threads so as not to + * compete with more critical UI tasks. + * + * <pre><code> + * + * public class MyManager { + * + * private final DialerExecutor<MyInputType> myExecutor; + * + * public void init() { + * // Don't use non-static or anonymous inner classes for worker! + * myExecutor = DialerExecutorComponent.get(context).dialerExecutorFactory() + * .createNonUiTaskBuilder(worker) + * .onSuccess(this::onSuccess) // Lambdas, anonymous, or non-static inner classes all fine + * .onFailure(this::onFailure) // Lambdas, anonymous, or non-static inner classes all fine + * .build(); + * ); + * } + * + * private static class MyWorker implements Worker<MyInputType, MyOutputType> { + * MyOutputType doInBackground(MyInputType input) { ... } + * } + * private void onSuccess(MyOutputType output) { ... } + * private void onFailure(Throwable throwable) { ... } + * + * private void userDidSomething() { myExecutor.executeParallel(input); } + * } + * </code></pre> + * + * Note that non-UI tasks are intended to be relatively quick; for example reading/writing shared + * preferences or doing simple database work. If you submit long running non-UI tasks you may + * saturate the shared application threads and block other tasks. Also, this class does not create + * any wakelocks, so a long running task could be killed if the device goes to sleep while your task + * is still running. If you have to do long running or periodic work, consider using a job + * scheduler. */ public interface DialerExecutor<InputT> { diff --git a/java/com/android/dialer/common/concurrent/DialerExecutors.java b/java/com/android/dialer/common/concurrent/DialerExecutors.java index 4d8331fb6..b29bf5d3b 100644 --- a/java/com/android/dialer/common/concurrent/DialerExecutors.java +++ b/java/com/android/dialer/common/concurrent/DialerExecutors.java @@ -16,135 +16,15 @@ package com.android.dialer.common.concurrent; -import android.app.FragmentManager; import android.content.Context; import android.support.annotation.NonNull; import com.android.dialer.common.Assert; -import com.android.dialer.common.concurrent.DialerExecutor.Worker; import java.util.concurrent.ExecutorService; -/** - * Factory methods for creating {@link DialerExecutor} objects for doing background work. - * - * <p>You may create an executor from a UI component (activity or fragment) or a non-UI component. - * Using this class provides a number of benefits: - * - * <ul> - * <li>Ensures that UI tasks keep running across configuration changes by using a headless - * fragment. - * <li>Forces exceptions to crash the application, unless the user implements their own onFailure - * method. - * <li>Checks for dead UI components which can be encountered if a UI task runs longer than its - * UI. If a dead UI component is encountered, onSuccess/onFailure are not called (because they - * can't be) but a message is logged. - * <li>Helps prevents memory leaks in UI tasks by ensuring that callbacks are nulled out when the - * headless fragment is detached. - * <li>UI and non-UI threads are shared across the application and run at reasonable priorities - * </ul> - * - * <p>Executors accept a single input and output parameter which should be immutable data objects. - * If you don't require an input or output, use Void and null as needed. - * - * <p>You may optionally specify onSuccess and onFailure listeners; the default behavior on success - * is a no-op and the default behavior on failure is to crash the application. - * - * <p>To use an executor from a UI component, you must create it in your onCreate method and then - * use it from anywhere: - * - * <pre><code> - * - * public class MyActivity extends Activity { - * - * private final DialerExecutor<MyInputType> myExecutor; - * - * public void onCreate(Bundle state) { - * super.onCreate(bundle); - * - * // Must be called in onCreate; don't use non-static or anonymous inner classes for worker! - * myExecutor = DialerExecutors.createUiTaskBuilder(fragmentManager, taskId, worker) - * .onSuccess(this::onSuccess) // Lambdas, anonymous, or non-static inner classes all fine - * .onFailure(this::onFailure) // Lambdas, anonymous, or non-static inner classes all fine - * .build(); - * ); - * } - * - * private static class MyWorker implements Worker<MyInputType, MyOutputType> { - * MyOutputType doInBackground(MyInputType input) { ... } - * } - * private void onSuccess(MyOutputType output) { ... } - * private void onFailure(Throwable throwable) { ... } - * - * private void userDidSomething() { myExecutor.executeParallel(input); } - * } - * </code></pre> - * - * <p>Usage for non-UI tasks is the same, except that tasks can be created from anywhere instead of - * in onCreate. Non-UI tasks use low-priority threads separate from the UI task threads so as not to - * compete with more critical UI tasks. - * - * <pre><code> - * - * public class MyManager { - * - * private final DialerExecutor<MyInputType> myExecutor; - * - * public void init() { - * // Don't use non-static or anonymous inner classes for worker! - * myExecutor = DialerExecutors.createNonUiTaskBuilder(worker) - * .onSuccess(this::onSuccess) // Lambdas, anonymous, or non-static inner classes all fine - * .onFailure(this::onFailure) // Lambdas, anonymous, or non-static inner classes all fine - * .build(); - * ); - * } - * - * private static class MyWorker implements Worker<MyInputType, MyOutputType> { - * MyOutputType doInBackground(MyInputType input) { ... } - * } - * private void onSuccess(MyOutputType output) { ... } - * private void onFailure(Throwable throwable) { ... } - * - * private void userDidSomething() { myExecutor.executeParallel(input); } - * } - * </code></pre> - * - * Note that non-UI tasks are intended to be relatively quick; for example reading/writing shared - * preferences or doing simple database work. If you submit long running non-UI tasks you may - * saturate the shared application threads and block other tasks. Also, this class does not create - * any wakelocks, so a long running task could be killed if the device goes to sleep while your task - * is still running. If you have to do long running or periodic work, consider using a job - * scheduler. - */ +/** Shared application executors. */ public final class DialerExecutors { /** - * @param context any valid context object from which the application context can be retrieved - * @see DialerExecutorFactory#createUiTaskBuilder(FragmentManager, String, Worker) - */ - @NonNull - public static <InputT, OutputT> DialerExecutor.Builder<InputT, OutputT> createUiTaskBuilder( - @NonNull Context context, - @NonNull FragmentManager fragmentManager, - @NonNull String taskId, - @NonNull Worker<InputT, OutputT> worker) { - return DialerExecutorComponent.get(Assert.isNotNull(context)) - .dialerExecutorFactory() - .createUiTaskBuilder( - Assert.isNotNull(fragmentManager), Assert.isNotNull(taskId), Assert.isNotNull(worker)); - } - - /** - * @param context any valid context object from which the application context can be retrieved - * @see DialerExecutorFactory#createNonUiTaskBuilder(Worker) - */ - @NonNull - public static <InputT, OutputT> DialerExecutor.Builder<InputT, OutputT> createNonUiTaskBuilder( - Context context, @NonNull Worker<InputT, OutputT> worker) { - return DialerExecutorComponent.get(Assert.isNotNull(context)) - .dialerExecutorFactory() - .createNonUiTaskBuilder(Assert.isNotNull(worker)); - } - - /** * An application-wide thread pool used for low priority (non-UI) tasks. * * <p>This exists to prevent each individual dialer component from having to create its own diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java index 7b551f79d..1f83d5545 100644 --- a/java/com/android/dialer/dialpadview/DialpadFragment.java +++ b/java/com/android/dialer/dialpadview/DialpadFragment.java @@ -77,7 +77,7 @@ import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor; import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.UiAction; @@ -343,8 +343,9 @@ public class DialpadFragment extends Fragment } initPhoneNumberFormattingTextWatcherExecutor = - DialerExecutors.createUiTaskBuilder( - getContext(), + DialerExecutorComponent.get(getContext()) + .dialerExecutorFactory() + .createUiTaskBuilder( getFragmentManager(), "DialpadFragment.initPhoneNumberFormattingTextWatcher", new InitPhoneNumberFormattingTextWatcherWorker()) diff --git a/java/com/android/dialer/dialpadview/DialpadTextView.java b/java/com/android/dialer/dialpadview/DialpadTextView.java index 5b1b7bb5d..b1eee4b9c 100644 --- a/java/com/android/dialer/dialpadview/DialpadTextView.java +++ b/java/com/android/dialer/dialpadview/DialpadTextView.java @@ -24,8 +24,8 @@ import android.util.AttributeSet; import android.widget.TextView; /** - * This is a custom text view intended only for rendering the numerals (and star and pound) on the - * dialpad. TextView has built in top/bottom padding to help account for ascenders/descenders. + * This is a custom text view intended for rendering text on the dialpad. TextView has built-in + * top/bottom padding to help account for ascenders/descenders. * * <p>Since vertical space is at a premium on the dialpad, particularly if the font size is scaled * to a larger default, for the dialpad we use this class to more precisely render characters diff --git a/java/com/android/dialer/dialpadview/DialpadView.java b/java/com/android/dialer/dialpadview/DialpadView.java index d70b0a6c2..5e79cb59f 100644 --- a/java/com/android/dialer/dialpadview/DialpadView.java +++ b/java/com/android/dialer/dialpadview/DialpadView.java @@ -223,29 +223,32 @@ public class DialpadView extends LinearLayout { if (mIsLandscape) { adjustKeyWidths(); } else { - adjustKeyHeightsInFirstRow(); + adjustDigitKeyHeights(); } } } /** - * Adjust key heights in the first row. + * Make the heights of all digit keys the same. * - * <p>A voice mail icon is shown under key "1", which makes its height different from other keys - * in the first row. + * <p>When the device is in portrait mode, we first find the maximum height among digit key + * layouts. Then for each key, we adjust the height of the layout containing letters/the voice + * mail icon to ensure the height of each digit key is the same. * * <p>This method should be called after the sizes of related layouts have been calculated by the * framework. */ - private void adjustKeyHeightsInFirstRow() { + private void adjustDigitKeyHeights() { + Assert.checkState(!mIsLandscape); + int maxHeight = 0; - for (int i = 1; i <= 3; i++) { + for (int i = 0; i <= 9; i++) { DialpadKeyButton dialpadKey = (DialpadKeyButton) findViewById(BUTTON_IDS[i]); LinearLayout keyLayout = (LinearLayout) dialpadKey.findViewById(R.id.dialpad_key_layout); maxHeight = Math.max(maxHeight, keyLayout.getHeight()); } - for (int i = 1; i <= 3; i++) { + for (int i = 0; i <= 9; i++) { DialpadKeyButton dialpadKey = (DialpadKeyButton) findViewById(BUTTON_IDS[i]); LinearLayout keyLayout = (LinearLayout) dialpadKey.findViewById(R.id.dialpad_key_layout); diff --git a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml b/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml index 12f24ac52..769e2d8bb 100644 --- a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml +++ b/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml @@ -39,7 +39,7 @@ android:id="@+id/dialpad_key_icon_or_letters_layout" style="@style/DialpadKeyInternalLayoutStyle"> - <TextView + <com.android.dialer.dialpadview.DialpadTextView android:id="@+id/dialpad_key_letters" style="@style/DialpadKeyLettersStyle"/> </LinearLayout> diff --git a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key_zero.xml b/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key_zero.xml deleted file mode 100644 index 714507202..000000000 --- a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key_zero.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2014 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. ---> - -<!-- A layout representing key "0" in the dialpad --> -<com.android.dialer.dialpadview.DialpadKeyButton - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/zero" - style="@style/DialpadKeyButtonStyle"> - - <LinearLayout - android:id="@+id/dialpad_key_layout" - style="@style/DialpadKeyInternalLayoutStyle" - android:layout_gravity="right|center_vertical" - android:baselineAligned="false" - android:orientation="horizontal"> - - <FrameLayout - android:layout_width="@dimen/dialpad_key_number_width" - android:layout_height="wrap_content" - android:layout_marginRight="@dimen/dialpad_key_margin_right"> - <com.android.dialer.dialpadview.DialpadTextView - android:id="@+id/dialpad_key_number" - style="@style/DialpadBottomKeyNumberStyle"/> - </FrameLayout> - - <TextView - android:id="@+id/dialpad_key_letters" - style="@style/DialpadKeyLettersStyle"/> - <!-- A placeholder to make the width the same as other keys. --> - <View - android:id="@+id/dialpad_key_horizontal_placeholder" - android:layout_width="0dp" - android:layout_height="match_parent"/> - </LinearLayout> -</com.android.dialer.dialpadview.DialpadKeyButton> diff --git a/java/com/android/dialer/dialpadview/res/layout/dialpad.xml b/java/com/android/dialer/dialpadview/res/layout/dialpad.xml index 5a14d14ea..0061d5497 100644 --- a/java/com/android/dialer/dialpadview/res/layout/dialpad.xml +++ b/java/com/android/dialer/dialpadview/res/layout/dialpad.xml @@ -16,84 +16,86 @@ <!-- Dialpad in the Phone app. --> <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/dialpad" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipChildren="false" - android:orientation="vertical"> - <LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/dialpad" android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:orientation="horizontal"> + android:layout_height="match_parent" + android:clipChildren="false" + android:orientation="vertical"> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:orientation="horizontal"> <Space style="@style/DialpadSpaceStyle"/> <include layout="@layout/dialpad_key_one"/> <include - android:id="@+id/two" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/two" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <include - android:id="@+id/three" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/three" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <Space style="@style/DialpadSpaceStyle"/> </LinearLayout> <LinearLayout - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:orientation="horizontal"> <Space style="@style/DialpadSpaceStyle"/> <include - android:id="@+id/four" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/four" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <include - android:id="@+id/five" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/five" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <include - android:id="@+id/six" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/six" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <Space style="@style/DialpadSpaceStyle"/> </LinearLayout> <LinearLayout - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:orientation="horizontal"> <Space style="@style/DialpadSpaceStyle"/> <include - android:id="@+id/seven" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/seven" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <include - android:id="@+id/eight" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/eight" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <include - android:id="@+id/nine" - style="@style/DialpadKeyButtonStyle" - layout="@layout/dialpad_key"/> + android:id="@+id/nine" + style="@style/DialpadKeyButtonStyle" + layout="@layout/dialpad_key"/> <Space style="@style/DialpadSpaceStyle"/> </LinearLayout> <LinearLayout - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:orientation="horizontal"> <Space style="@style/DialpadSpaceStyle"/> <include layout="@layout/dialpad_key_star"/> - <include layout="@layout/dialpad_key_zero"/> + <include + android:id="@+id/zero" + layout="@layout/dialpad_key"/> <include layout="@layout/dialpad_key_pound"/> <Space style="@style/DialpadSpaceStyle"/> </LinearLayout> <Space - android:layout_width="match_parent" - android:layout_height="?attr/dialpad_end_key_spacing"/> + android:layout_width="match_parent" + android:layout_height="?attr/dialpad_end_key_spacing"/> </LinearLayout> diff --git a/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml b/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml index 6c87cd2b4..bb9ec63f6 100644 --- a/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml +++ b/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml @@ -31,7 +31,7 @@ android:id="@+id/dialpad_key_icon_or_letters_layout" style="@style/DialpadKeyInternalLayoutStyle"> - <TextView + <com.android.dialer.dialpadview.DialpadTextView android:id="@+id/dialpad_key_letters" style="@style/DialpadKeyLettersStyle"/> </LinearLayout> diff --git a/java/com/android/dialer/dialpadview/res/layout/dialpad_key_zero.xml b/java/com/android/dialer/dialpadview/res/layout/dialpad_key_zero.xml deleted file mode 100644 index 8d9c7b216..000000000 --- a/java/com/android/dialer/dialpadview/res/layout/dialpad_key_zero.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2014 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. ---> - -<!-- A layout representing key "0" in the dialpad --> -<com.android.dialer.dialpadview.DialpadKeyButton - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/zero" - style="@style/DialpadKeyButtonStyle"> - - <LinearLayout - android:id="@+id/dialpad_key_layout" - style="@style/DialpadKeyInternalLayoutStyle"> - - <com.android.dialer.dialpadview.DialpadTextView - android:id="@+id/dialpad_key_number" - style="@style/DialpadBottomKeyNumberStyle"/> - <TextView - android:id="@+id/dialpad_key_letters" - style="@style/DialpadKeyLettersStyle"/> - </LinearLayout> -</com.android.dialer.dialpadview.DialpadKeyButton> diff --git a/java/com/android/dialer/dialpadview/res/values-land/styles.xml b/java/com/android/dialer/dialpadview/res/values-land/styles.xml index 012cfa2b2..de9ef1fbf 100644 --- a/java/com/android/dialer/dialpadview/res/values-land/styles.xml +++ b/java/com/android/dialer/dialpadview/res/values-land/styles.xml @@ -37,8 +37,6 @@ <item name="android:layout_gravity">center</item> </style> - <style name="DialpadBottomKeyNumberStyle" parent="DialpadKeyNumberStyle"/> - <style name="DialpadKeyPoundStyle"> <item name="android:textColor">?attr/dialpad_text_color_secondary</item> <item name="android:textSize">@dimen/dialpad_key_pound_size</item> @@ -56,6 +54,6 @@ <item name="android:fontFamily">sans-serif-regular</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> - <item name="android:gravity">left</item> + <item name="android:layout_gravity">left|center_vertical</item> </style> </resources> diff --git a/java/com/android/dialer/dialpadview/res/values/attrs.xml b/java/com/android/dialer/dialpadview/res/values/attrs.xml index d73946e65..972263883 100644 --- a/java/com/android/dialer/dialpadview/res/values/attrs.xml +++ b/java/com/android/dialer/dialpadview/res/values/attrs.xml @@ -25,7 +25,6 @@ <attr format="dimension" name="dialpad_digits_adjustable_height"/> <attr format="dimension" name="dialpad_key_numbers_size"/> <attr format="dimension" name="dialpad_key_number_margin_bottom"/> - <attr format="dimension" name="dialpad_zero_key_number_margin_bottom"/> </declare-styleable> <declare-styleable name="Theme.Dialpad"> diff --git a/java/com/android/dialer/dialpadview/res/values/dimens.xml b/java/com/android/dialer/dialpadview/res/values/dimens.xml index 1e5880a3e..797d7e839 100644 --- a/java/com/android/dialer/dialpadview/res/values/dimens.xml +++ b/java/com/android/dialer/dialpadview/res/values/dimens.xml @@ -22,8 +22,6 @@ <dimen name="dialpad_key_star_size">36sp</dimen> <dimen name="dialpad_key_height">64dp</dimen> <dimen name="dialpad_key_number_default_margin_bottom">3dp</dimen> - <!-- Zero key should have less space between self and text because "+" is smaller --> - <dimen name="dialpad_zero_key_number_default_margin_bottom">1dp</dimen> <dimen name="dialpad_symbol_margin_bottom">13dp</dimen> <dimen name="dialpad_digits_text_size">34sp</dimen> <dimen name="dialpad_digits_text_min_size">24sp</dimen> diff --git a/java/com/android/dialer/dialpadview/res/values/styles.xml b/java/com/android/dialer/dialpadview/res/values/styles.xml index 9d30021b9..653fe484f 100644 --- a/java/com/android/dialer/dialpadview/res/values/styles.xml +++ b/java/com/android/dialer/dialpadview/res/values/styles.xml @@ -32,10 +32,6 @@ <item name="android:gravity">center</item> </style> - <style name="DialpadBottomKeyNumberStyle" parent="DialpadKeyNumberStyle"> - <item name="android:layout_marginBottom">?attr/dialpad_zero_key_number_margin_bottom</item> - </style> - <style name="DialpadKeyStarStyle"> <item name="android:textColor">?attr/dialpad_text_color_secondary</item> <item name="android:textSize">@dimen/dialpad_key_star_size</item> @@ -44,7 +40,7 @@ <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_marginBottom">@dimen/dialpad_symbol_margin_bottom</item> - <item name="android:gravity">center</item> + <item name="android:layout_gravity">center</item> </style> <style name="DialpadKeyPoundStyle"> @@ -55,7 +51,7 @@ <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_marginBottom">@dimen/dialpad_symbol_margin_bottom</item> - <item name="android:gravity">center</item> + <item name="android:layout_gravity">center</item> </style> <style name="DialpadKeyLettersStyle"> @@ -64,7 +60,7 @@ <item name="android:fontFamily">sans-serif-regular</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> - <item name="android:gravity">center_horizontal</item> + <item name="android:layout_gravity">center</item> </style> <style name="DialpadKeyButtonStyle"> @@ -92,9 +88,6 @@ <item name="dialpad_key_numbers_size">@dimen/dialpad_key_numbers_default_size</item> <item name="dialpad_key_number_margin_bottom">@dimen/dialpad_key_number_default_margin_bottom </item> - <item name="dialpad_zero_key_number_margin_bottom"> - @dimen/dialpad_zero_key_number_default_margin_bottom - </item> <item name="dialpad_end_key_spacing">@dimen/dialpad_bottom_space_height</item> <item name="dialpad_elevation">0dp</item> </style> diff --git a/java/com/android/dialer/shortcuts/ShortcutRefresher.java b/java/com/android/dialer/shortcuts/ShortcutRefresher.java index 7fd02a96f..3201d592d 100644 --- a/java/com/android/dialer/shortcuts/ShortcutRefresher.java +++ b/java/com/android/dialer/shortcuts/ShortcutRefresher.java @@ -24,7 +24,7 @@ import com.android.contacts.common.list.ContactEntry; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import java.util.ArrayList; import java.util.List; @@ -45,7 +45,9 @@ public final class ShortcutRefresher { return; } - DialerExecutors.createNonUiTaskBuilder(context, new RefreshWorker(context)) + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new RefreshWorker(context)) .build() .executeSerial(new ArrayList<>(contacts)); } diff --git a/java/com/android/dialer/simulator/Simulator.java b/java/com/android/dialer/simulator/Simulator.java index bfa202c5c..2094b420e 100644 --- a/java/com/android/dialer/simulator/Simulator.java +++ b/java/com/android/dialer/simulator/Simulator.java @@ -35,10 +35,12 @@ public interface Simulator { @Retention(RetentionPolicy.SOURCE) @IntDef({ CONFERENCE_TYPE_GSM, + CONFERENCE_TYPE_VOLTE, }) @interface ConferenceType {} static final int CONFERENCE_TYPE_GSM = 1; + static final int CONFERENCE_TYPE_VOLTE = 2; /** Information about a connection event. */ public static class Event { diff --git a/java/com/android/dialer/simulator/impl/SimulatorConference.java b/java/com/android/dialer/simulator/impl/SimulatorConference.java index 7468b56b5..1a12d2a9f 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorConference.java +++ b/java/com/android/dialer/simulator/impl/SimulatorConference.java @@ -58,6 +58,17 @@ public final class SimulatorConference extends Conference implements SimulatorCo return simulatorConference; } + static SimulatorConference newVoLteConference(PhoneAccountHandle handle) { + SimulatorConference simulatorConference = + new SimulatorConference(handle, Simulator.CONFERENCE_TYPE_VOLTE); + simulatorConference.setConnectionCapabilities( + Connection.CAPABILITY_MUTE + | Connection.CAPABILITY_SUPPORT_HOLD + | Connection.CAPABILITY_HOLD + | Connection.CAPABILITY_MANAGE_CONFERENCE); + return simulatorConference; + } + public void addListener(@NonNull Listener listener) { listeners.add(Assert.isNotNull(listener)); } @@ -120,6 +131,11 @@ public final class SimulatorConference extends Conference implements SimulatorCo public void onSeparate(Connection connection) { LogUtil.i("SimulatorConference.onSeparate", "connection: " + connection); onEvent(new Event(Event.SEPARATE, SimulatorSimCallManager.getConnectionTag(connection), null)); + // if there is only 1 connection in a gsm conference, destroy the conference. + if (conferenceType == Simulator.CONFERENCE_TYPE_GSM && getConnections().size() == 1) { + removeConnection(getConnections().get(0)); + destroy(); + } } @Override diff --git a/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java b/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java index 838b58dc2..d0249938a 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java +++ b/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java @@ -64,6 +64,13 @@ final class SimulatorConferenceCreator String callerId = String.format(Locale.US, "+1-650-234%04d", callCount); Bundle extras = new Bundle(); extras.putInt(EXTRA_CALL_COUNT, callCount - 1); + switch (conferenceType) { + case Simulator.CONFERENCE_TYPE_VOLTE: + extras.putBoolean("ISVOLTE", true); + break; + default: + break; + } connectionTags.add( SimulatorSimCallManager.addNewIncomingCall(context, callerId, false /* isVideo */, extras)); } @@ -78,16 +85,11 @@ final class SimulatorConferenceCreator LogUtil.i("SimulatorConferenceCreator.onNewOutgoingConnection", "connection created"); connection.addListener(this); - // Telecom will force the connection to switch to DIALING when we return it. Wait until after - // we're returned it before changing call state. - ThreadUtil.postOnUiThread(() -> connection.setActive()); - // Once the connection is active, go ahead and conference it and add the next call. ThreadUtil.postDelayedOnUiThread( () -> { SimulatorConference conference = findCurrentConference(); if (conference == null) { - Assert.checkArgument(conferenceType == Simulator.CONFERENCE_TYPE_GSM); conference = SimulatorConference.newGsmConference( SimulatorSimCallManager.getSystemPhoneAccountHandle(context)); @@ -95,6 +97,7 @@ final class SimulatorConferenceCreator SimulatorConnectionService.getInstance().addConference(conference); } updateConferenceableConnections(); + connection.setActive(); conference.addConnection(connection); addNextCall(getCallCount(connection)); }, diff --git a/java/com/android/dialer/simulator/impl/SimulatorConnection.java b/java/com/android/dialer/simulator/impl/SimulatorConnection.java index e4a34b51b..168f5db98 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorConnection.java +++ b/java/com/android/dialer/simulator/impl/SimulatorConnection.java @@ -42,8 +42,10 @@ public final class SimulatorConnection extends Connection { | CAPABILITY_SUPPORT_HOLD | CAPABILITY_HOLD | CAPABILITY_CAN_UPGRADE_TO_VIDEO - | CAPABILITY_DISCONNECT_FROM_CONFERENCE - | CAPABILITY_SEPARATE_FROM_CONFERENCE); + | CAPABILITY_DISCONNECT_FROM_CONFERENCE); + if (request.getExtras() != null && !request.getExtras().getBoolean("ISVOLTE")) { + setConnectionCapabilities(getConnectionCapabilities() | CAPABILITY_SEPARATE_FROM_CONFERENCE); + } setVideoProvider(new SimulatorVideoProvider(context, this)); } diff --git a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java index 1a2cae18b..f4b1916c5 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java +++ b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java @@ -23,7 +23,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.ActionProvider; import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.databasepopulator.CallLogPopulator; import com.android.dialer.databasepopulator.ContactsPopulator; import com.android.dialer.databasepopulator.VoicemailPopulator; @@ -48,13 +48,17 @@ final class SimulatorMainMenu { } private static void populateDatabase(@NonNull Context context) { - DialerExecutors.createNonUiTaskBuilder(context, new PopulateDatabaseWorker()) + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new PopulateDatabaseWorker()) .build() .executeSerial(context); } private static void cleanDatabase(@NonNull Context context) { - DialerExecutors.createNonUiTaskBuilder(context, new CleanDatabaseWorker()) + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new CleanDatabaseWorker()) .build() .executeSerial(context); } @@ -65,7 +69,9 @@ final class SimulatorMainMenu { } private static void sharePersistentLog(@NonNull Context context) { - DialerExecutors.createNonUiTaskBuilder(context, new ShareLogWorker()) + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new ShareLogWorker()) .onSuccess( (String log) -> { Intent intent = new Intent(Intent.ACTION_SEND); diff --git a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java index f2a1d0901..d2eba6b03 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java +++ b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java @@ -42,7 +42,11 @@ final class SimulatorVoiceCall .addItem("Emergency call", () -> new SimulatorVoiceCall(context).addNewEmergencyCall()) .addItem( "GSM conference", - () -> new SimulatorConferenceCreator(context, Simulator.CONFERENCE_TYPE_GSM).start(5)); + () -> new SimulatorConferenceCreator(context, Simulator.CONFERENCE_TYPE_GSM).start(5)) + .addItem( + "VoLTE conference", + () -> + new SimulatorConferenceCreator(context, Simulator.CONFERENCE_TYPE_VOLTE).start(5)); } private SimulatorVoiceCall(@NonNull Context context) { diff --git a/java/com/android/dialer/storage/StorageComponent.java b/java/com/android/dialer/storage/StorageComponent.java index 067b99424..cb5c4a879 100644 --- a/java/com/android/dialer/storage/StorageComponent.java +++ b/java/com/android/dialer/storage/StorageComponent.java @@ -28,7 +28,11 @@ public abstract class StorageComponent { /** * Returns unencrypted default shared preferences. This method should not be used for private * data. + * + * <p>These shared prefs are available even when the device is in FBE mode and are generally the + * ones that should be used, because Dialer needs to function while in FBE mode. */ + @Unencrypted public abstract SharedPreferences unencryptedSharedPrefs(); public static StorageComponent get(Context context) { diff --git a/java/com/android/dialer/storage/StorageModule.java b/java/com/android/dialer/storage/StorageModule.java index 3ee72c8d8..e1c5b4b08 100644 --- a/java/com/android/dialer/storage/StorageModule.java +++ b/java/com/android/dialer/storage/StorageModule.java @@ -30,6 +30,7 @@ public class StorageModule { @Provides @Singleton + @Unencrypted static SharedPreferences provideUnencryptedSharedPrefs(@ApplicationContext Context appContext) { // #createDeviceProtectedStorageContext returns a new context each time, so we cache the shared // preferences object in order to avoid accessing disk for every operation. diff --git a/java/com/android/dialer/storage/DeviceProtected.java b/java/com/android/dialer/storage/Unencrypted.java index 862259a61..02c902145 100644 --- a/java/com/android/dialer/storage/DeviceProtected.java +++ b/java/com/android/dialer/storage/Unencrypted.java @@ -17,6 +17,6 @@ package com.android.dialer.storage; import javax.inject.Qualifier; -/** Annotation for retrieving device protected storage objects. */ +/** Annotation for retrieving unencrypted storage objects. */ @Qualifier -public @interface DeviceProtected {} +public @interface Unencrypted {} diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java index 2735461b2..67a294f97 100644 --- a/java/com/android/incallui/ContactInfoCache.java +++ b/java/com/android/incallui/ContactInfoCache.java @@ -45,7 +45,7 @@ import com.android.contacts.common.ContactsUtils; import com.android.dialer.common.Assert; import com.android.dialer.common.concurrent.DialerExecutor; import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.logging.ContactLookupResult; import com.android.dialer.logging.ContactSource; import com.android.dialer.oem.CequintCallerIdManager; @@ -126,7 +126,10 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { mContext = context; mPhoneNumberService = Bindings.get(context).newPhoneNumberService(context); cachedNumberLookupExecutor = - DialerExecutors.createNonUiTaskBuilder(mContext, new CachedNumberLookupWorker()).build(); + DialerExecutorComponent.get(mContext) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new CachedNumberLookupWorker()) + .build(); Trace.endSection(); } diff --git a/java/com/android/incallui/ContactsAsyncHelper.java b/java/com/android/incallui/ContactsAsyncHelper.java index 2e893b01a..abca9246e 100644 --- a/java/com/android/incallui/ContactsAsyncHelper.java +++ b/java/com/android/incallui/ContactsAsyncHelper.java @@ -27,7 +27,7 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import java.io.IOException; import java.io.InputStream; @@ -94,7 +94,9 @@ public class ContactsAsyncHelper { args.displayPhotoUri = displayPhotoUri; args.listener = listener; - DialerExecutors.createNonUiTaskBuilder(context, new Worker()) + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new Worker()) .onSuccess( output -> { if (args.listener != null) { diff --git a/java/com/android/incallui/res/values-sw360dp/dimens.xml b/java/com/android/incallui/res/values-sw360dp/dimens.xml index ad782e809..bb74a0208 100644 --- a/java/com/android/incallui/res/values-sw360dp/dimens.xml +++ b/java/com/android/incallui/res/values-sw360dp/dimens.xml @@ -21,10 +21,6 @@ <dimen name="incall_dialpad_key_number_margin_bottom"> @dimen/dialpad_key_number_default_margin_bottom </dimen> - <!-- Zero key should have less space between self and text because "+" is smaller --> - <dimen name="incall_dialpad_zero_key_number_margin_bottom"> - @dimen/dialpad_zero_key_number_default_margin_bottom - </dimen> <dimen name="incall_dialpad_digits_adjustable_text_size">@dimen/dialpad_digits_text_size</dimen> <dimen name="incall_dialpad_digits_adjustable_height">@dimen/dialpad_digits_height</dimen> <dimen name="incall_dialpad_key_numbers_size">@dimen/dialpad_key_numbers_default_size</dimen> diff --git a/java/com/android/incallui/res/values/dimens.xml b/java/com/android/incallui/res/values/dimens.xml index 93102812c..6e3722995 100644 --- a/java/com/android/incallui/res/values/dimens.xml +++ b/java/com/android/incallui/res/values/dimens.xml @@ -20,8 +20,6 @@ from dialer. Note, these are the default sizes for small devices. Larger screen sizes apply the values in values-sw360dp/dimens.xml. --> <dimen name="incall_dialpad_key_number_margin_bottom">1dp</dimen> - <!-- Zero key should have less space between self and text because "+" is smaller --> - <dimen name="incall_dialpad_zero_key_number_margin_bottom">0dp</dimen> <dimen name="incall_dialpad_digits_adjustable_text_size">20sp</dimen> <dimen name="incall_dialpad_digits_adjustable_height">50dp</dimen> <dimen name="incall_dialpad_key_numbers_size">36dp</dimen> diff --git a/java/com/android/incallui/res/values/styles.xml b/java/com/android/incallui/res/values/styles.xml index 5f1aefda1..6a26e9c14 100644 --- a/java/com/android/incallui/res/values/styles.xml +++ b/java/com/android/incallui/res/values/styles.xml @@ -46,9 +46,6 @@ <item name="dialpad_key_number_margin_bottom"> @dimen/incall_dialpad_key_number_margin_bottom </item> - <item name="dialpad_zero_key_number_margin_bottom"> - @dimen/incall_dialpad_zero_key_number_margin_bottom - </item> <item name="dialpad_digits_adjustable_text_size"> @dimen/incall_dialpad_digits_adjustable_text_size </item> |