Search in sources :

Example 11 with Window

use of wei.mark.standout.ui.Window in project StandOut by pingpongboss.

the class FloatingFolder method removeAppFromView.

private void removeAppFromView(int id, ActivityInfo app) {
    Window window = getWindow(id);
    View frame = window.findViewWithTag(app);
    ViewGroup flow = (ViewGroup) window.findViewById(R.id.flow);
    flow.removeView(frame);
}
Also used : Window(wei.mark.standout.ui.Window) StandOutWindow(wei.mark.standout.StandOutWindow) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 12 with Window

use of wei.mark.standout.ui.Window in project Roundr by MohammadAdib.

the class StandOutWindow method updateViewLayout.

/**
	 * Update the window corresponding to this id with the given params.
	 * 
	 * @param id
	 *            The id of the window.
	 * @param params
	 *            The updated layout params to apply.
	 */
public void updateViewLayout(int id, StandOutLayoutParams params) {
    Window window = getWindow(id);
    if (window == null) {
        return;
    }
    if (window.visibility == Window.VISIBILITY_GONE) {
        return;
    }
    if (window.visibility == Window.VISIBILITY_TRANSITION) {
        return;
    }
    // alert callbacks and cancel if instructed
    if (onUpdate(id, window, params)) {
        Log.w(TAG, "Window " + id + " update cancelled by implementation.");
        return;
    }
    try {
        window.setLayoutParams(params);
        mWindowManager.updateViewLayout(window, params);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Window(wei.mark.standout.ui.Window) PopupWindow(android.widget.PopupWindow)

Example 13 with Window

use of wei.mark.standout.ui.Window in project Roundr by MohammadAdib.

the class StandOutWindow method hide.

/**
	 * Hide a window corresponding to the id. Show a notification for the hidden
	 * window.
	 * 
	 * @param id
	 *            The id of the window.
	 */
public final synchronized void hide(int id) {
    // get the view corresponding to the id
    final Window window = getWindow(id);
    if (window == null) {
        throw new IllegalArgumentException("Tried to hide(" + id + ") a null window.");
    }
    if (window.visibility == Window.VISIBILITY_GONE) {
        throw new IllegalStateException("Tried to hide(" + id + ") a window that is not shown.");
    }
    // alert callbacks and cancel if instructed
    if (onHide(id, window)) {
        Log.w(TAG, "Window " + id + " hide cancelled by implementation.");
        return;
    }
    // check if hide enabled
    if (Utils.isSet(window.flags, StandOutFlags.FLAG_WINDOW_HIDE_ENABLE)) {
        window.visibility = Window.VISIBILITY_TRANSITION;
        // get the hidden notification for this view
        Notification notification = getHiddenNotification(id);
        // get animation
        Animation animation = getHideAnimation(id);
        try {
            // animate
            if (animation != null) {
                animation.setAnimationListener(new AnimationListener() {

                    @Override
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        // remove the window from the window manager
                        mWindowManager.removeView(window);
                        window.visibility = Window.VISIBILITY_GONE;
                    }
                });
                window.getChildAt(0).startAnimation(animation);
            } else {
                // remove the window from the window manager
                mWindowManager.removeView(window);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        // display the notification
        notification.flags = notification.flags | Notification.FLAG_NO_CLEAR | Notification.FLAG_AUTO_CANCEL;
        mNotificationManager.notify(getClass().hashCode() + id, notification);
    } else {
        // if hide not enabled, close window
        close(id);
    }
}
Also used : Window(wei.mark.standout.ui.Window) PopupWindow(android.widget.PopupWindow) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) Notification(android.app.Notification)

Example 14 with Window

use of wei.mark.standout.ui.Window in project Roundr by MohammadAdib.

the class StandOutWindow method bringToFront.

/**
	 * Bring the window corresponding to this id in front of all other windows.
	 * The window may flicker as it is removed and restored by the system.
	 * 
	 * @param id
	 *            The id of the window to bring to the front.
	 */
public final synchronized void bringToFront(int id) {
    Window window = getWindow(id);
    if (window == null) {
        throw new IllegalArgumentException("Tried to bringToFront(" + id + ") a null window.");
    }
    if (window.visibility == Window.VISIBILITY_GONE) {
        throw new IllegalStateException("Tried to bringToFront(" + id + ") a window that is not shown.");
    }
    if (window.visibility == Window.VISIBILITY_TRANSITION) {
        return;
    }
    // alert callbacks and cancel if instructed
    if (onBringToFront(id, window)) {
        Log.w(TAG, "Window " + id + " bring to front cancelled by implementation.");
        return;
    }
    StandOutLayoutParams params = window.getLayoutParams();
    // remove from window manager then add back
    try {
        mWindowManager.removeView(window);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    try {
        mWindowManager.addView(window, params);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Window(wei.mark.standout.ui.Window) PopupWindow(android.widget.PopupWindow)

Example 15 with Window

use of wei.mark.standout.ui.Window in project Roundr by MohammadAdib.

the class Corner method onReceiveData.

@Override
public void onReceiveData(int corner, int requestCode, Bundle data, Class<? extends StandOutWindow> fromCls, int fromId) {
    Window window = getWindow(corner);
    if (requestCode == UPDATE_CODE) {
        // Update the corners when device is rotated
        updateViewLayout(3, getParams(3, window));
        updateViewLayout(2, getParams(2, window));
        updateViewLayout(1, getParams(1, window));
        updateViewLayout(0, getParams(0, window));
    } else if (requestCode == NOTIFICATION_CODE) {
        if (!prefs.getBoolean("notification", true)) {
            // Hide Notification Icon (for <= Gingerbread devices only)
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = getPersistentNotification(corner);
            notification.icon = wei.mark.standout.R.drawable.nothing;
            mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
            Log.d("Hello World", "");
        } else {
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = getPersistentNotification(corner);
            mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
        }
    }
}
Also used : Window(wei.mark.standout.ui.Window) StandOutWindow(wei.mark.standout.StandOutWindow) NotificationManager(android.app.NotificationManager) Notification(android.app.Notification)

Aggregations

Window (wei.mark.standout.ui.Window)22 PopupWindow (android.widget.PopupWindow)16 Animation (android.view.animation.Animation)9 Notification (android.app.Notification)7 AnimationListener (android.view.animation.Animation.AnimationListener)6 StandOutWindow (wei.mark.standout.StandOutWindow)6 SharedPreferences (android.content.SharedPreferences)3 ViewGroup (android.view.ViewGroup)3 TextView (android.widget.TextView)3 ActivityInfo (android.content.pm.ActivityInfo)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 NotificationManager (android.app.NotificationManager)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 OnClickListener (android.view.View.OnClickListener)1