package epson.maintain.activity;

import android.os.Bundle;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.epson.mobilephone.common.license.RestoreScrollView;

import epson.common.IprintLicenseInfo;
import epson.print.R;

public class CheckEulaActivity extends AppCompatActivity {
    private static final String KEY_SCROLL_Y = "scroll_y";
    private RestoreScrollView mScrollView;

    public void onBackPressed() {
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_check_eula);

        ((Button) findViewById(R.id.eulaAgreeButton)).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                CheckEulaActivity.this.finishWithResult(-1);
            }
        });
        ((Button) findViewById(R.id.eulaDisagreeButton)).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                CheckEulaActivity.this.finishWithResult(0);
            }
        });
        mScrollView = (RestoreScrollView) findViewById(R.id.eulaCheckMainScrollView);
        ((TextView) findViewById(R.id.eulaTextView)).setText(new IprintLicenseInfo().getDocumentString(this, 1));
        if (bundle != null) {
            mScrollView.setScrollY(bundle.getInt(KEY_SCROLL_Y, 0));
        }
    }

    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putInt(KEY_SCROLL_Y, mScrollView.getLastY());
    }

    private void finishWithResult(int i) {
        setResult(i);
        finish();
    }
}
