@Override protected void displayAD() { if (null == mWindowManager) { mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); } lpWindow = new LayoutParams(); lpWindow.type = LayoutParams.TYPE_SYSTEM_ALERT; lpWindow.flags = LayoutParams.FLAG_NOT_FOCUSABLE; lpWindow.gravity = Gravity.TOP; Point point = new Point(); mWindowManager.getDefaultDisplay().getRealSize(point); lpWindow.x = 0; lpWindow.y = 0; lpWindow.width = point.x; lpWindow.height = CommonUtils.dip2px( mContext, mContext.getResources().getDimension(R.dimen.advanced_float_window_height)); lpWindow.format = PixelFormat.RGBA_8888; if (null == mRootView) { if (null == mInflater) { mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } mRootView = mInflater.inflate(R.layout.advanced_banner_window, null); } initViews(); initDatas(); }
private LayoutParams createPopupLayout(IBinder token) { LayoutParams p = new LayoutParams(); p.gravity = 8388659; p.width = -1; p.height = -1; p.format = -3; p.flags = this.computeFlags(p.flags); p.type = 1000; p.token = token; p.softInputMode = 3; p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(this.hashCode())); return p; }
private void initFloatView() { wmParams = new LayoutParams(); wmParams.format = PixelFormat.RGBA_8888; wmParams.x = PreSetting.getInstance().getFloatViewX(); wmParams.y = PreSetting.getInstance().getFloatViewY(); wmParams.width = LayoutParams.WRAP_CONTENT; wmParams.height = LayoutParams.WRAP_CONTENT; wmParams.flags = LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_NOT_FOCUSABLE; wmParams.type = LayoutParams.TYPE_PHONE; wmParams.windowAnimations = android.R.style.Animation_Translucent; LayoutInflater inflater = LayoutInflater.from(getApplication()); mFloatView = inflater.inflate(R.layout.layout_floatbutton, null); mFloatView.setOnTouchListener(onTouchListener); mFloatView.setOnClickListener(onClickListener); ((ButtonFloatSmall) mFloatView).setRippleColor(Color.TRANSPARENT); // ((ButtonFloatSmall)mFloatView).getBackground().setAlpha(50); }
@Override protected void displayAD() { if (null == mWindowManager) { mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); } LayoutParams lpWindow = new LayoutParams(); lpWindow.type = LayoutParams.TYPE_SYSTEM_ALERT; lpWindow.flags = LayoutParams.FLAG_DIM_BEHIND; lpWindow.dimAmount = 0.8f; lpWindow.gravity = Gravity.CENTER; Point point = new Point(); mWindowManager.getDefaultDisplay().getRealSize(point); lpWindow.x = 0; lpWindow.y = 0; lpWindow.width = CommonUtils.dip2px( mContext, mContext.getResources().getDimension(R.dimen.simple_window_width)); lpWindow.height = CommonUtils.dip2px( mContext, mContext.getResources().getDimension(R.dimen.simple_window_height)); lpWindow.format = PixelFormat.RGBA_8888; if (null == mRootView) { if (null == mInflater) { mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } mRootView = mInflater.inflate(R.layout.simple_window, null); } mWindowManager.addView(mRootView, lpWindow); initViews(); initDatas(); super.displayAD(); SharedPreferences sp = mContext.getSharedPreferences(AMConstants.SP_NAME, Context.MODE_PRIVATE); sp.edit().putLong(AMConstants.SP_LAST_AD_STAMP, System.currentTimeMillis()).commit(); AdDisplayUploadRequest request = new AdDisplayUploadRequest(null); request.start(mAD.getDisplayPager()); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) public void refreshTabIcon() { if (this.tabAddedToWindow.booleanValue()) { Log.d("SwipeTab", "refreshTabIcon"); LayoutParams layoutParamsMaxView = (LayoutParams) this.swipeTabTouchView.getLayoutParams(); layoutParamsMaxView.y = getTabVerticalOffset(); if (this.tabSizeState == eTabSizeState.FullSize) { layoutParamsMaxView.flags &= -17; } else { layoutParamsMaxView.flags |= 16; } layoutParamsMaxView.width = (int) this.context.getResources().getDimension(R.dimen.tab_maximized_width); if (getTabGravity() == 5) { layoutParamsMaxView.x = this.screenWidth - layoutParamsMaxView.width; } else { layoutParamsMaxView.x = 0; } getWindowManager().updateViewLayout(this.swipeTabTouchView, layoutParamsMaxView); LayoutParams layoutParamsMinView = (LayoutParams) this.swipeTabMinimizedTouchView.getLayoutParams(); layoutParamsMinView.y = getTabVerticalOffset(); if (this.tabSizeState == eTabSizeState.Minimized) { layoutParamsMinView.flags &= -17; } else { layoutParamsMinView.flags |= 16; } layoutParamsMinView.width = (int) this.context.getResources().getDimension(R.dimen.tab_minimized_touch_width); if (this.settings.getTabDisplayState().equals(TAB_DISPLAY_STATE_MESSAGE_ONLY)) { layoutParamsMinView.width = 0; } if (getTabGravity() == 5) { layoutParamsMinView.x = this.screenWidth - layoutParamsMinView.width; } else { layoutParamsMinView.x = 0; } getWindowManager().updateViewLayout(this.swipeTabMinimizedTouchView, layoutParamsMinView); float smallWidth = this.context.getResources().getDimension(R.dimen.tab_minimized_width); if (this.settings.getTabDisplayState().equals(TAB_DISPLAY_STATE_MESSAGE_ONLY)) { smallWidth = 0.0f; } float largeWidth = this.context.getResources().getDimension(R.dimen.tab_width); float renderWidth = this.context.getResources().getDimension(R.dimen.tab_maximized_width); float marginFromEdge = renderWidth - largeWidth; LayoutParams layoutParamsRenderView = (LayoutParams) this.swipeRenderView.getLayoutParams(); layoutParamsRenderView.y = getTabVerticalOffset(); this.swipeTabView.setScaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); this.swipeTabView.setScaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); if (getTabGravity() == 5) { layoutParamsRenderView.x = (int) ((this.screenWidth) - renderWidth); if (this.tabSizeState == eTabSizeState.FullSize) { this.swipeTabView.setX(marginFromEdge); } else { this.swipeTabView.setX((largeWidth - smallWidth) + marginFromEdge); } } else { layoutParamsRenderView.x = 0; if (this.tabSizeState == eTabSizeState.FullSize) { this.swipeTabView.setX(0.0f); } else { this.swipeTabView.setX((-largeWidth) + smallWidth); } } if (!this.relocationManager.isInProgress()) { if (this.inboxViewManager.isTabVisible().booleanValue()) { this.swipeTabView.animate().alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(0); } else { this.swipeTabView.animate().alpha(0.0f).setDuration(0); } } getWindowManager().updateViewLayout(this.swipeRenderView, layoutParamsRenderView); setupClickHandlers(); } }