package com.datarecovery.master.module.about;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.atmob.app.lib.base.BaseActivity;
import com.datarecovery.master.data.consts.Constants;
import com.datarecovery.master.databinding.ActivityAboutBinding;
import com.datarecovery.master.module.browser.BrowserActivity;
import com.datarecovery.master.utils.SystemUtil;
import com.gyf.immersionbar.ImmersionBar;

import dagger.hilt.android.AndroidEntryPoint;

/**
 * 关于
 */
@AndroidEntryPoint
public class AboutActivity extends BaseActivity<ActivityAboutBinding> {


    public static void start(Context context) {
        Intent intent = new Intent(context, AboutActivity.class);
        if (!(context instanceof Activity)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    @Override
    protected boolean shouldImmersion() {
        return true;
    }

    @Override
    protected void configImmersion(@NonNull ImmersionBar immersionBar) {
        immersionBar.statusBarDarkFont(true);
    }

    private void initView() {
        binding.tvVersionCode.setText(SystemUtil.getVersionName(getBaseContext()));
        binding.toolBar.setNavigationOnClickListener(v -> onBackPressed());
        addTopStatusBarHeight(binding.toolBar);
        binding.setUserAgreementClick(v -> BrowserActivity.start(this, Constants.USER_AGREEMENT));
        binding.setPrivacyAgreementClick(v -> BrowserActivity.start(this, Constants.PRIVACY_POLICY));
    }
}