package com.xplora.xpsettings.Activity;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
//import android.os.SystemProperties;
import android.widget.ImageView;

import com.xplora.xpsettings.R;
import com.xplora.xpsettings.Utils.QRCodeUtil;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class QRActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qr);
        ImageView qr = findViewById(R.id.qr);
//        String addr = SystemProperties.get("persist.zs.bt.address", "0A:1B:2C:3D:4E:5F");
//        String selfModel =  SystemProperties.get("persist.zs.bt.name", "IS-SW1.1");
        String addr = "1";
        String selfModel =  "1";
        String model = selfModel.trim().isEmpty() ? Build.MODEL : selfModel;
        String content = "{\"addr\":\"" + addr + "\",\"name\":\"" + model + "\"}";
        content = Base64.getEncoder().encodeToString(content.getBytes(StandardCharsets.UTF_8));
        qr.setImageBitmap(QRCodeUtil.createQRCodeBitmap(content, 240, 240));
    }
}
