Skip to content

Commit

Permalink
Hide notification if tray is detached or hidden (#1708)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and bluemarvin committed Aug 29, 2019
1 parent afe0a54 commit 105bd17
Showing 1 changed file with 42 additions and 29 deletions.
Expand Up @@ -8,7 +8,6 @@
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
Expand Down Expand Up @@ -281,6 +280,8 @@ public void show(@ShowFlags int aShowFlags) {

@Override
public void hide(@HideFlags int aHideFlags) {
ThreadUtils.postToUiThread(hideBookmarkNotification);

if (mWidgetPlacement.visible) {
mWidgetPlacement.visible = false;
if (aHideFlags == REMOVE_WIDGET) {
Expand All @@ -293,6 +294,8 @@ public void hide(@HideFlags int aHideFlags) {

@Override
public void detachFromWindow() {
ThreadUtils.postToUiThread(hideBookmarkNotification);

if (mSessionStack != null) {
mSessionStack.removeSessionChangeListener(this);
mSessionStack = null;
Expand Down Expand Up @@ -460,35 +463,45 @@ public void onBookmarksUpdated() {
@Override
public void onBookmarkAdded() {
mBookmarksButton.setNotificationMode(true);
ThreadUtils.postToUiThread(() -> {
if (mLibraryNotification != null && mLibraryNotification.isVisible()) {
return;
}
ThreadUtils.postToUiThread(showBookmarkNotification);
}
};

Rect offsetViewBounds = new Rect();
getDrawingRect(offsetViewBounds);
offsetDescendantRectToMyCoords(mBookmarksButton, offsetViewBounds);

float ratio = WidgetPlacement.viewToWidgetRatio(getContext(), TrayWidget.this);

mLibraryNotification = new TooltipWidget(getContext(), R.layout.library_notification);
mLibraryNotification.getPlacement().parentHandle = getHandle();
mLibraryNotification.getPlacement().anchorY = 0.0f;
mLibraryNotification.getPlacement().translationX = (offsetViewBounds.left + mBookmarksButton.getWidth() / 2.0f) * ratio;
mLibraryNotification.getPlacement().translationY = ((offsetViewBounds.top - 60) * ratio);
mLibraryNotification.getPlacement().translationZ = 25.0f;
mLibraryNotification.getPlacement().density = 3.0f;
mLibraryNotification.setText(R.string.bookmarks_saved_notification);
mLibraryNotification.setCurvedMode(false);
mLibraryNotification.show(UIWidget.CLEAR_FOCUS);

ThreadUtils.postDelayedToUiThread(() -> {
if (mLibraryNotification != null) {
mLibraryNotification.hide(UIWidget.REMOVE_WIDGET);
}
mBookmarksButton.setNotificationMode(false);
}, LIBRARY_NOTIFICATION_DURATION);
});
private Runnable showBookmarkNotification = new Runnable() {
@Override
public void run() {
if (mLibraryNotification != null && mLibraryNotification.isVisible()) {
return;
}

Rect offsetViewBounds = new Rect();
getDrawingRect(offsetViewBounds);
offsetDescendantRectToMyCoords(mBookmarksButton, offsetViewBounds);

float ratio = WidgetPlacement.viewToWidgetRatio(getContext(), TrayWidget.this);

mLibraryNotification = new TooltipWidget(getContext(), R.layout.library_notification);
mLibraryNotification.getPlacement().parentHandle = getHandle();
mLibraryNotification.getPlacement().anchorY = 0.0f;
mLibraryNotification.getPlacement().translationX = (offsetViewBounds.left + mBookmarksButton.getWidth() / 2.0f) * ratio;
mLibraryNotification.getPlacement().translationY = ((offsetViewBounds.top - 60) * ratio);
mLibraryNotification.getPlacement().translationZ = 25.0f;
mLibraryNotification.getPlacement().density = 3.0f;
mLibraryNotification.setText(R.string.bookmarks_saved_notification);
mLibraryNotification.setCurvedMode(false);
mLibraryNotification.show(UIWidget.CLEAR_FOCUS);

ThreadUtils.postDelayedToUiThread(hideBookmarkNotification, LIBRARY_NOTIFICATION_DURATION);
}
};

private Runnable hideBookmarkNotification = new Runnable() {
@Override
public void run() {
if (mLibraryNotification != null) {
mLibraryNotification.hide(UIWidget.REMOVE_WIDGET);
}
mBookmarksButton.setNotificationMode(false);
}
};

Expand Down

1 comment on commit 105bd17

@community-tc-integration
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitting the task to Taskcluster failed. Details

Taskcluster-GitHub attempted to create a task for this event with the following scopes:

[
  "assume:repo:github.com/MozillaReality/FirefoxReality:release",
  "queue:route:statuses",
  "queue:scheduler-id:taskcluster-github"
]

The expansion of these scopes is not sufficient to create the task, leading to the following:

Client ID static/taskcluster/github does not have sufficient scopes and is missing the following scopes:

{
  "AllOf": [
    "secrets:get:project/firefoxreality/github-deploy-key",
    "secrets:get:project/firefoxreality/release-signing-token",
    "secrets:get:project/firefoxreality/symbols-token",
    {
      "AnyOf": [
        "queue:create-task:highest:unknown/unknown",
        "queue:create-task:very-high:unknown/unknown",
        "queue:create-task:high:unknown/unknown",
        "queue:create-task:medium:unknown/unknown",
        "queue:create-task:low:unknown/unknown",
        "queue:create-task:very-low:unknown/unknown",
        "queue:create-task:lowest:unknown/unknown"
      ]
    }
  ]
}

This request requires the client to satisfy the following scope expression:

{
  "AllOf": [
    "secrets:get:project/firefoxreality/github-deploy-key",
    "secrets:get:project/firefoxreality/release-signing-token",
    "secrets:get:project/firefoxreality/symbols-token",
    "queue:route:notify.email.fxr-releng@mozilla.com.on-any",
    "queue:route:statuses",
    "queue:scheduler-id:taskcluster-github",
    {
      "AnyOf": [
        "queue:create-task:highest:unknown/unknown",
        "queue:create-task:very-high:unknown/unknown",
        "queue:create-task:high:unknown/unknown",
        "queue:create-task:medium:unknown/unknown",
        "queue:create-task:low:unknown/unknown",
        "queue:create-task:very-low:unknown/unknown",
        "queue:create-task:lowest:unknown/unknown"
      ]
    }
  ]
}

  • method: createTask
  • errorCode: InsufficientScopes
  • statusCode: 403
  • time: 2020-03-18T23:02:12.376Z

Please sign in to comment.