mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 07:01:19 +00:00
bug 603855 - Support canceling a displayed notification r=mfinkle,blassey sr=stuart a=blocking-fennec
This commit is contained in:
parent
87619027fa
commit
eac8985f62
@ -517,6 +517,15 @@ class GeckoAppShell
|
||||
notification.updateProgress(aAlertText, aProgress, aProgressMax);
|
||||
}
|
||||
|
||||
public static void alertsProgressListener_OnCancel(String aAlertName) {
|
||||
Log.i("GeckoAppJava", "GeckoAppShell.alertsProgressListener_OnCancel('" + aAlertName + "'");
|
||||
|
||||
removeObserver(aAlertName);
|
||||
|
||||
int notificationID = aAlertName.hashCode();
|
||||
removeNotification(notificationID);
|
||||
}
|
||||
|
||||
public static void handleNotification(String aAction, String aAlertName, String aAlertCookie) {
|
||||
int notificationID = aAlertName.hashCode();
|
||||
|
||||
|
@ -101,4 +101,12 @@ interface nsIAlertsProgressListener : nsISupports
|
||||
in long long progress,
|
||||
in long long progressMax,
|
||||
[optional] in AString text);
|
||||
|
||||
/**
|
||||
* Called to cancel and hide the given notification previously displayed
|
||||
* with showAlertNotification().
|
||||
*
|
||||
* @param name The name of the notification.
|
||||
*/
|
||||
void onCancel(in AString name);
|
||||
};
|
||||
|
@ -201,3 +201,13 @@ NS_IMETHODIMP nsAlertsService::OnProgress(const nsAString & aAlertName,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif // !ANDROID
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAlertsService::OnCancel(const nsAString & aAlertName)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
mozilla::AndroidBridge::Bridge()->AlertsProgressListener_OnCancel(aAlertName);
|
||||
return NS_OK;
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif // !ANDROID
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
||||
jSetClipboardText = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setClipboardText", "(Ljava/lang/String;)V");
|
||||
jShowAlertNotification = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showAlertNotification", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
jAlertsProgressListener_OnProgress = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnProgress", "(Ljava/lang/String;JJLjava/lang/String;)V");
|
||||
jAlertsProgressListener_OnCancel = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnCancel", "(Ljava/lang/String;)V");
|
||||
jGetDpi = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getDpi", "()I");
|
||||
|
||||
|
||||
@ -478,6 +479,18 @@ AndroidBridge::AlertsProgressListener_OnProgress(const nsAString& aAlertName,
|
||||
jstrName, aProgress, aProgressMax, jstrText);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::AlertsProgressListener_OnCancel(const nsAString& aAlertName)
|
||||
{
|
||||
ALOG("AlertsProgressListener_OnCancel");
|
||||
|
||||
AutoLocalJNIFrame jniFrame;
|
||||
|
||||
jstring jstrName = mJNIEnv->NewString(nsPromiseFlatString(aAlertName).get(), aAlertName.Length());
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jAlertsProgressListener_OnCancel, jstrName);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AndroidBridge::GetDPI()
|
||||
{
|
||||
|
@ -162,6 +162,8 @@ public:
|
||||
PRInt64 aProgressMax,
|
||||
const nsAString& aAlertText);
|
||||
|
||||
void AlertsProgressListener_OnCancel(const nsAString& aAlertName);
|
||||
|
||||
int GetDPI();
|
||||
|
||||
struct AutoLocalJNIFrame {
|
||||
@ -225,6 +227,7 @@ protected:
|
||||
jmethodID jSetClipboardText;
|
||||
jmethodID jShowAlertNotification;
|
||||
jmethodID jAlertsProgressListener_OnProgress;
|
||||
jmethodID jAlertsProgressListener_OnCancel;
|
||||
jmethodID jGetDpi;
|
||||
|
||||
// stuff we need for CallEglCreateWindowSurface
|
||||
|
Loading…
x
Reference in New Issue
Block a user