package epson.print.inkrpln;

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


import androidx.appcompat.app.AppCompatActivity;

import epson.print.R;
import epson.print.ThreeButtonDialog;

public class InkRplnProgressDialog extends AppCompatActivity implements ThreeButtonDialog.DialogCallback {
    private static final String PARAM_KEY_PARAM_CLASS_BUILDER = "param_class_builder";
    private InkRplnProgressFragment mInkDsFragment;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setTitle("");
        setContentView((int) R.layout.activity_ink_rpln_progress_dialog);
        setFinishOnTouchOutside(false);
        if (!InkReplenishSystem.isInkReplenishSystemEnabled(this)) {
            finish();
            return;
        }
        this.mInkDsFragment = InkRplnProgressFragment.getInstance(getSupportFragmentManager(), (DependencyBuilder) getIntent().getSerializableExtra(PARAM_KEY_PARAM_CLASS_BUILDER));
    }

    public void callback(int i) {
        if (i == 1) {
            this.mInkDsFragment.launchWebBrowseAndFinishActivity();
        } else if (i != 3) {
            finish();
        } else {
            this.mInkDsFragment.setInkDsServerCheckDisable(this);
            finish();
        }
    }

    public static Intent getStartIntent(Context context) {
        return new Intent(context, InkRplnProgressDialog.class);
    }

    public static Intent getStartIntent2(Context context, DependencyBuilder dependencyBuilder) {
        Intent intent = new Intent(context, InkRplnProgressDialog.class);
        intent.putExtra(PARAM_KEY_PARAM_CLASS_BUILDER, dependencyBuilder);
        return intent;
    }
}
