package com.gh.gamecenter;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gh.common.util.MessageShareUtils;
import com.gh.common.util.QRCodeUtils;
import com.gh.gamecenter.common.base.activity.ToolBarActivity;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.ShareUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.tencent.tauth.Tencent;

/**
 * Created by khy on 2017/2/6.
 */
public class ShareGhActivity extends ToolBarActivity {

    ImageView mGhQrcode;
    TextView mGhAddress;
    LinearLayout mContentLl;
    RelativeLayout mShareRl;

    @NonNull
    public static Intent getIntent(Context context) {
        Intent intent = new Intent(context, ShareGhActivity.class);
        return intent;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_share_gh;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == com.tencent.connect.common.Constants.REQUEST_QQ_SHARE
                || requestCode == com.tencent.connect.common.Constants.REQUEST_QZONE_SHARE) {
            Tencent.onActivityResultData(requestCode, resultCode, data, MessageShareUtils.getInstance(this).QqShareListener);
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
        mGhQrcode = findViewById(R.id.gh_address_qrcode);
        mGhAddress = findViewById(R.id.gh_address_tv);
        mContentLl = findViewById(R.id.content_ll);
        mShareRl = findViewById(R.id.share_rl);

        mGhAddress.setOnClickListener(v -> {
            MtaHelper.onEvent("我的光环_新", "分享光环", "复制官网");
            ExtensionsKt.copyTextAndToast(getString(R.string.gh_website_url_100), "网址复制成功，请到微信/QQ粘贴分享");
        });

        setNavigationTitle(getString(R.string.title_share_gh));

        mGhAddress.setText(Html.fromHtml("<u>" + "www.ghzs.com" + "</u>"));
        QRCodeUtils.setQRCode(this, getString(R.string.gh_website_url_100), mGhQrcode);
        ShareUtils.getInstance(this).showShareWindows(this, mShareRl, getString(R.string.gh_website_url_300)
                , getString(R.string.gh_icon_url), "玩手游不用肝的感觉真好"
                , "绿色安全的手游加速助手", ShareUtils.ShareEntrance.shareGh, "");
    }

    @Override
    protected void onDarkModeChanged() {
        super.onDarkModeChanged();
        ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
    }
}
