package in.techware.carrefour.activity.receive;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import in.techware.carrefour.R;
import in.techware.carrefour.activity.HomeActivity;
import in.techware.carrefour.util.AppConstants;

public class ReceivingActivity extends AppCompatActivity {

    EditText supplierEditText;
    EditText orderNoEditText;
    EditText barcodeEditText;
    EditText descEditText;
    EditText qtyTwoEditText;
    EditText qtyOneEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_receiving);
        initViews();
        handleKeyboard();
    }

    private void initViews() {
        supplierEditText = findViewById(R.id.etxt_supplier);
        orderNoEditText = findViewById(R.id.etxt_order_no);
        barcodeEditText = findViewById(R.id.etxt_barcode);
        descEditText = findViewById(R.id.etxt_desc);
        qtyOneEditText = findViewById(R.id.etxt_qty_one);
        qtyTwoEditText = findViewById(R.id.etxt_qty_two);
    }

    private void handleKeyboard() {
        if (getSharedPreferences(AppConstants.PREF_FILE, 0).getBoolean(AppConstants.KEYBOARD_STATUS, false)){
            barcodeEditText.setFocusableInTouchMode(true);
            supplierEditText.setFocusableInTouchMode(true);
            orderNoEditText.setFocusableInTouchMode(true);
            descEditText.setFocusableInTouchMode(true);
            qtyOneEditText.setFocusableInTouchMode(true);
            qtyTwoEditText.setFocusableInTouchMode(true);
            barcodeEditText.setFocusableInTouchMode(true);
        }
    }

    public void clickBackButton(View v){
        finish();
    }

    public void clickRejectButton(View v){
        Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
}
