package cn.ninegame.ad.demo.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import androidx.appcompat.widget.SwitchCompat;

import cn.ninegame.ad.demo.R;


/**
 * 隐私合规配置（非必须），该示例仅为功能示例，非正式代码，请勿直接拷贝使用，请根据游戏的具体情况进行配置
 * 相关配置项请查看[cn.sirius.nga.config.NGCustomController]
 */
public class PrivacyConfigActivity extends Activity {

    private static boolean isCanUseLocation = true;
    private static boolean isCanUsePhoneState = true;
    private static boolean isCanUseWifiState = true;
    private static boolean isCanUseAndroidId = true;
    private static boolean isCanUseWriteExternal = true;
    private static boolean isCanUseOaid = true;
    private static boolean isCanUsePermissionRecordAudio = true;
    private static boolean isLimitPersonalAds = false;
    private static boolean isProgrammaticRecommend = true;
    private static boolean isAppList = true;

    private static boolean hadCustomConfig = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_privacy_config);

        findViewById(R.id.btnOK).setOnClickListener(v -> {
            // 合规隐私配置
            PrivacyConfigActivity.setIsCanUseLocation(((SwitchCompat) findViewById(R.id.rbLocation)).isChecked());
            PrivacyConfigActivity.setIsCanUseOaid(((SwitchCompat) findViewById(R.id.rbOaid)).isChecked());
            PrivacyConfigActivity.setIsCanUseAndroidId(((SwitchCompat) findViewById(R.id.rbAndroidId)).isChecked());
            PrivacyConfigActivity.setIsCanUseWifiState(((SwitchCompat) findViewById(R.id.rbWifiState)).isChecked());
            PrivacyConfigActivity.setIsCanUsePhoneState(((SwitchCompat) findViewById(R.id.rbPhoneState)).isChecked());
            PrivacyConfigActivity.setIsCanUseWriteExternal(((SwitchCompat) findViewById(R.id.rbWriteExternal)).isChecked());
            PrivacyConfigActivity.setIsLimitPersonalAds(((SwitchCompat) findViewById(R.id.rbPersonal)).isChecked());
            PrivacyConfigActivity.setIsCanUsePermissionRecordAudio(((SwitchCompat) findViewById(R.id.rbRecordAudio)).isChecked());
            PrivacyConfigActivity.setIsProgrammaticRecommend(((SwitchCompat) findViewById(R.id.rbProgrammaticRecommend)).isChecked());
            PrivacyConfigActivity.setIsAppList(((SwitchCompat) findViewById(R.id.rbAppList)).isChecked());
            hadCustomConfig = true;
            Toast.makeText(this, "合规隐私配置完成，返回主页面后请开初始化", Toast.LENGTH_LONG).show();
            finish();
        });

    }

    public static boolean isCanUseLocation() {
        return isCanUseLocation;
    }

    public static void setIsCanUseLocation(boolean isCanUseLocation) {
        PrivacyConfigActivity.isCanUseLocation = isCanUseLocation;
    }

    public static boolean isCanUsePhoneState() {
        return isCanUsePhoneState;
    }

    public static void setIsCanUsePhoneState(boolean isCanUsePhoneState) {
        PrivacyConfigActivity.isCanUsePhoneState = isCanUsePhoneState;
    }

    public static boolean isCanUseWifiState() {
        return isCanUseWifiState;
    }

    public static void setIsCanUseWifiState(boolean isCanUseWifiState) {
        PrivacyConfigActivity.isCanUseWifiState = isCanUseWifiState;
    }

    public static boolean isCanUseAndroidId() {
        return isCanUseAndroidId;
    }

    public static void setIsCanUseAndroidId(boolean isCanUseAndroidId) {
        PrivacyConfigActivity.isCanUseAndroidId = isCanUseAndroidId;
    }

    public static boolean isCanUseWriteExternal() {
        return isCanUseWriteExternal;
    }

    public static void setIsCanUseWriteExternal(boolean isCanUseWriteExternal) {
        PrivacyConfigActivity.isCanUseWriteExternal = isCanUseWriteExternal;
    }

    public static boolean isCanUseOaid() {
        return isCanUseOaid;
    }

    public static void setIsCanUseOaid(boolean isCanUseOaid) {
        PrivacyConfigActivity.isCanUseOaid = isCanUseOaid;
    }

    public static boolean isCanUsePermissionRecordAudio() {
        return isCanUsePermissionRecordAudio;
    }

    public static void setIsCanUsePermissionRecordAudio(boolean isCanUsePermissionRecordAudio) {
        PrivacyConfigActivity.isCanUsePermissionRecordAudio = isCanUsePermissionRecordAudio;
    }

    public static boolean isLimitPersonalAds() {
        return isLimitPersonalAds;
    }

    public static void setIsLimitPersonalAds(boolean isLimitPersonalAds) {
        PrivacyConfigActivity.isLimitPersonalAds = isLimitPersonalAds;
    }

    public static boolean isProgrammaticRecommend() {
        return isProgrammaticRecommend;
    }

    public static void setIsProgrammaticRecommend(boolean isProgrammaticRecommend) {
        PrivacyConfigActivity.isProgrammaticRecommend = isProgrammaticRecommend;
    }

    public static boolean isAppList() {
        return isAppList;
    }

    public static void setIsAppList(boolean isAppList) {
        PrivacyConfigActivity.isAppList = isAppList;
    }

    public static boolean isHadCustomConfig() {
        return hadCustomConfig;
    }
}
