浏览代码

修改网络教室退出弹窗全屏问题

Pq 1 年之前
父节点
当前提交
8a74b44670

+ 56 - 0
BaseLibrary/src/main/java/com/cooleshow/base/widgets/dialog/BaseFullDialog.java

@@ -0,0 +1,56 @@
+package com.cooleshow.base.widgets.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+import com.cooleshow.base.R;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Author by pq, Date on 2023/9/11.
+ */
+public class BaseFullDialog extends Dialog {
+    public BaseFullDialog(@NonNull Context context) {
+        this(context, R.style.BaseDialog);
+    }
+
+    public BaseFullDialog(@NonNull Context context, int themeResId) {
+        super(context, themeResId);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        hideNavigationBar();
+        adjustFullScreen(getWindow());
+    }
+
+    private void hideNavigationBar() {
+        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                | View.SYSTEM_UI_FLAG_IMMERSIVE
+                | View.SYSTEM_UI_FLAG_FULLSCREEN;
+        this.getWindow().getDecorView().setSystemUiVisibility(uiOptions);
+    }
+    public void adjustFullScreen(Window window) {
+        if (window == null) {
+            return;
+        }
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+            WindowManager.LayoutParams lp = window.getAttributes();
+            lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
+            window.setAttributes(lp);
+            final View decorView = window.getDecorView();
+            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+        }
+    }
+}

+ 6 - 7
classRoom/src/main/java/com/dayayuemeng/classroom/ui/fragment/NewTopOperateControlFragment.java

@@ -33,6 +33,7 @@ import com.dayayuemeng.classroom.viewmodel.ClassViewModel;
 import com.dayayuemeng.classroom.widget.NetClassRoomExitTipDialog;
 import com.dayayuemeng.classroom.widget.OperateItem;
 import com.dayayuemeng.classroom.widget.TeachingToolsView;
+import com.dayayuemeng.classroom.widget.dialog.ExitConfirmDialog;
 import com.tencent.trtc.TRTCCloudDef;
 
 import java.util.ArrayList;
@@ -357,14 +358,12 @@ public class NewTopOperateControlFragment extends BaseMVPFragment<FgTopOperateCo
 
 
     private void showExitDialog() {
-        DialogUtil.showInCenterWithClose(getChildFragmentManager(), R.layout.view_common_popu, "提示", "是否退出课堂?", new DialogUtil.OnDialogButtonClickListener() {
+        ExitConfirmDialog exitConfirmDialog =new ExitConfirmDialog(getContext());
+        exitConfirmDialog.show();
+        exitConfirmDialog.setTitleAndContent("提示","是否退出课堂?");
+        exitConfirmDialog.setOnConfirmClickListener(new View.OnClickListener() {
             @Override
-            public void onCancel(View v) {
-
-            }
-
-            @Override
-            public void onCommit(View v) {
+            public void onClick(View v) {
                 leaveRoom(roomId);
             }
         });

+ 67 - 0
classRoom/src/main/java/com/dayayuemeng/classroom/widget/dialog/ExitConfirmDialog.java

@@ -0,0 +1,67 @@
+package com.dayayuemeng.classroom.widget.dialog;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.cooleshow.base.widgets.ColorTextView;
+import com.cooleshow.base.widgets.dialog.BaseFullDialog;
+import com.dayayuemeng.classroom.R;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Author by pq, Date on 2023/9/18.
+ */
+public class ExitConfirmDialog extends BaseFullDialog implements View.OnClickListener {
+
+    private TextView mTvTitle;
+    private TextView mTvContent;
+    private ImageView mIvClose;
+    private ColorTextView mBtnCancel;
+    private ColorTextView mBtnCommit;
+
+    public ExitConfirmDialog(@NonNull Context context) {
+        super(context);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.dialog_exit_confirm_layout);
+        mTvTitle = findViewById(R.id.tv_title);
+        mTvContent = findViewById(R.id.tv_content);
+        mIvClose = findViewById(R.id.iv_close);
+        mBtnCancel = findViewById(R.id.btn_cancel);
+        mBtnCommit = findViewById(R.id.btn_commit);
+        mIvClose.setOnClickListener(this);
+        mBtnCancel.setOnClickListener(this);
+    }
+
+    public void setTitleAndContent(String title, String content) {
+        if (mTvTitle != null) {
+            mTvTitle.setText(title);
+        }
+        if (mTvContent != null) {
+            mTvContent.setText(content);
+        }
+    }
+
+    public void setOnConfirmClickListener(View.OnClickListener onConfirmClickListener) {
+        if (mBtnCommit != null) {
+            mBtnCommit.setOnClickListener(onConfirmClickListener);
+        }
+    }
+
+
+    @Override
+    public void onClick(View v) {
+        int id = v.getId();
+        if (id == R.id.iv_close || id == R.id.btn_cancel) {
+            dismiss();
+            return;
+        }
+    }
+}

+ 103 - 0
classRoom/src/main/res/layout/dialog_exit_confirm_layout.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout 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"
+    android:gravity="center"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:background="@drawable/shape_12dp_white"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        tools:ignore="MissingConstraints">
+
+        <TextView
+            android:id="@+id/tv_title"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:paddingStart="@dimen/dp_13"
+            android:paddingTop="@dimen/dp_20"
+            android:paddingEnd="@dimen/dp_13"
+            android:paddingBottom="@dimen/dp_8"
+            android:text="请选择延时模式"
+            android:gravity="center"
+            android:textStyle="bold"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/dp_16"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+        <ImageView
+            android:id="@+id/iv_close"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            app:layout_constraintEnd_toEndOf="parent"
+            android:padding="@dimen/dp_10"
+            app:layout_constraintTop_toTopOf="@+id/tv_title"
+            app:layout_constraintBottom_toBottomOf="@+id/tv_title"
+            android:src="@drawable/tc_icon_close_page"/>
+
+        <TextView
+            android:id="@+id/tv_content"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/dp_15"
+            android:paddingStart="@dimen/dp_13"
+            android:paddingEnd="@dimen/dp_13"
+            android:text=""
+            android:gravity="center"
+            android:textColor="@color/color_666666"
+            android:textSize="@dimen/dp_15"
+            tools:text="允许学员自行解除静音"
+            app:layout_constraintEnd_toEndOf="@+id/tv_title"
+            app:layout_constraintStart_toStartOf="@+id/tv_title"
+            app:layout_constraintTop_toBottomOf="@+id/tv_title" />
+
+        <com.cooleshow.base.widgets.ColorTextView
+            android:id="@+id/btn_cancel"
+            android:layout_width="wrap_content"
+            android:layout_height="@dimen/dp_40"
+            android:layout_marginStart="@dimen/dp_30"
+            android:layout_marginTop="@dimen/dp_25"
+            android:layout_marginBottom="@dimen/dp_20"
+            android:paddingStart="@dimen/dp_40"
+            android:gravity="center"
+            android:paddingEnd="@dimen/dp_40"
+            android:text="取消"
+            android:textColor="@color/color_333333"
+            app:ctvBackground="@color/transparent"
+            app:ctvBorderColor="@color/color_dbdbdb"
+            app:ctvBorderWidth="1dp"
+            app:ctvCornerSize="20dp"
+            android:textSize="@dimen/dp_16"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toStartOf="@id/btn_commit"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@id/tv_content" />
+
+        <com.cooleshow.base.widgets.ColorTextView
+            android:id="@+id/btn_commit"
+            android:layout_width="wrap_content"
+            android:layout_height="@dimen/dp_40"
+            android:layout_marginStart="@dimen/dp_20"
+            android:layout_marginTop="@dimen/dp_25"
+            android:layout_marginEnd="@dimen/dp_30"
+            android:layout_marginBottom="@dimen/dp_20"
+            android:gravity="center"
+            android:paddingStart="@dimen/dp_40"
+            android:paddingEnd="@dimen/dp_40"
+            android:text="确认"
+            android:textColor="@color/white"
+            app:ctvCornerSize="20dp"
+            app:ctvBackground="@color/color_01c1b5"
+            android:textSize="@dimen/dp_16"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toEndOf="@id/btn_cancel"
+            app:layout_constraintTop_toBottomOf="@id/tv_content" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</LinearLayout>