package com.meeting.demo.view.sdk;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Switch;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.huawei.hwmconf.presentation.ConfUI;
import com.huawei.hwmconf.presentation.dependency.IScreenShareTransformNotificationHandle;
import com.meeting.demo.R;
import com.meeting.demo.view.base.BaseDialogFragment;
import com.huawei.hwmsdk.enums.ForbiddenScreenShotsEnableType;

public class ThirdPartyControlScreenShotFragment extends BaseDialogFragment {

    private View rootView;

    private Switch screenShotSwitch;

    private Button confirmButton;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.third_party_control_screen_shot, container, false);
        screenShotSwitch = rootView.findViewById(R.id.third_party_control_screen_shot_switch);
        screenShotSwitch.setChecked(ConfUI.getScreenShareNotificationHandle().isThirdPartyControlScreenshot());
        confirmButton = rootView.findViewById(R.id.confirm_btn);
        confirmButton.setOnClickListener(v -> onConfirmButtonClicked());
        return rootView;
    }

    private void onConfirmButtonClicked() {
        boolean isThirdPartyControlScreenShot = screenShotSwitch.isChecked();
        IScreenShareTransformNotificationHandle iScreenShareTransformNotificationHandle = new IScreenShareTransformNotificationHandle() {
            @Override
            public void startScreenShareNotification() {

            }

            @Override
            public void endScreenShareNotification() {

            }

            @Override
            public boolean canScreenShare() {
                return false;
            }

            @Override
            public boolean isThirdPartyControlScreenshot() {
                return isThirdPartyControlScreenShot;
            }

            @Override
            public void onConfForbiddenScreenShotsEnableChanged(ForbiddenScreenShotsEnableType forbiddenScreenShotsEnableType) {

            }
        };
        ConfUI.setScreenShareTransformNotificationHandle(iScreenShareTransformNotificationHandle);
        doDismissDialogAndFragment();
    }
}
