Example usage for android.graphics PixelFormat TRANSLUCENT

List of usage examples for android.graphics PixelFormat TRANSLUCENT

Introduction

In this page you can find the example usage for android.graphics PixelFormat TRANSLUCENT.

Prototype

int TRANSLUCENT

To view the source code for android.graphics PixelFormat TRANSLUCENT.

Click Source Link

Document

System chooses a format that supports translucency (many alpha bits)

Usage

From source file:com.nagravision.mediaplayer.FullscreenActivity.java

/**
 *
 *///from ww  w  . jav a 2  s  .  c  o m
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle inBundle) {
    Log.v(LOG_TAG, "FullscreenActivity::onCreate - Enter\n");
    super.onCreate(inBundle);

    getApplication().registerActivityLifecycleCallbacks(this);

    if (Build.VERSION.SDK_INT < 16) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_fullscreen);
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mMoviesList = (ListView) findViewById(R.id.start_drawer);
    mUrlsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, MOVIES_ARR);
    mMoviesList.setAdapter(mUrlsAdapter);
    mVideoHolder = (VideoView) findViewById(R.id.fullscreen_content);

    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    if (Build.VERSION.SDK_INT >= 19) {
        uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
    }
    decorView.setSystemUiVisibility(uiOptions);
    // Remember that you should never show the action bar if the
    // status bar is hidden, so hide that too if necessary.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.hide();

    mNotifBuilder = new Notification.Builder(this);
    mNotifMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mExplicitIntent = new Intent(Intent.ACTION_VIEW);
    mExplicitIntent.setClass(this, this.getClass());
    mDefaultIntent = PendingIntent.getActivity(this, REQUEST_DISPLAY, mExplicitIntent,
            Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_DEBUG_LOG_RESOLUTION);
    mInfosActionIntent = new Intent();
    mInfosActionIntent.setAction("com.nagravision.mediaplayer.VIDEO_INFOS");
    mInfosActionIntent.addCategory(Intent.CATEGORY_DEFAULT);
    mInfosActionIntent.addCategory(Intent.CATEGORY_INFO);
    mInfosIntent = PendingIntent.getActivity(this, REQUEST_INFOS, mInfosActionIntent,
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_DEBUG_LOG_RESOLUTION);

    if (Build.VERSION.SDK_INT >= 19) {
        mVideoHolder.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE);
    } else {
        mVideoHolder.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_FULLSCREEN);
    }
    OnItemClickListener mMessageClickedHandler = new OnItemClickListener() {
        public void onItemClick(@SuppressWarnings("rawtypes") AdapterView parent, View v, int position,
                long id) {
            Log.v(LOG_TAG, "FullscreenActivity.onCreate.OnItemClickListener::onItemClick - Enter\n");
            ClickItem(position, 0);
        }
    };

    mMoviesList.setOnItemClickListener(mMessageClickedHandler);

    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    mControlsView = new MediaController(this, true);
    mControlsView.setPrevNextListeners(new View.OnClickListener() {
        /*
         * Next listener
         */
        @Override
        public void onClick(View view) {
            Log.v(LOG_TAG, "FullscreenActivity.onCreate.OnClickListener::onClick(next) - Enter\n");
            mVideoHolder.stopPlayback();
            int position = 0;
            if (mLastPosition > 0)
                position = mLastPosition + 1;
            if (position >= MOVIES_URLS.length)
                position = 0;
            ClickItem(position, 0);

            String toaststr = getResources().getString(R.string.next_movie_toast_string) + MOVIES_ARR[position];
            Toast.makeText(FullscreenActivity.this, toaststr, Toast.LENGTH_LONG).show();
        }
    }, new View.OnClickListener() {
        /*
         * Prev listener
         */
        @Override
        public void onClick(View view) {
            Log.v(LOG_TAG, "FullscreenActivity.onCreate.OnClickListener::onClick(prev) - Enter\n");
            mVideoHolder.stopPlayback();
            int position = 0;
            if (mLastPosition > 0)
                position = mLastPosition - 1;
            if (position < 0)
                position = MOVIES_URLS.length - 1;
            ClickItem(position, 0);

            String toaststr = getResources().getString(R.string.prev_movie_toast_string) + MOVIES_ARR[position];
            Toast.makeText(FullscreenActivity.this, toaststr, Toast.LENGTH_LONG).show();
        }
    });
    mVideoHolder.setMediaController(mControlsView);

    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    mSystemUiHider = SystemUiHider.getInstance(this, mVideoHolder, HIDER_FLAGS);
    mSystemUiHider.setup();
    mSystemUiHider.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
        // Cached values.
        int mControlsHeight;
        int mShortAnimTime;

        @Override
        @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
        public void onVisibilityChange(boolean visible) {
            Log.v(LOG_TAG, "FullscreenActivity.OnVisibilityChangeListener::onVisibilityChange - Enter\n");

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
                if (mControlsHeight == 0)
                    mControlsHeight = mControlsView.getHeight();
                if (mShortAnimTime == 0)
                    mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
                mControlsView.animate().translationY(visible ? 0 : mControlsHeight).setDuration(mShortAnimTime);
            } else
                mControlsView.setVisibility(visible ? View.VISIBLE : View.GONE);

            if (visible && AUTO_HIDE)
                delayedHide(AUTO_HIDE_DELAY_MILLIS);
        }
    });

    // Set up the user interaction to manually show or hide the system UI.
    mVideoHolder.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (TOGGLE_ON_CLICK) {
                mSystemUiHider.toggle();
            } else {
                mSystemUiHider.show();
            }
        }
    });

    mDrawer.openDrawer(mMoviesList);
}

From source file:og.android.tether.MainActivity.java

private void openAdBar() {
    LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View ad_view = li.inflate(R.layout.ad_view, null);
    ad_view.setBackgroundColor(Color.TRANSPARENT);

    final WindowManager wm = getWindowManager();
    WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
    wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    wmParams.gravity = Gravity.BOTTOM;/*from ww  w.  j a  v a2s  .  c o  m*/
    wmParams.y = 100;
    wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
    wmParams.format = PixelFormat.TRANSLUCENT;

    wm.addView(ad_view, wmParams);

    View ad_open = ad_view.findViewById(R.id.ad_open);
    View ad_close = ad_view.findViewById(R.id.ad_close);

    OnClickListener adListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.ad_open:
                Log.i(MSG_TAG, "ad_open");
                Intent i = new Intent();
                i.setAction(Intent.ACTION_VIEW);
                i.addCategory(Intent.CATEGORY_BROWSABLE);
                i.setData(Uri.parse(
                        "market://details?id=com.opengarden.radiofreenet&referrer=utm_source%3Dog.android.tether%26utm_medium%3Dandroid%26utm_campaign%3Dbanner%26utm_content%3Dinstall"));
                try {
                    startActivity(i);
                } catch (android.content.ActivityNotFoundException e) {
                    Log.e(MSG_TAG, "", e);
                    MainActivity.this.application.displayToastMessage(e.toString());
                }
                break;

            case R.id.ad_close:
                Log.i(MSG_TAG, "ad_close");
                wm.removeView(ad_view);
                break;

            default:
                Log.i(MSG_TAG, "default");
                break;
            }
        }
    };
    ad_open.setOnClickListener(adListener);
    ad_close.setOnClickListener(adListener);
}

From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private WindowManager.LayoutParams createFilterLayoutParams() {
    WindowManager.LayoutParams wlp = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
            mScreenManager.getScreenHeight(), 0, -mScreenManager.getStatusBarHeightPx(),
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                    | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
            PixelFormat.TRANSLUCENT);

    wlp.gravity = Gravity.TOP | Gravity.START;
    wlp.buttonBrightness = mSettingsModel.getDimButtonsFlag() ? 0 : -1;

    return wlp;//from  w w  w .jav a 2  s  .  c om
}

From source file:com.cleveroad.audiowidget.AudioWidget.java

private void show(View view, int left, int top) {
    if (view.getParent() != null || view.getWindowToken() != null) {
        windowManager.removeView(view);//  ww  w  .  j a va2  s.  com
    }
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                    | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.START | Gravity.TOP;
    params.x = left;
    params.y = top;
    windowManager.addView(view, params);
}

From source file:com.fa.imaged.activity.DetailActivityV2.java

private void PlayVideo() {
    try {/*from   w  w  w  .  ja v a  2 s  .  c  o  m*/
        getWindow().setFormat(PixelFormat.TRANSLUCENT);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(detailVideoV2);
        detailVideoV2.setVisibility(View.VISIBLE);
        Uri video = Uri.parse(detailImageLoaderv2.video_standard_res);
        detailVideoV2.setMediaController(mediaController);
        detailVideoV2.setVideoURI(video);
        detailVideoV2.requestFocus();
        detailVideoV2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

            public void onPrepared(MediaPlayer mp) {
                detailImageV2.setVisibility(View.GONE);
                detailVideoV2.start();
            }
        });

    } catch (Exception e) {
        System.out.println("Video Play Error :" + e.toString());
    }

}

From source file:com.mikepenz.iconics.IconicsDrawable.java

@Override
public int getOpacity() {
    if (mTintFilter != null || mIconPaint.getColorFilter() != null) {
        return PixelFormat.TRANSLUCENT;
    }//from   ww w.j  a v  a 2s.c o  m
    switch (getAlpha()) {
    case 255:
        return PixelFormat.OPAQUE;
    case 0:
        return PixelFormat.TRANSPARENT;
    }
    return PixelFormat.TRANSLUCENT;
}

From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java

/**
 * Initiate the dragging process. Create a bitmap that is displayed as the dragging event
 * happens and is moved around across the screen.  This function is called once for each time
 * that a dragging event is initiated.// w  w  w.j  a  v a  2s .  c  o m
 *
 * The logic to this method was borrowed from the TouchInterceptor.java class from the
 * music app.
 *
 * @param draggedChild The child view being dragged
 * @param x The x coordinate of this view where dragging began
 * @param y The y coordinate of this view where dragging began
 */
private void startDragging(final View draggedChild, final int x, final int y) {
    if (!isDragReorderingSupported()) {
        return;
    }

    mDragBitmap = createDraggedChildBitmap(draggedChild);
    if (mDragBitmap == null) {
        // It appears that creating bitmaps for large views fail. For now, don't allow
        // dragging in this scenario.  When using the framework's drag and drop implementation,
        // drag shadow also fails with a OutofResourceException when trying to draw the drag
        // shadow onto a Surface.
        mReorderHelper.handleDragCancelled(draggedChild);
        return;
    }
    mTouchOffsetToChildLeft = x - draggedChild.getLeft();
    mTouchOffsetToChildTop = y - draggedChild.getTop();
    updateReorderStates(ReorderUtils.DRAG_STATE_DRAGGING);

    initializeDragScrollParameters(y);

    final LayoutParams params = (LayoutParams) draggedChild.getLayoutParams();
    mReorderHelper.handleDragStart(draggedChild, params.position, params.id,
            new Point(mTouchDownForDragStartX, mTouchDownForDragStartY));

    // TODO: Reconsider using the framework's DragShadow support for dragging,
    // and only draw the bitmap in onDrop for animation.
    final Context context = getContext();
    mDragView = new ImageView(context);
    mDragView.setImageBitmap(mDragBitmap);
    mDragView.setAlpha(160);

    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.gravity = Gravity.TOP | Gravity.START;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags = mWindowManagerLayoutFlags;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    // Use WindowManager to overlay a transparent image on drag
    mWindowManager.addView(mDragView, mWindowParams);
    updateDraggedBitmapLocation(x, y);
}

From source file:android.support.v17.leanback.app.BackgroundManager.java

private void attachBehindWindow(Window window) {
    if (DEBUG)/* w ww.  j  a  va  2s .  co  m*/
        Log.v(TAG, "attachBehindWindow " + window);
    mWindow = window;
    mWindowManager = window.getWindowManager();

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            // Media window sits behind the main application window
            WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA,
            // Avoid default to software format RGBA
            WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, android.graphics.PixelFormat.TRANSLUCENT);
    params.setTitle(WINDOW_NAME);
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;

    View backgroundView = LayoutInflater.from(mContext).inflate(R.layout.lb_background_window, null);
    mWindowManager.addView(backgroundView, params);

    attachToView(backgroundView);
}

From source file:tk.eatheat.omnisnitch.ui.SwitchLayout.java

private WindowManager.LayoutParams getParams() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            mConfiguration.getCurrentDisplayWidth() - mConfiguration.mHorizontalMargin,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, 0,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.TOP | Gravity.CENTER;
    params.y = mConfiguration.getCurrentOffsetStart() + mConfiguration.mHandleHeight / 2
            - mConfiguration.mHorizontalScrollerHeight / 2
            - (mButtonsVisible ? mConfiguration.mHorizontalMaxWidth : 0);

    return params;
}

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

private void openPanel(final PanelFeatureState st, KeyEvent event) {
    // Already open, return
    if (st.isOpen || isDestroyed()) {
        return;/*w w w . j  av  a2  s  . c om*/
    }

    // Don't open an options panel for honeycomb apps on xlarge devices.
    // (The app should be using an action bar for menu items.)
    if (st.featureId == FEATURE_OPTIONS_PANEL) {
        Context context = mContext;
        Configuration config = context.getResources().getConfiguration();
        boolean isXLarge = (config.screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
        boolean isHoneycombApp = context
                .getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB;

        if (isXLarge && isHoneycombApp) {
            return;
        }
    }

    Window.Callback cb = getWindowCallback();
    if ((cb != null) && (!cb.onMenuOpened(st.featureId, st.menu))) {
        // Callback doesn't want the menu to open, reset any state
        closePanel(st, true);
        return;
    }

    final WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    if (wm == null) {
        return;
    }

    // Prepare panel (should have been done before, but just in case)
    if (!preparePanel(st, event)) {
        return;
    }

    int width = WRAP_CONTENT;
    if (st.decorView == null || st.refreshDecorView) {
        if (st.decorView == null) {
            // Initialize the panel decor, this will populate st.decorView
            if (!initializePanelDecor(st) || (st.decorView == null))
                return;
        } else if (st.refreshDecorView && (st.decorView.getChildCount() > 0)) {
            // Decor needs refreshing, so remove its views
            st.decorView.removeAllViews();
        }

        // This will populate st.shownPanelView
        if (!initializePanelContent(st) || !st.hasPanelItems()) {
            return;
        }

        ViewGroup.LayoutParams lp = st.shownPanelView.getLayoutParams();
        if (lp == null) {
            lp = new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
        }

        int backgroundResId = st.background;
        st.decorView.setBackgroundResource(backgroundResId);

        ViewParent shownPanelParent = st.shownPanelView.getParent();
        if (shownPanelParent != null && shownPanelParent instanceof ViewGroup) {
            ((ViewGroup) shownPanelParent).removeView(st.shownPanelView);
        }
        st.decorView.addView(st.shownPanelView, lp);

        /*
         * Give focus to the view, if it or one of its children does not
         * already have it.
         */
        if (!st.shownPanelView.hasFocus()) {
            st.shownPanelView.requestFocus();
        }
    } else if (st.createdPanelView != null) {
        // If we already had a panel view, carry width=MATCH_PARENT through
        // as we did above when it was created.
        ViewGroup.LayoutParams lp = st.createdPanelView.getLayoutParams();
        if (lp != null && lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
            width = MATCH_PARENT;
        }
    }

    st.isHandled = false;

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, WRAP_CONTENT, st.x, st.y,
            WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL,
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
            PixelFormat.TRANSLUCENT);

    lp.gravity = st.gravity;
    lp.windowAnimations = st.windowAnimations;

    wm.addView(st.decorView, lp);
    st.isOpen = true;
}