192 lines
4.1 KiB
C#
192 lines
4.1 KiB
C#
![]() |
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace Kunpo.Privacy
|
|||
|
{
|
|||
|
class UI_PrivacyTerms : MonoBehaviour
|
|||
|
{
|
|||
|
public GameObject[] panels;
|
|||
|
|
|||
|
public Button closeBtn;
|
|||
|
public Image realNameAuthState;
|
|||
|
public Toggle adSetup;
|
|||
|
public Text mobile;
|
|||
|
|
|||
|
public GameObject personDataDownload;
|
|||
|
public GameObject appAuthorize;
|
|||
|
|
|||
|
public GameObject toastPanel;
|
|||
|
public Text toastText;
|
|||
|
|
|||
|
public GameObject messagePanel;
|
|||
|
public Text messageText;
|
|||
|
|
|||
|
public void Awake()
|
|||
|
{
|
|||
|
this.OnInitEvent();
|
|||
|
this.OnInitContext();
|
|||
|
}
|
|||
|
|
|||
|
private void OnInitEvent()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void OnInitContext()
|
|||
|
{
|
|||
|
#if SDK_OHAYOO
|
|||
|
if (PrivacyProxy.LoginUser != null)
|
|||
|
{
|
|||
|
realNameAuthState.gameObject.SetActive(PrivacyProxy.LoginUser.IsRealNameVerified);
|
|||
|
personDataDownload.SetActive(PrivacyProxy.LoginUser.LoginType != ByteDance.Union.LGLoginType.LOGIN_TYPE_VISITOR);
|
|||
|
appAuthorize.gameObject.SetActive(PrivacyProxy.LoginUser.LoginType == ByteDance.Union.LGLoginType.LOGIN_TYPE_DY);
|
|||
|
|
|||
|
if (PrivacyProxy.LoginUser.LoginType == ByteDance.Union.LGLoginType.LOGIN_TYPE_PHONE)
|
|||
|
{
|
|||
|
mobile.transform.parent.gameObject.SetActive(true);
|
|||
|
mobile.text = PrivacyProxy.LoginUser.Mobile;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
mobile.transform.parent.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
realNameAuthState.gameObject.SetActive(false);
|
|||
|
personDataDownload.SetActive(false);
|
|||
|
appAuthorize.gameObject.SetActive(false);
|
|||
|
mobile.transform.parent.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
#endif
|
|||
|
toastPanel.SetActive(false);
|
|||
|
UpdateUI();
|
|||
|
}
|
|||
|
|
|||
|
public void OnCloseBtnClick()
|
|||
|
{
|
|||
|
Object.Destroy(this.transform.parent.gameObject);
|
|||
|
}
|
|||
|
|
|||
|
void UpdateUI()
|
|||
|
{
|
|||
|
bool blocked = PlayerPrefs.GetInt("K_PersonalizedAdsBlocked", 0) == 1;
|
|||
|
this.adSetup.isOn = !blocked;
|
|||
|
}
|
|||
|
|
|||
|
void ShowToast(string text)
|
|||
|
{
|
|||
|
toastPanel.SetActive(true);
|
|||
|
toastText.text = text;
|
|||
|
Invoke(nameof(HideToast), 0.5f);
|
|||
|
}
|
|||
|
|
|||
|
void HideToast()
|
|||
|
{
|
|||
|
toastPanel.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void ShowMessage(string text)
|
|||
|
{
|
|||
|
messagePanel.SetActive(true);
|
|||
|
messageText.text = text;
|
|||
|
}
|
|||
|
|
|||
|
public void HideMessage()
|
|||
|
{
|
|||
|
messagePanel.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void OpenPanel(Transform target)
|
|||
|
{
|
|||
|
foreach (var panel in panels)
|
|||
|
{
|
|||
|
panel.SetActive(false);
|
|||
|
}
|
|||
|
target.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
public void OpenPrivacyAll()
|
|||
|
{
|
|||
|
#if SDK_OHAYOO
|
|||
|
ByteDance.Union.LGSDKDevKit.DevKitBaseService.OpenPrivacyProtocol();
|
|||
|
#endif
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 这个地方要适配
|
|||
|
/// </summary>
|
|||
|
public void OpenThirdPartySDK()
|
|||
|
{
|
|||
|
Application.OpenURL("https://lf3-cdn-tos.draftstatic.com/obj/ies-hotsoon-draft/88888888/8d74e635-8e7b-4b02-8c14-77a04ce4e7b3.html");
|
|||
|
}
|
|||
|
|
|||
|
public void OpenSystemSetting(int type)
|
|||
|
{
|
|||
|
SystemTools.OpenAppSetting();
|
|||
|
}
|
|||
|
|
|||
|
public void TogglePersonalizedAdState(bool isOn)
|
|||
|
{
|
|||
|
#if SDK_OHAYOO
|
|||
|
bool blocked = !isOn;
|
|||
|
PlayerPrefs.SetInt("K_PersonalizedAdsBlocked", blocked ? 1 : 0);
|
|||
|
ByteDance.Union.LGSDKAd.MediationAdService.BlockPersonalizedAds(blocked);
|
|||
|
#endif
|
|||
|
}
|
|||
|
|
|||
|
public void UnBindDouyin()
|
|||
|
{
|
|||
|
#if SDK_OHAYOO
|
|||
|
ByteDance.Union.LGSDKAccount.AccountService.UnBind(
|
|||
|
(user) =>
|
|||
|
{
|
|||
|
ShowToast("帐号解绑成功");
|
|||
|
OpenPanel(panels[0].transform);
|
|||
|
},
|
|||
|
(error, message) =>
|
|||
|
{
|
|||
|
ShowToast("帐号解绑失败" + message);
|
|||
|
});
|
|||
|
#endif
|
|||
|
}
|
|||
|
|
|||
|
public void OnPersonDataDownload()
|
|||
|
{
|
|||
|
#if SDK_OHAYOO
|
|||
|
ByteDance.Union.LGSDKAccount.AccountService.QueryAccountInfo(
|
|||
|
(data) =>
|
|||
|
{
|
|||
|
if (data != null)
|
|||
|
{
|
|||
|
var result = new System.Text.StringBuilder();
|
|||
|
foreach (var item in data)
|
|||
|
{
|
|||
|
result.Append(item.Key);
|
|||
|
result.Append(" ");
|
|||
|
result.Append(item.Value.ToString());
|
|||
|
result.AppendLine();
|
|||
|
}
|
|||
|
ShowMessage(result.ToString());
|
|||
|
//System.IO.File.WriteAllText(System.IO.Path.Combine(Application.dataPath, "person_data.txt"), result.ToString());
|
|||
|
}
|
|||
|
},
|
|||
|
(error, message) =>
|
|||
|
{
|
|||
|
ShowToast("个人数据下载失败");
|
|||
|
});
|
|||
|
#endif
|
|||
|
}
|
|||
|
|
|||
|
public void OnMessageBtnClick()
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(messageText.text))
|
|||
|
GUIUtility.systemCopyBuffer = messageText.text;
|
|||
|
|
|||
|
ShowToast("复制成功");
|
|||
|
HideMessage();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|