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
8797f0d6
authored
May 02, 2018
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added PTO request notification functionality.
parent
2cb9e987
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
59 deletions
app/src/main/java/com/vsoft/servicenow/adapters/HomeScreenAdapter.java
app/src/main/java/com/vsoft/servicenow/db/DBManager.java
app/src/main/java/com/vsoft/servicenow/service/NotificationMessagingService.java
app/src/vportal/google-services.json
app/src/vportal/java/com/vsoft/servicenow/MenuProvider.java
app/src/main/java/com/vsoft/servicenow/adapters/HomeScreenAdapter.java
View file @
8797f0d6
...
@@ -11,8 +11,11 @@ import android.widget.TextView;
...
@@ -11,8 +11,11 @@ import android.widget.TextView;
import
com.vsoft.servicenow.R
;
import
com.vsoft.servicenow.R
;
import
com.vsoft.servicenow.menu.HomeScreenMenuItemData
;
import
com.vsoft.servicenow.menu.HomeScreenMenuItemData
;
import
com.vsoft.servicenow.menu.NotificationMenuItemData
;
import
com.vsoft.servicenow.utils.CatalogueLog
;
import
com.vsoft.servicenow.utils.Constants
;
import
com.vsoft.servicenow.utils.Constants
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -27,7 +30,15 @@ public class HomeScreenAdapter extends BaseAdapter {
...
@@ -27,7 +30,15 @@ public class HomeScreenAdapter extends BaseAdapter {
//Constructor to initialize values
//Constructor to initialize values
public
HomeScreenAdapter
(
Context
context
,
List
<
HomeScreenMenuItemData
>
homeScreenMenuItemDataList
)
{
public
HomeScreenAdapter
(
Context
context
,
List
<
HomeScreenMenuItemData
>
homeScreenMenuItemDataList
)
{
mContext
=
context
;
mContext
=
context
;
mHomeScreenMenuItemDataList
=
homeScreenMenuItemDataList
;
// mHomeScreenMenuItemDataList = homeScreenMenuItemDataList;
mHomeScreenMenuItemDataList
=
new
ArrayList
<>(
homeScreenMenuItemDataList
.
size
()
-
1
);
for
(
int
i
=
0
;
i
<
homeScreenMenuItemDataList
.
size
();
i
++)
{
HomeScreenMenuItemData
homeScreenMenuItemData
=
homeScreenMenuItemDataList
.
get
(
i
);
if
(
homeScreenMenuItemData
instanceof
NotificationMenuItemData
)
{
}
else
{
mHomeScreenMenuItemDataList
.
add
(
homeScreenMenuItemData
);
}
}
mInflater
=
(
LayoutInflater
)
context
mInflater
=
(
LayoutInflater
)
context
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
}
}
...
...
app/src/main/java/com/vsoft/servicenow/db/DBManager.java
View file @
8797f0d6
...
@@ -41,9 +41,9 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
...
@@ -41,9 +41,9 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
createAttachmentTable
(
db
);
createAttachmentTable
(
db
);
createIncidentInputTable
(
db
);
createIncidentInputTable
(
db
);
if
(
Util
.
isNotificationsItemEnabled
())
{
//
if(Util.isNotificationsItemEnabled()) {
createNotificationsTable
(
db
);
//
createNotificationsTable(db);
}
//
}
if
(
Util
.
isChatItemEnabled
())
{
if
(
Util
.
isChatItemEnabled
())
{
createChatBotTable
(
db
);
createChatBotTable
(
db
);
...
...
app/src/main/java/com/vsoft/servicenow/service/NotificationMessagingService.java
View file @
8797f0d6
package
com
.
vsoft
.
servicenow
.
service
;
package
com
.
vsoft
.
servicenow
.
service
;
import
android.app.Notification
;
import
android.app.NotificationChannel
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.app.PendingIntent
;
...
@@ -19,6 +20,7 @@ import com.vsoft.servicenow.db.managers.NotificationsManager;
...
@@ -19,6 +20,7 @@ import com.vsoft.servicenow.db.managers.NotificationsManager;
import
com.vsoft.servicenow.db.models.Notifications
;
import
com.vsoft.servicenow.db.models.Notifications
;
import
com.vsoft.servicenow.ui.NotificationScreen
;
import
com.vsoft.servicenow.ui.NotificationScreen
;
import
com.vsoft.servicenow.ui.PendingApprovalsActivity
;
import
com.vsoft.servicenow.ui.PendingApprovalsActivity
;
import
com.vsoft.servicenow.utils.CatalogueLog
;
import
com.vsoft.servicenow.utils.Constants
;
import
com.vsoft.servicenow.utils.Constants
;
import
com.vsoft.servicenow.utils.PrefManager
;
import
com.vsoft.servicenow.utils.PrefManager
;
...
@@ -46,6 +48,7 @@ public class NotificationMessagingService extends FirebaseMessagingService {
...
@@ -46,6 +48,7 @@ public class NotificationMessagingService extends FirebaseMessagingService {
private
static
final
String
FCM_KEY_SHORT_DESCRIPTION
=
"short_description"
;
private
static
final
String
FCM_KEY_SHORT_DESCRIPTION
=
"short_description"
;
private
static
final
String
FCM_KEY_CREATED_BY
=
"created_by"
;
private
static
final
String
FCM_KEY_CREATED_BY
=
"created_by"
;
private
static
final
String
FCM_KEY_MESSAGE_BODY_TITLE
=
"title"
;
private
static
final
String
FCM_KEY_MESSAGE_BODY_TITLE
=
"title"
;
private
static
final
String
FCM_KEY_PTO_REQUEST_STATUS
=
"u_request_status"
;
private
static
final
String
CHANNEL_ID
=
"sn_channel"
;
private
static
final
String
CHANNEL_ID
=
"sn_channel"
;
...
@@ -62,8 +65,9 @@ public class NotificationMessagingService extends FirebaseMessagingService {
...
@@ -62,8 +65,9 @@ public class NotificationMessagingService extends FirebaseMessagingService {
if
(
userSysId
!=
null
&&
!
userSysId
.
isEmpty
())
{
if
(
userSysId
!=
null
&&
!
userSysId
.
isEmpty
())
{
Map
<
String
,
String
>
dataMap
=
remoteMessage
.
getData
();
Map
<
String
,
String
>
dataMap
=
remoteMessage
.
getData
();
String
title
=
dataMap
.
get
(
FCM_KEY_TITLE
);
String
title
=
dataMap
.
get
(
FCM_KEY_TITLE
);
CatalogueLog
.
e
(
"onMessageReceived: dataMap: "
+
dataMap
+
", title: "
+
title
);
String
messageBody
=
dataMap
.
get
(
FCM_KEY_BODY
);
String
messageBody
=
dataMap
.
get
(
FCM_KEY_BODY
);
String
priority
=
null
,
shortDes
=
null
,
createdBy
=
null
,
messageBodyTitle
=
null
,
requestState
=
null
,
documentId
=
null
;
String
priority
=
null
,
shortDes
=
null
,
createdBy
=
null
,
messageBodyTitle
=
null
,
requestState
=
null
,
documentId
=
null
,
ptoRequestStatus
=
null
;
try
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
messageBody
);
JSONObject
jsonObject
=
new
JSONObject
(
messageBody
);
if
(!
jsonObject
.
isNull
(
FCM_KEY_INCIDENT_PRIORITY
))
{
if
(!
jsonObject
.
isNull
(
FCM_KEY_INCIDENT_PRIORITY
))
{
...
@@ -75,42 +79,49 @@ public class NotificationMessagingService extends FirebaseMessagingService {
...
@@ -75,42 +79,49 @@ public class NotificationMessagingService extends FirebaseMessagingService {
if
(!
jsonObject
.
isNull
(
FCM_KEY_REQUEST_STATE
))
{
if
(!
jsonObject
.
isNull
(
FCM_KEY_REQUEST_STATE
))
{
requestState
=
jsonObject
.
getString
(
FCM_KEY_REQUEST_STATE
);
requestState
=
jsonObject
.
getString
(
FCM_KEY_REQUEST_STATE
);
}
}
if
(!
jsonObject
.
isNull
(
FCM_KEY_CREATED_BY
))
{
createdBy
=
jsonObject
.
getString
(
FCM_KEY_CREATED_BY
);
createdBy
=
jsonObject
.
getString
(
FCM_KEY_CREATED_BY
);
}
if
(!
jsonObject
.
isNull
(
FCM_KEY_MESSAGE_BODY_TITLE
))
{
messageBodyTitle
=
jsonObject
.
getString
(
FCM_KEY_MESSAGE_BODY_TITLE
);
messageBodyTitle
=
jsonObject
.
getString
(
FCM_KEY_MESSAGE_BODY_TITLE
);
}
if
(!
jsonObject
.
isNull
(
FCM_KEY_PTO_REQUEST_STATUS
))
{
ptoRequestStatus
=
jsonObject
.
getString
(
FCM_KEY_PTO_REQUEST_STATUS
);
}
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
Notifications
newNotification
=
null
;
Notifications
newNotification
=
null
;
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_INCIDENT_TITLE
))
{
// if(messageBodyTitle.equals(MESSAGE_BODY_INCIDENT_TITLE)) {
newNotification
=
new
Notifications
();
newNotification
.
setTitle
(
title
);
newNotification
.
setShortDescription
(
shortDes
);
newNotification
.
setPriority
(
priority
);
newNotification
.
setCreated_by
(
createdBy
);
NotificationsManager
.
save
(
newNotification
);
}
else
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_REQUEST_TITLE
))
{
newNotification
=
new
Notifications
();
newNotification
.
setTitle
(
title
);
newNotification
.
setShortDescription
(
shortDes
);
newNotification
.
setPriority
(
requestState
);
newNotification
.
setCreated_by
(
createdBy
);
NotificationsManager
.
save
(
newNotification
);
}
else
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_APPROVALS_TITLE
))
{
newNotification
=
new
Notifications
();
newNotification
=
new
Notifications
();
newNotification
.
setTitle
(
title
);
newNotification
.
setTitle
(
title
);
newNotification
.
setShortDescription
(
shortDes
);
newNotification
.
setShortDescription
(
shortDes
);
newNotification
.
setPriority
(
requestState
);
newNotification
.
setPriority
(
ptoRequestStatus
);
newNotification
.
setCreated_by
(
createdBy
);
newNotification
.
setCreated_by
(
createdBy
);
}
// NotificationsManager.save(newNotification);
// } else if(messageBodyTitle.equals(MESSAGE_BODY_REQUEST_TITLE)) {
// newNotification = new Notifications();
// newNotification.setTitle(title);
// newNotification.setShortDescription(shortDes);
// newNotification.setPriority(requestState);
// newNotification.setCreated_by(createdBy);
// NotificationsManager.save(newNotification);
// } else if(messageBodyTitle.equals(MESSAGE_BODY_APPROVALS_TITLE)) {
// newNotification = new Notifications();
// newNotification.setTitle(title);
// newNotification.setShortDescription(shortDes);
// newNotification.setPriority(requestState);
// newNotification.setCreated_by(createdBy);
// }
sendNotification
(
newNotification
,
messageBodyTitle
,
null
);
sendNotification
(
newNotification
,
messageBodyTitle
,
null
);
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_APPROVALS_TITLE
))
{
//
if(messageBodyTitle.equals(MESSAGE_BODY_APPROVALS_TITLE)) {
sendLocalMessage
(
NotificationMessagingService
.
this
,
newNotification
,
true
);
//
sendLocalMessage(NotificationMessagingService.this, newNotification, true);
}
else
{
//
} else {
sendLocalMessage
(
NotificationMessagingService
.
this
,
newNotification
,
false
);
//
sendLocalMessage(NotificationMessagingService.this, newNotification, false);
}
//
}
}
}
}
}
...
@@ -124,35 +135,35 @@ public class NotificationMessagingService extends FirebaseMessagingService {
...
@@ -124,35 +135,35 @@ public class NotificationMessagingService extends FirebaseMessagingService {
private
void
sendNotification
(
Notifications
notification
,
String
messageBodyTitle
,
String
documentId
)
{
private
void
sendNotification
(
Notifications
notification
,
String
messageBodyTitle
,
String
documentId
)
{
String
title
=
null
;
String
title
=
null
;
Intent
newIntent
=
null
;
//
Intent newIntent = null;
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_APPROVALS_TITLE
))
{
//
if(messageBodyTitle.equals(MESSAGE_BODY_APPROVALS_TITLE)) {
title
=
getString
(
R
.
string
.
notification_status_bar_approvals_title_string
);
//
title = getString(R.string.notification_status_bar_approvals_title_string);
newIntent
=
new
Intent
(
this
,
PendingApprovalsActivity
.
class
);
//
newIntent = new Intent(this, PendingApprovalsActivity.class);
}
else
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_INCIDENT_TITLE
))
{
//
} else if(messageBodyTitle.equals(MESSAGE_BODY_INCIDENT_TITLE)) {
title
=
getString
(
R
.
string
.
notification_status_bar_incident_title_string
);
//
title = getString(R.string.notification_status_bar_incident_title_string);
newIntent
=
new
Intent
(
this
,
NotificationScreen
.
class
);
//
newIntent = new Intent(this, NotificationScreen.class);
}
else
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_REQUEST_TITLE
))
{
//
} else if(messageBodyTitle.equals(MESSAGE_BODY_REQUEST_TITLE)) {
title
=
getString
(
R
.
string
.
notification_status_bar_request_title_string
);
//
title = getString(R.string.notification_status_bar_request_title_string);
newIntent
=
new
Intent
(
this
,
NotificationScreen
.
class
);
//
newIntent = new Intent(this, NotificationScreen.class);
}
else
if
(
messageBodyTitle
.
equals
(
MESSAGE_BODY_HR_CASE_TITLE
))
{
//
} else if(messageBodyTitle.equals(MESSAGE_BODY_HR_CASE_TITLE)) {
title
=
getString
(
R
.
string
.
notification_status_bar_hr_case_title_string
);
//
title = getString(R.string.notification_status_bar_hr_case_title_string);
newIntent
=
new
Intent
(
this
,
NotificationScreen
.
class
);
//
newIntent = new Intent(this, NotificationScreen.class);
}
//
}
newIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
//
newIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
newIntent
,
//
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, newIntent,
PendingIntent
.
FLAG_ONE_SHOT
);
//
PendingIntent.FLAG_ONE_SHOT);
Uri
defaultSoundUri
=
RingtoneManager
.
getDefaultUri
(
RingtoneManager
.
TYPE_NOTIFICATION
);
Uri
defaultSoundUri
=
RingtoneManager
.
getDefaultUri
(
RingtoneManager
.
TYPE_NOTIFICATION
);
NotificationCompat
.
Builder
notificationBuilder
=
new
NotificationCompat
.
Builder
(
this
,
CHANNEL_ID
)
NotificationCompat
.
Builder
notificationBuilder
=
new
NotificationCompat
.
Builder
(
this
,
CHANNEL_ID
)
.
setSmallIcon
(
R
.
drawable
.
notification_icon
)
.
setSmallIcon
(
R
.
drawable
.
notification_icon
)
.
setContentTitle
(
title
)
.
setContentTitle
(
notification
.
getTitle
()
)
.
setContentText
(
notification
!=
null
?
notification
.
getShortDescription
()
:
documentId
)
.
setContentText
(
notification
.
getShortDescription
()
+
"\n"
+
"Status: "
+
notification
.
getPriority
()
)
.
setAutoCancel
(
true
)
.
setAutoCancel
(
true
)
.
setContentIntent
(
pendingIntent
)
// .setContentIntent(null
)
.
setChannelId
(
CHANNEL_ID
)
.
setChannelId
(
CHANNEL_ID
)
.
setSound
(
defaultSoundUri
);
.
setSound
(
defaultSoundUri
);
...
...
app/src/vportal/google-services.json
View file @
8797f0d6
...
@@ -8,9 +8,9 @@
...
@@ -8,9 +8,9 @@
"client"
:
[
"client"
:
[
{
{
"client_info"
:
{
"client_info"
:
{
"mobilesdk_app_id"
:
"1:222593508124:android:
d77c1b70d2a38b4
d"
,
"mobilesdk_app_id"
:
"1:222593508124:android:
afc437977a23c97
d"
,
"android_client_info"
:
{
"android_client_info"
:
{
"package_name"
:
"com.vsoft.servicenow.
arrow.debu
g"
"package_name"
:
"com.vsoft.servicenow.
vportal.stagin
g"
}
}
},
},
"oauth_client"
:
[
"oauth_client"
:
[
...
@@ -39,9 +39,9 @@
...
@@ -39,9 +39,9 @@
},
},
{
{
"client_info"
:
{
"client_info"
:
{
"mobilesdk_app_id"
:
"1:222593508124:android:a
de631ceed1f3560
"
,
"mobilesdk_app_id"
:
"1:222593508124:android:a
fc437977a23c97d
"
,
"android_client_info"
:
{
"android_client_info"
:
{
"package_name"
:
"com.vsoft.servicenow.vportal
.debug
"
"package_name"
:
"com.vsoft.servicenow.vportal"
}
}
},
},
"oauth_client"
:
[
"oauth_client"
:
[
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
"client_info"
:
{
"client_info"
:
{
"mobilesdk_app_id"
:
"1:222593508124:android:ade631ceed1f3560"
,
"mobilesdk_app_id"
:
"1:222593508124:android:ade631ceed1f3560"
,
"android_client_info"
:
{
"android_client_info"
:
{
"package_name"
:
"com.vsoft.servicenow.vportal"
"package_name"
:
"com.vsoft.servicenow.vportal
.debug
"
}
}
},
},
"oauth_client"
:
[
"oauth_client"
:
[
...
...
app/src/vportal/java/com/vsoft/servicenow/MenuProvider.java
View file @
8797f0d6
...
@@ -47,11 +47,11 @@ public class MenuProvider {
...
@@ -47,11 +47,11 @@ public class MenuProvider {
new
ChatMenuItemData
.
Builder
()
new
ChatMenuItemData
.
Builder
()
.
setTitle
(
R
.
string
.
home_screen_chat_title
)
.
setTitle
(
R
.
string
.
home_screen_chat_title
)
.
setMenuIconResId
(
R
.
string
.
home_screen_chat_icon
)
.
setMenuIconResId
(
R
.
string
.
home_screen_chat_icon
)
.
build
(),
new
NotificationMenuItemData
.
Builder
()
.
setTitle
(
R
.
string
.
home_screen_notification_title
)
.
setMenuIconResId
(
R
.
string
.
home_screen_notification_icon
)
.
build
()
.
build
()
// new NotificationMenuItemData.Builder()
// .setTitle(R.string.home_screen_notification_title)
// .setMenuIconResId(R.string.home_screen_notification_icon)
// .build(),
// new ApprovalsMenuItemData.Builder()
// new ApprovalsMenuItemData.Builder()
// .setTitle(R.string.home_screen_approvals_title)
// .setTitle(R.string.home_screen_approvals_title)
// .setMenuIconResId(R.string.home_screen_approvals_icon)
// .setMenuIconResId(R.string.home_screen_approvals_icon)
...
...
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