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
58b67311
authored
Apr 18, 2018
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fixed - Remove Create Incident notification when on chat screen.
parent
b66050a9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
app/src/main/java/com/vsoft/servicenow/service/NotificationMessagingService.java
app/src/main/java/com/vsoft/servicenow/ui/ChatActivity.java
app/src/main/java/com/vsoft/servicenow/service/NotificationMessagingService.java
View file @
58b67311
package
com
.
vsoft
.
servicenow
.
service
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.media.RingtoneManager
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.content.LocalBroadcastManager
;
...
...
@@ -37,6 +39,8 @@ public class NotificationMessagingService extends FirebaseMessagingService {
private
static
final
String
FCM_KEY_SHORT_DESCRIPTION
=
"short_description"
;
private
static
final
String
FCM_KEY_CREATED_BY
=
"created_by"
;
private
static
final
String
CHANNEL_ID
=
"sn_channel"
;
/**
* This is default constructor of NotificationMessagingService.
*/
...
...
@@ -94,10 +98,19 @@ public class NotificationMessagingService extends FirebaseMessagingService {
.
setContentText
(
notification
.
getShortDescription
())
.
setAutoCancel
(
true
)
.
setContentIntent
(
pendingIntent
)
.
setChannelId
(
CHANNEL_ID
)
.
setSound
(
defaultSoundUri
);
NotificationManager
notificationManager
=
(
NotificationManager
)
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
CharSequence
name
=
getString
(
R
.
string
.
app_name
);
// The user-visible name of the channel.
int
importance
=
NotificationManager
.
IMPORTANCE_DEFAULT
;
NotificationChannel
mChannel
=
new
NotificationChannel
(
CHANNEL_ID
,
name
,
importance
);
notificationManager
.
createNotificationChannel
(
mChannel
);
}
notificationManager
.
notify
(
1
,
notificationBuilder
.
build
());
}
...
...
app/src/main/java/com/vsoft/servicenow/ui/ChatActivity.java
View file @
58b67311
package
com
.
vsoft
.
servicenow
.
ui
;
import
android.app.NotificationManager
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.speech.tts.TextToSpeech
;
import
android.speech.tts.UtteranceProgressListener
;
import
android.support.v4.content.LocalBroadcastManager
;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.AlertDialog
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.Toolbar
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.MenuItem
;
import
android.view.MotionEvent
;
...
...
@@ -50,7 +59,7 @@ import java.util.List;
/**
* A chat Activity containing messages view and input form.
*/
public
class
ChatActivity
extends
HandleNotification
Activity
implements
OnDSListener
,
OnDSPermissionsListener
{
public
class
ChatActivity
extends
AppCompat
Activity
implements
OnDSListener
,
OnDSPermissionsListener
{
private
static
final
String
TAG
=
"ChatActivity"
;
...
...
@@ -99,6 +108,27 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
}
@Override
public
void
onResume
()
{
super
.
onResume
();
LocalBroadcastManager
.
getInstance
(
this
)
.
registerReceiver
(
mMessageReceiver
,
new
IntentFilter
(
Constants
.
BROADCAST_NOTIFICATION
));
}
private
final
BroadcastReceiver
mMessageReceiver
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
CatalogueLog
.
e
(
"Notification Receive"
);
final
NotificationManager
notificationManager
=
(
NotificationManager
)
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
//Play notification sound because Above we already cancel notifications.
// That's why we need to play explicitly
Util
.
playNotificationSound
(
ChatActivity
.
this
);
}
};
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -516,7 +546,8 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
@Override
public
void
onPause
()
{
super
.
onPause
();
LocalBroadcastManager
.
getInstance
(
this
)
.
unregisterReceiver
(
mMessageReceiver
);
if
(
speaker
!=
null
&&
speaker
.
isSpeaking
())
{
speaker
.
stop
();
}
...
...
@@ -524,6 +555,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
droidSpeech
.
closeDroidSpeechOperations
();
}
CURRENT_STATE
=
NONE
;
super
.
onPause
();
}
@Override
...
...
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