Moving the scrim to draglayer

> This causes the scrim to animate with the content on first launch
> Also removing the logic to disable scrim based on state. That
logic was only executing onResume which could lead to an invalid state

Bug: 30972956
Bug: 30576826

Change-Id: Ia8386b303ce260f69e3b3b93041226f409301a01
This commit is contained in:
Sunny Goyal
2016-08-19 10:50:12 -07:00
parent 8f90dcff37
commit 65ceb5aa55
7 changed files with 3 additions and 179 deletions
+1
View File
@@ -27,6 +27,7 @@
android:id="@+id/drag_layer" android:id="@+id/drag_layer"
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false" android:clipToPadding="false"
android:background="@drawable/workspace_bg"
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
+1
View File
@@ -29,6 +29,7 @@
android:clipChildren="false" android:clipChildren="false"
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:clipToPadding="false" android:clipToPadding="false"
android:background="@drawable/workspace_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
+1
View File
@@ -28,6 +28,7 @@
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false" android:clipToPadding="false"
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:background="@drawable/workspace_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
-130
View File
@@ -25,7 +25,6 @@ import android.animation.ValueAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.SearchManager; import android.app.SearchManager;
@@ -51,10 +50,8 @@ import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
@@ -81,7 +78,6 @@ import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.animation.OvershootInterpolator; import android.view.animation.OvershootInterpolator;
@@ -164,10 +160,6 @@ public class Launcher extends Activity
private static final int REQUEST_PERMISSION_CALL_PHONE = 13; private static final int REQUEST_PERMISSION_CALL_PHONE = 13;
private static final int WORKSPACE_BACKGROUND_GRADIENT = 0;
private static final int WORKSPACE_BACKGROUND_TRANSPARENT = 1;
private static final int WORKSPACE_BACKGROUND_BLACK = 2;
private static final float BOUNCE_ANIMATION_TENSION = 1.3f; private static final float BOUNCE_ANIMATION_TENSION = 1.3f;
/** /**
@@ -198,8 +190,6 @@ public class Launcher extends Activity
// Type: parcelable // Type: parcelable
private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id"; private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id";
static final String INTRO_SCREEN_DISMISSED = "launcher.intro_screen_dismissed";
static final String FIRST_RUN_ACTIVITY_DISPLAYED = "launcher.first_run_activity_displayed";
static final String APPS_VIEW_SHOWN = "launcher.apps_view_shown"; static final String APPS_VIEW_SHOWN = "launcher.apps_view_shown";
/** The different states that Launcher can be in. */ /** The different states that Launcher can be in. */
@@ -316,8 +306,6 @@ public class Launcher extends Activity
// match the sensor state. // match the sensor state.
private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500; private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;
@Thunk Drawable mWorkspaceBackgroundDrawable;
private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<Integer>(); private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<Integer>();
private static final boolean DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE = false; private static final boolean DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE = false;
@@ -504,12 +492,6 @@ public class Launcher extends Activity
if (mLauncherCallbacks != null) { if (mLauncherCallbacks != null) {
mLauncherCallbacks.onCreate(savedInstanceState); mLauncherCallbacks.onCreate(savedInstanceState);
} }
if (shouldShowIntroScreen()) {
showIntroScreen();
} else {
showFirstRunActivity();
}
} }
@Override @Override
@@ -1015,10 +997,6 @@ public class Launcher extends Activity
} }
mOnResumeState = State.NONE; mOnResumeState = State.NONE;
// Background was set to gradient in onPause(), restore to transparent if in all apps.
setWorkspaceBackground(mState == State.WORKSPACE ? WORKSPACE_BACKGROUND_GRADIENT
: WORKSPACE_BACKGROUND_TRANSPARENT);
mPaused = false; mPaused = false;
if (mRestoring || mOnResumeNeedsLoad) { if (mRestoring || mOnResumeNeedsLoad) {
setWorkspaceLoading(true); setWorkspaceLoading(true);
@@ -1367,10 +1345,8 @@ public class Launcher extends Activity
mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE); | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
mWorkspaceBackgroundDrawable = getResources().getDrawable(R.drawable.workspace_bg);
// Setup the drag layer // Setup the drag layer
mDragLayer.setup(this, mDragController, mAllAppsController); mDragLayer.setup(this, mDragController, mAllAppsController);
// Setup the hotseat // Setup the hotseat
@@ -3285,29 +3261,6 @@ public class Launcher extends Activity
return (mState == State.WIDGETS) || (mOnResumeState == State.WIDGETS); return (mState == State.WIDGETS) || (mOnResumeState == State.WIDGETS);
} }
private void setWorkspaceBackground(int background) {
switch (background) {
case WORKSPACE_BACKGROUND_TRANSPARENT:
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
break;
case WORKSPACE_BACKGROUND_BLACK:
getWindow().setBackgroundDrawable(null);
break;
default:
getWindow().setBackgroundDrawable(mWorkspaceBackgroundDrawable);
}
}
protected void changeWallpaperVisiblity(boolean visible) {
int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0;
int curflags = getWindow().getAttributes().flags
& WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
if (wpflags != curflags) {
getWindow().setFlags(wpflags, WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
}
setWorkspaceBackground(visible ? WORKSPACE_BACKGROUND_GRADIENT : WORKSPACE_BACKGROUND_BLACK);
}
@Override @Override
public void onTrimMemory(int level) { public void onTrimMemory(int level) {
super.onTrimMemory(level); super.onTrimMemory(level);
@@ -4455,51 +4408,6 @@ public class Launcher extends Activity
} }
} }
/**
* To be overridden by subclasses to indicate that there is an activity to launch
* before showing the standard launcher experience.
*/
protected boolean hasFirstRunActivity() {
if (mLauncherCallbacks != null) {
return mLauncherCallbacks.hasFirstRunActivity();
}
return false;
}
/**
* To be overridden by subclasses to launch any first run activity
*/
protected Intent getFirstRunActivity() {
if (mLauncherCallbacks != null) {
return mLauncherCallbacks.getFirstRunActivity();
}
return null;
}
private boolean shouldRunFirstRunActivity() {
return !ActivityManager.isRunningInTestHarness() &&
!mSharedPrefs.getBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, false);
}
public boolean showFirstRunActivity() {
if (shouldRunFirstRunActivity() &&
hasFirstRunActivity()) {
Intent firstRunIntent = getFirstRunActivity();
if (firstRunIntent != null) {
startActivity(firstRunIntent);
markFirstRunActivityShown();
return true;
}
}
return false;
}
private void markFirstRunActivityShown() {
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, true);
editor.apply();
}
private void markAppsViewShown() { private void markAppsViewShown() {
if (mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false)) { if (mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false)) {
return; return;
@@ -4523,44 +4431,6 @@ public class Launcher extends Activity
return true; return true;
} }
/**
* To be overridden by subclasses to indicate that there is an in-activity full-screen intro
* screen that must be displayed and dismissed.
*/
protected boolean hasDismissableIntroScreen() {
if (mLauncherCallbacks != null) {
return mLauncherCallbacks.hasDismissableIntroScreen();
}
return false;
}
/**
* Full screen intro screen to be shown and dismissed before the launcher can be used.
*/
protected View getIntroScreen() {
if (mLauncherCallbacks != null) {
return mLauncherCallbacks.getIntroScreen();
}
return null;
}
/**
* To be overriden by subclasses to indicate whether the in-activity intro screen has been
* dismissed. This method is ignored if #hasDismissableIntroScreen returns false.
*/
private boolean shouldShowIntroScreen() {
return hasDismissableIntroScreen() &&
!mSharedPrefs.getBoolean(INTRO_SCREEN_DISMISSED, false);
}
protected void showIntroScreen() {
View introScreen = getIntroScreen();
changeWallpaperVisiblity(false);
if (introScreen != null) {
mDragLayer.showOverlayView(introScreen);
}
}
// TODO: These method should be a part of LauncherSearchCallback // TODO: These method should be a part of LauncherSearchCallback
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ItemInfo createAppDragInfo(Intent appLaunchIntent) { public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
@@ -91,10 +91,6 @@ public interface LauncherCallbacks {
* Extensions points for adding / replacing some other aspects of the Launcher experience. * Extensions points for adding / replacing some other aspects of the Launcher experience.
*/ */
public UserEventDispatcher getUserEventDispatcher(); public UserEventDispatcher getUserEventDispatcher();
public Intent getFirstRunActivity();
public boolean hasFirstRunActivity();
public boolean hasDismissableIntroScreen();
public View getIntroScreen();
public boolean shouldMoveToDefaultScreenOnHomeIntent(); public boolean shouldMoveToDefaultScreenOnHomeIntent();
public boolean hasSettings(); public boolean hasSettings();
public AllAppsSearchBarController getAllAppsSearchBarController(); public AllAppsSearchBarController getAllAppsSearchBarController();
@@ -100,7 +100,6 @@ public class DragLayer extends InsettableFrameLayout {
private TouchCompleteListener mTouchCompleteListener; private TouchCompleteListener mTouchCompleteListener;
private View mOverlayView;
private int mTopViewIndex; private int mTopViewIndex;
private int mChildCountOnLastUpdate = -1; private int mChildCountOnLastUpdate = -1;
@@ -172,20 +171,6 @@ public class DragLayer extends InsettableFrameLayout {
? null : new PinchToOverviewListener(mLauncher); ? null : new PinchToOverviewListener(mLauncher);
} }
public void showOverlayView(View overlayView) {
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
mOverlayView = overlayView;
addView(overlayView, lp);
// ensure that the overlay view stays on top. we can't use drawing order for this
// because in API level 16 touch dispatch doesn't respect drawing order.
mOverlayView.bringToFront();
}
public void dismissOverlayView() {
removeView(mOverlayView);
}
public boolean isEventOverPageIndicator(MotionEvent ev) { public boolean isEventOverPageIndicator(MotionEvent ev) {
getDescendantRectRelativeToSelf(mLauncher.getWorkspace().getPageIndicator(), mHitRect); getDescendantRectRelativeToSelf(mLauncher.getWorkspace().getPageIndicator(), mHitRect);
return mHitRect.contains((int) ev.getX(), (int) ev.getY()); return mHitRect.contains((int) ev.getX(), (int) ev.getY());
@@ -903,11 +888,6 @@ public class DragLayer extends InsettableFrameLayout {
@Override @Override
public void onChildViewAdded(View parent, View child) { public void onChildViewAdded(View parent, View child) {
super.onChildViewAdded(parent, child); super.onChildViewAdded(parent, child);
if (mOverlayView != null) {
// ensure that the overlay view stays on top. we can't use drawing order for this
// because in API level 16 touch dispatch doesn't respect drawing order.
mOverlayView.bringToFront();
}
updateChildIndices(); updateChildIndices();
} }
@@ -919,11 +899,6 @@ public class DragLayer extends InsettableFrameLayout {
@Override @Override
public void bringChildToFront(View child) { public void bringChildToFront(View child) {
super.bringChildToFront(child); super.bringChildToFront(child);
if (child != mOverlayView && mOverlayView != null) {
// ensure that the overlay view stays on top. we can't use drawing order for this
// because in API level 16 touch dispatch doesn't respect drawing order.
mOverlayView.bringToFront();
}
updateChildIndices(); updateChildIndices();
} }
@@ -197,26 +197,6 @@ public class LauncherExtension extends Launcher {
return new Bundle(); return new Bundle();
} }
@Override
public Intent getFirstRunActivity() {
return null;
}
@Override
public boolean hasFirstRunActivity() {
return false;
}
@Override
public boolean hasDismissableIntroScreen() {
return false;
}
@Override
public View getIntroScreen() {
return null;
}
@Override @Override
public boolean shouldMoveToDefaultScreenOnHomeIntent() { public boolean shouldMoveToDefaultScreenOnHomeIntent() {
return true; return true;