Search in sources :

Example 91 with Window

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;
}
Also used : KeyEvent(android.view.KeyEvent) Window(android.view.Window)

Example 92 with Window

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;
}
Also used : Window(android.view.Window)

Example 93 with Window

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);
}
Also used : Window(android.view.Window) Explode(android.transition.Explode) Transition(android.transition.Transition) TargetApi(android.annotation.TargetApi)

Example 94 with Window

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);
    }
}
Also used : Window(android.view.Window) ActivityManager(android.app.ActivityManager)

Example 95 with Window

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();
}
Also used : Window(android.view.Window) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

Window (android.view.Window)322 View (android.view.View)72 WindowManager (android.view.WindowManager)58 TextView (android.widget.TextView)34 TargetApi (android.annotation.TargetApi)29 ImageView (android.widget.ImageView)25 ViewGroup (android.view.ViewGroup)22 Activity (android.app.Activity)17 Dialog (android.app.Dialog)17 ColorDrawable (android.graphics.drawable.ColorDrawable)16 AdapterView (android.widget.AdapterView)16 PhoneWindow (com.android.internal.policy.PhoneWindow)15 Intent (android.content.Intent)11 Context (android.content.Context)10 LayoutInflater (android.view.LayoutInflater)10 WindowDecorActionBar (com.android.internal.app.WindowDecorActionBar)10 RemoteException (android.os.RemoteException)9 DisplayMetrics (android.util.DisplayMetrics)9 LinearLayout (android.widget.LinearLayout)9 PopupWindow (android.widget.PopupWindow)8