use of android.view.WindowManager.LayoutParams in project storymaker by StoryMaker.
the class OverlayCameraActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
overlayGroup = getIntent().getIntExtra("group", 0);
overlayIdx = getIntent().getIntExtra("overlay", 0);
mStoryMode = getIntent().getIntExtra("mode", -1);
mOverlayView = new ImageView(this);
ActivitySwipeDetector swipe = new ActivitySwipeDetector(this);
mOverlayView.setOnTouchListener(swipe);
mOverlayView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
closeOverlay();
}
});
mSurfaceView = new SurfaceView(this);
addContentView(mSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
addContentView(mOverlayView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
use of android.view.WindowManager.LayoutParams in project cornerstone by Onskreen.
the class WindowManagerService method handleAppTransitionReadyLocked.
/**
* Extracted from {@link #performLayoutAndPlaceSurfacesLockedInner} to reduce size of method.
*
* @return bitmap indicating if another pass through layout must be made.
*/
public int handleAppTransitionReadyLocked() {
int changes = 0;
int i;
int NN = mOpeningApps.size();
boolean goodToGo = true;
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "Checking " + NN + " opening apps (frozen=" + mDisplayFrozen + " timeout=" + mAppTransitionTimeout + ")...");
if (!mDisplayFrozen && !mAppTransitionTimeout) {
// we'll unfreeze the display when everyone is ready.
for (i = 0; i < NN && goodToGo; i++) {
AppWindowToken wtoken = mOpeningApps.get(i);
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "Check opening app=" + wtoken + ": allDrawn=" + wtoken.allDrawn + " startingDisplayed=" + wtoken.startingDisplayed + " startingMoved=" + wtoken.startingMoved);
if (!wtoken.allDrawn && !wtoken.startingDisplayed && !wtoken.startingMoved) {
goodToGo = false;
}
}
}
if (goodToGo) {
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "**** GOOD TO GO");
int transit = mNextAppTransition;
if (mSkipAppTransitionAnimation) {
transit = WindowManagerPolicy.TRANSIT_UNSET;
}
mNextAppTransition = WindowManagerPolicy.TRANSIT_UNSET;
mAppTransitionReady = false;
mAppTransitionRunning = true;
mAppTransitionTimeout = false;
mStartingIconInTransition = false;
mSkipAppTransitionAnimation = false;
mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
rebuildAppWindowListLocked();
// if wallpaper is animating in or out set oldWallpaper to null else to wallpaper
WindowState oldWallpaper = mWallpaperTarget != null && mWallpaperTarget.mWinAnimator.isAnimating() && !mWallpaperTarget.mWinAnimator.isDummyAnimation() ? null : mWallpaperTarget;
adjustWallpaperWindowsLocked();
mInnerFields.mWallpaperMayChange = false;
// The top-most window will supply the layout params,
// and we will determine it below.
LayoutParams animLp = null;
int bestAnimLayer = -1;
boolean fullscreenAnim = false;
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "New wallpaper target=" + mWallpaperTarget + ", oldWallpaper=" + oldWallpaper + ", lower target=" + mLowerWallpaperTarget + ", upper target=" + mUpperWallpaperTarget);
int foundWallpapers = 0;
// Do a first pass through the tokens for two
// things:
// (1) Determine if both the closing and opening
// app token sets are wallpaper targets, in which
// case special animations are needed
// (since the wallpaper needs to stay static
// behind them).
// (2) Find the layout params of the top-most
// application window in the tokens, which is
// what will control the animation theme.
final int NC = mClosingApps.size();
NN = NC + mOpeningApps.size();
for (i = 0; i < NN; i++) {
AppWindowToken wtoken;
int mode;
if (i < NC) {
wtoken = mClosingApps.get(i);
mode = 1;
} else {
wtoken = mOpeningApps.get(i - NC);
mode = 2;
}
if (mLowerWallpaperTarget != null) {
if (mLowerWallpaperTarget.mAppToken == wtoken || mUpperWallpaperTarget.mAppToken == wtoken) {
foundWallpapers |= mode;
}
}
if (wtoken.appFullscreen) {
WindowState ws = wtoken.findMainWindow();
if (ws != null) {
animLp = ws.mAttrs;
bestAnimLayer = ws.mLayer;
fullscreenAnim = true;
}
} else if (!fullscreenAnim) {
WindowState ws = wtoken.findMainWindow();
if (ws != null) {
if (ws.mLayer > bestAnimLayer) {
animLp = ws.mAttrs;
bestAnimLayer = ws.mLayer;
}
}
}
}
if (foundWallpapers == 3) {
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "Wallpaper animation!");
switch(transit) {
case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
case WindowManagerPolicy.TRANSIT_TASK_OPEN:
case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT:
transit = WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN;
break;
case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
case WindowManagerPolicy.TRANSIT_TASK_CLOSE:
case WindowManagerPolicy.TRANSIT_TASK_TO_BACK:
transit = WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_CLOSE;
break;
}
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "New transit: " + transit);
} else if ((oldWallpaper != null) && !mOpeningApps.contains(oldWallpaper.mAppToken)) {
// We are transitioning from an activity with
// a wallpaper to one without.
transit = WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE;
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "New transit away from wallpaper: " + transit);
} else if (mWallpaperTarget != null) {
// We are transitioning from an activity without
// a wallpaper to now showing the wallpaper
transit = WindowManagerPolicy.TRANSIT_WALLPAPER_OPEN;
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "New transit into wallpaper: " + transit);
}
// the lock screen.
if (!mPolicy.allowAppAnimationsLw()) {
animLp = null;
}
AppWindowToken topOpeningApp = null;
int topOpeningLayer = 0;
NN = mOpeningApps.size();
for (i = 0; i < NN; i++) {
AppWindowToken wtoken = mOpeningApps.get(i);
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "Now opening app" + wtoken);
wtoken.mAppAnimator.clearThumbnail();
wtoken.reportedVisible = false;
wtoken.inPendingTransaction = false;
wtoken.mAppAnimator.animation = null;
setTokenVisibilityLocked(wtoken, animLp, true, transit, false);
wtoken.updateReportedVisibilityLocked();
wtoken.waitingToShow = false;
mAnimator.mAnimating |= wtoken.mAppAnimator.showAllWindowsLocked();
if (animLp != null) {
int layer = -1;
for (int j = 0; j < wtoken.windows.size(); j++) {
WindowState win = wtoken.windows.get(j);
if (win.mWinAnimator.mAnimLayer > layer) {
layer = win.mWinAnimator.mAnimLayer;
}
}
if (topOpeningApp == null || layer > topOpeningLayer) {
topOpeningApp = wtoken;
topOpeningLayer = layer;
}
}
}
NN = mClosingApps.size();
for (i = 0; i < NN; i++) {
AppWindowToken wtoken = mClosingApps.get(i);
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "Now closing app" + wtoken);
wtoken.mAppAnimator.clearThumbnail();
wtoken.inPendingTransaction = false;
wtoken.mAppAnimator.animation = null;
setTokenVisibilityLocked(wtoken, animLp, false, transit, false);
wtoken.updateReportedVisibilityLocked();
wtoken.waitingToHide = false;
// Force the allDrawn flag, because we want to start
// this guy's animations regardless of whether it's
// gotten drawn.
wtoken.allDrawn = true;
}
if (mNextAppTransitionThumbnail != null && topOpeningApp != null && topOpeningApp.mAppAnimator.animation != null) {
// This thumbnail animation is very special, we need to have
// an extra surface with the thumbnail included with the animation.
Rect dirty = new Rect(0, 0, mNextAppTransitionThumbnail.getWidth(), mNextAppTransitionThumbnail.getHeight());
try {
Surface surface = new Surface(mFxSession, Process.myPid(), "thumbnail anim", 0, dirty.width(), dirty.height(), PixelFormat.TRANSLUCENT, Surface.HIDDEN);
topOpeningApp.mAppAnimator.thumbnail = surface;
if (SHOW_TRANSACTIONS)
Slog.i(TAG, " THUMBNAIL " + surface + ": CREATE");
Surface drawSurface = new Surface();
drawSurface.copyFrom(surface);
Canvas c = drawSurface.lockCanvas(dirty);
c.drawBitmap(mNextAppTransitionThumbnail, 0, 0, null);
drawSurface.unlockCanvasAndPost(c);
drawSurface.release();
topOpeningApp.mAppAnimator.thumbnailLayer = topOpeningLayer;
Animation anim = createThumbnailAnimationLocked(transit, true, true, mNextAppTransitionDelayed);
topOpeningApp.mAppAnimator.thumbnailAnimation = anim;
anim.restrictDuration(MAX_ANIMATION_DURATION);
anim.scaleCurrentDuration(mTransitionAnimationScale);
topOpeningApp.mAppAnimator.thumbnailX = mNextAppTransitionStartX;
topOpeningApp.mAppAnimator.thumbnailY = mNextAppTransitionStartY;
} catch (Surface.OutOfResourcesException e) {
Slog.e(TAG, "Can't allocate thumbnail surface w=" + dirty.width() + " h=" + dirty.height(), e);
topOpeningApp.mAppAnimator.clearThumbnail();
}
}
mNextAppTransitionType = ActivityOptions.ANIM_NONE;
mNextAppTransitionPackage = null;
mNextAppTransitionThumbnail = null;
scheduleAnimationCallback(mNextAppTransitionCallback);
mNextAppTransitionCallback = null;
mOpeningApps.clear();
mClosingApps.clear();
// This has changed the visibility of windows, so perform
// a new layout to get them all up-to-date.
changes |= PhoneWindowManager.FINISH_LAYOUT_REDO_LAYOUT | WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
mLayoutNeeded = true;
if (!moveInputMethodWindowsIfNeededLocked(true)) {
assignLayersLocked();
}
updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, false);
mFocusMayChange = false;
}
return changes;
}
use of android.view.WindowManager.LayoutParams in project superCleanMaster by joyoyao.
the class ShortCutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_short_cut);
rect = getIntent().getSourceBounds();
if (rect == null) {
finish();
return;
}
if (rect != null) {
Class<?> c = null;
Object obj = null;
Field field = null;
int x = 0, statusBarHeight = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
statusBarHeight = getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
layoutAnim.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
int height = layoutAnim.getMeasuredHeight();
int width = layoutAnim.getMeasuredWidth();
RelativeLayout.LayoutParams layoutparams = (RelativeLayout.LayoutParams) layoutAnim.getLayoutParams();
layoutparams.leftMargin = rect.left + rect.width() / 2 - width / 2;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
setTranslucentStatus(true);
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.transparent);
layoutparams.topMargin = rect.top + rect.height() / 2 - height / 2;
} else {
layoutparams.topMargin = rect.top + rect.height() / 2 - height / 2 - statusBarHeight;
}
mRelativeLayout.updateViewLayout(layoutAnim, layoutparams);
}
cleanLightImg.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_anim));
bindService(new Intent(mContext, CoreService.class), mServiceConnection, Context.BIND_AUTO_CREATE);
}
use of android.view.WindowManager.LayoutParams in project platform_frameworks_base by android.
the class WindowSurfacePlacer method handleAppTransitionReadyLocked.
/**
* @param windows List of windows on default display.
* @return bitmap indicating if another pass through layout must be made.
*/
private int handleAppTransitionReadyLocked(WindowList windows) {
int appsCount = mService.mOpeningApps.size();
if (!transitionGoodToGo(appsCount)) {
return 0;
}
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "AppTransitionReady");
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "**** GOOD TO GO");
int transit = mService.mAppTransition.getAppTransition();
if (mService.mSkipAppTransitionAnimation) {
transit = AppTransition.TRANSIT_UNSET;
}
mService.mSkipAppTransitionAnimation = false;
mService.mNoAnimationNotifyOnTransitionFinished.clear();
mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
mService.rebuildAppWindowListLocked();
mWallpaperMayChange = false;
// The top-most window will supply the layout params,
// and we will determine it below.
LayoutParams animLp = null;
int bestAnimLayer = -1;
boolean fullscreenAnim = false;
boolean voiceInteraction = false;
int i;
for (i = 0; i < appsCount; i++) {
final AppWindowToken wtoken = mService.mOpeningApps.valueAt(i);
// Clearing the mAnimatingExit flag before entering animation. It's set to
// true if app window is removed, or window relayout to invisible.
// This also affects window visibility. We need to clear it *before*
// maybeUpdateTransitToWallpaper() as the transition selection depends on
// wallpaper target visibility.
wtoken.clearAnimatingFlags();
}
// Adjust wallpaper before we pull the lower/upper target, since pending changes
// (like the clearAnimatingFlags() above) might affect wallpaper target result.
final DisplayContent displayContent = mService.getDefaultDisplayContentLocked();
if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 && mWallpaperControllerLocked.adjustWallpaperWindows()) {
mService.mLayersController.assignLayersLocked(windows);
displayContent.layoutNeeded = true;
}
final WindowState lowerWallpaperTarget = mWallpaperControllerLocked.getLowerWallpaperTarget();
final WindowState upperWallpaperTarget = mWallpaperControllerLocked.getUpperWallpaperTarget();
boolean openingAppHasWallpaper = false;
boolean closingAppHasWallpaper = false;
final AppWindowToken lowerWallpaperAppToken;
final AppWindowToken upperWallpaperAppToken;
if (lowerWallpaperTarget == null) {
lowerWallpaperAppToken = upperWallpaperAppToken = null;
} else {
lowerWallpaperAppToken = lowerWallpaperTarget.mAppToken;
upperWallpaperAppToken = upperWallpaperTarget.mAppToken;
}
// Do a first pass through the tokens for two
// things:
// (1) Determine if both the closing and opening
// app token sets are wallpaper targets, in which
// case special animations are needed
// (since the wallpaper needs to stay static
// behind them).
// (2) Find the layout params of the top-most
// application window in the tokens, which is
// what will control the animation theme.
final int closingAppsCount = mService.mClosingApps.size();
appsCount = closingAppsCount + mService.mOpeningApps.size();
for (i = 0; i < appsCount; i++) {
final AppWindowToken wtoken;
if (i < closingAppsCount) {
wtoken = mService.mClosingApps.valueAt(i);
if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
closingAppHasWallpaper = true;
}
} else {
wtoken = mService.mOpeningApps.valueAt(i - closingAppsCount);
if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
openingAppHasWallpaper = true;
}
}
voiceInteraction |= wtoken.voiceInteraction;
if (wtoken.appFullscreen) {
WindowState ws = wtoken.findMainWindow();
if (ws != null) {
animLp = ws.mAttrs;
bestAnimLayer = ws.mLayer;
fullscreenAnim = true;
}
} else if (!fullscreenAnim) {
WindowState ws = wtoken.findMainWindow();
if (ws != null) {
if (ws.mLayer > bestAnimLayer) {
animLp = ws.mAttrs;
bestAnimLayer = ws.mLayer;
}
}
}
}
transit = maybeUpdateTransitToWallpaper(transit, openingAppHasWallpaper, closingAppHasWallpaper, lowerWallpaperTarget, upperWallpaperTarget);
// the lock screen.
if (!mService.mPolicy.allowAppAnimationsLw()) {
if (DEBUG_APP_TRANSITIONS)
Slog.v(TAG, "Animations disallowed by keyguard or dream.");
animLp = null;
}
processApplicationsAnimatingInPlace(transit);
mTmpLayerAndToken.token = null;
handleClosingApps(transit, animLp, voiceInteraction, mTmpLayerAndToken);
final AppWindowToken topClosingApp = mTmpLayerAndToken.token;
final int topClosingLayer = mTmpLayerAndToken.layer;
final AppWindowToken topOpeningApp = handleOpeningApps(transit, animLp, voiceInteraction, topClosingLayer);
mService.mAppTransition.setLastAppTransition(transit, topOpeningApp, topClosingApp);
final AppWindowAnimator openingAppAnimator = (topOpeningApp == null) ? null : topOpeningApp.mAppAnimator;
final AppWindowAnimator closingAppAnimator = (topClosingApp == null) ? null : topClosingApp.mAppAnimator;
mService.mAppTransition.goodToGo(openingAppAnimator, closingAppAnimator, mService.mOpeningApps, mService.mClosingApps);
mService.mAppTransition.postAnimationCallback();
mService.mAppTransition.clear();
mService.mOpeningApps.clear();
mService.mClosingApps.clear();
// This has changed the visibility of windows, so perform
// a new layout to get them all up-to-date.
displayContent.layoutNeeded = true;
// TODO(multidisplay): IMEs are only supported on the default display.
if (windows == mService.getDefaultWindowListLocked() && !mService.moveInputMethodWindowsIfNeededLocked(true)) {
mService.mLayersController.assignLayersLocked(windows);
}
mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, true);
mService.mFocusMayChange = false;
mService.notifyActivityDrawnForKeyguard();
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG;
}
use of android.view.WindowManager.LayoutParams in project platform_frameworks_base by android.
the class WindowSurfacePlacer method handleNotObscuredLocked.
/**
* @param w WindowState this method is applied to.
* @param dispInfo info of the display that the window's obscuring state is checked against.
*/
private void handleNotObscuredLocked(final WindowState w, final DisplayInfo dispInfo) {
final LayoutParams attrs = w.mAttrs;
final int attrFlags = attrs.flags;
final boolean canBeSeen = w.isDisplayedLw();
final int privateflags = attrs.privateFlags;
if (canBeSeen && w.isObscuringFullscreen(dispInfo)) {
// performance reasons).
if (!mObscured) {
mObsuringWindow = w;
}
mObscured = true;
}
if (w.mHasSurface && canBeSeen) {
if ((attrFlags & FLAG_KEEP_SCREEN_ON) != 0) {
mHoldScreen = w.mSession;
mHoldScreenWindow = w;
} else if (DEBUG_KEEP_SCREEN_ON && w == mService.mLastWakeLockHoldingWindow) {
Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked: " + w + " was holding " + "screen wakelock but no longer has FLAG_KEEP_SCREEN_ON!!! called by" + Debug.getCallers(10));
}
if (!mSyswin && w.mAttrs.screenBrightness >= 0 && mScreenBrightness < 0) {
mScreenBrightness = w.mAttrs.screenBrightness;
}
if (!mSyswin && w.mAttrs.buttonBrightness >= 0 && mButtonBrightness < 0) {
mButtonBrightness = w.mAttrs.buttonBrightness;
}
if (!mSyswin && w.mAttrs.userActivityTimeout >= 0 && mUserActivityTimeout < 0) {
mUserActivityTimeout = w.mAttrs.userActivityTimeout;
}
final int type = attrs.type;
if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
mSyswin = true;
}
// This function assumes that the contents of the default display are
// processed first before secondary displays.
final DisplayContent displayContent = w.getDisplayContent();
if (displayContent != null && displayContent.isDefaultDisplay) {
// keyguard dialogs to be shown.
if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
mObscureApplicationContentOnSecondaryDisplays = true;
}
mDisplayHasContent = true;
} else if (displayContent != null && (!mObscureApplicationContentOnSecondaryDisplays || (mObscured && type == TYPE_KEYGUARD_DIALOG))) {
// Allow full screen keyguard presentation dialogs to be seen.
mDisplayHasContent = true;
}
if (mPreferredRefreshRate == 0 && w.mAttrs.preferredRefreshRate != 0) {
mPreferredRefreshRate = w.mAttrs.preferredRefreshRate;
}
if (mPreferredModeId == 0 && w.mAttrs.preferredDisplayModeId != 0) {
mPreferredModeId = w.mAttrs.preferredDisplayModeId;
}
if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) {
mSustainedPerformanceModeCurrent = true;
}
}
}
Aggregations