@@ -29,6 +29,8 @@ public class ApplicationUpdateBroadcastReceiver extends BroadcastReceiver {
29
29
30
30
private static final int NOTIFICATION_ID = 1 ;
31
31
32
+ private static final boolean mTestWasChanged = false ;
33
+
32
34
@ Override
33
35
public void onReceive (final Context context , final Intent intent ) {
34
36
List <String > currentTestsAvailable = new ArrayList <>();
@@ -41,7 +43,7 @@ public void onReceive(final Context context, final Intent intent) {
41
43
42
44
// First run, save the current list of scans.
43
45
if (testsAvailableOnPreviousBuild == null ) {
44
- Log .d (TAG , "This is the first time this detection is running." );
46
+ Log .d (TAG , "This is the first time this detection is running." );
45
47
SharedPreferencesUtils .setTheListOfScansAvailable (context , currentTestsAvailable );
46
48
47
49
return ;
@@ -50,11 +52,16 @@ public void onReceive(final Context context, final Intent intent) {
50
52
// Update application with the tests available.
51
53
SharedPreferencesUtils .setTheListOfScansAvailable (context , currentTestsAvailable );
52
54
55
+ if (mTestWasChanged ){
56
+ buildNotification (context , false );
57
+ Log .d (TAG , "An existing test was updated" );
58
+ }
59
+
53
60
for (String testName : currentTestsAvailable ) {
54
61
if (!testsAvailableOnPreviousBuild .contains (testName )) {
55
62
56
63
// This test is new, show a notification to the user.
57
- buildNotification (context );
64
+ buildNotification (context , true );
58
65
Log .d (TAG , String .format ("New test available:, %s" , testName ));
59
66
60
67
return ;
@@ -64,11 +71,12 @@ public void onReceive(final Context context, final Intent intent) {
64
71
Log .d (TAG , "Without new tests detected." );
65
72
}
66
73
67
- private void buildNotification (Context context ) {
74
+ private void buildNotification (Context context , boolean forNewTest ) {
68
75
NotificationCompat .Builder builder = new NotificationCompat .Builder (context ).setSmallIcon (R .drawable .ic_notification )
69
76
.setAutoCancel (true )
70
77
.setContentTitle (context .getString (R .string .app_name ))
71
- .setContentText (context .getString (R .string .notification_new_tests ));
78
+ .setContentText (forNewTest ? context .getString (R .string .notification_new_tests ) :
79
+ context .getString (R .string .existing_test_updated ));
72
80
73
81
Intent notificationIntent = new Intent (context , MainActivity .class );
74
82
0 commit comments