package com.mbridge.msdk.widget.dialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.util.DisplayMetrics; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import androidx.core.view.InputDeviceCompat; import androidx.core.view.accessibility.AccessibilityEventCompat; import com.mbridge.msdk.foundation.controller.c; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.foundation.tools.ak; import com.mbridge.msdk.foundation.tools.x; import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode; /* loaded from: classes4.dex */ public class MBFeedBackDialog extends Dialog { private Button a; private Button b; private LinearLayout c; private a d; private Button e; private TextView f; private int g; private int h; public void clear() { if (this.d != null) { this.d = null; } } public a getListener() { return this.d; } public void setConfirmText(String str) { } public void setListener(a aVar) { this.d = aVar; } public MBFeedBackDialog(Context context, a aVar) { super(context); getWindow().setBackgroundDrawable(new ColorDrawable(0)); requestWindowFeature(1); View inflate = LayoutInflater.from(context).inflate(x.a(context, "mbridge_cm_feedbackview", TtmlNode.TAG_LAYOUT), (ViewGroup) null); setDialogWidthAndHeight(0.5f, 0.8f); this.d = aVar; if (inflate != null) { setContentView(inflate); try { this.f = (TextView) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_titleview", "id")); } catch (Exception e) { af.a("MBAlertDialog", e.getMessage()); } try { this.c = (LinearLayout) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_contentview", "id")); this.b = (Button) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_confirm_button", "id")); this.a = (Button) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_cancel_button", "id")); this.e = (Button) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_private_action_button", "id")); } catch (Exception e2) { af.a("MBAlertDialog", e2.getMessage()); } } setCanceledOnTouchOutside(false); setCancelable(false); Button button = this.a; if (button != null) { button.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.widget.dialog.MBFeedBackDialog.1 @Override // android.view.View.OnClickListener public final void onClick(View view) { if (MBFeedBackDialog.this.d != null) { MBFeedBackDialog.this.d.a(); } MBFeedBackDialog.this.dismiss(); } }); } Button button2 = this.b; if (button2 != null) { button2.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.widget.dialog.MBFeedBackDialog.2 @Override // android.view.View.OnClickListener public final void onClick(View view) { if (MBFeedBackDialog.this.d != null) { MBFeedBackDialog.this.d.b(); } MBFeedBackDialog.this.dismiss(); } }); } Button button3 = this.e; if (button3 != null) { button3.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.widget.dialog.MBFeedBackDialog.3 @Override // android.view.View.OnClickListener public final void onClick(View view) { MBFeedBackDialog.this.dismiss(); if (MBFeedBackDialog.this.d != null) { MBFeedBackDialog.this.d.c(); } } }); } setOnCancelListener(new DialogInterface.OnCancelListener() { // from class: com.mbridge.msdk.widget.dialog.MBFeedBackDialog.4 @Override // android.content.DialogInterface.OnCancelListener public final void onCancel(DialogInterface dialogInterface) { if (MBFeedBackDialog.this.d != null) { MBFeedBackDialog.this.d.b(); } } }); } public void setDialogWidthAndHeight(float f, float f2) { DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics(); if (isScreenOrientationPortrait(getContext())) { this.h = displayMetrics.widthPixels; this.g = displayMetrics.heightPixels; WindowManager.LayoutParams attributes = getWindow().getAttributes(); attributes.width = -1; attributes.height = (int) (this.g * f2); attributes.gravity = 80; getWindow().setAttributes(attributes); return; } this.h = displayMetrics.heightPixels; this.g = displayMetrics.widthPixels; WindowManager.LayoutParams attributes2 = getWindow().getAttributes(); attributes2.width = (int) (this.g * f); attributes2.height = -1; attributes2.gravity = 17; getWindow().setAttributes(attributes2); } public static boolean isScreenOrientationPortrait(Context context) { return context.getResources().getConfiguration().orientation == 1; } public void setTitle(String str) { TextView textView = this.f; if (textView != null) { textView.setText(str); } } public void setContent(ViewGroup viewGroup) { LinearLayout linearLayout = this.c; if (linearLayout != null) { linearLayout.removeAllViews(); ViewGroup viewGroup2 = (ViewGroup) viewGroup.getParent(); if (viewGroup2 != null) { viewGroup2.removeView(viewGroup); } LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1); layoutParams.leftMargin = ak.a(c.m().c(), 16.0f); layoutParams.rightMargin = ak.a(c.m().c(), 16.0f); layoutParams.topMargin = ak.a(c.m().c(), 3.0f); layoutParams.bottomMargin = ak.a(c.m().c(), 3.0f); this.c.addView(viewGroup, layoutParams); } } public void setCancelText(String str) { Button button = this.a; if (button != null) { button.setText(str); } } public void setCancelButtonClickable(boolean z) { Button button = this.a; if (button != null) { button.setClickable(z); if (z) { this.a.setBackgroundResource(getContext().getResources().getIdentifier("mbridge_cm_feedback_choice_btn_bg_pressed", "drawable", c.m().g())); this.a.setAlpha(1.0f); } else { this.a.setBackgroundResource(getContext().getResources().getIdentifier("mbridge_cm_feedback_choice_btn_bg_pressed", "drawable", c.m().g())); this.a.setAlpha(0.4f); } } } public void setPrivacyText(String str) { Button button = this.e; if (button != null) { button.setText(str); } } @Override // android.app.Dialog public void show() { super.show(); try { getWindow().setFlags(8, 8); super.show(); hideNavigationBar(getWindow()); getWindow().clearFlags(8); } catch (Exception e) { af.b("MBAlertDialog", e.getMessage()); super.show(); } } public void hideNavigationBar(Window window) { if (window != null) { window.setFlags(1024, 1024); int i = Build.VERSION.SDK_INT; window.addFlags(AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL); window.getDecorView().setSystemUiVisibility(InputDeviceCompat.SOURCE_TOUCHSCREEN); if (i >= 28) { WindowManager.LayoutParams attributes = window.getAttributes(); attributes.layoutInDisplayCutoutMode = 1; window.setAttributes(attributes); } window.setBackgroundDrawable(new ColorDrawable(0)); window.setLayout(-1, -1); window.setGravity(17); } } }