package com.kfb.kfbv1;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.kfb.kfbv1.model.KfbConstans;

public class PinActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pin);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);

        Button im = (Button)findViewById(R.id.idOkPin);
        im.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                onCheckPIN(v);
            }
        });
    }
    private void onCheckPIN(View v)
    {
        TextView t = findViewById(R.id.idPin);
        if(t.getText().toString().equals(KfbConstans.PIN))
        {
            Intent i = new Intent(getApplicationContext(),ConfigActivity.class);
            startActivity(i);
            finish();
        }
        else
        {
            Toast.makeText(getApplicationContext(), "Błędny PIN podaj poprawny", Toast.LENGTH_SHORT).show();
        }
    }
}
