Bug 608624 - Clearing update notification launches fennec r=blassey a=dougt

This commit is contained in:
Alex Pakhotin 2010-11-30 21:57:21 -08:00
parent f4e14ea96e
commit 0597546369
3 changed files with 14 additions and 22 deletions

View File

@ -64,14 +64,12 @@
</intent-filter>
</activity>
<activity android:name="NotificationHandler"
android:label="@MOZ_APP_DISPLAYNAME@ Notification"
android:theme="@android:style/Theme.NoTitleBar">
<receiver android:name="NotificationHandler">
<intent-filter>
<action android:name="org.mozilla.gecko.ACTION_ALERT_CLICK" />
<action android:name="org.mozilla.gecko.ACTION_ALERT_CLEAR" />
</intent-filter>
</activity>
</receiver>
<activity android:name="Restarter"
android:theme="@android:style/Theme.Light.NoTitleBar">

View File

@ -528,7 +528,7 @@ class GeckoAppShell
Uri dataUri = Uri.fromParts("alert", aAlertName, aAlertCookie);
notificationIntent.setData(dataUri);
PendingIntent contentIntent = PendingIntent.getActivity(GeckoApp.mAppContext, 0, notificationIntent, 0);
PendingIntent contentIntent = PendingIntent.getBroadcast(GeckoApp.mAppContext, 0, notificationIntent, 0);
notification.setLatestEventInfo(GeckoApp.mAppContext, aAlertTitle, aAlertText, contentIntent);
// The intent to execute when the status entry is deleted by the user with the "Clear All Notifications" button
@ -536,9 +536,7 @@ class GeckoAppShell
clearNotificationIntent.setClassName(GeckoApp.mAppContext,
"org.mozilla." + GeckoApp.mAppContext.getAppName() + ".NotificationHandler");
clearNotificationIntent.setData(dataUri);
PendingIntent pendingClearIntent = PendingIntent.getActivity(GeckoApp.mAppContext, 0, clearNotificationIntent, 0);
notification.deleteIntent = pendingClearIntent;
notification.deleteIntent = PendingIntent.getBroadcast(GeckoApp.mAppContext, 0, clearNotificationIntent, 0);
mAlertNotifications.put(notificationID, notification);

View File

@ -38,30 +38,25 @@
#filter substitution
package org.mozilla.@MOZ_APP_NAME@;
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.net.Uri;
public class NotificationHandler
extends Activity
extends BroadcastReceiver
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("GeckoAppJava", "NotificationHandler.onCreate");
Intent intent = getIntent();
public void onReceive(Context context, Intent intent) {
if (intent != null)
handleIntent(intent);
finish();
handleIntent(context, intent);
}
protected void handleIntent(Intent notificationIntent) {
protected void handleIntent(Context context, Intent notificationIntent) {
String action = notificationIntent.getAction();
String alertName = "";
String alertCookie = "";
@ -87,16 +82,17 @@ public class NotificationHandler
App.mAppContext.handleNotification(action, alertName, alertCookie);
} else {
// The app is not running, just cancel this notification
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(notificationID);
}
if (App.ACTION_ALERT_CLICK.equals(action)) {
// Start or bring to front the main activity
Intent appIntent = new Intent(Intent.ACTION_MAIN);
appIntent.setClassName(this, "org.mozilla.@MOZ_APP_NAME@.App");
appIntent.setClassName(context, "org.mozilla.@MOZ_APP_NAME@.App");
appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(appIntent);
context.startActivity(appIntent);
} catch (ActivityNotFoundException e) {
Log.e("GeckoAppJava", "NotificationHandler Exception: " + e.getMessage());
}