Search in sources :

Example 76 with Display

use of android.view.Display in project wire-android by wireapp.

the class ViewUtils method getRealDisplayWidth.

public static int getRealDisplayWidth(Context context) {
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int realWidth;
    if (Build.VERSION.SDK_INT >= 17) {
        //new pleasant way to get real metrics
        DisplayMetrics realMetrics = new DisplayMetrics();
        display.getRealMetrics(realMetrics);
        realWidth = realMetrics.widthPixels;
    } else if (Build.VERSION.SDK_INT >= 14) {
        //reflection for this weird in-between time
        try {
            Method getRawW = Display.class.getMethod("getRawWidth");
            realWidth = (Integer) getRawW.invoke(display);
        } catch (Exception e) {
            //this may not be 100% accurate, but it's all we've got
            realWidth = display.getWidth();
        }
    } else {
        //This should be close, as lower API devices should not have window navigation bars
        realWidth = display.getWidth();
    }
    return realWidth;
}
Also used : Method(java.lang.reflect.Method) DisplayMetrics(android.util.DisplayMetrics) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Display(android.view.Display) WindowManager(android.view.WindowManager)

Example 77 with Display

use of android.view.Display in project ADWLauncher2 by boombuler.

the class Launcher method setWallpaperDimension.

private void setWallpaperDimension() {
    WallpaperManager wpm = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
    Display display = getWindowManager().getDefaultDisplay();
    boolean isPortrait = display.getWidth() < display.getHeight();
    final int width = isPortrait ? display.getWidth() : display.getHeight();
    final int height = isPortrait ? display.getHeight() : display.getWidth();
    wpm.suggestDesiredDimensions(width * WALLPAPER_SCREENS_SPAN, height);
}
Also used : WallpaperManager(android.app.WallpaperManager) Display(android.view.Display)

Example 78 with Display

use of android.view.Display in project glitch-hq-android by tinyspeck.

the class HomeScreen method dismissSidebar.

public void dismissSidebar() {
    // Get display width
    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    // Create the dismiss animation
    Animation animation = new TranslateAnimation(width, 0, 0, 0);
    animation.setDuration(m_sidebarAnimationDuration);
    animation.setAnimationListener(new AnimationListener() {

        public void onAnimationEnd(Animation animation) {
            // Get display width
            Display display = getWindowManager().getDefaultDisplay();
            // Move back to normal position and fill the whole display
            // width-wise
            // m_stack.layout(-27, 0, display.getWidth(),
            // m_stack.getHeight());
            HomeScreen.this.m_showingSidebar = false;
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }
    });
    animation.setFillAfter(true);
    // Run the dismiss animation
    m_stack.startAnimation(animation);
    m_stack.getParent().bringChildToFront(m_stack);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationListener(android.view.animation.Animation.AnimationListener) Display(android.view.Display)

Example 79 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class VirtualDisplayTest method testPrivatePresentationVirtualDisplay.

/**
     * Ensures that an application can create a private presentation virtual display and show
     * its own windows on it.
     */
public void testPrivatePresentationVirtualDisplay() throws Exception {
    VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME, WIDTH, HEIGHT, DENSITY, mSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
    assertNotNull("virtual display must not be null", virtualDisplay);
    Display display = virtualDisplay.getDisplay();
    try {
        assertDisplayRegistered(display, Display.FLAG_PRIVATE | Display.FLAG_PRESENTATION);
        // Show a private presentation on the display.
        assertDisplayCanShowPresentation("private presentation window", display, BLUEISH, WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION, 0);
    } finally {
        virtualDisplay.release();
    }
    assertDisplayUnregistered(display);
}
Also used : VirtualDisplay(android.hardware.display.VirtualDisplay) Display(android.view.Display) VirtualDisplay(android.hardware.display.VirtualDisplay)

Example 80 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class FakeApp method onCreate.

@Override
public void onCreate() {
    String processName = ActivityThread.currentProcessName();
    Slog.i("FakeOEMFeatures", "Creating app in process: " + processName);
    if (!getApplicationInfo().packageName.equals(processName)) {
        // our extra overhead stuff.
        return;
    }
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    // is a user build, WARN!  Do not want!
    if ("user".equals(android.os.Build.TYPE)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Should not be on user build");
        builder.setMessage("The app Fake OEM Features should not be installed on a " + "user build.  Please remove this .apk before shipping this build to " + " your customers!");
        builder.setCancelable(false);
        builder.setPositiveButton("I understand", null);
        Dialog dialog = builder.create();
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        dialog.show();
    }
    // Make a fake window that is always around eating graphics resources.
    FakeView view = new FakeView(this);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    if (ActivityManager.isHighEndGfx()) {
        lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
    }
    lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
    int maxSize = display.getMaximumSizeDimension();
    maxSize *= 2;
    lp.x = maxSize;
    lp.y = maxSize;
    lp.setTitle(getPackageName());
    wm.addView(view, lp);
    // Bind to a fake service we want to keep running in another process.
    bindService(new Intent(this, FakeCoreService.class), mServiceConnection, Context.BIND_AUTO_CREATE);
    bindService(new Intent(this, FakeCoreService2.class), mServiceConnection2, Context.BIND_AUTO_CREATE);
    bindService(new Intent(this, FakeCoreService3.class), mServiceConnection3, Context.BIND_AUTO_CREATE);
    // Start to a fake service that should run in the background of
    // another process.
    mHandler.sendEmptyMessage(MSG_TICK);
    // Make a fake allocation to consume some RAM.
    mStuffing = new int[STUFFING_SIZE_INTS];
    for (int i = 0; i < STUFFING_SIZE_BYTES / PAGE_SIZE; i++) {
        // Fill each page with a unique value.
        final int VAL = i * 2 + 100;
        final int OFF = (i * PAGE_SIZE) / 4;
        for (int j = 0; j < (PAGE_SIZE / 4); j++) {
            mStuffing[OFF + j] = VAL;
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) Intent(android.content.Intent) WindowManager(android.view.WindowManager) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) Display(android.view.Display)

Aggregations

Display (android.view.Display)697 Point (android.graphics.Point)356 WindowManager (android.view.WindowManager)349 DisplayMetrics (android.util.DisplayMetrics)126 View (android.view.View)57 TextView (android.widget.TextView)54 LinearLayout (android.widget.LinearLayout)45 SuppressLint (android.annotation.SuppressLint)43 Method (java.lang.reflect.Method)41 ImageView (android.widget.ImageView)39 Bitmap (android.graphics.Bitmap)38 Resources (android.content.res.Resources)36 Intent (android.content.Intent)34 Camera (android.hardware.Camera)31 Context (android.content.Context)26 Rect (android.graphics.Rect)25 IOException (java.io.IOException)24 ViewGroup (android.view.ViewGroup)23 Canvas (android.graphics.Canvas)22 RemoteException (android.os.RemoteException)22