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;
}
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;
}
Aggregations