/** Create and return a new FloatyFox, adding it to the list of tracked FloatyFoxes. */ private PageFloatyFox getPageFloatyFox(WindowManager.LayoutParams params, String url) { PageFloatyFox floatyFox = new PageFloatyFox(context, windowManager, params, url); floatyFoxes.add(floatyFox); floatyFox.show(); return floatyFox; }
/** * Create a new floaty fox to represent the newly-added page and have it hover irritatingly for a * while. If ignored, the irritatingly-hovering floaty fox whizzes over and merges with the * primary. If tapped, it expands into a menu of quick actions. If dragged, it goes where it's put * and the timer for when to whizz is reset. * * @param url URL of the page being exhibited. Used to start the process of fetching an icon for * this FloatyFox to replace the default one. */ public void exhibitFloatyFox(String url) { spawnPrimaryFox(); final PageFloatyFox newFloater = getPageFloatyFox(getOverlayLayoutParams(), url); // Register a callback to cause this FloatyFox to merge with the primary one after a timeout. final Runnable mergeCallback = new Runnable() { @Override public void run() { mergeFloater(newFloater); } }; callbackHandler.postDelayed(mergeCallback, BUBBLE_HOVER_DELAY); // Register listener to spawn the share overlay if the bubble is tapped. newFloater.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { transitionToShareOverlay(newFloater); // Cancel the merging if the bubble is clicked. callbackHandler.removeCallbacks(mergeCallback); } }); }