Dialer: Add ability to set full screen photos for calls
@neobuddy89: Refactored and cleaned up.
Change-Id: I90ee1c30f7ab248e9fdb8b94d33434c23b327389
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Signed-off-by: Jis G Jacob <studiokeys@blissroms.org>
diff --git a/assets/quantum/res/drawable/quantum_ic_arrow_drop_down_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_arrow_drop_down_vd_theme_24.xml
new file mode 100644
index 0000000..0c1c4f0
--- /dev/null
+++ b/assets/quantum/res/drawable/quantum_ic_arrow_drop_down_vd_theme_24.xml
@@ -0,0 +1,25 @@
+<!--
+ ~ Copyright (C) 2017 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
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M7,10l5,5 5,-5z"/>
+</vector>
\ No newline at end of file
diff --git a/java/com/android/dialer/app/res/values/cr_strings.xml b/java/com/android/dialer/app/res/values/cr_strings.xml
index c7e92bb..8227977 100644
--- a/java/com/android/dialer/app/res/values/cr_strings.xml
+++ b/java/com/android/dialer/app/res/values/cr_strings.xml
@@ -29,4 +29,8 @@
<string name="smart_category_title">Other options</string>
<string name="smart_mute_title">Smart mute</string>
<string name="smart_mute_summary">Mute the incoming call by flipping the device</string>
+
+ <!-- Full Screen Caller Photo -->
+ <string name="fullscreen_caller_photo_title">Fullscreen photo</string>
+ <string name="fullscreen_caller_photo_summary">Display full-screen photo for incoming and outgoing calls</string>
</resources>
diff --git a/java/com/android/dialer/app/res/xml/display_options_settings.xml b/java/com/android/dialer/app/res/xml/display_options_settings.xml
index 0f424ea..9442dae 100644
--- a/java/com/android/dialer/app/res/xml/display_options_settings.xml
+++ b/java/com/android/dialer/app/res/xml/display_options_settings.xml
@@ -39,4 +39,11 @@
android:defaultValue="@string/display_options_view_given_name_first_value"
app:iconSpaceReserved="false"/>
+ <SwitchPreferenceCompat
+ android:key="fullscreen_caller_photo"
+ android:title="@string/fullscreen_caller_photo_title"
+ android:summary="@string/fullscreen_caller_photo_summary"
+ android:defaultValue="false" />
+ app:iconSpaceReserved="false"/>
+
</PreferenceScreen>
diff --git a/java/com/android/dialer/app/settings/DisplayOptionsSettingsFragment.java b/java/com/android/dialer/app/settings/DisplayOptionsSettingsFragment.java
index 93853ae..a04ec62 100644
--- a/java/com/android/dialer/app/settings/DisplayOptionsSettingsFragment.java
+++ b/java/com/android/dialer/app/settings/DisplayOptionsSettingsFragment.java
@@ -17,17 +17,52 @@
package com.android.dialer.app.settings;
+import android.content.Context;
+import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.Nullable;
+import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceManager;
+import androidx.preference.SwitchPreferenceCompat;
import com.android.dialer.R;
-public class DisplayOptionsSettingsFragment extends PreferenceFragmentCompat {
+public class DisplayOptionsSettingsFragment extends PreferenceFragmentCompat
+ implements Preference.OnPreferenceChangeListener {
+
+ private static final String FULLSCREEN_CALLER_PHOTO = "fullscreen_caller_photo";
+
+ private SharedPreferences mPrefs;
+ private boolean mEnabled;
+
+ private SwitchPreferenceCompat mFullscreenCallerPhoto;
@Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
addPreferencesFromResource(R.xml.display_options_settings);
+
+ Context context = getActivity();
+
+ mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ mFullscreenCallerPhoto = findPreference(FULLSCREEN_CALLER_PHOTO);
+ mFullscreenCallerPhoto.setChecked(mPrefs.getBoolean(FULLSCREEN_CALLER_PHOTO, false));
+ mFullscreenCallerPhoto.setOnPreferenceChangeListener(this);
+
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object objValue) {
+ if (preference == mFullscreenCallerPhoto) {
+ boolean value = (Boolean) objValue;
+ mPrefs
+ .edit()
+ .putBoolean(FULLSCREEN_CALLER_PHOTO, value)
+ .apply();
+ return true;
+ }
+ return false;
}
}
diff --git a/java/com/android/dialer/glidephotomanager/GlidePhotoManager.java b/java/com/android/dialer/glidephotomanager/GlidePhotoManager.java
index 78e61a4..316be53 100644
--- a/java/com/android/dialer/glidephotomanager/GlidePhotoManager.java
+++ b/java/com/android/dialer/glidephotomanager/GlidePhotoManager.java
@@ -40,5 +40,5 @@
* ends.
*/
@MainThread
- void loadContactPhoto(ImageView imageView, PhotoInfo photoInfo);
+ void loadContactPhoto(ImageView imageView, PhotoInfo photoInfo, boolean isFullscreenPhoto);
}
diff --git a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java
index 078a6ce..7c990b2 100644
--- a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java
+++ b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java
@@ -68,12 +68,12 @@
? DefaultLookupUriGenerator.generateUri(photoInfo)
: parseUri(photoInfo.getLookupUri()));
badge.setOverlay(null);
- loadContactPhoto(badge, photoInfo);
+ loadContactPhoto(badge, photoInfo, false);
}
@MainThread
@Override
- public void loadContactPhoto(ImageView imageView, PhotoInfo photoInfo) {
+ public void loadContactPhoto(ImageView imageView, PhotoInfo photoInfo, boolean isFullscreenPhoto) {
Assert.isMainThread();
imageView.setContentDescription(
TextUtils.expandTemplate(
@@ -82,11 +82,11 @@
// and a phone number. We use DialerBidiFormatter to wrap the phone number with TTS
// span.
DialerBidiFormatter.format(photoInfo.getName())));
- GlideRequest<Drawable> request = buildRequest(GlideApp.with(imageView), photoInfo);
+ GlideRequest<Drawable> request = buildRequest(GlideApp.with(imageView), photoInfo, isFullscreenPhoto);
request.into(imageView);
}
- private GlideRequest<Drawable> buildRequest(GlideRequests requestManager, PhotoInfo photoInfo) {
+ private GlideRequest<Drawable> buildRequest(GlideRequests requestManager, PhotoInfo photoInfo, boolean isFullscreenPhoto) {
// Warning: Glide ignores extra attributes on BitmapDrawable such as tint and draw the bitmap
// directly so be sure not to set tint in the XML of any drawable referenced below.
@@ -118,7 +118,7 @@
.placeholder(defaultDrawable) // when the photo is still loading.
.fallback(defaultDrawable); // when there's nothing to load.
- if (circleCrop) {
+ if (circleCrop && !isFullscreenPhoto) {
request.circleCrop();
}
diff --git a/java/com/android/dialer/rtt/RttTranscriptMessageViewHolder.java b/java/com/android/dialer/rtt/RttTranscriptMessageViewHolder.java
index 839d617..5ebf79e 100644
--- a/java/com/android/dialer/rtt/RttTranscriptMessageViewHolder.java
+++ b/java/com/android/dialer/rtt/RttTranscriptMessageViewHolder.java
@@ -68,7 +68,7 @@
avatarImageView.setVisibility(View.VISIBLE);
GlidePhotoManagerComponent.get(container.getContext())
.glidePhotoManager()
- .loadContactPhoto(avatarImageView, photoInfo);
+ .loadContactPhoto(avatarImageView, photoInfo, false);
}
messageTextView.setTextAppearance(R.style.RttTranscriptBubble_Remote);
} else {
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index d3ce392..5cfb19e 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -27,6 +27,7 @@
import android.app.KeyguardManager.KeyguardDismissCallback;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.SharedPreferences;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
@@ -51,6 +52,7 @@
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.fragment.app.Fragment;
+import androidx.preference.PreferenceManager;
import com.android.dialer.R;
import com.android.dialer.common.Assert;
@@ -157,6 +159,7 @@
private ContactGridManager contactGridManager;
private VideoCallScreen answerVideoCallScreen;
private final Handler handler = new Handler(Looper.getMainLooper());
+ private boolean isFullscreenPhoto = false;
private enum SecondaryBehavior {
REJECT_WITH_SMS(
@@ -649,7 +652,15 @@
buttonAcceptClicked = false;
buttonRejectClicked = false;
- View view = inflater.inflate(R.layout.fragment_incoming_call, container, false);
+ SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ isFullscreenPhoto = mPrefs.getBoolean("fullscreen_caller_photo", false);
+
+ int res = R.layout.fragment_incoming_call;
+ if(isFullscreenPhoto){
+ res = R.layout.fragment_incoming_call_fullscreen_photo;
+ }
+
+ View view = inflater.inflate(res, container, false);
secondaryButton = (SwipeButtonView) view.findViewById(R.id.incoming_secondary_button);
answerAndReleaseButton = (SwipeButtonView) view.findViewById(R.id.incoming_secondary_button2);
@@ -1099,7 +1110,14 @@
@Override
public View onCreateView(
LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
- return layoutInflater.inflate(R.layout.fragment_avatar, viewGroup, false);
+ SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ boolean isFullscreenPhoto = mPrefs.getBoolean("fullscreen_caller_photo", false);
+
+ int res = R.layout.fragment_avatar;
+ if(isFullscreenPhoto){
+ res = R.layout.fragment_avatar_fullscreen_photo;
+ }
+ return layoutInflater.inflate(res, viewGroup, false);
}
@Override
diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_avatar_fullscreen_photo.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_avatar_fullscreen_photo.xml
new file mode 100644
index 0000000..5f32dc5
--- /dev/null
+++ b/java/com/android/incallui/answer/impl/res/layout/fragment_avatar_fullscreen_photo.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2016 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
+ -->
+
+<ImageView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@id/contactgrid_avatar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:scaleType="centerCrop"/>
diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml
index 19ebf5d..9611cb5 100644
--- a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml
+++ b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml
@@ -102,9 +102,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
- android:layout_marginStart="24dp"
- android:layout_marginEnd="24dp"
- android:singleLine="true"
+ android:layout_marginStart="@dimen/incall_window_margin_horizontal"
+ android:layout_marginEnd="@dimen/incall_window_margin_horizontal"
+ android:gravity="center"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:singleLine="false"
android:textAppearance="@style/Dialer.Incall.TextAppearance.Large"
android:textSize="@dimen/answer_contact_name_text_size"
app:autoResizeText_minTextSize="@dimen/answer_contact_name_min_size"
diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call_fullscreen_photo.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call_fullscreen_photo.xml
new file mode 100644
index 0000000..1e83dd2
--- /dev/null
+++ b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call_fullscreen_photo.xml
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2016 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
+ -->
+<com.android.incallui.answer.impl.AffordanceHolderLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/incoming_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:keepScreenOn="true">
+
+ <TextureView
+ android:id="@+id/incoming_preview_texture_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:importantForAccessibility="no"
+ android:visibility="gone"/>
+
+ <com.android.incallui.answer.impl.FixedAspectSurfaceView
+ android:id="@+id/incoming_preview_surface_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:importantForAccessibility="no"
+ android:visibility="gone"
+ app:scaleHeight="@bool/scale_height"
+ app:scaleWidth="@bool/scale_width"/>
+
+ <View
+ android:id="@+id/incoming_preview_texture_view_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/videocall_overlay_background_color"
+ android:visibility="gone"/>
+
+ <FrameLayout
+ android:id="@+id/incall_data_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipChildren="false"
+ android:clipToPadding="false"/>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true">
+
+ <FrameLayout
+ android:id="@+id/answer_method_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipChildren="false"
+ android:clipToPadding="false"/>
+
+ <TextView
+ android:id="@+id/videocall_video_off"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:padding="64dp"
+ android:accessibilityTraversalBefore="@+id/videocall_speaker_button"
+ android:drawablePadding="8dp"
+ android:drawableTop="@drawable/quantum_ic_videocam_off_vd_theme_24"
+ android:gravity="center"
+ android:text="@string/call_incoming_video_is_off"
+ android:textAppearance="@style/Dialer.Incall.TextAppearance"
+ android:visibility="gone"/>
+
+ <LinearLayout
+ android:id="@+id/incall_contact_grid"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:focusable="true"
+ android:gravity="top|center_horizontal"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="24dp"
+ android:paddingBottom="8dp"
+ android:gravity="top|center_horizontal"
+ android:background="#55000000"
+ android:orientation="vertical">
+
+ <include
+ android:id="@id/contactgrid_top_row"
+ layout="@layout/incall_contactgrid_top_row"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:layout_marginStart="@dimen/incall_window_margin_horizontal"
+ android:layout_marginEnd="@dimen/incall_window_margin_horizontal"/>
+
+ <!-- We have to keep deprecated singleLine to allow long text being truncated with ellipses.
+ b/31396406 -->
+ <com.android.incallui.autoresizetext.AutoResizeTextView
+ android:id="@id/contactgrid_contact_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:layout_marginStart="@dimen/incall_window_margin_horizontal"
+ android:layout_marginEnd="@dimen/incall_window_margin_horizontal"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:maxLines="2"
+ android:singleLine="false"
+ android:textAppearance="@style/Dialer.Incall.TextAppearance.Large"
+ android:textSize="@dimen/answer_contact_name_text_size"
+ app:autoResizeText_minTextSize="@dimen/answer_contact_name_min_size"
+ tools:ignore="Deprecated"
+ tools:text="Jake Peralta"/>
+
+ <include
+ android:id="@id/contactgrid_bottom_row"
+ layout="@layout/incall_contactgrid_bottom_row"
+ android:layout_below="@+id/contactgrid_contact_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/incall_window_margin_horizontal"
+ android:layout_marginEnd="@dimen/incall_window_margin_horizontal"/>
+ </LinearLayout>
+
+ <!-- TODO(a bug): textColorPrimary or textColorPrimaryInverse? -->
+ <TextView
+ android:id="@+id/incall_important_call_badge"
+ android:textStyle="bold"
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_marginTop="4dp"
+ android:layout_marginBottom="@dimen/answer_importance_margin_bottom"
+ android:background="@drawable/urgent_call_background"
+ android:elevation="@dimen/answer_data_elevation"
+ android:gravity="center"
+ android:maxLines="1"
+ android:text="@string/call_incoming_important"
+ android:textAllCaps="true"
+ android:textColor="?android:attr/colorBackground"
+ android:textSize="14sp"/>
+
+ <FrameLayout
+ android:id="@+id/incall_location_holder"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <LinearLayout
+ android:id="@+id/incall_data_container_chip_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal|bottom"
+ android:orientation="horizontal"
+ android:visibility="gone">
+ </LinearLayout>
+
+ <!-- Space holder for answer method. This is used to get better scaling to make room for
+ incall_data_container on different screen size. -->
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="220dp"/>
+ </LinearLayout>
+ </FrameLayout>
+
+ <com.android.incallui.answer.impl.affordance.SwipeButtonView
+ android:id="@+id/incoming_secondary_button"
+ android:layout_width="56dp"
+ android:layout_height="56dp"
+ android:layout_gravity="bottom|start"
+ android:scaleType="center"
+ android:src="@drawable/quantum_ic_message_vd_theme_24"
+ android:visibility="invisible"
+ tools:visibility="visible"/>
+
+ <com.android.incallui.answer.impl.affordance.SwipeButtonView
+ android:id="@+id/incoming_secondary_button2"
+ android:layout_width="56dp"
+ android:layout_height="56dp"
+ android:layout_gravity="bottom|end"
+ android:scaleType="center"
+ android:src="@drawable/ic_end_answer_32"
+ android:visibility="invisible"
+ tools:visibility="visible"/>
+</com.android.incallui.answer.impl.AffordanceHolderLayout>
diff --git a/java/com/android/incallui/answer/impl/res/values/dimens.xml b/java/com/android/incallui/answer/impl/res/values/dimens.xml
index 0bda9d3..d8ffc5b 100644
--- a/java/com/android/incallui/answer/impl/res/values/dimens.xml
+++ b/java/com/android/incallui/answer/impl/res/values/dimens.xml
@@ -15,8 +15,8 @@
~ limitations under the License
-->
<resources>
- <dimen name="answer_contact_name_text_size">24sp</dimen>
- <dimen name="answer_contact_name_min_size">24sp</dimen>
+ <dimen name="answer_contact_name_text_size">26sp</dimen>
+ <dimen name="answer_contact_name_min_size">18sp</dimen>
<dimen name="answer_avatar_size">0dp</dimen>
<dimen name="answer_importance_margin_bottom">0dp</dimen>
<bool name="answer_important_call_allowed">false</bool>
diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java
index 27142c8..c2e24ed 100644
--- a/java/com/android/incallui/contactgrid/ContactGridManager.java
+++ b/java/com/android/incallui/contactgrid/ContactGridManager.java
@@ -18,6 +18,7 @@
package com.android.incallui.contactgrid;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
@@ -35,6 +36,7 @@
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
+import androidx.preference.PreferenceManager;
import com.android.dialer.R;
import com.android.dialer.common.Assert;
@@ -42,6 +44,7 @@
import com.android.dialer.glidephotomanager.GlidePhotoManagerComponent;
import com.android.dialer.glidephotomanager.PhotoInfo;
import com.android.dialer.widget.BidiTextView;
+import com.android.incallui.autoresizetext.AutoResizeTextView;
import com.android.incallui.incall.protocol.ContactPhotoType;
import com.android.incallui.incall.protocol.PrimaryCallState;
import com.android.incallui.incall.protocol.PrimaryInfo;
@@ -97,6 +100,8 @@
private PrimaryCallState primaryCallState = PrimaryCallState.empty();
private boolean isInMultiWindowMode;
+ private boolean isFullscreenPhoto = false;
+
public ContactGridManager(View view, @Nullable ImageView avatarImageView, int avatarSize,
boolean showAnonymousAvatar) {
context = view.getContext();
@@ -123,6 +128,9 @@
deviceNumberTextView = view.findViewById(R.id.contactgrid_device_number_text);
deviceNumberDivider = view.findViewById(R.id.contactgrid_location_divider);
+
+ SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ isFullscreenPhoto = mPrefs.getBoolean("fullscreen_caller_photo", false);
}
public void show() {
@@ -292,10 +300,14 @@
// Set direction of the name field
int nameDirection = View.TEXT_DIRECTION_INHERIT;
+ boolean singleLine = false;
if (primaryInfo.nameIsNumber()) {
nameDirection = View.TEXT_DIRECTION_LTR;
+ singleLine = true;
}
contactNameTextView.setTextDirection(nameDirection);
+ contactNameTextView.setSingleLine(singleLine);
+ ((AutoResizeTextView)contactNameTextView).setMaxLines(2);
}
if (avatarImageView != null) {
@@ -336,7 +348,7 @@
GlidePhotoManagerComponent.get(context)
.glidePhotoManager()
- .loadContactPhoto(avatarImageView, photoInfoBuilder.build());
+ .loadContactPhoto(avatarImageView, photoInfoBuilder.build(), isFullscreenPhoto);
}
/**
diff --git a/java/com/android/incallui/incall/impl/CheckableLabeledButton.java b/java/com/android/incallui/incall/impl/CheckableLabeledButton.java
index 4cb8132..f0ba166 100644
--- a/java/com/android/incallui/incall/impl/CheckableLabeledButton.java
+++ b/java/com/android/incallui/incall/impl/CheckableLabeledButton.java
@@ -120,7 +120,8 @@
labelView.setLayoutParams(labelParams);
labelView.setTextAppearance(R.style.Dialer_Incall_TextAppearance_Label);
labelView.setText(labelText);
- labelView.setSingleLine();
+ labelView.setSingleLine(false);
+ labelView.setMaxLines(2);
labelView.setMaxEms(9);
labelView.setEllipsize(TruncateAt.END);
labelView.setGravity(Gravity.CENTER);
diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java
index ed194f4..042dd4d 100644
--- a/java/com/android/incallui/incall/impl/InCallFragment.java
+++ b/java/com/android/incallui/incall/impl/InCallFragment.java
@@ -23,6 +23,8 @@
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.SharedPreferences;
+import android.graphics.Color;
import android.graphics.Insets;
import android.os.Bundle;
import android.os.Handler;
@@ -48,6 +50,7 @@
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
+import androidx.preference.PreferenceManager;
import com.android.dialer.R;
import com.android.dialer.common.Assert;
@@ -63,6 +66,7 @@
import com.android.incallui.incall.impl.ButtonController.SpeakerButtonController;
import com.android.incallui.incall.impl.ButtonController.UpgradeToRttButtonController;
import com.android.incallui.incall.impl.InCallButtonGridFragment.OnButtonGridCreatedListener;
+import com.android.incallui.incall.protocol.ContactPhotoType;
import com.android.incallui.incall.protocol.InCallButtonIds;
import com.android.incallui.incall.protocol.InCallButtonIdsExtension;
import com.android.incallui.incall.protocol.InCallButtonUi;
@@ -103,6 +107,8 @@
private int phoneType;
private boolean stateRestored;
private boolean userDeniedBluetooth;
+ private View topPhoneContainer;
+ private boolean isFullscreenPhoto = false;
private final ActivityResultLauncher<String[]> permissionLauncher = registerForActivityResult(
new ActivityResultContracts.RequestMultiplePermissions(),
@@ -178,8 +184,18 @@
@Nullable Bundle bundle) {
LogUtil.i("InCallFragment.onCreateView", null);
getActivity().setTheme(R.style.Theme_InCallScreen);
- // Bypass to avoid StrictModeResourceMismatchViolation
- final View view = layoutInflater.inflate(R.layout.frag_incall_voice, viewGroup, false);
+
+ SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ isFullscreenPhoto = mPrefs.getBoolean("fullscreen_caller_photo", false);
+
+ final int res = isFullscreenPhoto ? R.layout.frag_incall_voice_fullscreen_photo :
+ R.layout.frag_incall_voice;
+ final View view = layoutInflater.inflate(res, viewGroup, false);
+
+ if (isFullscreenPhoto) {
+ topPhoneContainer = view.findViewById(R.id.incall_contactgrid_container);
+ }
+
contactGridManager =
new ContactGridManager(
view,
@@ -294,6 +310,15 @@
LogUtil.i("InCallFragment.setPrimary", primaryInfo.toString());
setAdapterMedia(primaryInfo.multimediaData(), primaryInfo.showInCallButtonGrid());
contactGridManager.setPrimary(primaryInfo);
+
+ if (topPhoneContainer != null) {
+ boolean hasPhoto = primaryInfo.photo() != null && primaryInfo.photoType() == ContactPhotoType.CONTACT;
+ if (hasPhoto) {
+ topPhoneContainer.setBackgroundColor(0x55000000);
+ } else {
+ topPhoneContainer.setBackgroundColor(Color.TRANSPARENT);
+ }
+ }
}
private void setAdapterMedia(MultimediaData multimediaData, boolean showInCallButtonGrid) {
diff --git a/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml
index 45870f3..9b7063a 100644
--- a/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml
+++ b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml
@@ -60,9 +60,13 @@
android:layout_marginBottom="4dp"
android:layout_marginStart="@dimen/incall_window_margin_horizontal"
android:layout_marginEnd="@dimen/incall_window_margin_horizontal"
- android:singleLine="true"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:maxLines="2"
+ android:singleLine="false"
android:textAppearance="@style/Dialer.Incall.TextAppearance.Large"
- app:autoResizeText_minTextSize="28sp"
+ android:textSize="@dimen/answer_contact_name_text_size"
+ app:autoResizeText_minTextSize="@dimen/answer_contact_name_min_size"
tools:ignore="Deprecated"
tools:text="Jake Peralta"/>
diff --git a/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice_fullscreen_photo.xml b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice_fullscreen_photo.xml
new file mode 100644
index 0000000..76e5a36
--- /dev/null
+++ b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice_fullscreen_photo.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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
+ -->
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <RelativeLayout
+ android:id="@+id/incall_ui_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipChildren="false"
+ android:clipToPadding="false" >
+
+ <RelativeLayout
+ android:id="@id/incall_contact_grid"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal">
+
+ <ImageView
+ android:id="@id/contactgrid_avatar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop"/>
+
+ <RelativeLayout
+ android:id="@+id/incall_contactgrid_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:background="#55000000"
+ android:paddingTop="24dp"
+ android:paddingBottom="8dp">
+
+ <include
+ android:id="@id/contactgrid_top_row"
+ layout="@layout/incall_contactgrid_top_row"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_marginBottom="8dp"
+ android:layout_marginStart="@dimen/incall_window_margin_horizontal"
+ android:layout_marginEnd="@dimen/incall_window_margin_horizontal"/>
+ <!-- We have to keep deprecated singleLine to allow long text being truncated with ellipses.
+ b/31396406 -->
+ <com.android.incallui.autoresizetext.AutoResizeTextView
+ android:id="@id/contactgrid_contact_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_centerInParent="true"
+ android:layout_marginTop="36dp"
+ android:layout_marginStart="@dimen/incall_window_margin_horizontal"
+ android:layout_marginEnd="@dimen/incall_window_margin_horizontal"
+ android:layout_marginBottom="4dp"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:maxLines="2"
+ android:singleLine="false"
+ android:textAppearance="@style/Dialer.Incall.TextAppearance.Large"
+ android:textSize="@dimen/answer_contact_name_text_size"
+ app:autoResizeText_minTextSize="@dimen/answer_contact_name_min_size"
+ tools:text="Jake Peralta"
+ tools:ignore="Deprecated"/>
+
+ <include
+ android:id="@id/contactgrid_bottom_row"
+ layout="@layout/incall_contactgrid_bottom_row"
+ android:layout_below="@+id/contactgrid_contact_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"/>
+ </RelativeLayout>
+ <FrameLayout
+ android:id="@+id/incall_location_holder"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+ </RelativeLayout>
+
+ <com.android.dialer.widget.LockableViewPager
+ android:id="@+id/incall_pager"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_above="@+id/incall_paginator"
+ android:layout_centerHorizontal="true"/>
+
+ <com.android.incallui.incall.impl.InCallPaginator
+ android:id="@+id/incall_paginator"
+ android:layout_width="@dimen/paginator_width"
+ android:layout_height="@dimen/paginator_height"
+ android:layout_above="@+id/incall_end_call"
+ android:layout_centerHorizontal="true"
+ android:visibility="gone"/>
+
+ <FrameLayout
+ android:id="@+id/incall_dialpad_container"
+ style="@style/DialpadContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ tools:background="@android:color/white"
+ tools:visibility="gone"/>
+ <ImageButton
+ android:id="@+id/incall_end_call"
+ style="@style/Incall.Button.End"
+ android:layout_marginTop="36dp"
+ android:layout_marginBottom="36dp"
+ android:layout_alignParentBottom="true"
+ android:layout_centerHorizontal="true"
+ android:contentDescription="@string/incall_content_description_end_call"/>
+ </RelativeLayout>
+
+ <FrameLayout
+ android:id="@id/incall_on_hold_banner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"/>
+</FrameLayout>
diff --git a/java/com/android/incallui/incall/impl/res/layout/incall_button_grid.xml b/java/com/android/incallui/incall/impl/res/layout/incall_button_grid.xml
index 59e9944..0cb564c 100644
--- a/java/com/android/incallui/incall/impl/res/layout/incall_button_grid.xml
+++ b/java/com/android/incallui/incall/impl/res/layout/incall_button_grid.xml
@@ -10,7 +10,7 @@
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center"
+ android:layout_gravity="center_horizontal|bottom"
android:columnCount="3"
android:orientation="horizontal">
<com.android.incallui.incall.impl.CheckableLabeledButton
diff --git a/java/com/android/incallui/incall/impl/res/values-h650dp/styles.xml b/java/com/android/incallui/incall/impl/res/values-h650dp/styles.xml
index b58ef48..c9c7e71 100644
--- a/java/com/android/incallui/incall/impl/res/values-h650dp/styles.xml
+++ b/java/com/android/incallui/incall/impl/res/values-h650dp/styles.xml
@@ -18,7 +18,6 @@
<resources>
<style name="DialpadContainer">
- <item name="android:layout_below">@id/incall_contact_grid</item>
<item name="android:layout_marginTop">8dp</item>
</style>
</resources>
diff --git a/java/com/android/incallui/incall/impl/res/values/styles.xml b/java/com/android/incallui/incall/impl/res/values/styles.xml
index a8cf2dd..cfb76e1 100644
--- a/java/com/android/incallui/incall/impl/res/values/styles.xml
+++ b/java/com/android/incallui/incall/impl/res/values/styles.xml
@@ -21,6 +21,5 @@
<color name="paginator_path">#66FFFFFF</color>
<style name="DialpadContainer">
- <item name="android:layout_alignParentTop">true</item>
</style>
</resources>
diff --git a/java/com/android/incallui/theme/res/values/styles.xml b/java/com/android/incallui/theme/res/values/styles.xml
index bfedd14..abfce0a 100644
--- a/java/com/android/incallui/theme/res/values/styles.xml
+++ b/java/com/android/incallui/theme/res/values/styles.xml
@@ -29,6 +29,7 @@
<item name="android:windowBackground">@color/dialer_theme_color_dark</item>
<item name="android:windowShowWallpaper">true</item>
<item name="bottomSheetDialogTheme">@style/TransparentBottomSheetDialogTheme</item>
+ <item name="android:windowTranslucentStatus">true</item>
</style>
<style name="Theme.InCallScreen.ManageConference" parent="Dialer.ThemeBase.ActionBar">
diff --git a/java/com/android/incallui/video/impl/res/layout/video_contact_grid.xml b/java/com/android/incallui/video/impl/res/layout/video_contact_grid.xml
index 56797d9..3146a85 100644
--- a/java/com/android/incallui/video/impl/res/layout/video_contact_grid.xml
+++ b/java/com/android/incallui/video/impl/res/layout/video_contact_grid.xml
@@ -34,7 +34,12 @@
android:id="@id/contactgrid_contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:singleLine="true"
+ android:layout_marginStart="@dimen/incall_window_margin_horizontal"
+ android:layout_marginEnd="@dimen/incall_window_margin_horizontal"
+ android:gravity="center"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:singleLine="false"
android:textAppearance="@style/Dialer.Incall.TextAppearance.Large"
app:autoResizeText_minTextSize="28sp"
tools:text="Jake Peralta"