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.htc.dotdesign.ToolBoxService.java

@Override
public void onCreate() {
    Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onCreate");
    super.onCreate();

    Resources res = getResources();
    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
    if (mLocalBroadcastManager != null) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(SHOW_HIDE_TOOL_BAR);
        filter.addAction(USER_START_DRAWING);
        mLocalBroadcastManager.registerReceiver(mToolBarReceiver, filter);
    }//w  w w .ja v a  2 s .co m

    // Get full window size
    Display display = mWindowManager.getDefaultDisplay();
    Point size = new Point();
    display.getRealSize(size);
    mScreenWidth = size.x;
    mScreenHeight = size.y;

    // Get arrow width
    BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
    bitmapOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(res, R.drawable.dot_design_popupmenu_arrow, bitmapOptions);
    mArrowWidth = bitmapOptions.outWidth;

    // Initialize LayoutParams
    mDragButtonParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.drag_button_width),
            res.getDimensionPixelSize(R.dimen.drag_button_height), WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
    mDragButtonParams.gravity = Gravity.TOP | Gravity.START;
    mDragButtonParams.x = 0;
    mDragButtonParams.y = mScreenHeight / 2;

    mToolBarParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.tool_bar_width),
            res.getDimensionPixelSize(R.dimen.tool_bar_height), WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
    mToolBarParams.alpha = 0.9f;
    mToolBarParams.gravity = Gravity.TOP | Gravity.START;
    mToolBarParams.x = 0;
    mToolBarParams.y = mDragButtonParams.y;

    // Initialize drag button width and height
    //mDragButtonWidth = res.getDimensionPixelSize(R.dimen.drag_button_width);
    mDragButtonHeight = res.getDimensionPixelSize(R.dimen.drag_button_height);
    mDragBtnColorIcon = (GradientDrawable) res.getDrawable(R.drawable.round_button);
    mDragBtnEraserIcon = res.getDrawable(R.drawable.dot_design_circle_shape_dark);

    // Inflate layout
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mDragButton = inflater.inflate(R.layout.drag_button, null);
    mToolBarParent = inflater.inflate(R.layout.tool_bar, null);
    mPalette = inflater.inflate(R.layout.palette, null);
    mEraser = inflater.inflate(R.layout.eraser, null);
    mMenu = inflater.inflate(R.layout.menu, null);

    initToolBar();
    initMenu();
    initAnimation();
    initBrushColor();
    initDragButton();

    mWindowManager.addView(mToolBarParent, mToolBarParams);
    mWindowManager.addView(mDragButton, mDragButtonParams);
    mToolBarParent.setVisibility(View.INVISIBLE);
}

From source file:de.localtoast.launchit.BackgroundService.java

private void switchToSidebar() {
    if (!sidebarVisible) {
        sidebarVisible = true;// www.  ja v  a  2s.c om

        Context context = getBaseContext();

        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(225,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.TOP | Gravity.RIGHT;

        removeView();
        wm.addView(sidebar, params);
        // TODO move this animation stuff in some sort of gui class or directly to the view
        Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_in_right);
        animation.setDuration(FADING_DURATION_MS);
        appListView.startAnimation(animation);
        appListView.setVisibility(View.VISIBLE);
    }
}

From source file:com.farmerbb.secondscreen.service.NotificationService.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override// w w  w  . j  a v  a 2s. c o m
public void onCreate() {
    // Load preferences
    SharedPreferences prefCurrent = U.getPrefCurrent(this);
    SharedPreferences prefMain = U.getPrefMain(this);

    // Register broadcast receivers for screen on and user present
    final IntentFilter filter1 = new IntentFilter();
    final IntentFilter filter2 = new IntentFilter();

    filter1.addAction(Intent.ACTION_SCREEN_ON);
    filter1.addAction(Intent.ACTION_DREAMING_STARTED);
    filter2.addAction(Intent.ACTION_USER_PRESENT);

    registerReceiver(screenOnReceiver, filter1);
    registerReceiver(userPresentReceiver, filter2);

    DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
    manager.registerDisplayListener(listener, null);

    // Intent to launch MainActivity when notification is clicked
    Intent mainActivityIntent = new Intent(this, MainActivity.class);
    PendingIntent mainActivityPendingIntent = PendingIntent.getActivity(this, 0, mainActivityIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Build the notification
    mBuilder = new NotificationCompat.Builder(this).setContentIntent(mainActivityPendingIntent)
            .setSmallIcon(R.drawable.ic_action_dock)
            .setContentTitle(getResources().getString(R.string.notification))
            .setContentText(
                    prefCurrent.getString("profile_name", getResources().getString(R.string.action_new)))
            .setOngoing(true);

    // Set action buttons
    setActionButton(prefMain.getString("notification_action_2", "turn-off"), prefCurrent, 0);
    setActionButton(prefMain.getString("notification_action", "lock-device"), prefCurrent, 1);

    // Respect setting to hide notification
    if (prefMain.getBoolean("hide_notification", false))
        mBuilder.setPriority(Notification.PRIORITY_MIN);

    // Set notification color on Lollipop
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBuilder.setColor(getResources().getColor(R.color.primary_dark))
                .setVisibility(Notification.VISIBILITY_PUBLIC);
    }

    // Start NotificationService
    startForeground(1, mBuilder.build());

    // Draw system overlay, if needed
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Settings.canDrawOverlays(this)
            && prefCurrent.getString("rotation_lock_new", "fallback").equals("landscape")) {
        windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);

        params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;

        view = new View(this);
        windowManager.addView(view, params);
    }
}

From source file:jp.morihirosoft.twwb.TwwbService.java

private void blockScreen() {
    if (DEBUG)/* ww w .ja  v  a2s .c o m*/
        Log.d(TAG, "blockScreen");
    if (mBlockScreen == null) {
        if (mIsCalling) {
            return;
        }
        if (SystemClock.uptimeMillis() - mStartTime < mSettings.getPending() * 1000) {
            return;
        }
        mBlockScreen = LayoutInflater.from(this).inflate(R.layout.view_block, null);
        int alpha = 255 * mSettings.getAlpha() / 100;
        mBlockScreen.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
        ((ImageView) mBlockScreen.findViewById(R.id.img_logo)).setAlpha(alpha);
        ((Button) mBlockScreen.findViewById(R.id.btn_unblock)).setOnClickListener(this);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.MATCH_PARENT;
        params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
        params.flags = 0;
        params.format = PixelFormat.TRANSLUCENT;

        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        wm.addView(mBlockScreen, params);
    }
}

From source file:org.deviceconnect.android.deviceplugin.host.camera.CameraOverlay.java

private synchronized void showInternal(@NonNull final Callback callback) {
    mHandler.post(new Runnable() {
        @Override//from   w ww. j a  v a 2 s .  c  o m
        public void run() {
            try {
                mPreview = new Preview(mContext);

                Point size = getDisplaySize();
                int pt = (int) (5 * getScaledDensity());
                WindowManager.LayoutParams l = new WindowManager.LayoutParams(pt, pt,
                        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                        PixelFormat.TRANSLUCENT);
                l.x = -size.x / 2;
                l.y = -size.y / 2;
                mWinMgr.addView(mPreview, l);

                mCamera = Camera.open(mCameraId);
                setRequestedPictureSize(mCamera);
                setRequestedPreviewSize(mCamera);
                mPreview.switchCamera(mCameraId, mCamera);
                mCamera.setPreviewCallback(CameraOverlay.this);
                mCamera.setErrorCallback(CameraOverlay.this);

                IntentFilter filter = new IntentFilter();
                filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
                mContext.registerReceiver(mOrientReceiver, filter);

                sendNotification();

                callback.onSuccess();
            } catch (Throwable t) {
                if (BuildConfig.DEBUG) {
                    Log.w("Overlay", "", t);
                }
                callback.onFail();
            }
        }
    });
}

From source file:com.htc.dotdesign.ToolBoxService.java

private void setToolPanelVisibility(boolean bShow) {
    if (mCurrExtend != null) {
        mWindowManager.removeView(mCurrExtend);
        mCurrExtend = null;/*from w w w  .j  a  va  2 s .c o m*/
    }

    if (bShow) {
        mIsToolBarExtend = true;
        if (mCurrFun == FunType.Fun_Palette) {
            Resources res = getResources();
            WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            params.gravity = Gravity.START;
            if (mDragButtonParams.y < mScreenHeight / 2) {
                params.gravity = Gravity.TOP | params.gravity;
                params.y = mDragButtonParams.y + mDragButtonHeight;
                View top_arrow = mPalette.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.VISIBLE);
                View bottom_arrow = mPalette.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.GONE);
            } else {
                params.gravity = Gravity.BOTTOM | params.gravity;
                params.y = mScreenHeight - mDragButtonParams.y;
                View top_arrow = mPalette.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.GONE);
                View bottom_arrow = mPalette.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.VISIBLE);
            }
            int[] locations = new int[2];
            mBtnPalette.getLocationOnScreen(locations);
            int x = locations[0];
            params.x = (x + mBtnPalette.getWidth() / 2)
                    - (mArrowWidth / 2 + res.getDimensionPixelSize(R.dimen.h02));

            mPalette.setVisibility(View.VISIBLE);
            mWindowManager.addView(mPalette, params);
            mCurrExtend = mPalette;
            initBrushSize();
        } else if (mCurrFun == FunType.Fun_Eraser) {
            Resources res = getResources();
            WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            params.gravity = Gravity.START;
            if (mDragButtonParams.y < mScreenHeight / 2) {
                params.gravity = Gravity.TOP | params.gravity;
                params.y = mDragButtonParams.y + mDragButtonHeight;
                View top_arrow = mEraser.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.VISIBLE);
                View bottom_arrow = mEraser.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.GONE);
            } else {
                params.gravity = Gravity.BOTTOM | params.gravity;
                params.y = mScreenHeight - mDragButtonParams.y;
                View top_arrow = mEraser.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.GONE);
                View bottom_arrow = mEraser.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.VISIBLE);
            }
            int[] locations = new int[2];
            mBtnEraser.getLocationOnScreen(locations);
            int x = locations[0];
            params.x = (x + mBtnEraser.getWidth() / 2)
                    - (mArrowWidth / 2 + res.getDimensionPixelSize(R.dimen.h02));

            mEraser.setVisibility(View.VISIBLE);
            mWindowManager.addView(mEraser, params);
            mCurrExtend = mEraser;
            initBrushSize();
        } else if (mCurrFun == FunType.Fun_VirtualDot) {

        } else if (mCurrFun == FunType.Fun_Menu) {
            Resources res = getResources();
            WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            params.gravity = Gravity.END;
            if (mDragButtonParams.y < mScreenHeight / 2) {
                params.gravity = Gravity.TOP | params.gravity;
                params.y = mDragButtonParams.y + mDragButtonHeight;
                // Set top_arrow to visible and align to parent right.
                View top_arrow = mMenu.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.VISIBLE);
                LinearLayout.LayoutParams arrowParams = (LinearLayout.LayoutParams) top_arrow.getLayoutParams();
                arrowParams.setMarginEnd(res.getDimensionPixelSize(R.dimen.h02));
                arrowParams.gravity = Gravity.END;
                top_arrow.setLayoutParams(arrowParams);
                // Set bottom_arrow to gone
                View bottom_arrow = mMenu.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.GONE);
            } else {
                params.gravity = Gravity.BOTTOM | params.gravity;
                params.y = mScreenHeight - mDragButtonParams.y;
                // Set top_arrow to gone
                View top_arrow = mMenu.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.GONE);
                // Set bottom_arrow to visible and align to parent right.
                View bottom_arrow = mMenu.findViewById(R.id.bottom_arrow);
                LinearLayout.LayoutParams arrowParams = (LinearLayout.LayoutParams) bottom_arrow
                        .getLayoutParams();
                arrowParams.setMarginEnd(res.getDimensionPixelSize(R.dimen.h02));
                arrowParams.gravity = Gravity.END;
                bottom_arrow.setLayoutParams(arrowParams);
                bottom_arrow.setVisibility(View.VISIBLE);
            }
            int[] locations = new int[2];
            mBtnMenu.getLocationOnScreen(locations);
            int x = locations[0];
            //params.x = (x + mBtnMenu.getWidth()/2) - (mArrowWidth/2 + res.getDimensionPixelSize(R.dimen.h02));
            params.x = mScreenWidth - (x + mBtnMenu.getWidth() / 2)
                    - (mArrowWidth / 2 + res.getDimensionPixelSize(R.dimen.h02));

            mMenu.setVisibility(View.VISIBLE);
            mWindowManager.addView(mMenu, params);
            mCurrExtend = mMenu;
        }
    } else {
        mIsToolBarExtend = false;
    }

    updateToolBarFunIconColor();
}

From source file:com.woodblockwithoutco.quickcontroldock.ui.factory.ServiceViewFactory.java

public WindowManager.LayoutParams getServiceViewLayoutParams() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams();
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.MATCH_PARENT;
    params.dimAmount = GeneralResolver.getDimAmount(mContext);
    params.format = PixelFormat.TRANSLUCENT;
    params.gravity = Gravity.BOTTOM;/*from w w w.  j  ava2s.  com*/
    params.windowAnimations = android.R.style.Animation_Toast;
    int type = 0;
    if (LockscreenResolver.isEnabledOnLockscreen(mContext)) {
        type = ConstantHolder.getLockscreenType();
    } else {
        type = ConstantHolder.getNormalType();
    }
    params.type = type;
    params.flags = ConstantHolder.getPanelViewFlags();
    return params;
}

From source file:android.support.graphics.drawable.VectorDrawableCompat.java

@Override
public int getOpacity() {
    if (mDelegateDrawable != null) {
        return mDelegateDrawable.getOpacity();
    }//from w ww  .j  a v a 2 s  . co  m

    return PixelFormat.TRANSLUCENT;
}

From source file:com.alibaba.weex.IndexActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_index);
    setContainer((ViewGroup) findViewById(R.id.index_container));
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   www.  j  ava  2  s  .  c o m*/
    getWindow().setFormat(PixelFormat.TRANSLUCENT);

    mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
    mTipView = (TextView) findViewById(R.id.index_tip);
    mProgressBar.setVisibility(View.VISIBLE);
    mTipView.setVisibility(View.VISIBLE);

    if (!WXSoInstallMgrSdk.isCPUSupport()) {
        mProgressBar.setVisibility(View.INVISIBLE);
        mTipView.setText(R.string.cpu_not_support_tip);
        return;
    }

    if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
        renderPage(WXFileUtils.loadAsset("index.js", this), getIndexUrl());
    } else {
        renderPageByURL(getIndexUrl());
    }

    mReloadReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            createWeexInstance();
            if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
                renderPage(WXFileUtils.loadAsset("index.js", getApplicationContext()), getIndexUrl());
            } else {
                renderPageByURL(getIndexUrl());
            }
            mProgressBar.setVisibility(View.VISIBLE);
        }
    };

    LocalBroadcastManager.getInstance(this).registerReceiver(mReloadReceiver,
            new IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD));
}

From source file:com.woodblockwithoutco.quickcontroldock.ui.factory.ServiceViewFactory.java

public WindowManager.LayoutParams getDetectorViewLayoutParams() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams();
    params.width = (int) LaunchResolver.getSwipeDetectorSize2(mContext);
    params.height = (int) LaunchResolver.getSwipeDetectorSize1(mContext);
    params.dimAmount = 0.3f;//  ww w.  ja v a 2 s  .  co  m
    params.format = PixelFormat.TRANSLUCENT;
    params.gravity = LaunchResolver.getSwipeDetectorAlignment(mContext);
    params.windowAnimations = android.R.style.Animation_Toast;
    int type = 0;
    if (LockscreenResolver.isEnabledOnLockscreen(mContext)) {
        type = ConstantHolder.getLockscreenType();
    } else {
        type = ConstantHolder.getNormalType();
    }
    params.type = type;
    params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;

    if (LaunchResolver.getSwipeDetectorAlignment(mContext) == Gravity.BOTTOM) {
        params.x = LaunchResolver.getSwipeDetectorOffset(mContext);
    } else {
        params.y = LaunchResolver.getSwipeDetectorOffset(mContext);
    }

    //if we have to show it on lockscreen
    if (LockscreenResolver.isEnabledOnLockscreen(mContext)) {
        params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
    }

    return params;
}