Search in sources :

Example 6 with Window

use of android.view.Window in project android_frameworks_base by ParanoidAndroid.

the class Activity method dispatchKeyEvent.

/**
     * Called to process key events.  You can override this to intercept all 
     * key events before they are dispatched to the window.  Be sure to call 
     * this implementation for key events that should be handled normally.
     * 
     * @param event The key event.
     * 
     * @return boolean Return true if this event was consumed.
     */
public boolean dispatchKeyEvent(KeyEvent event) {
    onUserInteraction();
    Window win = getWindow();
    if (win.superDispatchKeyEvent(event)) {
        return true;
    }
    View decor = mDecor;
    if (decor == null)
        decor = win.getDecorView();
    return event.dispatch(this, decor != null ? decor.getKeyDispatcherState() : null, this);
}
Also used : Window(android.view.Window) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 7 with Window

use of android.view.Window in project android_frameworks_base by ParanoidAndroid.

the class Instrumentation method invokeMenuActionSync.

/**
     * Execute a particular menu item.
     * 
     * @param targetActivity The activity in question.
     * @param id The identifier associated with the 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 invokeMenuActionSync(Activity targetActivity, int id, int flag) {
    class MenuRunnable implements Runnable {

        private final Activity activity;

        private final int identifier;

        private final int flags;

        boolean returnValue;

        public MenuRunnable(Activity _activity, int _identifier, int _flags) {
            activity = _activity;
            identifier = _identifier;
            flags = _flags;
        }

        public void run() {
            Window win = activity.getWindow();
            returnValue = win.performPanelIdentifierAction(Window.FEATURE_OPTIONS_PANEL, identifier, flags);
        }
    }
    MenuRunnable mr = new MenuRunnable(targetActivity, id, flag);
    runOnMainSync(mr);
    return mr.returnValue;
}
Also used : Window(android.view.Window)

Example 8 with Window

use of android.view.Window in project android_frameworks_base by ParanoidAndroid.

the class BrightnessDialog method onCreate.

/**
     * Create the brightness dialog and any resources that are used for the
     * entire lifetime of the dialog.
     */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window window = getWindow();
    window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
    window.getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
    window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    window.requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.quick_settings_brightness_dialog);
    setCanceledOnTouchOutside(true);
}
Also used : Window(android.view.Window)

Example 9 with Window

use of android.view.Window in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindowManager method addStartingWindow.

/** {@inheritDoc} */
@Override
public View addStartingWindow(IBinder appToken, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int windowFlags) {
    if (!SHOW_STARTING_ANIMATIONS) {
        return null;
    }
    if (packageName == null) {
        return null;
    }
    WindowManager wm = null;
    View view = null;
    try {
        Context context = mContext;
        if (DEBUG_STARTING_WINDOW)
            Slog.d(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" + Integer.toHexString(theme));
        try {
            context = context.createPackageContext(packageName, 0);
            if (theme != context.getThemeResId()) {
                context.setTheme(theme);
            }
        } catch (PackageManager.NameNotFoundException e) {
        // Ignore
        }
        Window win = PolicyManager.makeNewWindow(context);
        final TypedArray ta = win.getWindowStyle();
        if (ta.getBoolean(com.android.internal.R.styleable.Window_windowDisablePreview, false) || ta.getBoolean(com.android.internal.R.styleable.Window_windowShowWallpaper, false)) {
            return null;
        }
        Resources r = context.getResources();
        win.setTitle(r.getText(labelRes, nonLocalizedLabel));
        win.setType(WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
        // Force the window flags: this is a fake window, so it is not really
        // touchable or focusable by the user.  We also add in the ALT_FOCUSABLE_IM
        // flag because we do know that the next window will take input
        // focus, so we want to get the IME window up on top of us right away.
        win.setFlags(windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        if (!compatInfo.supportsScreen()) {
            win.addFlags(WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW);
        }
        win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        final WindowManager.LayoutParams params = win.getAttributes();
        params.token = appToken;
        params.packageName = packageName;
        params.windowAnimations = win.getWindowStyle().getResourceId(com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        params.setTitle("Starting " + packageName);
        wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        view = win.getDecorView();
        if (win.isFloating()) {
            // earlier.)
            return null;
        }
        if (DEBUG_STARTING_WINDOW)
            Slog.d(TAG, "Adding starting window for " + packageName + " / " + appToken + ": " + (view.getParent() != null ? view : null));
        wm.addView(view, params);
        // window manager... which we can tell by it having a parent.
        return view.getParent() != null ? view : null;
    } catch (WindowManager.BadTokenException e) {
        // ignore
        Log.w(TAG, appToken + " already running, starting window not displayed");
    } catch (RuntimeException e) {
        // don't crash if something else bad happens, for example a
        // failure loading resources because we are loading from an app
        // on external storage that has been unmounted.
        Log.w(TAG, appToken + " failed creating starting window", e);
    } finally {
        if (view != null && view.getParent() == null) {
            Log.w(TAG, "view not successfully added to wm, removing view");
            wm.removeViewImmediate(view);
        }
    }
    return null;
}
Also used : Context(android.content.Context) Window(android.view.Window) PackageManager(android.content.pm.PackageManager) TypedArray(android.content.res.TypedArray) LayoutParams(android.view.WindowManager.LayoutParams) Resources(android.content.res.Resources) PointerLocationView(com.android.internal.widget.PointerLocationView) View(android.view.View) IWindowManager(android.view.IWindowManager) WindowManager(android.view.WindowManager)

Example 10 with Window

use of android.view.Window in project HoloEverywhere by Prototik.

the class DialogPreference method requestInputMethod.

private void requestInputMethod(Dialog dialog) {
    Window window = dialog.getWindow();
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
Also used : Window(android.view.Window)

Aggregations

Window (android.view.Window)310 View (android.view.View)69 WindowManager (android.view.WindowManager)56 TextView (android.widget.TextView)34 TargetApi (android.annotation.TargetApi)26 ImageView (android.widget.ImageView)25 Activity (android.app.Activity)17 Dialog (android.app.Dialog)17 ViewGroup (android.view.ViewGroup)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