Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
9246b5f9
Commit
9246b5f9
authored
Jul 25, 2018
by
Sajal Narang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Temporarily disable notifications for Oreo
parent
95a5ead9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
42 deletions
+41
-42
app/src/main/java/app/insti/MainActivity.java
app/src/main/java/app/insti/MainActivity.java
+3
-1
app/src/main/java/app/insti/notifications/NotificationEventReceiver.java
...va/app/insti/notifications/NotificationEventReceiver.java
+3
-5
app/src/main/java/app/insti/notifications/NotificationIntentService.java
...va/app/insti/notifications/NotificationIntentService.java
+35
-36
No files found.
app/src/main/java/app/insti/MainActivity.java
View file @
9246b5f9
...
...
@@ -3,6 +3,7 @@ package app.insti;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.design.widget.NavigationView
;
import
android.support.v4.app.Fragment
;
...
...
@@ -97,7 +98,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
NotificationEventReceiver
.
setupAlarm
(
getApplicationContext
());
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
O
)
NotificationEventReceiver
.
setupAlarm
(
getApplicationContext
());
}
private
void
handleIntent
(
Intent
appLinkIntent
)
{
...
...
app/src/main/java/app/insti/notifications/NotificationEventReceiver.java
View file @
9246b5f9
...
...
@@ -2,7 +2,6 @@ package app.insti.notifications;
import
android.app.AlarmManager
;
import
android.app.PendingIntent
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.v4.content.WakefulBroadcastReceiver
;
...
...
@@ -11,9 +10,8 @@ import android.util.Log;
import
java.util.Calendar
;
import
java.util.Date
;
import
static
android
.
support
.
v4
.
content
.
ContextCompat
.
startForegroundService
;
public
class
NotificationEventReceiver
extends
BroadcastReceiver
{
public
class
NotificationEventReceiver
extends
WakefulBroadcastReceiver
{
private
static
final
String
ACTION_START_NOTIFICATION_SERVICE
=
"ACTION_START_NOTIFICATION_SERVICE"
;
private
static
final
String
ACTION_DELETE_NOTIFICATION
=
"ACTION_DELETE_NOTIFICATION"
;
...
...
@@ -59,7 +57,7 @@ public class NotificationEventReceiver extends BroadcastReceiver {
}
if
(
serviceIntent
!=
null
)
{
start
Foreground
Service
(
context
,
serviceIntent
);
start
Wakeful
Service
(
context
,
serviceIntent
);
}
}
}
\ No newline at end of file
app/src/main/java/app/insti/notifications/NotificationIntentService.java
View file @
9246b5f9
...
...
@@ -9,6 +9,7 @@ import android.content.Intent;
import
android.graphics.BitmapFactory
;
import
android.net.Uri
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.content.WakefulBroadcastReceiver
;
import
android.util.Log
;
import
java.util.Date
;
...
...
@@ -41,12 +42,6 @@ public class NotificationIntentService extends IntentService {
super
(
NotificationIntentService
.
class
.
getSimpleName
());
}
@Override
public
void
onCreate
()
{
super
.
onCreate
();
startForeground
(
1
,
new
Notification
());
}
public
static
Intent
createIntentStartNotificationService
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
NotificationIntentService
.
class
);
intent
.
setAction
(
ACTION_START
);
...
...
@@ -67,40 +62,44 @@ public class NotificationIntentService extends IntentService {
@Override
protected
void
onHandleIntent
(
Intent
intent
)
{
Log
.
d
(
getClass
().
getSimpleName
(),
"onHandleIntent, started handling a notification event"
);
String
action
=
intent
.
getAction
();
if
(
ACTION_START
.
equals
(
action
))
{
processStartNotification
();
}
if
(
ACTION_DELETE
.
equals
(
action
))
{
processDeleteNotification
(
intent
);
}
if
(
ACTION_NOT_GOING
.
equals
(
action
))
{
String
eventID
=
intent
.
getStringExtra
(
Constants
.
EVENT_ID
);
String
sessionID
=
intent
.
getStringExtra
(
Constants
.
SESSION_ID
);
try
{
String
action
=
intent
.
getAction
();
if
(
ACTION_START
.
equals
(
action
))
{
processStartNotification
();
}
if
(
ACTION_DELETE
.
equals
(
action
))
{
processDeleteNotification
(
intent
);
}
if
(
ACTION_NOT_GOING
.
equals
(
action
))
{
String
eventID
=
intent
.
getStringExtra
(
Constants
.
EVENT_ID
);
String
sessionID
=
intent
.
getStringExtra
(
Constants
.
SESSION_ID
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
retrofitInterface
.
updateUserEventStatus
(
"sessionid="
+
sessionID
,
eventID
,
Constants
.
STATUS_NOT_GOING
).
enqueue
(
new
Callback
<
Void
>()
{
@Override
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
retrofitInterface
.
updateUserEventStatus
(
"sessionid="
+
sessionID
,
eventID
,
Constants
.
STATUS_NOT_GOING
).
enqueue
(
new
Callback
<
Void
>()
{
@Override
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
}
}
@Override
public
void
onFailure
(
Call
<
Void
>
call
,
Throwable
t
)
{
@Override
public
void
onFailure
(
Call
<
Void
>
call
,
Throwable
t
)
{
}
});
manager
=
(
NotificationManager
)
this
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
manager
.
cancel
(
intent
.
getIntExtra
(
"NOTIFICATION_ID"
,
-
1
));
}
if
(
ACTION_NAVIGATE
.
equals
(
action
))
{
manager
=
(
NotificationManager
)
this
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
manager
.
cancel
(
intent
.
getIntExtra
(
"NOTIFICATION_ID"
,
-
1
));
double
latitude
=
intent
.
getDoubleExtra
(
Constants
.
EVENT_LATITUDE
,
0
);
double
longitude
=
intent
.
getDoubleExtra
(
Constants
.
EVENT_LONGITUDE
,
0
);
Uri
gmmIntentUri
=
Uri
.
parse
(
"google.navigation:q="
+
latitude
+
","
+
longitude
+
"&mode=w"
);
Intent
mapIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
gmmIntentUri
);
startActivity
(
mapIntent
);
}
});
manager
=
(
NotificationManager
)
this
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
manager
.
cancel
(
intent
.
getIntExtra
(
"NOTIFICATION_ID"
,
-
1
));
}
if
(
ACTION_NAVIGATE
.
equals
(
action
))
{
manager
=
(
NotificationManager
)
this
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
manager
.
cancel
(
intent
.
getIntExtra
(
"NOTIFICATION_ID"
,
-
1
));
double
latitude
=
intent
.
getDoubleExtra
(
Constants
.
EVENT_LATITUDE
,
0
);
double
longitude
=
intent
.
getDoubleExtra
(
Constants
.
EVENT_LONGITUDE
,
0
);
Uri
gmmIntentUri
=
Uri
.
parse
(
"google.navigation:q="
+
latitude
+
","
+
longitude
+
"&mode=w"
);
Intent
mapIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
gmmIntentUri
);
startActivity
(
mapIntent
);
}
}
finally
{
WakefulBroadcastReceiver
.
completeWakefulIntent
(
intent
);
}
}
...
...
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