diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:29:54 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:29:54 +0000 |
commit | 43b3152d075138b11e1fe297682b3bbc775e5641 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/incallui/sessiondata/MultimediaFragment.java | |
parent | 2034759538273aed8a0b412d8fb90994eba1f7ea (diff) | |
parent | 300a8683b9c28424fb0f0c571a0abe128c461f69 (diff) |
Update Dialer to V10 RC16 am: 10b34a5ebf
am: 300a8683b9
Change-Id: If5695bad59f8a4dab6e6c90b54943b900bd2652a
Diffstat (limited to 'java/com/android/incallui/sessiondata/MultimediaFragment.java')
-rw-r--r-- | java/com/android/incallui/sessiondata/MultimediaFragment.java | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/java/com/android/incallui/sessiondata/MultimediaFragment.java b/java/com/android/incallui/sessiondata/MultimediaFragment.java index 14aa0a3aa..85a60b6e3 100644 --- a/java/com/android/incallui/sessiondata/MultimediaFragment.java +++ b/java/com/android/incallui/sessiondata/MultimediaFragment.java @@ -46,7 +46,7 @@ import com.bumptech.glide.request.target.Target; * Displays info from {@link MultimediaData MultimediaData}. * * <p>Currently displays image, location (as a map), and message that come bundled with - * MultimediaData when calling {@link #newInstance(MultimediaData, boolean, boolean)}. + * MultimediaData when calling {@link #newInstance(MultimediaData, boolean, boolean, boolean)}. */ public class MultimediaFragment extends Fragment implements AvatarPresenter { @@ -55,18 +55,24 @@ public class MultimediaFragment extends Fragment implements AvatarPresenter { private static final String ARG_LOCATION = "location"; private static final String ARG_INTERACTIVE = "interactive"; private static final String ARG_SHOW_AVATAR = "show_avatar"; + private static final String ARG_IS_SPAM = "is_spam"; private ImageView avatarImageView; private boolean showAvatar; + private boolean isSpam; public static MultimediaFragment newInstance( - @NonNull MultimediaData multimediaData, boolean isInteractive, boolean showAvatar) { + @NonNull MultimediaData multimediaData, + boolean isInteractive, + boolean showAvatar, + boolean isSpam) { return newInstance( multimediaData.getText(), multimediaData.getImageUri(), multimediaData.getLocation(), isInteractive, - showAvatar); + showAvatar, + isSpam); } @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @@ -75,13 +81,15 @@ public class MultimediaFragment extends Fragment implements AvatarPresenter { @Nullable Uri imageUri, @Nullable Location location, boolean isInteractive, - boolean showAvatar) { + boolean showAvatar, + boolean isSpam) { Bundle args = new Bundle(); args.putString(ARG_SUBJECT, subject); args.putParcelable(ARG_IMAGE, imageUri); args.putParcelable(ARG_LOCATION, location); args.putBoolean(ARG_INTERACTIVE, isInteractive); args.putBoolean(ARG_SHOW_AVATAR, showAvatar); + args.putBoolean(ARG_IS_SPAM, isSpam); MultimediaFragment fragment = new MultimediaFragment(); fragment.setArguments(args); return fragment; @@ -91,12 +99,17 @@ public class MultimediaFragment extends Fragment implements AvatarPresenter { public void onCreate(@Nullable Bundle bundle) { super.onCreate(bundle); showAvatar = getArguments().getBoolean(ARG_SHOW_AVATAR); + isSpam = getArguments().getBoolean(ARG_IS_SPAM); } @Nullable @Override public View onCreateView( LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { + if (isSpam) { + return layoutInflater.inflate(R.layout.fragment_spam, viewGroup, false); + } + boolean hasImage = getImageUri() != null; boolean hasSubject = !TextUtils.isEmpty(getSubject()); boolean hasMap = getLocation() != null; @@ -127,6 +140,21 @@ public class MultimediaFragment extends Fragment implements AvatarPresenter { @Override public void onViewCreated(View view, @Nullable Bundle bundle) { super.onViewCreated(view, bundle); + View container = view.findViewById(R.id.answer_message_container); + if (container != null) { + container.setClipToOutline(true); + } + + // If the call is spam and only has a subject, update the view to reflect that. + if (isSpam + && getLocation() == null + && getImageUri() == null + && !TextUtils.isEmpty(getSubject())) { + ((ImageView) view.findViewById(R.id.spam_image)) + .setImageResource(R.drawable.quantum_ic_message_white_24); + ((TextView) view.findViewById(R.id.spam_text)).setText(R.string.spam_message_text); + } + TextView messageText = (TextView) view.findViewById(R.id.answer_message_text); if (messageText != null) { messageText.setText(getSubject()); @@ -175,7 +203,9 @@ public class MultimediaFragment extends Fragment implements AvatarPresenter { .commitNow(); } avatarImageView = ((ImageView) view.findViewById(R.id.answer_message_avatar)); - avatarImageView.setVisibility(showAvatar ? View.VISIBLE : View.GONE); + if (avatarImageView != null) { + avatarImageView.setVisibility(showAvatar ? View.VISIBLE : View.GONE); + } Holder parent = FragmentUtils.getParent(this, Holder.class); if (parent != null) { |