Search in sources :

Example 6 with StandOutLayoutParams

use of wei.mark.standout.StandOutWindow.StandOutLayoutParams in project FloatingStickies by MohammadAdib.

the class Window method onFocus.

/**
     * Request or remove the focus from this window.
     *
     * @param focus Whether we want to gain or lose focus.
     * @return True if focus changed successfully, false if it failed.
     */
public boolean onFocus(boolean focus) {
    if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE)) {
        if (focus == focused) {
            // window already focused/unfocused
            return false;
        }
        focused = focus;
        // alert callbacks and cancel if instructed
        if (mContext.onFocusChange(id, this, focus)) {
            Log.d(TAG, "Window " + id + " focus change " + (focus ? "(true)" : "(false)") + " cancelled by implementation.");
            focused = !focus;
            return false;
        }
        if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUS_INDICATOR_DISABLE)) {
            // change visual state
            View content = findViewById(R.id.content);
            if (focus) {
            // gaining focus
            // content.setBackgroundResource(R.drawable.border_focused);
            } else {
                // losing focus
                if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_SYSTEM)) {
                // system decorations
                // content.setBackgroundResource(R.drawable.border);
                } else {
                    // no decorations
                    content.setBackgroundResource(0);
                }
            }
        }
        // set window manager params
        StandOutLayoutParams params = getLayoutParams();
        params.setFocusFlag(focus);
        mContext.updateViewLayout(id, params);
        if (focus) {
            mContext.setFocusedWindow(this);
        } else {
            if (mContext.getFocusedWindow() == this) {
                mContext.setFocusedWindow(null);
            }
        }
        return true;
    }
    return false;
}
Also used : StandOutLayoutParams(wei.mark.standout.StandOutWindow.StandOutLayoutParams) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView)

Example 7 with StandOutLayoutParams

use of wei.mark.standout.StandOutWindow.StandOutLayoutParams in project StandOut by pingpongboss.

the class Window method onFocus.

/**
 * Request or remove the focus from this window.
 *
 * @param focus
 *            Whether we want to gain or lose focus.
 * @return True if focus changed successfully, false if it failed.
 */
public boolean onFocus(boolean focus) {
    if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE)) {
        if (focus == focused) {
            // window already focused/unfocused
            return false;
        }
        focused = focus;
        // alert callbacks and cancel if instructed
        if (mContext.onFocusChange(id, this, focus)) {
            Log.d(TAG, "Window " + id + " focus change " + (focus ? "(true)" : "(false)") + " cancelled by implementation.");
            focused = !focus;
            return false;
        }
        if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUS_INDICATOR_DISABLE)) {
            // change visual state
            View content = findViewById(R.id.content);
            if (focus) {
                // gaining focus
                content.setBackgroundResource(R.drawable.border_focused);
            } else {
                // losing focus
                if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_SYSTEM)) {
                    // system decorations
                    content.setBackgroundResource(R.drawable.border);
                } else {
                    // no decorations
                    content.setBackgroundResource(0);
                }
            }
        }
        // set window manager params
        StandOutLayoutParams params = getLayoutParams();
        params.setFocusFlag(focus);
        mContext.updateViewLayout(id, params);
        if (focus) {
            mContext.setFocusedWindow(this);
        } else {
            if (mContext.getFocusedWindow() == this) {
                mContext.setFocusedWindow(null);
            }
        }
        return true;
    }
    return false;
}
Also used : StandOutLayoutParams(wei.mark.standout.StandOutWindow.StandOutLayoutParams) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

StandOutLayoutParams (wei.mark.standout.StandOutWindow.StandOutLayoutParams)7 View (android.view.View)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 MotionEvent (android.view.MotionEvent)1 PopupWindow (android.widget.PopupWindow)1 ScrollView (android.widget.ScrollView)1