mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Binding AllApps synchronously. (Bug 6855061)
- Also ensuring that we restore to the settling page index if it is in motion Change-Id: I9c6760383113f7614f6cb962ab6562b0e7eb7138
This commit is contained in:
@@ -528,18 +528,22 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
public void onPackagesUpdated() {
|
||||
// TODO: this isn't ideal, but we actually need to delay here. This call is triggered
|
||||
// by a broadcast receiver, and in order for it to work correctly, we need to know that
|
||||
// the AppWidgetService has already received and processed the same broadcast. Since there
|
||||
// is no guarantee about ordering of broadcast receipt, we just delay here. This is a
|
||||
// workaround until we add a callback from AppWidgetService to AppWidgetHost when widget
|
||||
// packages are added, updated or removed.
|
||||
postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
updatePackages();
|
||||
}
|
||||
}, 1500);
|
||||
public void onPackagesUpdated(boolean immediate) {
|
||||
if (immediate) {
|
||||
updatePackages();
|
||||
} else {
|
||||
// TODO: this isn't ideal, but we actually need to delay here. This call is triggered
|
||||
// by a broadcast receiver, and in order for it to work correctly, we need to know that
|
||||
// the AppWidgetService has already received and processed the same broadcast. Since there
|
||||
// is no guarantee about ordering of broadcast receipt, we just delay here. This is a
|
||||
// workaround until we add a callback from AppWidgetService to AppWidgetHost when widget
|
||||
// packages are added, updated or removed.
|
||||
postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
updatePackages();
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePackages() {
|
||||
@@ -578,7 +582,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// When we have exited all apps or are in transition, disregard clicks
|
||||
if (!mLauncher.isAllAppsCustomizeOpen() ||
|
||||
if (!mLauncher.isAllAppsVisible() ||
|
||||
mLauncher.getWorkspace().isSwitchingState()) return;
|
||||
|
||||
if (v instanceof PagedViewIcon) {
|
||||
|
||||
@@ -81,7 +81,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
||||
* reflects the new content (but doesn't do the animation and logic associated with changing
|
||||
* tabs manually).
|
||||
*/
|
||||
private void setContentTypeImmediate(AppsCustomizePagedView.ContentType type) {
|
||||
void setContentTypeImmediate(AppsCustomizePagedView.ContentType type) {
|
||||
onTabChangedStart();
|
||||
onTabChangedEnd(type);
|
||||
}
|
||||
@@ -158,10 +158,11 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
||||
if (contentWidth > 0 && mTabs.getLayoutParams().width != contentWidth) {
|
||||
// Set the width and show the tab bar
|
||||
mTabs.getLayoutParams().width = contentWidth;
|
||||
post(mRelayoutAndMakeVisible);
|
||||
mRelayoutAndMakeVisible.run();
|
||||
}
|
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
|
||||
@@ -371,7 +371,7 @@ public final class Launcher extends Activity
|
||||
|
||||
// Update customization drawer _after_ restoring the states
|
||||
if (mAppsCustomizeContent != null) {
|
||||
mAppsCustomizeContent.onPackagesUpdated();
|
||||
mAppsCustomizeContent.onPackagesUpdated(true);
|
||||
}
|
||||
|
||||
if (PROFILE_STARTUP) {
|
||||
@@ -890,10 +890,8 @@ public final class Launcher extends Activity
|
||||
if (mAppsCustomizeTabHost != null) {
|
||||
String curTab = savedState.getString("apps_customize_currentTab");
|
||||
if (curTab != null) {
|
||||
// We set this directly so that there is no delay before the tab is set
|
||||
mAppsCustomizeContent.setContentType(
|
||||
mAppsCustomizeTabHost.setContentTypeImmediate(
|
||||
mAppsCustomizeTabHost.getContentTypeForTabTag(curTab));
|
||||
mAppsCustomizeTabHost.setCurrentTabByTag(curTab);
|
||||
mAppsCustomizeContent.loadAssociatedPages(
|
||||
mAppsCustomizeContent.getCurrentPage());
|
||||
}
|
||||
@@ -1424,7 +1422,7 @@ public final class Launcher extends Activity
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getCurrentPage());
|
||||
outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getNextPage());
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putInt(RUNTIME_STATE, mState.ordinal());
|
||||
@@ -1808,7 +1806,7 @@ public final class Launcher extends Activity
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mState == State.APPS_CUSTOMIZE) {
|
||||
if (isAllAppsVisible()) {
|
||||
showWorkspace(true);
|
||||
} else if (mWorkspace.getOpenFolder() != null) {
|
||||
Folder openFolder = mWorkspace.getOpenFolder();
|
||||
@@ -1881,7 +1879,7 @@ public final class Launcher extends Activity
|
||||
handleFolderClick(fi);
|
||||
}
|
||||
} else if (v == mAllAppsButton) {
|
||||
if (mState == State.APPS_CUSTOMIZE) {
|
||||
if (isAllAppsVisible()) {
|
||||
showWorkspace(true);
|
||||
} else {
|
||||
onClickAllAppsButton(v);
|
||||
@@ -2285,7 +2283,7 @@ public final class Launcher extends Activity
|
||||
|
||||
// Now a part of LauncherModel.Callbacks. Used to reorder loading steps.
|
||||
public boolean isAllAppsVisible() {
|
||||
return (mState == State.APPS_CUSTOMIZE);
|
||||
return (mState == State.APPS_CUSTOMIZE) || (mOnResumeState == State.APPS_CUSTOMIZE);
|
||||
}
|
||||
|
||||
public boolean isAllAppsButtonRank(int rank) {
|
||||
@@ -2312,7 +2310,7 @@ public final class Launcher extends Activity
|
||||
|
||||
void disableWallpaperIfInAllApps() {
|
||||
// Only disable it if we are in all apps
|
||||
if (mState == State.APPS_CUSTOMIZE) {
|
||||
if (isAllAppsVisible()) {
|
||||
if (mAppsCustomizeTabHost != null &&
|
||||
!mAppsCustomizeTabHost.isTransitioning()) {
|
||||
updateWallpaperVisibility(false);
|
||||
@@ -2753,7 +2751,7 @@ public final class Launcher extends Activity
|
||||
}
|
||||
|
||||
void enterSpringLoadedDragMode() {
|
||||
if (mState == State.APPS_CUSTOMIZE) {
|
||||
if (isAllAppsVisible()) {
|
||||
hideAppsCustomizeHelper(State.APPS_CUSTOMIZE_SPRING_LOADED, true, true, null);
|
||||
hideDockDivider();
|
||||
mState = State.APPS_CUSTOMIZE_SPRING_LOADED;
|
||||
@@ -2827,10 +2825,6 @@ public final class Launcher extends Activity
|
||||
// TODO
|
||||
}
|
||||
|
||||
public boolean isAllAppsCustomizeOpen() {
|
||||
return mState == State.APPS_CUSTOMIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the hotseat area.
|
||||
*/
|
||||
@@ -3460,23 +3454,30 @@ public final class Launcher extends Activity
|
||||
* Implementation of the method from LauncherModel.Callbacks.
|
||||
*/
|
||||
public void bindAllApplications(final ArrayList<ApplicationInfo> apps) {
|
||||
Runnable setAllAppsRunnable = new Runnable() {
|
||||
public void run() {
|
||||
if (mAppsCustomizeContent != null) {
|
||||
mAppsCustomizeContent.setApps(apps);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Remove the progress bar entirely; we could also make it GONE
|
||||
// but better to remove it since we know it's not going to be used
|
||||
View progressBar = mAppsCustomizeTabHost.
|
||||
findViewById(R.id.apps_customize_progress_bar);
|
||||
if (progressBar != null) {
|
||||
((ViewGroup)progressBar.getParent()).removeView(progressBar);
|
||||
|
||||
// We just post the call to setApps so the user sees the progress bar
|
||||
// disappear-- otherwise, it just looks like the progress bar froze
|
||||
// which doesn't look great
|
||||
mAppsCustomizeTabHost.post(setAllAppsRunnable);
|
||||
} else {
|
||||
// If we did not initialize the spinner in onCreate, then we can directly set the
|
||||
// list of applications without waiting for any progress bars views to be hidden.
|
||||
setAllAppsRunnable.run();
|
||||
}
|
||||
// We just post the call to setApps so the user sees the progress bar
|
||||
// disappear-- otherwise, it just looks like the progress bar froze
|
||||
// which doesn't look great
|
||||
mAppsCustomizeTabHost.post(new Runnable() {
|
||||
public void run() {
|
||||
if (mAppsCustomizeContent != null) {
|
||||
mAppsCustomizeContent.setApps(apps);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3531,7 +3532,7 @@ public final class Launcher extends Activity
|
||||
*/
|
||||
public void bindPackagesUpdated() {
|
||||
if (mAppsCustomizeContent != null) {
|
||||
mAppsCustomizeContent.onPackagesUpdated();
|
||||
mAppsCustomizeContent.onPackagesUpdated(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1686,7 +1686,7 @@ public class LauncherModel extends BroadcastReceiver {
|
||||
@SuppressWarnings("unchecked")
|
||||
final ArrayList<ApplicationInfo> list
|
||||
= (ArrayList<ApplicationInfo>) mAllAppsList.data.clone();
|
||||
mHandler.post(new Runnable() {
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
final long t = SystemClock.uptimeMillis();
|
||||
final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
|
||||
@@ -1698,7 +1698,13 @@ public class LauncherModel extends BroadcastReceiver {
|
||||
+ (SystemClock.uptimeMillis()-t) + "ms");
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid());
|
||||
if (oldCallbacks.isAllAppsVisible() && isRunningOnMainThread) {
|
||||
r.run();
|
||||
} else {
|
||||
mHandler.post(r);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAllAppsByBatch() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -44,6 +45,7 @@ public class PagedViewWidget extends LinearLayout {
|
||||
boolean mShortPressTriggered = false;
|
||||
static PagedViewWidget sShortpressTarget = null;
|
||||
boolean mIsAppWidget;
|
||||
private final Rect mOriginalImagePadding = new Rect();
|
||||
|
||||
public PagedViewWidget(Context context) {
|
||||
this(context, null);
|
||||
@@ -63,6 +65,17 @@ public class PagedViewWidget extends LinearLayout {
|
||||
setClipToPadding(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
|
||||
mOriginalImagePadding.left = image.getPaddingLeft();
|
||||
mOriginalImagePadding.top = image.getPaddingTop();
|
||||
mOriginalImagePadding.right = image.getPaddingRight();
|
||||
mOriginalImagePadding.bottom = image.getPaddingBottom();
|
||||
}
|
||||
|
||||
public static void setDeletePreviewsWhenDetachedFromWindow(boolean value) {
|
||||
sDeletePreviewsWhenDetachedFromWindow = value;
|
||||
}
|
||||
@@ -79,7 +92,7 @@ public class PagedViewWidget extends LinearLayout {
|
||||
preview.getBitmap().recycle();
|
||||
}
|
||||
image.setImageDrawable(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +130,8 @@ public class PagedViewWidget extends LinearLayout {
|
||||
public int[] getPreviewSize() {
|
||||
final ImageView i = (ImageView) findViewById(R.id.widget_preview);
|
||||
int[] maxSize = new int[2];
|
||||
maxSize[0] = i.getWidth() - i.getPaddingLeft() - i.getPaddingRight();
|
||||
maxSize[1] = i.getHeight() - i.getPaddingTop();
|
||||
maxSize[0] = i.getWidth() - mOriginalImagePadding.left - mOriginalImagePadding.right;
|
||||
maxSize[1] = i.getHeight() - mOriginalImagePadding.top;
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
@@ -132,10 +145,10 @@ public class PagedViewWidget extends LinearLayout {
|
||||
// center horizontally
|
||||
int[] imageSize = getPreviewSize();
|
||||
int centerAmount = (imageSize[0] - preview.getIntrinsicWidth()) / 2;
|
||||
image.setPadding(image.getPaddingLeft() + centerAmount,
|
||||
image.getPaddingTop(),
|
||||
image.getPaddingRight(),
|
||||
image.getPaddingBottom());
|
||||
image.setPadding(mOriginalImagePadding.left + centerAmount,
|
||||
mOriginalImagePadding.top,
|
||||
mOriginalImagePadding.right,
|
||||
mOriginalImagePadding.bottom);
|
||||
}
|
||||
image.setAlpha(1f);
|
||||
image.mAllowRequestLayout = true;
|
||||
|
||||
@@ -105,7 +105,7 @@ public abstract class PagedViewWithDraggableItems extends PagedView
|
||||
// Return early if we are still animating the pages
|
||||
if (mNextPage != INVALID_PAGE) return false;
|
||||
// When we have exited all apps or are in transition, disregard long clicks
|
||||
if (!mLauncher.isAllAppsCustomizeOpen() ||
|
||||
if (!mLauncher.isAllAppsVisible() ||
|
||||
mLauncher.getWorkspace().isSwitchingState()) return false;
|
||||
// Return if global dragging is not enabled
|
||||
if (!mLauncher.isDraggingEnabled()) return false;
|
||||
|
||||
Reference in New Issue
Block a user