// Path: phial-overlay/src/main/java/com/mindcoders/phial/Page.java
// public final class Page {
// 
//     /**
//      * Factory that is used to create views when page is selected
//      *
//      * @param <T> view to display
//      */
//     public interface PageViewFactory<T extends View & PageView> {
// 
//         /**
//          * @param context         android application context
//          * @param overlayCallback interface for communication with Phial
//          * @return view to display
//          */
//         T createPageView(Context context, OverlayCallback overlayCallback);
// 
//     }
// 
//     private final String id;
//     private final int iconResourceId;
//     private final CharSequence title;
//     private final PageViewFactory pageViewFactory;
//     private final Set<TargetScreen> targetScreens;
// 
//     /**
//      * @param id              unique pageId
//      * @param iconResourceId  page icon
//      * @param title           page title
//      * @param pageViewFactory factory that will create view when page is selected
//      */
//     public Page(
//             String id,
//             int iconResourceId,
//             CharSequence title,
//             PageViewFactory pageViewFactory
//     ) {
//         this(id, iconResourceId, title, pageViewFactory, Collections.<TargetScreen>emptySet());
//     }
// 
//     /**
//      * @param id              unique pageId
//      * @param iconResourceId  page icon
//      * @param title           page title
//      * @param pageViewFactory factory that will create view when page is selected
//      * @param targetScreens   screens to present this page on. Page will be present on all screens if this is empty.
//      */
//     public Page(
//             String id,
//             int iconResourceId,
//             CharSequence title,
//             PageViewFactory pageViewFactory,
//             Set<TargetScreen> targetScreens
//     ) {
//         this.id = id;
//         this.iconResourceId = iconResourceId;
//         this.title = title;
//         this.pageViewFactory = pageViewFactory;
//         this.targetScreens = Collections.unmodifiableSet(targetScreens);
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public int getIconResourceId() {
//         return iconResourceId;
//     }
// 
//     public CharSequence getTitle() {
//         return title;
//     }
// 
//     public PageViewFactory getPageViewFactory() {
//         return pageViewFactory;
//     }
// 
//     public Set<TargetScreen> getTargetScreens() {
//         return targetScreens;
//     }
// 
// }


import android.app.Activity;
import android.content.Context;
import android.graphics.PixelFormat;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import com.mindcoders.phial.Page;
import com.mindcoders.phial.R;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;

    OverlayView(Context context, DragHelper dragHelper, ExpandedView expandedView) {
        this.dragHelper = dragHelper;
        this.expandedView = expandedView;
        this.context = context;
        expandedView.setCallback(this);
    }

    void setPresenter(OverlayPresenter presenter) {
        this.presenter = presenter;
    }

    void showButton(Activity activity, boolean animated) {
        WindowManager windowManager = activity.getWindowManager();
        final View button = createButton();
        buttons.put(activity, button);
        final LayoutParams wrap = wrap(BUTTON_PARAMS);
        windowManager.addView(button, wrap);
        dragHelper.manage(windowManager, button);
        if (animated) {
            dragHelper.animateFromDefaultPosition(button, null);
        }
    }

    void removeButton(Activity activity) {
        final View button = buttons.remove(activity);
        dragHelper.unmanage(button);
        activity.getWindowManager().removeView(button);
    }

// Path: phial-overlay/src/main/java/com/mindcoders/phial/Page.java
// public final class Page {
// 
//     /**
//      * Factory that is used to create views when page is selected
//      *
//      * @param <T> view to display
//      */
//     public interface PageViewFactory<T extends View & PageView> {
// 
//         /**
//          * @param context         android application context
//          * @param overlayCallback interface for communication with Phial
//          * @return view to display
//          */
//         T createPageView(Context context, OverlayCallback overlayCallback);
// 
//     }
// 
//     private final String id;
//     private final int iconResourceId;
//     private final CharSequence title;
//     private final PageViewFactory pageViewFactory;
//     private final Set<TargetScreen> targetScreens;
// 
//     /**
//      * @param id              unique pageId
//      * @param iconResourceId  page icon
//      * @param title           page title
//      * @param pageViewFactory factory that will create view when page is selected
//      */
//     public Page(
//             String id,
//             int iconResourceId,
//             CharSequence title,
//             PageViewFactory pageViewFactory
//     ) {
//         this(id, iconResourceId, title, pageViewFactory, Collections.<TargetScreen>emptySet());
//     }
// 
//     /**
//      * @param id              unique pageId
//      * @param iconResourceId  page icon
//      * @param title           page title
//      * @param pageViewFactory factory that will create view when page is selected
//      * @param targetScreens   screens to present this page on. Page will be present on all screens if this is empty.
//      */
//     public Page(
//             String id,
//             int iconResourceId,
//             CharSequence title,
//             PageViewFactory pageViewFactory,
//             Set<TargetScreen> targetScreens
//     ) {
//         this.id = id;
//         this.iconResourceId = iconResourceId;
//         this.title = title;
//         this.pageViewFactory = pageViewFactory;
//         this.targetScreens = Collections.unmodifiableSet(targetScreens);
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public int getIconResourceId() {
//         return iconResourceId;
//     }
// 
//     public CharSequence getTitle() {
//         return title;
//     }
// 
//     public PageViewFactory getPageViewFactory() {
//         return pageViewFactory;
//     }
// 
//     public Set<TargetScreen> getTargetScreens() {
//         return targetScreens;
//     }
// 
// }


// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/overlay/OverlayView.java
import android.app.Activity;
import android.content.Context;
import android.graphics.PixelFormat;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import com.mindcoders.phial.Page;
import com.mindcoders.phial.R;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;


    OverlayView(Context context, DragHelper dragHelper, ExpandedView expandedView) {
        this.dragHelper = dragHelper;
        this.expandedView = expandedView;
        this.context = context;
        expandedView.setCallback(this);
    }

    void setPresenter(OverlayPresenter presenter) {
        this.presenter = presenter;
    }

    void showButton(Activity activity, boolean animated) {
        WindowManager windowManager = activity.getWindowManager();
        final View button = createButton();
        buttons.put(activity, button);
        final LayoutParams wrap = wrap(BUTTON_PARAMS);
        windowManager.addView(button, wrap);
        dragHelper.manage(windowManager, button);
        if (animated) {
            dragHelper.animateFromDefaultPosition(button, null);
        }
    }

    void removeButton(Activity activity) {
        final View button = buttons.remove(activity);
        dragHelper.unmanage(button);
        activity.getWindowManager().removeView(button);
    }

    void showExpandedView(Activity activity, List<Page> pages, Page selected, boolean animated) {