1.修改电影房出现的不能横屏的问题

This commit is contained in:
2025-09-24 18:55:47 +08:00
parent ea82b59b0a
commit a0ecafbbd7
4 changed files with 134 additions and 39 deletions

View File

@@ -29,8 +29,8 @@ isBuildModule=false
#org.gradle.deamon=false
android.injected.testOnly=false
APP_VERSION_NAME=1.0.5
APP_VERSION_CODE=158
APP_VERSION_NAME=1.0.6
APP_VERSION_CODE=159
org.gradle.jvm.toolchain.useLegacyAdapters=false
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15

View File

@@ -96,6 +96,9 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
public String playId;
public String lable_id;
public boolean isMicPlace;
public boolean isShowAg;
public String playCover;
public boolean showSelf;//盲盒是否能送自己
public String playName;

View File

@@ -424,7 +424,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
// // 保持Activity alive不调用finish()
// minimizeToBackground();
// }
if (mRoomInfoResp!=null) {
if (mRoomInfoResp != null) {
if (!mRoomInfoResp.getRoom_info().getType_id().equals("6")) {
// 只有在用户主动离开应用时才执行最小化操作
if (!userLeaving) {
@@ -1162,13 +1162,67 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
if (isFullScreen) {
exitFullScreen();
} else {
enterFullScreen();
// enterFullScreen();
// 修改为横屏展示模式而不是全屏模式
enterLandscapeMode();
}
}
private void enterLandscapeMode() {
isFullScreen = true;
// 设置横屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
if (floatingMagnetView != null) {
// 修改Floa组件的布局参数使其在横屏时占据更大区域
ViewGroup.LayoutParams layoutParams = floatingMagnetView.getLayoutParams();
if (layoutParams instanceof ConstraintLayout.LayoutParams) {
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) layoutParams;
params.width = ConstraintLayout.LayoutParams.MATCH_CONSTRAINT;
params.height = ConstraintLayout.LayoutParams.MATCH_CONSTRAINT;
params.horizontalBias = 0.5f;
params.verticalBias = 0.5f;
floatingMagnetView.setLayoutParams(params);
} else {
// 如果不是ConstraintLayout.LayoutParams创建新的
ConstraintLayout.LayoutParams params = new ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_CONSTRAINT,
ConstraintLayout.LayoutParams.MATCH_CONSTRAINT
);
params.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
params.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
params.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
params.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
floatingMagnetView.setLayoutParams(params);
}
// 可以调整内部fl_screenshare的布局参数
FrameLayout flScreenshare = floatingMagnetView.findViewById(R.id.fl_screenshare);
ViewGroup.LayoutParams screenParams = flScreenshare.getLayoutParams();
if (!(screenParams instanceof FrameLayout.LayoutParams)) {
// 如果不是FrameLayout.LayoutParams创建新的
FrameLayout.LayoutParams newScreenParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
);
flScreenshare.setLayoutParams(newScreenParams);
} else {
FrameLayout.LayoutParams newScreenParams = (FrameLayout.LayoutParams) screenParams;
newScreenParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
newScreenParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
flScreenshare.setLayoutParams(newScreenParams);
}
// 显示退出按钮
ivQuan.setVisibility(View.VISIBLE);
}
}
private void enterFullScreen() {
isFullScreen = true;
// 隐藏系统UI
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
@@ -1194,46 +1248,77 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
safelyMoveViewToParent(fl_screenshare, floatingMagnetView);
// 显示全屏容器
fullScreenContainer.setVisibility(View.VISIBLE);
// floatingMagnetView.setVisibility(View.GONE);
floatingMagnetView.setVisibility(View.GONE);
ivExitFullscreen.setVisibility(View.VISIBLE); // 显示退出按钮
}
}
private void exitFullScreen() {
isFullScreen = false;
// 恢复系统UI
View decorView = getWindow().getDecorView();
// decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
// 设置回竖屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
// 找到 fl_screenshare 并移回原父容器
FrameLayout fl_screenshare = findViewById(R.id.fl_screenshare);
if (fl_screenshare != null) {
safelyMoveViewToParent(fl_screenshare, fullScreenContainer);
// ViewParent parent = fl_screenshare.getParent();
// if (parent instanceof ViewGroup) {
// ((ViewGroup) parent).removeView(fl_screenshare);
// }
// // 添加到全屏容器
// fullScreenContainer.addView(fl_screenshare);
// 找到原始父容器并重新添加
// FrameLayout originalParent = findViewById(R.id.fullscreen_container); // 或者你实际的容器
// if (originalParent != null) {
// originalParent.removeView(fl_screenshare); // 防止重复添加
// }
// floatingMagnetView.addView(fl_screenshare);
if (floatingMagnetView != null) {
// 恢复原始尺寸
ConstraintLayout.LayoutParams params = new ConstraintLayout.LayoutParams(
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_240),
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_135)
);
params.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
params.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
params.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
params.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
floatingMagnetView.setLayoutParams(params);
// 恢复内部fl_screenshare的布局参数
FrameLayout flScreenshare = floatingMagnetView.findViewById(R.id.fl_screenshare);
FrameLayout.LayoutParams screenParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
);
flScreenshare.setLayoutParams(screenParams);
}
// 恢复界面
fullScreenContainer.setVisibility(View.GONE);
floatingMagnetView.setVisibility(View.VISIBLE);
ivQuan.setVisibility(View.VISIBLE);
ivExitFullscreen.setVisibility(View.GONE); // 隐藏退出按钮
// 隐藏退出按钮
ivExitFullscreen.setVisibility(View.GONE);
// isFullScreen = false;
// // 恢复系统UI
// View decorView = getWindow().getDecorView();
//// decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// decorView.setSystemUiVisibility(
// View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// );
// // 设置回竖屏
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
// // 找到 fl_screenshare 并移回原父容器
// FrameLayout fl_screenshare = findViewById(R.id.fl_screenshare);
// if (fl_screenshare != null) {
// safelyMoveViewToParent(fl_screenshare, fullScreenContainer);
//// ViewParent parent = fl_screenshare.getParent();
//// if (parent instanceof ViewGroup) {
//// ((ViewGroup) parent).removeView(fl_screenshare);
//// }
//// // 添加到全屏容器
//// fullScreenContainer.addView(fl_screenshare);
// // 找到原始父容器并重新添加
//// FrameLayout originalParent = findViewById(R.id.fullscreen_container); // 或者你实际的容器
//// if (originalParent != null) {
//// originalParent.removeView(fl_screenshare); // 防止重复添加
//// }
//
//// floatingMagnetView.addView(fl_screenshare);
// }
// // 恢复界面
// fullScreenContainer.setVisibility(View.GONE);
// floatingMagnetView.setVisibility(View.VISIBLE);
// ivQuan.setVisibility(View.VISIBLE);
// ivExitFullscreen.setVisibility(View.GONE); // 隐藏退出按钮
}
@Override
@@ -1471,7 +1556,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
.commitAllowingStateLoss();
}
roomFragment.handleMsgType1028(messageEvent);
}else if ( msgType == 1058) {
} else if (msgType == 1058) {
if (roomFragment == null) {
roomFragment = RoomFragment.newInstance();
getSupportFragmentManager()
@@ -2627,8 +2712,8 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
return true;
}
}
}else {
return true ;
} else {
return true;
}
return false;
}

View File

@@ -210,8 +210,12 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
}
});
if (!CommonAppContext.getInstance().isShowAg){
switchMic(1);
}else {
isShow = true;
switchMic(2);
}
mBinding.im3.setOnClickListener(new View.OnClickListener() {
@@ -344,6 +348,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(false);
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(true,SpUtil.getUserId()+"");
isShow = false;
CommonAppContext.getInstance().isShowAg=false;
} else {
mBinding.im1.setImageResource(com.xscm.moduleutil.R.mipmap.op_m);
@@ -351,6 +356,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(true);
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(false,SpUtil.getUserId()+"");
isShow = true;
CommonAppContext.getInstance().isShowAg=true;
}
}
@@ -831,5 +837,6 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
mediaProjection[0].stop();
mediaProjection[0] = null;
}
}
}