Example usage for android.content Context WINDOW_SERVICE

List of usage examples for android.content Context WINDOW_SERVICE

Introduction

In this page you can find the example usage for android.content Context WINDOW_SERVICE.

Prototype

String WINDOW_SERVICE

To view the source code for android.content Context WINDOW_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.WindowManager for accessing the system's window manager.

Usage

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

private void closePanel(PanelFeatureState st, boolean doCallback) {
    if (doCallback && st.featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null
            && mDecorContentParent.isOverflowMenuShowing()) {
        checkCloseActionMenu(st.menu);/*from   w  w  w.j  a  v  a  2s .  com*/
        return;
    }

    final boolean wasOpen = st.isOpen;

    final WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    if (wm != null && wasOpen && st.decorView != null) {
        wm.removeView(st.decorView);
    }

    st.isPrepared = false;
    st.isHandled = false;
    st.isOpen = false;

    if (wasOpen && doCallback) {
        // If the panel was open and we should callback, do so. This should be done after
        // isOpen is updated to ensure that we do not get into an infinite recursion
        callOnPanelClosed(st.featureId, st, null);
    }

    // This view is no longer shown, so null it out
    st.shownPanelView = null;

    // Next time the menu opens, it should not be in expanded mode, so
    // force a refresh of the decor
    st.refreshDecorView = true;

    if (mPreparedPanel == st) {
        mPreparedPanel = null;
    }
}

From source file:org.cryptsecure.Utility.java

/**
 * Get the screen width.//from   w w w. j a v  a 2  s  .com
 * 
 * @param context
 *            the context
 * @return the screen width
 */
@SuppressWarnings("deprecation")
public static int getScreenWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    return display.getWidth(); // API LEVEL 11
    // API LEVEL 13
    // Point size = new Point();
    // display.getSize(size);
    // int width = size.x;
    // int height = size.y;
    // return width;
}

From source file:org.cryptsecure.Utility.java

/**
 * Get the screen height.//  w  w  w  .  j  ava2 s .  c  om
 * 
 * @param context
 *            the context
 * @return the screen height
 */
@SuppressWarnings("deprecation")
public static int getScreenHeight(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    return display.getHeight();
    // API LEVEL 11
    // API LEVEL 13
    // Point size = new Point();
    // display.getSize(size);
    // int width = size.x;
    // int height = size.y;
    // return height;
}

From source file:self.philbrown.droidQuery.$.java

/**
 * Animates the selected views out of their parent views by sliding it down, past its bottom
 * @param duration the length of time the animation should last
 * @param complete the function to call when the animation has completed
 *//*  ww w. jav  a 2 s . c o  m*/
public void slideDown(long duration, final Function complete) {
    AnimatorSet anim = new AnimatorSet();
    anim.addListener(new AnimatorListener() {
        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (complete != null)
                complete.invoke($.this);
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationStart(Animator animation) {
        }
    });
    AnimatorSet.Builder builder = null;
    for (int i = 0; i < this.views.size(); i++) {
        View view = this.views.get(i);
        ViewParent parent = view.getParent();
        float y = 0;
        if (parent != null && parent instanceof View) {
            y = ((View) parent).getHeight();
        } else {
            Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
                    .getDefaultDisplay();
            y = display.getHeight();
        }
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, "y", y);
        if (builder == null)
            builder = anim.play(animator);
        else
            builder.with(animator);
    }
    anim.setDuration(duration);
    anim.start();
}

From source file:self.philbrown.droidQuery.$.java

/**
 * Animates the selected views out of its parent by sliding it down, past its bottom
 * @param options use to modify the behavior of the animation
 *//*from ww  w  .j  a v  a2  s  .  c  o m*/
public void slideDown(final AnimationOptions options) {
    List<Animator> animations = new ArrayList<Animator>();
    for (final View view : this.views) {
        ViewParent parent = view.getParent();
        float y = 0;
        if (parent != null && parent instanceof View) {
            y = ((View) parent).getHeight();
        } else {
            Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
                    .getDefaultDisplay();
            y = display.getHeight();
        }
        ObjectAnimator anim = ObjectAnimator.ofFloat(view, "y", new Float(y));
        if (options.progress() != null) {
            anim.addUpdateListener(new AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    options.progress().invoke($.with(view), "y", animation.getAnimatedValue(),
                            animation.getDuration() - animation.getCurrentPlayTime());
                }

            });
        }
        animations.add(anim);
    }

    AnimatorSet animation = animationWithOptions(options, animations);
    animation.start();

}

From source file:androidx.media.widget.VideoView2.java

@SuppressWarnings("deprecation")
private void extractAudioMetadata() {
    if (!mIsMusicMediaType) {
        return;// w  ww .j  a  v  a  2 s .c  o m
    }

    mResources = getResources();
    mManager = (WindowManager) getContext().getApplicationContext().getSystemService(Context.WINDOW_SERVICE);

    byte[] album = mRetriever.getEmbeddedPicture();
    if (album != null) {
        Bitmap bitmap = BitmapFactory.decodeByteArray(album, 0, album.length);
        mMusicAlbumDrawable = new BitmapDrawable(bitmap);

        // TODO: replace with visualizer
        Palette.Builder builder = Palette.from(bitmap);
        builder.generate(new Palette.PaletteAsyncListener() {
            @Override
            public void onGenerated(Palette palette) {
                // TODO: add dominant color for default album image.
                mDominantColor = palette.getDominantColor(0);
                if (mMusicView != null) {
                    mMusicView.setBackgroundColor(mDominantColor);
                }
            }
        });
    } else {
        mMusicAlbumDrawable = mResources.getDrawable(R.drawable.ic_default_album_image);
    }

    String title = mRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
    if (title != null) {
        mMusicTitleText = title;
    } else {
        mMusicTitleText = mResources.getString(R.string.mcv2_music_title_unknown_text);
    }

    String artist = mRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
    if (artist != null) {
        mMusicArtistText = artist;
    } else {
        mMusicArtistText = mResources.getString(R.string.mcv2_music_artist_unknown_text);
    }

    // Send title and artist string to MediaControlView2
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, mMusicTitleText);
    builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, mMusicArtistText);
    mMediaSession.setMetadata(builder.build());

    // Display Embedded mode as default
    removeView(mSurfaceView);
    removeView(mTextureView);
    inflateMusicView(R.layout.embedded_music);
}

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

private void closePanel(PanelFeatureState st, boolean doCallback) {
    if (doCallback && st.featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null
            && mDecorContentParent.isOverflowMenuShowing()) {
        checkCloseActionMenu(st.menu);/*  ww  w  .  jav  a  2s  .co m*/
        return;
    }

    final WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    if (wm != null && st.isOpen && st.decorView != null) {
        wm.removeView(st.decorView);

        if (doCallback) {
            callOnPanelClosed(st.featureId, st, null);
        }
    }

    st.isPrepared = false;
    st.isHandled = false;
    st.isOpen = false;

    // This view is no longer shown, so null it out
    st.shownPanelView = null;

    // Next time the menu opens, it should not be in expanded mode, so
    // force a refresh of the decor
    st.refreshDecorView = true;

    if (mPreparedPanel == st) {
        mPreparedPanel = null;
    }
}

From source file:self.philbrown.droidQuery.$.java

/**
 * Animates the selected views out of its parent by sliding it right, past its edge
 * @param duration the length of time the animation should last
 * @param complete the function to call when the animation has completed
 *//*  w  w  w .ja  va2s . c  om*/
public void slideRight(long duration, final Function complete) {
    AnimatorSet anim = new AnimatorSet();
    anim.addListener(new AnimatorListener() {
        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (complete != null)
                complete.invoke($.this);
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationStart(Animator animation) {
        }
    });
    AnimatorSet.Builder builder = null;
    for (int i = 0; i < this.views.size(); i++) {
        View view = this.views.get(i);
        ViewParent parent = view.getParent();
        float x = 0;
        if (parent != null && parent instanceof View) {
            x = ((View) parent).getWidth();
        } else {
            Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
                    .getDefaultDisplay();
            x = display.getHeight();
        }
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, "x", x);
        if (builder == null)
            builder = anim.play(animator);
        else
            builder.with(animator);
    }
    anim.setDuration(duration);
    anim.start();
}

From source file:self.philbrown.droidQuery.$.java

/**
 * Animates the selected views out of its parent by sliding it right, past its edge
 * @param options use to modify the behavior of the animation
 *///from  w  ww. j av a 2  s  . co m
public void slideRight(final AnimationOptions options) {
    List<Animator> animations = new ArrayList<Animator>();
    for (final View view : this.views) {
        ViewParent parent = view.getParent();
        float x = 0;
        if (parent != null && parent instanceof View) {
            x = ((View) parent).getWidth();
        } else {
            Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
                    .getDefaultDisplay();
            x = display.getHeight();
        }
        ObjectAnimator anim = ObjectAnimator.ofFloat(view, "x", x);
        if (options.progress() != null) {
            anim.addUpdateListener(new AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    options.progress().invoke($.with(view), "x", animation.getAnimatedValue(),
                            animation.getDuration() - animation.getCurrentPlayTime());
                }

            });
        }
        animations.add(anim);
    }

    AnimatorSet animation = animationWithOptions(options, animations);
    animation.start();
}

From source file:com.almalence.opencam.ApplicationScreen.java

@Override
public void surfaceCreated(SurfaceHolder holder) {
    // ----- Find 'normal' orientation of the device

    Display display = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int rotation = display.getRotation();
    if ((rotation == Surface.ROTATION_90) || (rotation == Surface.ROTATION_270))
        landscapeIsNormal = true; // false; - if landscape view orientation
    // set for ApplicationScreen
    else//from w w  w  .j a v a2  s.  c o m
        landscapeIsNormal = false;

    surfaceCreated = true;

    mCameraSurface = surfaceHolder.getSurface();
}