Permalink
Browse files

[Mobile] Fixed bug which prevented tram notifications from scheduling…

…. Also fixed Firebase Messaging issue which prevented notifications from displaying.

[Trivial] Bumped version numbers for release v0.109.
  • Loading branch information...
thecosmicfrog committed Jun 18, 2018
1 parent 5e33129 commit 0f170a4cb8c33609cbafefe3de971367b157a04b
View
@@ -8,8 +8,8 @@ android {
applicationId "org.thecosmicfrog.luasataglance"
minSdkVersion 16
targetSdkVersion 26
versionCode 103
versionName "0.103"
versionCode 109
versionName "0.109"
}
buildTypes {
release {
@@ -30,8 +30,8 @@ dependencies {
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
api 'com.google.firebase:firebase-core:11.8.0'
api 'com.google.firebase:firebase-messaging:11.8.0'
}
// Firebase
@@ -34,11 +34,9 @@
import android.widget.Button;
import android.widget.Spinner;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.iid.FirebaseInstanceId;
import org.thecosmicfrog.luasataglance.R;
import org.thecosmicfrog.luasataglance.object.NotifyTimesMap;
import org.thecosmicfrog.luasataglance.receiver.NotifyTimesReceiver;
import org.thecosmicfrog.luasataglance.util.Analytics;
import org.thecosmicfrog.luasataglance.util.Constant;
import org.thecosmicfrog.luasataglance.util.Preferences;
@@ -99,6 +97,8 @@ public void onClick(View v) {
* LineFragment.
*/
Intent intent = new Intent();
intent.setPackage(getPackageName());
intent.setClass(getApplicationContext(), NotifyTimesReceiver.class);
intent.setAction(NotifyTimeActivity.class.getName());
intent.putExtra(
Constant.NOTIFY_STOP_NAME,
@@ -23,13 +23,15 @@
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.RingtoneManager;
import android.os.Build;
import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
import android.widget.Toast;
@@ -143,6 +145,7 @@ public void onReceive(Context context, Intent intent) {
* stop-to-notify-for as a String extra.
*/
Intent intentOpenMainActivity = new Intent(context, MainActivity.class);
intentOpenMainActivity.setPackage(context.getPackageName());
intentOpenMainActivity.setAction(NotifyTimesReceiver.class.getName());
intentOpenMainActivity.setFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
@@ -156,14 +159,42 @@ public void onReceive(Context context, Intent intent) {
PendingIntent.FLAG_UPDATE_CURRENT
);
/*
* Create a NotificationManager.
*/
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE
);
/* Android Oreo and above require a NotificationChannel to be created. */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel =
new NotificationChannel(
"notifyTimes",
"Notify Times",
NotificationManager.IMPORTANCE_HIGH
);
/* Configure notification channel. */
notificationChannel.setDescription("Notify Times");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(context.getColor(R.color.luas_purple));
notificationChannel.setVibrationPattern(new long[] {100, 1000, 1000, 1000, 1000});
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
}
/*
* Create the NotificationBuilder, setting an appropriate title and the message
* built in the StringBuilder. The default notification sound should be played
* and the device should vibrate twice for 1 second with a 1 second delay
* between them. Setting MAX priority due to the time-sensitive nature of trams.
*/
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(context)
new NotificationCompat.Builder(context, "notifyTimes")
.setPriority(Notification.PRIORITY_MAX)
.setContentIntent(pendingIntentOpenMainActivity)
.setContentTitle(
@@ -181,13 +212,7 @@ public void onReceive(Context context, Intent intent) {
)
.setAutoCancel(true);
/*
* Create a NotificationManager and display the notification to the user.
*/
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE
);
/* Display notification. */
notificationManager.notify(1, notificationBuilder.build());
}
};
@@ -200,7 +225,7 @@ public void onReceive(Context context, Intent intent) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context,
REQUEST_CODE_SCHEDULE_NOTIFICATION,
new Intent("org.thecosmicfrog.luasataglance"),
new Intent(context.getPackageName()),
PendingIntent.FLAG_UPDATE_CURRENT
);
@@ -22,11 +22,13 @@
package org.thecosmicfrog.luasataglance.util;
import android.app.Notification;
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.os.Build;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
@@ -122,10 +124,34 @@ public static void showNotification(Context context, RemoteMessage remoteMessage
);
/*
* Prepare the notification.
* Create a NotificationManager.
*/
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE
);
/* Android Oreo and above require a NotificationChannel to be created. */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel =
new NotificationChannel(
"fcmNotification",
"Firebase Cloud Messaging notification",
NotificationManager.IMPORTANCE_HIGH
);
/* Configure notification channel. */
notificationChannel.setDescription("Firebase Cloud Messaging notification");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(context.getColor(R.color.luas_purple));
notificationChannel.setVibrationPattern(new long[] {100, 1000, 1000, 1000, 1000});
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
}
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(context)
new NotificationCompat.Builder(context, "fcmNotification")
.setPriority(Notification.PRIORITY_DEFAULT)
.setContentIntent(pendingIntentOpenActivity)
.setContentTitle(remoteMessage.getNotification().getTitle())
@@ -139,13 +165,7 @@ public static void showNotification(Context context, RemoteMessage remoteMessage
)
.setAutoCancel(true);
/*
* Create a NotificationManager and display the notification to the user.
*/
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE
);
/* Display notification. */
notificationManager.notify(1, notificationBuilder.build());
}
}
@@ -23,8 +23,8 @@
App
-->
<string name="app_name">Luas at a Glance</string>
<string name="version_code" translatable="false">103</string>
<string name="version_name" translatable="false">0.103</string>
<string name="version_code" translatable="false">109</string>
<string name="version_name" translatable="false">0.109</string>
<!--
Activities
@@ -161,12 +161,12 @@
<!--
What's New
-->
<string name="whatsnew_title_current" translatable="false">Version 0.103 (9th January 2018)
<string name="whatsnew_title_current" translatable="false">Version 0.109 (18th June 2018)
</string>
<string name="whatsnew_content_current" translatable="false">\u2022 [FIXED] Fixed bug where stop
forecast would not display on Android Wear devices. Thanks to everyone who reported this!
\nIf you have an Android Wear smartwatch, you can install Luas at a Glance from the Play
Store on your watch.
forecast would not display on Wear OS (Android Wear) devices. Thanks to everyone who
reported this!\nIf you have a Wear OS smartwatch, you can install Luas at a Glance from the
Play Store on your watch.
</string>
<string name="whatsnew_title_previous" translatable="false">Version 0.100 (8th December 2017)
</string>
View
@@ -10,8 +10,8 @@ android {
applicationId "org.thecosmicfrog.luasataglance"
minSdkVersion 21
targetSdkVersion 26
versionCode 10300
versionName "0.103"
versionCode 10900
versionName "0.109"
}
buildTypes {
release {
@@ -23,7 +23,7 @@ android {
productFlavors {
wear2 {
minSdkVersion 25
versionCode 10301
versionCode 10901
}
}
}
@@ -23,8 +23,8 @@
App
-->
<string name="app_name">Luas at a Glance</string>
<string name="version_code" translatable="false">103</string>
<string name="version_name" translatable="false">0.103</string>
<string name="version_code" translatable="false">109</string>
<string name="version_name" translatable="false">0.109</string>
<!--
Activities

0 comments on commit 0f170a4

Please sign in to comment.