use of android.view.View.OnLayoutChangeListener in project AndroidChromium by JackyAndroid.
the class FullscreenHtmlApiHandler method enterFullscreen.
/**
* Handles hiding the system UI components to allow the content to take up the full screen.
* @param tab The tab that is entering fullscreen.
*/
public void enterFullscreen(final Tab tab) {
ContentViewCore contentViewCore = tab.getContentViewCore();
if (contentViewCore == null)
return;
final View contentView = contentViewCore.getContainerView();
int systemUiVisibility = contentView.getSystemUiVisibility();
systemUiVisibility |= SYSTEM_UI_FLAG_LOW_PROFILE;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if ((systemUiVisibility & SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) {
systemUiVisibility |= SYSTEM_UI_FLAG_FULLSCREEN;
systemUiVisibility |= getExtraFullscreenUIFlags();
} else {
systemUiVisibility |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
}
} else {
mWindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
if (mFullscreenOnLayoutChangeListener != null) {
contentView.removeOnLayoutChangeListener(mFullscreenOnLayoutChangeListener);
}
mFullscreenOnLayoutChangeListener = new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
// height and always just trigger the next step of the fullscreen initialization.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
// Posting the message to set the fullscreen flag because setting it
// directly in the onLayoutChange would have no effect.
mHandler.sendEmptyMessage(MSG_ID_SET_FULLSCREEN_SYSTEM_UI_FLAGS);
}
if ((bottom - top) <= (oldBottom - oldTop))
return;
if (mDelegate.shouldShowNotificationToast()) {
showNotificationToast();
}
contentView.removeOnLayoutChangeListener(this);
}
};
contentView.addOnLayoutChangeListener(mFullscreenOnLayoutChangeListener);
contentView.setSystemUiVisibility(systemUiVisibility);
mContentViewCoreInFullscreen = contentViewCore;
mTabInFullscreen = tab;
}
use of android.view.View.OnLayoutChangeListener in project AndroidChromium by JackyAndroid.
the class FullscreenHtmlApiHandler method exitFullscreen.
private void exitFullscreen(final ContentViewCore contentViewCore, final Tab tab) {
final View contentView = contentViewCore.getContainerView();
hideNotificationToast();
mHandler.removeMessages(MSG_ID_SET_FULLSCREEN_SYSTEM_UI_FLAGS);
mHandler.removeMessages(MSG_ID_CLEAR_LAYOUT_FULLSCREEN_FLAG);
int systemUiVisibility = contentView.getSystemUiVisibility();
systemUiVisibility &= ~SYSTEM_UI_FLAG_LOW_PROFILE;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
systemUiVisibility &= ~SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
systemUiVisibility &= ~SYSTEM_UI_FLAG_FULLSCREEN;
systemUiVisibility &= ~getExtraFullscreenUIFlags();
} else {
mWindow.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
contentView.setSystemUiVisibility(systemUiVisibility);
if (mFullscreenOnLayoutChangeListener != null) {
contentView.removeOnLayoutChangeListener(mFullscreenOnLayoutChangeListener);
}
mFullscreenOnLayoutChangeListener = new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if ((bottom - top) < (oldBottom - oldTop)) {
mDelegate.onFullscreenExited(tab);
contentView.removeOnLayoutChangeListener(this);
}
}
};
contentView.addOnLayoutChangeListener(mFullscreenOnLayoutChangeListener);
// getWebContents() will return null if contentViewCore has been destroyed
if (contentViewCore.getWebContents() != null) {
contentViewCore.getWebContents().exitFullscreen();
}
}
use of android.view.View.OnLayoutChangeListener in project platform_frameworks_base by android.
the class TileAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final Holder holder, int position) {
if (holder.getItemViewType() == TYPE_DIVIDER) {
holder.itemView.setVisibility(mTileDividerIndex < mTiles.size() - 1 ? View.VISIBLE : View.INVISIBLE);
return;
}
if (holder.getItemViewType() == TYPE_EDIT) {
((TextView) holder.itemView.findViewById(android.R.id.title)).setText(mCurrentDrag != null ? R.string.drag_to_remove_tiles : R.string.drag_to_add_tiles);
return;
}
if (holder.getItemViewType() == TYPE_ACCESSIBLE_DROP) {
holder.mTileView.setClickable(true);
holder.mTileView.setFocusable(true);
holder.mTileView.setFocusableInTouchMode(true);
holder.mTileView.setVisibility(View.VISIBLE);
holder.mTileView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
holder.mTileView.setContentDescription(mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1));
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
selectPosition(holder.getAdapterPosition(), v);
}
});
if (mNeedsFocus) {
// Wait for this to get laid out then set its focus.
// Ensure that tile gets laid out so we get the callback.
holder.mTileView.requestLayout();
holder.mTileView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
holder.mTileView.removeOnLayoutChangeListener(this);
holder.mTileView.requestFocus();
}
});
mNeedsFocus = false;
}
return;
}
TileInfo info = mTiles.get(position);
if (position > mEditIndex) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_add_tile_label, info.state.label);
} else if (mAccessibilityMoving) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1);
} else {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_tile_label, position + 1, info.state.label);
}
holder.mTileView.onStateChanged(info.state);
holder.mTileView.setAppLabel(info.appLabel);
holder.mTileView.setShowAppLabel(position > mEditIndex && !info.isSystem);
if (mAccessibilityManager.isTouchExplorationEnabled()) {
final boolean selectable = !mAccessibilityMoving || position < mEditIndex;
holder.mTileView.setClickable(selectable);
holder.mTileView.setFocusable(selectable);
holder.mTileView.setImportantForAccessibility(selectable ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
if (selectable) {
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int position = holder.getAdapterPosition();
if (mAccessibilityMoving) {
selectPosition(position, v);
} else {
if (position < mEditIndex) {
showAccessibilityDialog(position, v);
} else {
startAccessibleDrag(position);
}
}
}
});
}
}
}
use of android.view.View.OnLayoutChangeListener in project android_frameworks_base by AOSPA.
the class TileAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final Holder holder, int position) {
if (holder.getItemViewType() == TYPE_DIVIDER) {
holder.itemView.setVisibility(mTileDividerIndex < mTiles.size() - 1 ? View.VISIBLE : View.INVISIBLE);
return;
}
if (holder.getItemViewType() == TYPE_EDIT) {
((TextView) holder.itemView.findViewById(android.R.id.title)).setText(mCurrentDrag != null ? R.string.drag_to_remove_tiles : R.string.drag_to_add_tiles);
return;
}
if (holder.getItemViewType() == TYPE_ACCESSIBLE_DROP) {
holder.mTileView.setClickable(true);
holder.mTileView.setFocusable(true);
holder.mTileView.setFocusableInTouchMode(true);
holder.mTileView.setVisibility(View.VISIBLE);
holder.mTileView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
holder.mTileView.setContentDescription(mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1));
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
selectPosition(holder.getAdapterPosition(), v);
}
});
if (mNeedsFocus) {
// Wait for this to get laid out then set its focus.
// Ensure that tile gets laid out so we get the callback.
holder.mTileView.requestLayout();
holder.mTileView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
holder.mTileView.removeOnLayoutChangeListener(this);
holder.mTileView.requestFocus();
}
});
mNeedsFocus = false;
}
return;
}
TileInfo info = mTiles.get(position);
if (position > mEditIndex) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_add_tile_label, info.state.label);
} else if (mAccessibilityMoving) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1);
} else {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_tile_label, position + 1, info.state.label);
}
holder.mTileView.onStateChanged(info.state);
holder.mTileView.setAppLabel(info.appLabel);
holder.mTileView.setShowAppLabel(position > mEditIndex && !info.isSystem);
if (mAccessibilityManager.isTouchExplorationEnabled()) {
final boolean selectable = !mAccessibilityMoving || position < mEditIndex;
holder.mTileView.setClickable(selectable);
holder.mTileView.setFocusable(selectable);
holder.mTileView.setImportantForAccessibility(selectable ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
if (selectable) {
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int position = holder.getAdapterPosition();
if (mAccessibilityMoving) {
selectPosition(position, v);
} else {
if (position < mEditIndex) {
showAccessibilityDialog(position, v);
} else {
startAccessibleDrag(position);
}
}
}
});
}
}
}
use of android.view.View.OnLayoutChangeListener in project android_frameworks_base by ResurrectionRemix.
the class TileAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final Holder holder, int position) {
if (holder.getItemViewType() == TYPE_DIVIDER) {
holder.itemView.setVisibility(mTileDividerIndex < mTiles.size() - 1 ? View.VISIBLE : View.INVISIBLE);
return;
}
if (holder.getItemViewType() == TYPE_EDIT) {
((TextView) holder.itemView.findViewById(android.R.id.title)).setText(mCurrentDrag != null ? R.string.drag_to_remove_tiles : R.string.drag_to_add_tiles);
return;
}
if (holder.getItemViewType() == TYPE_ACCESSIBLE_DROP) {
holder.mTileView.setClickable(true);
holder.mTileView.setFocusable(true);
holder.mTileView.setFocusableInTouchMode(true);
holder.mTileView.setVisibility(View.VISIBLE);
holder.mTileView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
holder.mTileView.setContentDescription(mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1));
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
selectPosition(holder.getAdapterPosition(), v);
}
});
if (mNeedsFocus) {
// Wait for this to get laid out then set its focus.
// Ensure that tile gets laid out so we get the callback.
holder.mTileView.requestLayout();
holder.mTileView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
holder.mTileView.removeOnLayoutChangeListener(this);
holder.mTileView.requestFocus();
}
});
mNeedsFocus = false;
}
return;
}
TileInfo info = mTiles.get(position);
if (position > mEditIndex) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_add_tile_label, info.state.label);
} else if (mAccessibilityMoving) {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1);
} else {
info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_tile_label, position + 1, info.state.label);
}
holder.mTileView.onStateChanged(info.state);
holder.mTileView.setAppLabel(info.appLabel);
holder.mTileView.setShowAppLabel(position > mEditIndex && !info.isSystem);
if (mAccessibilityManager.isTouchExplorationEnabled()) {
final boolean selectable = !mAccessibilityMoving || position < mEditIndex;
holder.mTileView.setClickable(selectable);
holder.mTileView.setFocusable(selectable);
holder.mTileView.setImportantForAccessibility(selectable ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
if (selectable) {
holder.mTileView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int position = holder.getAdapterPosition();
if (mAccessibilityMoving) {
selectPosition(position, v);
} else {
if (position < mEditIndex) {
showAccessibilityDialog(position, v);
} else {
startAccessibleDrag(position);
}
}
}
});
}
}
}
Aggregations