use of android.view.Window in project android_frameworks_base by ResurrectionRemix.
the class Instrumentation method invokeContextMenuAction.
/**
* Show the context menu for the currently focused view and executes a
* particular context menu item.
*
* @param targetActivity The activity in question.
* @param id The identifier associated with the context menu item.
* @param flag Additional flags, if any.
* @return Whether the invocation was successful (for example, it could be
* false if item is disabled).
*/
public boolean invokeContextMenuAction(Activity targetActivity, int id, int flag) {
validateNotAppThread();
// Bring up context menu for current focus.
// It'd be nice to do this through code, but currently ListView depends on
// long press to set metadata for its selected child
final KeyEvent downEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER);
sendKeySync(downEvent);
// Need to wait for long press
waitForIdleSync();
try {
Thread.sleep(ViewConfiguration.getLongPressTimeout());
} catch (InterruptedException e) {
Log.e(TAG, "Could not sleep for long press timeout", e);
return false;
}
final KeyEvent upEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER);
sendKeySync(upEvent);
// Wait for context menu to appear
waitForIdleSync();
class ContextMenuRunnable implements Runnable {
private final Activity activity;
private final int identifier;
private final int flags;
boolean returnValue;
public ContextMenuRunnable(Activity _activity, int _identifier, int _flags) {
activity = _activity;
identifier = _identifier;
flags = _flags;
}
public void run() {
Window win = activity.getWindow();
returnValue = win.performContextMenuIdentifierAction(identifier, flags);
}
}
ContextMenuRunnable cmr = new ContextMenuRunnable(targetActivity, id, flag);
runOnMainSync(cmr);
return cmr.returnValue;
}
use of android.view.Window in project android_frameworks_base by ResurrectionRemix.
the class LocalActivityManager method destroyActivity.
/**
* Destroy the activity associated with a particular id. This activity
* will go through the normal lifecycle events and fine onDestroy(), and
* then the id removed from the group.
*
* @param id Unique identifier of the activity to be destroyed
* @param finish If true, this activity will be finished, so its id and
* all state are removed from the group.
*
* @return Returns the window that was used to display the activity, or
* null if there was none.
*/
public Window destroyActivity(String id, boolean finish) {
LocalActivityRecord r = mActivities.get(id);
Window win = null;
if (r != null) {
win = performDestroy(r, finish);
if (finish) {
mActivities.remove(id);
mActivityArray.remove(r);
}
}
return win;
}
use of android.view.Window in project Douya by DreaminginCodeZH.
the class TransitionUtils method setEnterReturnExplode.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setEnterReturnExplode(Fragment fragment) {
if (!shouldEnableTransition()) {
return;
}
Window window = fragment.getActivity().getWindow();
Transition explode = new Explode().excludeTarget(android.R.id.statusBarBackground, true).excludeTarget(android.R.id.navigationBarBackground, true);
window.setEnterTransition(explode);
window.setReturnTransition(explode);
}
use of android.view.Window in project MagicaSakura by Bilibili.
the class MainActivity method onPostCreate.
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 21) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ThemeUtils.getColorById(this, R.color.theme_color_primary_dark));
ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(null, null, ThemeUtils.getThemeAttrColor(this, android.R.attr.colorPrimary));
setTaskDescription(description);
}
}
use of android.view.Window in project AndroidChromium by JackyAndroid.
the class WebsiteSettingsPopup method showDialog.
/**
* Displays the WebsiteSettingsPopup.
*/
@CalledByNative
private void showDialog() {
if (!DeviceFormFactor.isTablet(mContext)) {
// On smaller screens, make the dialog fill the width of the screen.
ScrollView scrollView = new ScrollView(mContext);
scrollView.addView(mContainer);
mDialog.addContentView(scrollView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
// This must be called after addContentView, or it won't fully fill to the edge.
Window window = mDialog.getWindow();
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
} else {
// On larger screens, make the dialog centered in the screen and have a maximum width.
ScrollView scrollView = new ScrollView(mContext) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int maxDialogWidthInPx = (int) (MAX_TABLET_DIALOG_WIDTH_DP * mContext.getResources().getDisplayMetrics().density);
if (MeasureSpec.getSize(widthMeasureSpec) > maxDialogWidthInPx) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxDialogWidthInPx, MeasureSpec.EXACTLY);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
scrollView.addView(mContainer);
mDialog.addContentView(scrollView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
}
mDialog.show();
}
Aggregations