Commit f53239e2 by Kunj Gupta

Added - Listening dialog will dismiss after 10 secs if user will not respond.

parent 26d2ec39
......@@ -100,6 +100,16 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
private static final int SCREEN_OFF = 0;
private static final int SCREEN_ON = 1;
private static final long LISTENING_DIALOG_DISMISS_DELAY_TIME = 10000;
/**
* These var will to set delay for listing dialog. Previously it will open for infinite time.
* Now open the listening, if user will not response it'll close after 10 Secs.
* */
private static final int LISTENING_DELAY_STARTED_STATE = 1;
private static final int LISTENING_DELAY_DONE_STATE = 2;
private static int LISTENING_DELAY_STATE = LISTENING_DELAY_DONE_STATE;
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
......@@ -567,6 +577,9 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public void onDroidSpeechFinalResult(String finalSpeechResult) {
LISTENING_DELAY_STATE = LISTENING_DELAY_DONE_STATE;
handler.removeCallbacks(runnable);
if(droidSpeech != null) {
droidSpeech.closeDroidSpeechOperations();
}
......@@ -575,6 +588,16 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
}
@Override
public void onDroidSpeechStarted() {
callScreenOnAndOff(SCREEN_ON);
if(LISTENING_DELAY_STATE == LISTENING_DELAY_DONE_STATE) {
LISTENING_DELAY_STATE = LISTENING_DELAY_STARTED_STATE;
handler.postDelayed(runnable, LISTENING_DIALOG_DISMISS_DELAY_TIME);
}
}
@Override
public void onDroidSpeechClosedByUser() {
callScreenOnAndOff(SCREEN_OFF);
}
......@@ -602,11 +625,6 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
}
@Override
public void onDroidSpeechStarted() {
callScreenOnAndOff(SCREEN_ON);
}
@Override
public void onDestroy() {
super.onDestroy();
......@@ -663,5 +681,13 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
message.what = screenState;
handler.sendMessage(message);
}
Runnable runnable = new Runnable() {
@Override
public void run() {
LISTENING_DELAY_STATE = LISTENING_DELAY_DONE_STATE;
droidSpeech.closeDroidSpeechOperations();
}
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment