priya-zha / Software-Engineering-Project

0 stars 2 forks source link

No error handling in the getstarted page - if a user says any word except 'start', it does nothing (should have asked for input again) #2

Open priya-zha opened 11 months ago

priya-zha commented 11 months ago

Steps to reproduce: In the getstarted page, say any word except for 'start' and notice the app does nothing and cannot move forward.

Actual Result: If a user says any word except 'Start' in the getstarted page, the app does nothing

Expected Result: If a user says any word except 'start' on the getstarted page, the app should inform the user and the app should reopen the speech recognition dialog box for the user's input until the user inputs the right instruction.

In the current scenario, in the getstarted page that opens up after the splash screen, if a user says 'start', it navigates to a second page. But if a user says any word except 'start', it does nothing. Since a user is blind, he will not be able to move forward. Thus, error handling mechanism should be implemented here where if a user says any word except 'start', the system should respond by informing user that he didn't give us the input and the recognition dialog box should reopen again for asking user input until and unless he gives the right instruction.

Before fixing:

https://github.com/priya-zha/Software-Engineering-Project/assets/34065075/564ef0ef-2aaa-4c6f-9da8-535ac3929cf3

After fixing:

https://github.com/priya-zha/Software-Engineering-Project/assets/34065075/c263983c-4676-488b-9105-fcbe54fcd0cf

priya-zha commented 11 months ago

Solution:

In getstarted page, we can keep an else condition in case if user speaks any other word except start.

https://github.com/priya-zha/Software-Engineering-Project/blob/2da8cc17807297e2b2a7ec59d183edb1f416f06c/app/src/main/java/com/example/se/GetStarted.java#L133C17-L136C18

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == SPEECH_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
            ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            if (matches != null && !matches.isEmpty()) {
                String recognizedText = matches.get(0).toLowerCase();
                if (recognizedText.equals("start")) {
                    // User said "start"
                    start.setBackgroundColor(Color.parseColor("#FF0000"));
                    navigateToSecondPage();

                }
                else{
                    textToSpeech.speak("Sorry. I didn't get you. Can you please say start to move forward?", TextToSpeech.QUEUE_FLUSH, null);
                     speakInstructionsAndStartListening(5000);
                }
            }
        }
}