Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishna Vemulavada
/
vera_2.1_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
19d3ced5
authored
Apr 11, 2018
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added conversation flag in chatscreen.
parent
0d0aeea9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
app/src/main/java/com/vsoft/servicenow/ui/ChatActivity.java
app/src/main/java/com/vsoft/servicenow/ui/ChatActivity.java
View file @
19d3ced5
...
...
@@ -60,6 +60,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
private
static
String
NEW_MESSAGE_USER_NAME
=
"username"
;
private
static
String
NEW_MESSAGE_MESSAGE
=
"message"
;
private
static
String
IS_END_OF_INTENT
=
"is_end_of_intent"
;
private
static
final
int
CHECK_CODE
=
102
;
...
...
@@ -82,6 +83,9 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
private
ImageButton
mVoiceButton
;
private
DroidSpeech
droidSpeech
;
/*According to this flag we'll close the conversation from mobile side. We'll get this flag in chat response*/
private
boolean
mIsConversationEnd
;
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
menuItem
)
{
if
(
menuItem
.
getItemId
()
==
android
.
R
.
id
.
home
)
{
...
...
@@ -213,7 +217,6 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
if
(
CURRENT_STATE
==
VOICE_STATE
&&
!
username
.
equals
(
mLoggedInUsername
))
{
if
(
droidSpeech
!=
null
)
{
CatalogueLog
.
i
(
"addMessage: close droid speech"
);
droidSpeech
.
closeDroidSpeechOperations
();
}
speaker
.
allow
(
true
);
...
...
@@ -278,7 +281,6 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
CatalogueLog
.
e
(
"diconnected"
);
isConnected
=
false
;
Toast
.
makeText
(
getApplicationContext
(),
R
.
string
.
disconnect
,
Toast
.
LENGTH_LONG
).
show
();
...
...
@@ -296,7 +298,6 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
CatalogueLog
.
e
(
"Error connecting"
);
Toast
.
makeText
(
getApplicationContext
(),
R
.
string
.
error_connect
,
Toast
.
LENGTH_LONG
).
show
();
}
...
...
@@ -310,6 +311,8 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
private
Emitter
.
Listener
onNewMessage
=
new
Emitter
.
Listener
()
{
@Override
public
void
call
(
final
Object
...
args
)
{
/*Reset this flag every time*/
mIsConversationEnd
=
false
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -319,6 +322,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
try
{
username
=
data
.
getString
(
NEW_MESSAGE_USER_NAME
);
message
=
data
.
getString
(
NEW_MESSAGE_MESSAGE
);
mIsConversationEnd
=
data
.
getBoolean
(
IS_END_OF_INTENT
);
}
catch
(
JSONException
e
)
{
CatalogueLog
.
e
(
e
.
getMessage
());
return
;
...
...
@@ -345,7 +349,6 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
private
Emitter
.
Listener
authenticated
=
new
Emitter
.
Listener
()
{
@Override
public
void
call
(
final
Object
...
args
)
{
CatalogueLog
.
e
(
"authorized user: "
+
args
[
0
]);
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -371,7 +374,6 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
@Override
public
void
run
()
{
//TODO : need to check if access token is valid or not.
CatalogueLog
.
e
(
"unauthorized user: "
+
args
[
0
]);
Toast
.
makeText
(
getApplicationContext
(),
R
.
string
.
unauthorized_user
,
Toast
.
LENGTH_LONG
).
show
();
}
...
...
@@ -437,8 +439,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
speaker
.
getTTS
().
setOnUtteranceProgressListener
(
new
UtteranceProgressListener
()
{
@Override
public
void
onDone
(
String
utteranceId
)
{
CatalogueLog
.
i
(
"onActivityResult: Speaking done: isSpeaking: "
+
speaker
.
isSpeaking
()+
", droidSpeech: "
+
droidSpeech
);
if
(!
speaker
.
isSpeaking
()
&&
droidSpeech
!=
null
)
{
if
(!
mIsConversationEnd
&&
(!
speaker
.
isSpeaking
()
&&
droidSpeech
!=
null
))
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -456,7 +457,6 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
@Override
public
void
onStart
(
String
utteranceId
)
{
if
(
droidSpeech
!=
null
)
{
CatalogueLog
.
i
(
"onActivityResult: close droid speech"
);
droidSpeech
.
closeDroidSpeechOperations
();
}
}
...
...
@@ -503,7 +503,6 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
speaker
.
stop
();
}
if
(
droidSpeech
!=
null
)
{
CatalogueLog
.
i
(
"onPause: close droid speech"
);
droidSpeech
.
closeDroidSpeechOperations
();
}
CURRENT_STATE
=
NONE
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment