package epson.epsonconnectregistration;

import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.epson.iprint.prtlogger.Analytics;

import epson.common.IPAddressUtils;
import epson.print.MyPrinter;
import epson.print.R;

public class ActivityECConfiguration extends AppCompatActivity {
    public static final String INTENT_EC_BLE_CONTENT = "Epson-Connect-BLE-Content";
    private static final String TAG = "ActivityECConfiguration";

    public void onBackPressed() {
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_config_service);
        boolean booleanExtra = getIntent().getBooleanExtra(INTENT_EC_BLE_CONTENT, false);
        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
        if (curPrinter.getIp() == null) {
            finish();
            return;
        }
        Uri parse = Uri.parse(IPAddressUtils.buildURL(Analytics.EXTENSION_STRING_WEB, curPrinter.getIp(), ""));
        if (parse != null) {
            ECAvailableCheckTask eCAvailableCheckTask = new ECAvailableCheckTask(booleanExtra);
            eCAvailableCheckTask.setContext(this);
            eCAvailableCheckTask.setRootUri(parse);
            eCAvailableCheckTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
        }
    }

    public void finish() {
        super.finish();
        overridePendingTransition(0, 0);
    }
}
