private void setUpViews() {
        glucometerAttribution = findViewById(R.id.glucometerAttribution);
        glucometerImg = findViewById(R.id.glucometerImg);
        insertStripText = findViewById(R.id.insertStripText);
        upArrow = findViewById(R.id.upArrow);
        droplet = findViewById(R.id.dropletImg);
        attributionText = findViewById(R.id.attributionText);
        placeBloodSweatImg = findViewById(R.id.placeBloodSweatImg);
        placeBloodSweatText = findViewById(R.id.placeBloodSweatText);
        waitForReadingText = findViewById(R.id.waitForReadingText);
        progressBar = findViewById(R.id.progressBar);
        unitsText = findViewById(R.id.unitsText);
        glucoseLevelText = findViewById(R.id.glucoseLevelText);
        descriptionTxt = findViewById(R.id.descriptionTxt);
        detailsBtn = findViewById(R.id.detailsBtn);
        anotherReadingBtn = findViewById(R.id.anotherReadingBtn);
        showBtn = findViewById(R.id.button7);
        dippedBtn = findViewById(R.id.button6);
        stripBtn = findViewById(R.id.button8);
        startButton = findViewById(R.id.btnStripInserted);
        rgMode = findViewById(R.id.rgMode);
        rbBlood = findViewById(R.id.rbBlood);
        rbSweat = findViewById(R.id.rbSweat);
        rb_mg_dL = findViewById(R.id.rb_mg_dL);
        rb_mmol_L = findViewById(R.id.rb_mmol_L);
        glucometerSwitch = findViewById(R.id.glucometerSwitch);
        rgUnits = findViewById(R.id.rgUnits);
        startButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!rbSweat.isChecked() && !rbBlood.isChecked()) {
                    Toast.makeText(GlucometerActivity.this, "Please select a mode", Toast.LENGTH_SHORT).show();
                }
                else {
                    instance.sendDataToArduino("start");
                    instance.setReading(true);
                    glucometerSwitch.setEnabled(false);
                    rbBlood.setEnabled(false);
                    rbSweat.setEnabled(false);
                    rb_mg_dL.setEnabled(false);
                    rb_mmol_L.setEnabled(false);
                    startButton.setEnabled(false);
                    glucometerImg.setVisibility(View.VISIBLE);
                    glucometerAttribution.setVisibility(View.VISIBLE);
                    insertStripText.setVisibility(View.VISIBLE);
                    upArrow.setVisibility(View.VISIBLE);
                }
            }
        });
        rgMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rbBlood:
                        instance.sendDataToArduino("Blood");
                        droplet.setColorFilter(Color.parseColor("#F44336"));
                        placeBloodSweatText.setText("Place blood on the test strip");
                        break;
                    case R.id.rbSweat:
                        instance.sendDataToArduino("Sweat");
                        droplet.setColorFilter(Color.parseColor("#1b95e0"));
                        placeBloodSweatText.setText("Place sweat on the test strip");
                        break;
                }
                viewDelay();
            }
        });
        glucometerSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    instance.sendDataToArduino("G_on");
                    viewDelay();
                }else {
                    instance.sendDataToArduino("G_off");
                    startButton.setEnabled(false);
                    rbBlood.setEnabled(false);
                    rbSweat.setEnabled(false);
                    rb_mg_dL.setEnabled(false);
                    rb_mmol_L.setEnabled(false);
                    glucometerSwitch.setEnabled(false);
                    viewHandler = new Handler();
                    Runnable delay = new Runnable() {
                        @Override
                        public void run() {
                            glucometerSwitch.setEnabled(true);
                        }
                    };
                    viewHandler.postDelayed(delay, 1000);
                }
            }
        });
        rgUnits.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rb_mg_dL:
                        //TODO Display readings in mg/dL
                        unitsText.setText("mg/dL");
                        break;
                    case R.id.rb_mmol_L:
                        //TODO Display readings in mmol/L
                        unitsText.setText("mmol/L");
                        break;
                }
                viewDelay();
            }
        });
        detailsBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Move to new activity
                Intent intent = new Intent(GlucometerActivity.this, GlucoseReadingDetailsActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
            }
        });
        anotherReadingBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setReading(false);
                glucometerSwitch.setEnabled(true);
                rbBlood.setEnabled(true);
                rbSweat.setEnabled(true);
                rb_mg_dL.setEnabled(true);
                rb_mmol_L.setEnabled(true);
                startButton.setEnabled(true);
                instance.setStringData(null);
                instance.setCommand(null);
                unitsText.setVisibility(View.INVISIBLE);
                glucoseLevelText.setVisibility(View.INVISIBLE);
                descriptionTxt.setVisibility(View.INVISIBLE);
                detailsBtn.setVisibility(View.INVISIBLE);
                anotherReadingBtn.setVisibility(View.INVISIBLE);
            }
        });
        showBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setCommand("show");
            }
        });
        stripBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setCommand("strip");
            }
        });
        dippedBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setCommand("dipped");
            }
        });
    }
private void setUpViews() {
        glucometerAttribution = findViewById(R.id.glucometerAttribution);
        glucometerImg = findViewById(R.id.glucometerImg);
        insertStripText = findViewById(R.id.insertStripText);
        upArrow = findViewById(R.id.upArrow);
        droplet = findViewById(R.id.dropletImg);
        attributionText = findViewById(R.id.attributionText);
        placeBloodSweatImg = findViewById(R.id.placeBloodSweatImg);
        placeBloodSweatText = findViewById(R.id.placeBloodSweatText);
        waitForReadingText = findViewById(R.id.waitForReadingText);
        progressBar = findViewById(R.id.progressBar);
        unitsText = findViewById(R.id.unitsText);
        glucoseLevelText = findViewById(R.id.glucoseLevelText);
        descriptionTxt = findViewById(R.id.descriptionTxt);
        detailsBtn = findViewById(R.id.detailsBtn);
        anotherReadingBtn = findViewById(R.id.anotherReadingBtn);
        showBtn = findViewById(R.id.button7);
        dippedBtn = findViewById(R.id.button6);
        stripBtn = findViewById(R.id.button8);
        startButton = findViewById(R.id.btnStripInserted);
        rgMode = findViewById(R.id.rgMode);
        rbBlood = findViewById(R.id.rbBlood);
        rbSweat = findViewById(R.id.rbSweat);
        rb_mg_dL = findViewById(R.id.rb_mg_dL);
        rb_mmol_L = findViewById(R.id.rb_mmol_L);
        glucometerSwitch = findViewById(R.id.glucometerSwitch);
        rgUnits = findViewById(R.id.rgUnits);
        startButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!rbSweat.isChecked() && !rbBlood.isChecked()) {
                    Toast.makeText(GlucometerActivity.this, "Please select a mode", Toast.LENGTH_SHORT).show();
                }
                else {
                    instance.sendDataToArduino("start");
                    instance.setReading(true);
                    glucometerSwitch.setEnabled(false);
                    rbBlood.setEnabled(false);
                    rbSweat.setEnabled(false);
                    rb_mg_dL.setEnabled(false);
                    rb_mmol_L.setEnabled(false);
                    startButton.setEnabled(false);
                    glucometerImg.setVisibility(View.VISIBLE);
                    glucometerAttribution.setVisibility(View.VISIBLE);
                    insertStripText.setVisibility(View.VISIBLE);
                    upArrow.setVisibility(View.VISIBLE);
                }
            }
        });
        rgMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rbBlood:
                        instance.sendDataToArduino("Blood");
                        droplet.setColorFilter(Color.parseColor("#F44336"));
                        placeBloodSweatText.setText("Place blood on the test strip");
                        break;
                    case R.id.rbSweat:
                        instance.sendDataToArduino("Sweat");
                        droplet.setColorFilter(Color.parseColor("#1b95e0"));
                        placeBloodSweatText.setText("Place sweat on the test strip");
                        break;
                }
                viewDelay();
            }
        });
        glucometerSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    instance.sendDataToArduino("G_on");
                    viewDelay();
                }else {
                    instance.sendDataToArduino("G_off");
                    startButton.setEnabled(false);
                    rbBlood.setEnabled(false);
                    rbSweat.setEnabled(false);
                    rb_mg_dL.setEnabled(false);
                    rb_mmol_L.setEnabled(false);
                    glucometerSwitch.setEnabled(false);
                    viewHandler = new Handler();
                    Runnable delay = new Runnable() {
                        @Override
                        public void run() {
                            glucometerSwitch.setEnabled(true);
                        }
                    };
                    viewHandler.postDelayed(delay, 1000);
                }
            }
        });
        rgUnits.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rb_mg_dL:
                       
                        unitsText.setText("mg/dL");
                        break;
                    case R.id.rb_mmol_L:
                       
                        unitsText.setText("mmol/L");
                        break;
                }
                viewDelay();
            }
        });
        detailsBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               
                Intent intent = new Intent(GlucometerActivity.this, GlucoseReadingDetailsActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
            }
        });
        anotherReadingBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setReading(false);
                glucometerSwitch.setEnabled(true);
                rbBlood.setEnabled(true);
                rbSweat.setEnabled(true);
                rb_mg_dL.setEnabled(true);
                rb_mmol_L.setEnabled(true);
                startButton.setEnabled(true);
                instance.setStringData(null);
                instance.setCommand(null);
                unitsText.setVisibility(View.INVISIBLE);
                glucoseLevelText.setVisibility(View.INVISIBLE);
                descriptionTxt.setVisibility(View.INVISIBLE);
                detailsBtn.setVisibility(View.INVISIBLE);
                anotherReadingBtn.setVisibility(View.INVISIBLE);
            }
        });
        showBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setCommand("show");
            }
        });
        stripBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setCommand("strip");
            }
        });
        dippedBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                instance.setCommand("dipped");
            }
        });
    }
private void setupviews() { glucometerattribution = findviewbyid(r.id.glucometerattribution); glucometerimg = findviewbyid(r.id.glucometerimg); insertstriptext = findviewbyid(r.id.insertstriptext); uparrow = findviewbyid(r.id.uparrow); droplet = findviewbyid(r.id.dropletimg); attributiontext = findviewbyid(r.id.attributiontext); placebloodsweatimg = findviewbyid(r.id.placebloodsweatimg); placebloodsweattext = findviewbyid(r.id.placebloodsweattext); waitforreadingtext = findviewbyid(r.id.waitforreadingtext); progressbar = findviewbyid(r.id.progressbar); unitstext = findviewbyid(r.id.unitstext); glucoseleveltext = findviewbyid(r.id.glucoseleveltext); descriptiontxt = findviewbyid(r.id.descriptiontxt); detailsbtn = findviewbyid(r.id.detailsbtn); anotherreadingbtn = findviewbyid(r.id.anotherreadingbtn); showbtn = findviewbyid(r.id.button7); dippedbtn = findviewbyid(r.id.button6); stripbtn = findviewbyid(r.id.button8); startbutton = findviewbyid(r.id.btnstripinserted); rgmode = findviewbyid(r.id.rgmode); rbblood = findviewbyid(r.id.rbblood); rbsweat = findviewbyid(r.id.rbsweat); rb_mg_dl = findviewbyid(r.id.rb_mg_dl); rb_mmol_l = findviewbyid(r.id.rb_mmol_l); glucometerswitch = findviewbyid(r.id.glucometerswitch); rgunits = findviewbyid(r.id.rgunits); startbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if (!rbsweat.ischecked() && !rbblood.ischecked()) { toast.maketext(glucometeractivity.this, "please select a mode", toast.length_short).show(); } else { instance.senddatatoarduino("start"); instance.setreading(true); glucometerswitch.setenabled(false); rbblood.setenabled(false); rbsweat.setenabled(false); rb_mg_dl.setenabled(false); rb_mmol_l.setenabled(false); startbutton.setenabled(false); glucometerimg.setvisibility(view.visible); glucometerattribution.setvisibility(view.visible); insertstriptext.setvisibility(view.visible); uparrow.setvisibility(view.visible); } } }); rgmode.setoncheckedchangelistener(new radiogroup.oncheckedchangelistener() { @override public void oncheckedchanged(radiogroup group, int checkedid) { switch (checkedid) { case r.id.rbblood: instance.senddatatoarduino("blood"); droplet.setcolorfilter(color.parsecolor("#f44336")); placebloodsweattext.settext("place blood on the test strip"); break; case r.id.rbsweat: instance.senddatatoarduino("sweat"); droplet.setcolorfilter(color.parsecolor("#1b95e0")); placebloodsweattext.settext("place sweat on the test strip"); break; } viewdelay(); } }); glucometerswitch.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if (ischecked){ instance.senddatatoarduino("g_on"); viewdelay(); }else { instance.senddatatoarduino("g_off"); startbutton.setenabled(false); rbblood.setenabled(false); rbsweat.setenabled(false); rb_mg_dl.setenabled(false); rb_mmol_l.setenabled(false); glucometerswitch.setenabled(false); viewhandler = new handler(); runnable delay = new runnable() { @override public void run() { glucometerswitch.setenabled(true); } }; viewhandler.postdelayed(delay, 1000); } } }); rgunits.setoncheckedchangelistener(new radiogroup.oncheckedchangelistener() { @override public void oncheckedchanged(radiogroup group, int checkedid) { switch (checkedid) { case r.id.rb_mg_dl: unitstext.settext("mg/dl"); break; case r.id.rb_mmol_l: unitstext.settext("mmol/l"); break; } viewdelay(); } }); detailsbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent intent = new intent(glucometeractivity.this, glucosereadingdetailsactivity.class); intent.addflags(intent.flag_activity_no_animation); startactivity(intent); } }); anotherreadingbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { instance.setreading(false); glucometerswitch.setenabled(true); rbblood.setenabled(true); rbsweat.setenabled(true); rb_mg_dl.setenabled(true); rb_mmol_l.setenabled(true); startbutton.setenabled(true); instance.setstringdata(null); instance.setcommand(null); unitstext.setvisibility(view.invisible); glucoseleveltext.setvisibility(view.invisible); descriptiontxt.setvisibility(view.invisible); detailsbtn.setvisibility(view.invisible); anotherreadingbtn.setvisibility(view.invisible); } }); showbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { instance.setcommand("show"); } }); stripbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { instance.setcommand("strip"); } }); dippedbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { instance.setcommand("dipped"); } }); }