This repository has been archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
168 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
app/src/main/java/org/iilab/pb/receiver/UpdateReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.iilab.pb.receiver; | ||
|
||
import android.app.PendingIntent; | ||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.support.v4.app.NotificationCompat; | ||
import android.support.v4.app.NotificationManagerCompat; | ||
import android.util.Log; | ||
|
||
import org.iilab.pb.CalculatorActivity; | ||
import org.iilab.pb.R; | ||
|
||
import static org.iilab.pb.common.AppConstants.APP_RELEASE_VERSION_1_5; | ||
import static org.iilab.pb.common.ApplicationSettings.getLastUpdatedVersion; | ||
|
||
public class UpdateReceiver extends BroadcastReceiver | ||
{ | ||
private static final String TAG = UpdateReceiver.class.getName(); | ||
public static class LegacyUpdateReceiver extends BroadcastReceiver | ||
{ | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
if (intent != null && intent.getData() != null && context.getPackageName().equals(intent.getData().getSchemeSpecificPart())) { | ||
onUpdate(context); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) | ||
{ | ||
onUpdate(context); | ||
} | ||
|
||
public static void onUpdate(Context context) | ||
{ | ||
Log.d(TAG, "PB app updated"); | ||
if (getLastUpdatedVersion(context) == APP_RELEASE_VERSION_1_5) | ||
displayNotification(context); | ||
} | ||
|
||
public static void displayNotification(Context context) { | ||
// Invoking the default notification service | ||
Log.d(TAG, "inside displayNotification for update of PB triggerred for 1.5 release"); | ||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context); | ||
int notifyID = 1; | ||
mBuilder.setContentTitle("Calculate!"); | ||
mBuilder.setContentText("Calculate! has been updated!"); | ||
mBuilder.setSmallIcon(R.drawable.warning); | ||
mBuilder.setAutoCancel(true); | ||
Intent calculatorActivityIntent = new Intent(context.getApplicationContext(), CalculatorActivity.class); | ||
calculatorActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, | ||
calculatorActivityIntent, 0); | ||
// start the activity when the user clicks the notification text | ||
mBuilder.setContentIntent(resultPendingIntent); | ||
NotificationManagerCompat myNotificationManager = NotificationManagerCompat.from(context); | ||
// pass the Notification object to the system | ||
myNotificationManager.notify(notifyID, mBuilder.build()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<item name="is_at_least_api_12" type="bool">true</item> | ||
<item name="is_at_most_api_11" type="bool">false</item> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<item name="is_at_least_api_12" type="bool">false</item> | ||
<item name="is_at_most_api_11" type="bool">true</item> | ||
|
||
</resources> |