Cleaning up home / back behaviour in overview mode (issue 10965421)
Change-Id: Ib85e8b3ca369582122298ca0a66109c8a363880c
This commit is contained in:
@@ -270,6 +270,7 @@ public class Launcher extends Activity
|
|||||||
private IconCache mIconCache;
|
private IconCache mIconCache;
|
||||||
private boolean mUserPresent = true;
|
private boolean mUserPresent = true;
|
||||||
private boolean mVisible = false;
|
private boolean mVisible = false;
|
||||||
|
private boolean mHasFocus = false;
|
||||||
private boolean mAttached = false;
|
private boolean mAttached = false;
|
||||||
private static final boolean DISABLE_CLINGS = false;
|
private static final boolean DISABLE_CLINGS = false;
|
||||||
private static final boolean DISABLE_CUSTOM_CLINGS = true;
|
private static final boolean DISABLE_CUSTOM_CLINGS = true;
|
||||||
@@ -1009,25 +1010,11 @@ public class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can't hide the IME if it was forced open. So don't bother
|
// We can't hide the IME if it was forced open. So don't bother
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
mHasFocus = hasFocus;
|
||||||
if (hasFocus) {
|
|
||||||
final InputMethodManager inputManager = (InputMethodManager)
|
|
||||||
getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
WindowManager.LayoutParams lp = getWindow().getAttributes();
|
|
||||||
inputManager.hideSoftInputFromWindow(lp.token, 0, new android.os.ResultReceiver(new
|
|
||||||
android.os.Handler()) {
|
|
||||||
protected void onReceiveResult(int resultCode, Bundle resultData) {
|
|
||||||
Log.d(TAG, "ResultReceiver got resultCode=" + resultCode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Log.d(TAG, "called hideSoftInputFromWindow from onWindowFocusChanged");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
private boolean acceptFilter() {
|
private boolean acceptFilter() {
|
||||||
final InputMethodManager inputManager = (InputMethodManager)
|
final InputMethodManager inputManager = (InputMethodManager)
|
||||||
@@ -1485,7 +1472,7 @@ public class Launcher extends Activity
|
|||||||
// Reset AllApps to its initial state only if we are not in the middle of
|
// Reset AllApps to its initial state only if we are not in the middle of
|
||||||
// processing a multi-step drop
|
// processing a multi-step drop
|
||||||
if (mAppsCustomizeTabHost != null && mPendingAddInfo.container == ItemInfo.NO_ID) {
|
if (mAppsCustomizeTabHost != null && mPendingAddInfo.container == ItemInfo.NO_ID) {
|
||||||
showWorkspaceAndExitOverviewMode(false);
|
showWorkspace(false);
|
||||||
}
|
}
|
||||||
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
|
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
|
||||||
mUserPresent = true;
|
mUserPresent = true;
|
||||||
@@ -1669,9 +1656,9 @@ public class Launcher extends Activity
|
|||||||
// also will cancel mWaitingForResult.
|
// also will cancel mWaitingForResult.
|
||||||
closeSystemDialogs();
|
closeSystemDialogs();
|
||||||
|
|
||||||
final boolean alreadyOnHome =
|
final boolean alreadyOnHome = mHasFocus && ((intent.getFlags() &
|
||||||
((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
|
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
|
||||||
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
|
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
|
||||||
|
|
||||||
if (mWorkspace == null) {
|
if (mWorkspace == null) {
|
||||||
// Can be cases where mWorkspace is null, this prevents a NPE
|
// Can be cases where mWorkspace is null, this prevents a NPE
|
||||||
@@ -1691,7 +1678,7 @@ public class Launcher extends Activity
|
|||||||
// If we are already on home, then just animate back to the workspace,
|
// If we are already on home, then just animate back to the workspace,
|
||||||
// otherwise, just wait until onResume to set the state back to Workspace
|
// otherwise, just wait until onResume to set the state back to Workspace
|
||||||
if (alreadyOnHome) {
|
if (alreadyOnHome) {
|
||||||
showWorkspaceAndExitOverviewMode(true);
|
showWorkspace(true);
|
||||||
} else {
|
} else {
|
||||||
mOnResumeState = State.WORKSPACE;
|
mOnResumeState = State.WORKSPACE;
|
||||||
}
|
}
|
||||||
@@ -1708,21 +1695,12 @@ public class Launcher extends Activity
|
|||||||
mAppsCustomizeTabHost.reset();
|
mAppsCustomizeTabHost.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG_RESUME_TIME) {
|
if (DEBUG_RESUME_TIME) {
|
||||||
Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
|
Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showWorkspaceAndExitOverviewMode(boolean animate) {
|
|
||||||
showWorkspace(animate);
|
|
||||||
if (mWorkspace.isInOverviewMode()) {
|
|
||||||
mWorkspace.exitOverviewMode(animate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected void showWorkspaceAndExitOverviewMode() {
|
|
||||||
showWorkspaceAndExitOverviewMode(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRestoreInstanceState(Bundle state) {
|
public void onRestoreInstanceState(Bundle state) {
|
||||||
super.onRestoreInstanceState(state);
|
super.onRestoreInstanceState(state);
|
||||||
@@ -2079,7 +2057,6 @@ public class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void startWallpaper() {
|
protected void startWallpaper() {
|
||||||
showWorkspace(true);
|
|
||||||
final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);
|
final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);
|
||||||
pickWallpaper.setComponent(getWallpaperPickerComponent());
|
pickWallpaper.setComponent(getWallpaperPickerComponent());
|
||||||
startActivityForResult(pickWallpaper, REQUEST_PICK_WALLPAPER);
|
startActivityForResult(pickWallpaper, REQUEST_PICK_WALLPAPER);
|
||||||
@@ -2125,7 +2102,12 @@ public class Launcher extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (isAllAppsVisible()) {
|
if (isAllAppsVisible()) {
|
||||||
showWorkspace(true);
|
if (mAppsCustomizeContent.getContentType() ==
|
||||||
|
AppsCustomizePagedView.ContentType.Applications) {
|
||||||
|
showWorkspace(true);
|
||||||
|
} else {
|
||||||
|
showOverviewMode(true);
|
||||||
|
}
|
||||||
} else if (mWorkspace.isInOverviewMode()) {
|
} else if (mWorkspace.isInOverviewMode()) {
|
||||||
mWorkspace.exitOverviewMode(true);
|
mWorkspace.exitOverviewMode(true);
|
||||||
} else if (mWorkspace.getOpenFolder() != null) {
|
} else if (mWorkspace.getOpenFolder() != null) {
|
||||||
@@ -2943,7 +2925,7 @@ public class Launcher extends Activity
|
|||||||
* This is the opposite of showAppsCustomizeHelper.
|
* This is the opposite of showAppsCustomizeHelper.
|
||||||
* @param animated If true, the transition will be animated.
|
* @param animated If true, the transition will be animated.
|
||||||
*/
|
*/
|
||||||
private void hideAppsCustomizeHelper(State toState, final boolean animated,
|
private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated,
|
||||||
final boolean springLoaded, final Runnable onCompleteRunnable) {
|
final boolean springLoaded, final Runnable onCompleteRunnable) {
|
||||||
|
|
||||||
if (mStateAnimation != null) {
|
if (mStateAnimation != null) {
|
||||||
@@ -2961,13 +2943,14 @@ public class Launcher extends Activity
|
|||||||
final View fromView = mAppsCustomizeTabHost;
|
final View fromView = mAppsCustomizeTabHost;
|
||||||
final View toView = mWorkspace;
|
final View toView = mWorkspace;
|
||||||
Animator workspaceAnim = null;
|
Animator workspaceAnim = null;
|
||||||
if (toState == State.WORKSPACE) {
|
if (toState == Workspace.State.NORMAL) {
|
||||||
int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
|
int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
|
||||||
workspaceAnim = mWorkspace.getChangeStateAnimation(
|
workspaceAnim = mWorkspace.getChangeStateAnimation(
|
||||||
Workspace.State.NORMAL, animated, stagger, -1);
|
toState, animated, stagger, -1);
|
||||||
} else if (toState == State.APPS_CUSTOMIZE_SPRING_LOADED) {
|
} else if (toState == Workspace.State.SPRING_LOADED ||
|
||||||
|
toState == Workspace.State.OVERVIEW) {
|
||||||
workspaceAnim = mWorkspace.getChangeStateAnimation(
|
workspaceAnim = mWorkspace.getChangeStateAnimation(
|
||||||
Workspace.State.SPRING_LOADED, animated);
|
toState, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPivotsForZoom(fromView, scaleFactor);
|
setPivotsForZoom(fromView, scaleFactor);
|
||||||
@@ -3039,15 +3022,22 @@ public class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void showWorkspace(boolean animated) {
|
protected void showWorkspace(boolean animated) {
|
||||||
showWorkspace(animated, null);
|
showWorkspace(animated, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showWorkspace() {
|
||||||
|
showWorkspace(true);
|
||||||
|
}
|
||||||
|
|
||||||
void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
|
void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
|
||||||
|
if (mWorkspace.isInOverviewMode()) {
|
||||||
|
mWorkspace.exitOverviewMode(animated);
|
||||||
|
}
|
||||||
if (mState != State.WORKSPACE) {
|
if (mState != State.WORKSPACE) {
|
||||||
boolean wasInSpringLoadedMode = (mState != State.WORKSPACE);
|
boolean wasInSpringLoadedMode = (mState != State.WORKSPACE);
|
||||||
mWorkspace.setVisibility(View.VISIBLE);
|
mWorkspace.setVisibility(View.VISIBLE);
|
||||||
hideAppsCustomizeHelper(State.WORKSPACE, animated, false, onCompleteRunnable);
|
hideAppsCustomizeHelper(Workspace.State.NORMAL, animated, false, onCompleteRunnable);
|
||||||
|
|
||||||
// Show the search bar (only animate if we were showing the drop target bar in spring
|
// Show the search bar (only animate if we were showing the drop target bar in spring
|
||||||
// loaded mode)
|
// loaded mode)
|
||||||
@@ -3075,6 +3065,13 @@ public class Launcher extends Activity
|
|||||||
onWorkspaceShown(animated);
|
onWorkspaceShown(animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showOverviewMode(boolean animated) {
|
||||||
|
mWorkspace.setVisibility(View.VISIBLE);
|
||||||
|
hideAppsCustomizeHelper(Workspace.State.OVERVIEW, animated, false, null);
|
||||||
|
mState = State.WORKSPACE;
|
||||||
|
onWorkspaceShown(animated);
|
||||||
|
}
|
||||||
|
|
||||||
public void onWorkspaceShown(boolean animated) {
|
public void onWorkspaceShown(boolean animated) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3100,7 +3097,7 @@ public class Launcher extends Activity
|
|||||||
|
|
||||||
void enterSpringLoadedDragMode() {
|
void enterSpringLoadedDragMode() {
|
||||||
if (isAllAppsVisible()) {
|
if (isAllAppsVisible()) {
|
||||||
hideAppsCustomizeHelper(State.APPS_CUSTOMIZE_SPRING_LOADED, true, true, null);
|
hideAppsCustomizeHelper(Workspace.State.SPRING_LOADED, true, true, null);
|
||||||
mState = State.APPS_CUSTOMIZE_SPRING_LOADED;
|
mState = State.APPS_CUSTOMIZE_SPRING_LOADED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2074,7 +2074,7 @@ public class Workspace extends SmoothPagedView
|
|||||||
R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, true);
|
R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, true);
|
||||||
} else {
|
} else {
|
||||||
// Fade the background gradient away
|
// Fade the background gradient away
|
||||||
animateBackgroundGradient(0f, true);
|
animateBackgroundGradient(0f, animated);
|
||||||
}
|
}
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user