示例#1
0
  /**
   * Create a ShareOverlay for given title/url combination and add it to the screen.
   *
   * @return A reference to the created ShareOverlay.
   */
  private ShareOverlay getShareOverlay(String title, String url) {
    final WindowManager.LayoutParams params = getOverlayLayoutParams();

    params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;

    final ShareOverlay shareOverlay = new ShareOverlay(context, url);
    shareOverlay.setTitle(title);

    windowManager.addView(shareOverlay, params);

    return shareOverlay;
  }
示例#2
0
  /**
   * Transition the given PageFloatyFox into a ShareOverlay. Causes the bubble to fly to the
   * location of the favicon of an overlay, which is then spawned. This allows the user to
   * immediately interact with the bubble (open in a tab, reading list it, etc.).
   */
  protected void transitionToShareOverlay(final PageFloatyFox floatyFox) {
    // TODO: Find a title to go here. Perhaps we went to the internet before the user tapped
    // and downloaded the title? Perhaps we query the database? Perhaps we make something up?
    final ShareOverlay overlay = getShareOverlay("", floatyFox.url);
    overlay.setVisibility(View.INVISIBLE);

    // Wait for the layout to complete so we can figure out the location of the icon we want to
    // zoom the bubble to.
    overlay
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                // Yes, Android actually did that. This statement is necessary to guard against the
                // day that the deprecated version finally gets removed.
                // TODO: Refactor all of these into a helper method somewhere?
                if (Build.VERSION.SDK_INT >= 16) {
                  overlay.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                } else {
                  overlay.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                }

                View favicon = overlay.findViewById(R.id.favicon);
                int[] targetPosition = new int[2];
                favicon.getLocationOnScreen(targetPosition);

                AnimationUtils.convertToLayoutSpaceForView(targetPosition, favicon);

                OverlayAnimation translation =
                    OverlayAnimation.TransformTo(
                        floatyFox, 500, targetPosition[0], targetPosition[1]);
                translation.addListener(
                    new AnimatorListenerAdapter() {
                      @Override
                      public void onAnimationEnd(Animator animation) {
                        OverlayAnimation fadeShareOverlay = OverlayAnimation.FadeIn(overlay, 500);
                        fadeShareOverlay.start();
                        overlay.setOnClickListener(null);
                        overlay.fadeInSecondaryButtons();
                        overlay.setVisibility(View.VISIBLE);
                      }
                    });
                translation.start();
              }
            });
  }
示例#3
0
  /**
   * Show the overlay for a shared URL.
   *
   * @param title The title text for the shared URL, if any, to be displayed with the URL.
   * @param url The URL being shared.
   */
  public void showShareOverlay(String title, String url) {
    ShareOverlay shareOverlay = getShareOverlay(title, url);

    shareOverlay.present();
  }