diff options
Diffstat (limited to 'java')
6 files changed, 58 insertions, 46 deletions
diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java index c1ffbd396..2561e28cd 100644 --- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java +++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java @@ -29,6 +29,7 @@ import android.telephony.TelephonyManager; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProvider; import com.android.dialer.configprovider.ConfigProviderBindings; +import com.android.dialer.strictmode.StrictModeUtils; /** * A Creator for AssistedDialingMediators. @@ -90,8 +91,11 @@ public final class ConcreteCreator { return new AssistedDialingMediatorImpl( new LocationDetector( telephonyManager, - PreferenceManager.getDefaultSharedPreferences(context) - .getString(context.getString(R.string.assisted_dialing_setting_cc_key), null)), + StrictModeUtils.bypass( + () -> + PreferenceManager.getDefaultSharedPreferences(context) + .getString( + context.getString(R.string.assisted_dialing_setting_cc_key), null))), new NumberTransformer(constraints)); } diff --git a/java/com/android/dialer/assisteddialing/Constraints.java b/java/com/android/dialer/assisteddialing/Constraints.java index f95312a21..788b875ff 100644 --- a/java/com/android/dialer/assisteddialing/Constraints.java +++ b/java/com/android/dialer/assisteddialing/Constraints.java @@ -25,6 +25,7 @@ import android.text.TextUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; +import com.android.dialer.strictmode.StrictModeUtils; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; @@ -36,7 +37,7 @@ import java.util.Optional; @TargetApi(VERSION_CODES.N) @SuppressWarnings("AndroidApiChecker") // Use of optional final class Constraints { - private final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); + private final PhoneNumberUtil phoneNumberUtil; private final Context context; private final CountryCodeProvider countryCodeProvider; @@ -56,10 +57,8 @@ final class Constraints { throw new NullPointerException("Provided configProviderCountryCodes cannot be null"); } - // We allow dynamic country support only in Dialer; this should be removed in the framework - // implementation. - // TODO(erfanian): Remove in the framework implementation. this.countryCodeProvider = countryCodeProvider; + this.phoneNumberUtil = StrictModeUtils.bypass(() -> PhoneNumberUtil.getInstance()); } /** @@ -148,16 +147,18 @@ final class Constraints { */ private Optional<PhoneNumber> parsePhoneNumber( @NonNull String numberToParse, @NonNull String userHomeCountryCode) { - try { - // TODO(erfanian): confirm behavior of blocking the foreground thread when moving to the - // framework - return Optional.of(phoneNumberUtil.parseAndKeepRawInput(numberToParse, userHomeCountryCode)); - } catch (NumberParseException e) { - Logger.get(context) - .logImpression(DialerImpression.Type.ASSISTED_DIALING_CONSTRAINT_PARSING_FAILURE); - LogUtil.i("Constraints.parsePhoneNumber", "could not parse the number"); - return Optional.empty(); - } + return StrictModeUtils.bypass( + () -> { + try { + return Optional.of( + phoneNumberUtil.parseAndKeepRawInput(numberToParse, userHomeCountryCode)); + } catch (NumberParseException e) { + Logger.get(context) + .logImpression(DialerImpression.Type.ASSISTED_DIALING_CONSTRAINT_PARSING_FAILURE); + LogUtil.i("Constraints.parsePhoneNumber", "could not parse the number"); + return Optional.empty(); + } + }); } /** Returns a boolean indicating if the provided number is already internationally formatted. */ @@ -195,7 +196,8 @@ final class Constraints { /** Returns a boolean indicating if the provided number is considered to be a valid number. */ private boolean isValidNumber(@NonNull Optional<PhoneNumber> parsedPhoneNumber) { - boolean result = PhoneNumberUtil.getInstance().isValidNumber(parsedPhoneNumber.get()); + boolean result = + StrictModeUtils.bypass(() -> phoneNumberUtil.isValidNumber(parsedPhoneNumber.get())); LogUtil.i("Constraints.isValidNumber", String.valueOf(result)); return result; diff --git a/java/com/android/dialer/assisteddialing/NumberTransformer.java b/java/com/android/dialer/assisteddialing/NumberTransformer.java index 0156f2ec2..8bbad329d 100644 --- a/java/com/android/dialer/assisteddialing/NumberTransformer.java +++ b/java/com/android/dialer/assisteddialing/NumberTransformer.java @@ -21,6 +21,7 @@ import android.os.Build.VERSION_CODES; import android.support.annotation.NonNull; import android.text.TextUtils; import com.android.dialer.common.LogUtil; +import com.android.dialer.strictmode.StrictModeUtils; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; @@ -29,11 +30,12 @@ import java.util.Optional; /** Responsible for transforming numbers to make them dialable and valid when roaming. */ final class NumberTransformer { - private final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); + private final PhoneNumberUtil phoneNumberUtil; private final Constraints constraints; public NumberTransformer(Constraints constraints) { this.constraints = constraints; + this.phoneNumberUtil = StrictModeUtils.bypass(() -> PhoneNumberUtil.getInstance()); } /** @@ -68,16 +70,27 @@ final class NumberTransformer { return Optional.empty(); } - PhoneNumber phoneNumber; - try { - phoneNumber = phoneNumberUtil.parse(numbertoTransform, userHomeCountryCode); - } catch (NumberParseException e) { - LogUtil.i("NumberTransformer.doAssistedDialingTransformation", "number failed to parse"); + PhoneNumber phoneNumber = + StrictModeUtils.bypass( + () -> { + try { + return phoneNumberUtil.parse(numbertoTransform, userHomeCountryCode); + } catch (NumberParseException e) { + LogUtil.i( + "NumberTransformer.doAssistedDialingTransformation", "number failed to parse"); + return null; + } + }); + + if (phoneNumber == null) { return Optional.empty(); } String transformedNumber = - phoneNumberUtil.formatNumberForMobileDialing(phoneNumber, userRoamingCountryCode, true); + StrictModeUtils.bypass( + () -> + phoneNumberUtil.formatNumberForMobileDialing( + phoneNumber, userRoamingCountryCode, true)); // formatNumberForMobileDialing may return an empty String. if (TextUtils.isEmpty(transformedNumber)) { diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java index 2e98ad17b..54e56ba61 100644 --- a/java/com/android/newbubble/NewBubble.java +++ b/java/com/android/newbubble/NewBubble.java @@ -25,7 +25,6 @@ import android.annotation.SuppressLint; import android.app.PendingIntent.CanceledException; import android.content.Context; import android.content.Intent; -import android.graphics.Outline; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.Animatable; @@ -47,7 +46,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.AccessibilityDelegate; import android.view.ViewGroup; -import android.view.ViewOutlineProvider; import android.view.ViewTreeObserver.OnPreDrawListener; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; @@ -525,7 +523,7 @@ public class NewBubble { public void updateAvatar(@NonNull Drawable avatar) { if (!avatar.equals(currentInfo.getAvatar())) { currentInfo = NewBubbleInfo.from(currentInfo).setAvatar(avatar).build(); - viewHolder.getPrimaryAvatar().setImageDrawable(currentInfo.getAvatar()); + viewHolder.getPrimaryAvatar().setBackground(currentInfo.getAvatar()); } } @@ -560,7 +558,7 @@ public class NewBubble { savedYPosition = -1; viewHolder - .getPrimaryButton() + .getPrimaryAvatar() .animate() .translationZ( context @@ -569,7 +567,7 @@ public class NewBubble { } void onMoveFinish() { - viewHolder.getPrimaryButton().animate().translationZ(0); + viewHolder.getPrimaryAvatar().animate().translationZ(0); } void primaryButtonClick() { @@ -669,17 +667,9 @@ public class NewBubble { primaryIconMoveDistance = context.getResources().getDimensionPixelSize(R.dimen.bubble_size) - context.getResources().getDimensionPixelSize(R.dimen.bubble_small_icon_size); - // Set boundary for primary button to show elevation (background is transparent) - viewHolder - .getPrimaryButton() - .setOutlineProvider( - new ViewOutlineProvider() { - @Override - public void getOutline(View view, Outline outline) { - ViewOutlineProvider.BACKGROUND.getOutline(view, outline); - outline.setAlpha(1); - } - }); + + // Avatar + viewHolder.getPrimaryAvatar().setBackground(currentInfo.getAvatar()); // Small icon Drawable smallIconBackgroundCircle = @@ -689,7 +679,6 @@ public class NewBubble { smallIconBackgroundCircle.setTint(context.getColor(R.color.bubble_button_color_blue)); viewHolder.getPrimaryIcon().setBackground(smallIconBackgroundCircle); viewHolder.getPrimaryIcon().setImageIcon(currentInfo.getPrimaryIcon()); - viewHolder.getPrimaryAvatar().setImageDrawable(currentInfo.getAvatar()); updatePrimaryIconAnimation(); updateButtonStates(); @@ -873,6 +862,9 @@ public class NewBubble { xValueAnimator.setInterpolator(new LinearOutSlowInInterpolator()); xValueAnimator.addUpdateListener( (valueAnimator) -> { + if (windowParams == null) { + return; + } // Update windowParams and the root layout. // We can't do ViewPropertyAnimation since it clips children. float newX = (float) valueAnimator.getAnimatedValue(); diff --git a/java/com/android/newbubble/res/layout/new_bubble_base.xml b/java/com/android/newbubble/res/layout/new_bubble_base.xml index c86d3bbcc..9b8250d6b 100644 --- a/java/com/android/newbubble/res/layout/new_bubble_base.xml +++ b/java/com/android/newbubble/res/layout/new_bubble_base.xml @@ -40,14 +40,13 @@ android:layout_marginTop="@dimen/bubble_shadow_padding_size_vertical" android:layout_marginBottom="@dimen/bubble_shadow_padding_size_vertical" android:contentDescription="@string/a11y_bubble_description" - android:background="@drawable/bubble_shape_circle" - android:measureAllChildren="false" - android:elevation="@dimen/bubble_elevation"> + android:measureAllChildren="false"> <ImageView android:id="@+id/bubble_icon_avatar" android:layout_width="@dimen/bubble_size" android:layout_height="@dimen/bubble_size" - tools:src="@android:drawable/ic_btn_speak_now"/> + android:background="@android:drawable/ic_btn_speak_now" + android:elevation="@dimen/bubble_elevation"/> <ImageView android:id="@+id/bubble_icon_primary" android:layout_width="@dimen/bubble_small_icon_size" @@ -59,7 +58,8 @@ android:background="@drawable/bubble_shape_circle_small" android:measureAllChildren="false" tools:backgroundTint="#FF0000AA" - tools:src="@android:drawable/ic_btn_speak_now"/> + tools:src="@android:drawable/ic_btn_speak_now" + android:elevation="@dimen/bubble_dragging_elevation"/> </FrameLayout> </RelativeLayout> <!-- The RelativeLayout below serves as boundary for @id/bubble_expanded_layout during animation --> diff --git a/java/com/android/newbubble/res/values/values.xml b/java/com/android/newbubble/res/values/values.xml index 2e72c5e5e..f449c9bed 100644 --- a/java/com/android/newbubble/res/values/values.xml +++ b/java/com/android/newbubble/res/values/values.xml @@ -19,6 +19,7 @@ <dimen name="bubble_size">56dp</dimen> <dimen name="bubble_icon_padding">16dp</dimen> <dimen name="bubble_dragging_elevation_change">6dp</dimen> + <dimen name="bubble_dragging_elevation">12dp</dimen> <dimen name="bubble_button_height">36dp</dimen> <dimen name="bubble_button_icon_padding">16dp</dimen> |