package com.meeting.demo.utils;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.view.WindowManager;

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

import com.huawei.hwmchat.view.activity.ConfMsgActivity;
import com.huawei.hwmconf.presentation.ConfUI;
import com.huawei.hwmconf.presentation.view.activity.InMeetingActivity;
import com.huawei.hwmconf.presentation.view.activity.ParticipantActivity;
import com.huawei.hwmconf.presentation.view.activity.SubtitlesRecordActivity;

import java.util.HashSet;
import java.util.Set;

public class DemoActivityLifecycleHandle implements Application.ActivityLifecycleCallbacks{

    private final Set<String> forbidScreenShotActivities = new HashSet<String>() {
        {
            add(InMeetingActivity.class.getSimpleName());
            add(ParticipantActivity.class.getSimpleName());
            add(ConfMsgActivity.class.getSimpleName());
            add(SubtitlesRecordActivity.class.getSimpleName());
        }
    };

    @Override
    public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {

    }

    @Override
    public void onActivityStarted(@NonNull Activity activity) {

    }

    @Override
    public void onActivityResumed(@NonNull Activity activity) {
        if (ConfUI.getScreenShareNotificationHandle().isThirdPartyControlScreenshot()) {
            if (forbidScreenShotActivities.contains(activity.getClass().getSimpleName())) {
                activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
            }
        }
    }

    @Override
    public void onActivityPaused(@NonNull Activity activity) {

    }

    @Override
    public void onActivityStopped(@NonNull Activity activity) {

    }

    @Override
    public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {

    }

    @Override
    public void onActivityDestroyed(@NonNull Activity activity) {

    }
}
