Commit 17d34dc8 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

TVCallFragment: set title for PIP mode

Change-Id: I59b7369e63abb6b2680e91edd2f357829b6c3376
parent 8006fc41
......@@ -44,6 +44,8 @@ import androidx.appcompat.view.menu.MenuPopupHelper;
import androidx.appcompat.widget.PopupMenu;
import androidx.percentlayout.widget.PercentFrameLayout;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.text.TextUtils;
import android.util.Log;
import android.util.Rational;
......@@ -126,6 +128,8 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
private final AlphaAnimation fadeOutAnimation = new AlphaAnimation(1, 0);
private MediaSessionCompat mSession;
@Inject
DeviceRuntimeService mDeviceRuntimeService;
......@@ -205,17 +209,26 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
}
};
@Override
public void onStart() {
super.onStart();
if (mScreenWakeLock != null && !mScreenWakeLock.isHeld()) {
mScreenWakeLock.acquire();
}
}
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
PowerManager powerManager = (PowerManager) view.getContext().getSystemService(Context.POWER_SERVICE);
mSession = new MediaSessionCompat(requireContext(), TAG);
mSession.setMetadata(new MediaMetadataCompat.Builder()
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, getString(R.string.pip_title))
.build());
PowerManager powerManager = (PowerManager) requireContext().getSystemService(Context.POWER_SERVICE);
mScreenWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "ring:callLock");
mScreenWakeLock.setReferenceCounted(false);
if (mScreenWakeLock != null && !mScreenWakeLock.isHeld()) {
mScreenWakeLock.acquire();
}
binding.videoSurface.getHolder().setFormat(PixelFormat.RGBA_8888);
binding.videoSurface.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
......@@ -256,6 +269,11 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
if (mScreenWakeLock != null && mScreenWakeLock.isHeld()) {
mScreenWakeLock.release();
}
mScreenWakeLock = null;
if (mSession != null) {
mSession.release();
mSession = null;
}
presenter.hangupCall();
runnable = null;
binding = null;
......@@ -397,6 +415,12 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
String ringId = contact.getIds().get(0);
Log.d(TAG, "updateContactBubble: username=" + username + ", ringId=" + ringId + " photo:" + contact.getPhoto());
if (mSession != null) {
mSession.setMetadata(new MediaMetadataCompat.Builder()
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, displayName)
.build());
}
boolean hasProfileName = displayName != null && !displayName.contentEquals(username);
if (hasProfileName) {
binding.contactBubbleNumTxt.setVisibility(View.VISIBLE);
......@@ -466,6 +490,8 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
@Override
public void initNormalStateDisplay(boolean audioOnly, boolean muted) {
mSession.setActive(true);
binding.shapeRipple.stopRipple();
binding.callAcceptBtn.setVisibility(View.GONE);
......@@ -481,6 +507,8 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
@Override
public void initIncomingCallDisplay() {
mSession.setActive(true);
binding.callAcceptBtn.setVisibility(View.VISIBLE);
binding.callAcceptBtn.requestFocus();
binding.callRefuseBtn.setVisibility(View.VISIBLE);
......@@ -710,6 +738,9 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
@Override
public void finish() {
Activity activity = getActivity();
if (mSession != null) {
mSession.setActive(false);
}
if (activity != null) {
if (mBackstackLost) {
activity.finishAndRemoveTask();
......
......@@ -45,6 +45,7 @@ along with this program; if not, write to the Free Software
<string name="license">This software is provided \"as is\", without warranty of any kind. For details, see <u>GNU General Public License version 3 or later</u></string>
<string name="description">Jami is free software for universal communication which respects the freedoms and privacy of its users.</string>
<string name="credits">Credits</string>
<string name="pip_title">Jami Conference</string>
<string name="call_service_description">This service is necessary to keep your calls running in the foreground. It only runs during calls.</string>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment