package com.android.launcher3.settings;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.WindowManager;

import com.android.launcher3.function.pwd.EncryptedActivity;
import com.android.launcher3.function.pwd.PwdPinSetPwdActivity;
import com.secspace.lib.common.base.BaseActivity;
import com.secspace.lib.common.function.DialogManager;
import com.secspace.lib.common.utils.IntentUtil;
import com.secspace.lib.common.utils.Prefs;

public class BlankActivity extends BaseActivity {

    @Override
    public int getLayoutId() {
        return 0;
    }

    @Override
    public void initView() {

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (!Prefs.isPrivacyPolicyAccept(this)) {
            DialogManager.INSTANCE.showPrivacyPolicyDialog(this);
            return;
        }
        String encrypted = Prefs.getEncrypted(this);
        if(TextUtils.isEmpty(encrypted)){
            Intent intent = new Intent(this, EncryptedActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            return;
        }
        String pwd = Prefs.getLoginPwd(this);
        if (TextUtils.isEmpty(pwd)) {
            Intent intent = new Intent(this, PwdPinSetPwdActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            return;
        }
        IntentUtil.startEduLauncher(this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
    }

    @Override
    public void overridePendingTransition(int enterAnim, int exitAnim) {
        super.overridePendingTransition(0, 0);
    }
}
