mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-01 12:11:59 +00:00
enable pip support for CallNotificationActivity
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
7e68ecbde9
commit
e05334cb9a
@ -134,6 +134,7 @@
|
||||
<activity
|
||||
android:name=".activities.CallNotificationActivity"
|
||||
android:theme="@style/AppTheme.CallLauncher"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:launchMode="singleTask"
|
||||
android:taskAffinity=".call"
|
||||
|
@ -2340,33 +2340,6 @@ public class CallActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUiForPipMode(){
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0,0,0, 0);
|
||||
binding.gridview.setLayoutParams(params);
|
||||
|
||||
|
||||
binding.callControls.setVisibility(View.GONE);
|
||||
binding.callInfosLinearLayout.setVisibility(View.GONE);
|
||||
binding.selfVideoViewWrapper.setVisibility(View.GONE);
|
||||
binding.callStates.callStateRelativeLayout.setVisibility(View.GONE);
|
||||
|
||||
binding.selfVideoRenderer.release();
|
||||
}
|
||||
|
||||
public void updateUiForNormalMode(){
|
||||
if (isVoiceOnlyCall) {
|
||||
binding.callControls.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.callControls.setVisibility(View.INVISIBLE); // animateCallControls needs this to be invisible for a check.
|
||||
}
|
||||
initViews();
|
||||
|
||||
binding.callInfosLinearLayout.setVisibility(View.VISIBLE);
|
||||
binding.selfVideoViewWrapper.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private String getDescriptionForCallType() {
|
||||
String appName = getResources().getString(R.string.nc_app_product_name);
|
||||
if (isVoiceOnlyCall) {
|
||||
@ -2474,6 +2447,44 @@ public class CallActivity extends BaseActivity {
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
|
||||
isInPipMode = isInPictureInPictureMode;
|
||||
if (isInPictureInPictureMode) {
|
||||
updateUiForPipMode();
|
||||
} else {
|
||||
updateUiForNormalMode();
|
||||
}
|
||||
}
|
||||
public void updateUiForPipMode(){
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0,0,0, 0);
|
||||
binding.gridview.setLayoutParams(params);
|
||||
|
||||
|
||||
binding.callControls.setVisibility(View.GONE);
|
||||
binding.callInfosLinearLayout.setVisibility(View.GONE);
|
||||
binding.selfVideoViewWrapper.setVisibility(View.GONE);
|
||||
binding.callStates.callStateRelativeLayout.setVisibility(View.GONE);
|
||||
|
||||
binding.selfVideoRenderer.release();
|
||||
}
|
||||
|
||||
public void updateUiForNormalMode(){
|
||||
if (isVoiceOnlyCall) {
|
||||
binding.callControls.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.callControls.setVisibility(View.INVISIBLE); // animateCallControls needs this to be invisible for a check.
|
||||
}
|
||||
initViews();
|
||||
|
||||
binding.callInfosLinearLayout.setVisibility(View.VISIBLE);
|
||||
binding.selfVideoViewWrapper.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
eventBus.post(new ConfigurationChangeEvent());
|
||||
@ -2502,18 +2513,6 @@ public class CallActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
|
||||
isInPipMode = isInPictureInPictureMode;
|
||||
if (isInPictureInPictureMode) {
|
||||
updateUiForPipMode();
|
||||
} else {
|
||||
updateUiForNormalMode();
|
||||
}
|
||||
}
|
||||
|
||||
private class SelfVideoTouchListener implements View.OnTouchListener {
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -21,8 +21,10 @@
|
||||
package com.nextcloud.talk.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.PictureInPictureParams;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
@ -30,10 +32,12 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Rational;
|
||||
import android.view.View;
|
||||
|
||||
import com.bluelinelabs.logansquare.LoganSquare;
|
||||
@ -79,6 +83,7 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import autodagger.AutoInjector;
|
||||
import butterknife.OnClick;
|
||||
@ -118,6 +123,7 @@ public class CallNotificationActivity extends BaseActivity {
|
||||
private boolean leavingScreen = false;
|
||||
private Handler handler;
|
||||
private CallNotificationActivityBinding binding;
|
||||
private Boolean isInPipMode = false;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -357,7 +363,7 @@ public class CallNotificationActivity extends BaseActivity {
|
||||
binding.avatarImageView.getHierarchy().setImage(new BitmapDrawable(bitmap), 100,
|
||||
true);
|
||||
if (getResources() != null) {
|
||||
binding.incomingTextRelativeLayout.setBackground(
|
||||
binding.incomingCallRelativeLayout.setBackground(
|
||||
getResources().getDrawable(R.drawable.incoming_gradient));
|
||||
}
|
||||
|
||||
@ -473,4 +479,51 @@ public class CallNotificationActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBackPressed() {
|
||||
enterPipMode();
|
||||
}
|
||||
|
||||
public void onUserLeaveHint() {
|
||||
enterPipMode();
|
||||
}
|
||||
|
||||
void enterPipMode() {
|
||||
// enableKeyguard();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
enterPictureInPictureMode(getPipParams());
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
public PictureInPictureParams getPipParams() {
|
||||
Rational pipRatio = new Rational(300, 500);
|
||||
return new PictureInPictureParams.Builder()
|
||||
.setAspectRatio(pipRatio)
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
|
||||
isInPipMode = isInPictureInPictureMode;
|
||||
if (isInPictureInPictureMode) {
|
||||
updateUiForPipMode();
|
||||
} else {
|
||||
updateUiForNormalMode();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUiForPipMode(){
|
||||
binding.callAnswerButtons.setVisibility(View.INVISIBLE);
|
||||
binding.incomingCallRelativeLayout.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void updateUiForNormalMode(){
|
||||
binding.callAnswerButtons.setVisibility(View.VISIBLE);
|
||||
binding.incomingCallRelativeLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
@ -35,6 +35,7 @@
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/callAnswerButtons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
@ -75,7 +76,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/incomingTextRelativeLayout"
|
||||
android:id="@+id/incomingCallRelativeLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user