diff options
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 148 |
1 files changed, 113 insertions, 35 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8de95e9ff..d2ba9d28e 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -70,6 +70,8 @@ import android.os.Message; import android.os.StrictMode; import android.os.SystemClock; import android.speech.RecognizerIntent; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.text.Selection; import android.text.SpannableStringBuilder; import android.text.TextUtils; @@ -297,6 +299,9 @@ public class Launcher extends Activity OverviewSettingsPanel mOverviewSettingsPanel; private View mAllAppsButton; + protected RecyclerView mAppDrawer; + private AppDrawerListAdapter mAppDrawerAdapter; + private AppDrawerScrubber mScrubber; protected SearchDropTargetBar mSearchDropTargetBar; private AppsCustomizeTabHost mAppsCustomizeTabHost; @@ -596,6 +601,26 @@ public class Launcher extends Activity protected void populateCustomContentContainer() { } + private void initializeScrubber() { + if (mScrubber == null) { + mScrubber = new AppDrawerScrubber(this); + int scrubberPadding = getResources() + .getDimensionPixelSize(R.dimen.scrubber_bottom_padding); + mScrubber.setPadding(0, 0, 0, scrubberPadding); + mScrubber.setGravity(Gravity.BOTTOM); + mScrubber.setSource(mAppDrawer); + } + } + + public void updateScrubber() { + mScrubber.updateSections(); + } + + public void initializeAdapter() { + mAppDrawerAdapter = new AppDrawerListAdapter(this); + mAppDrawerAdapter.notifyDataSetChanged(); + } + /** * Invoked by subclasses to signal a change to the {@link #addCustomContentToLeft} value to * ensure the custom content page is added or removed if necessary. @@ -1644,6 +1669,9 @@ public class Launcher extends Activity mAppsCustomizeTabHost.findViewById(R.id.apps_customize_pane_content); mAppsCustomizeContent.setup(this, dragController); + // Setup AppDrawer + setupAppDrawer(); + // Setup the drag controller (drop targets have to be added in reverse order in priority) dragController.setDragScoller(mWorkspace); dragController.setScrollView(mDragLayer); @@ -1669,6 +1697,22 @@ public class Launcher extends Activity } } + private void setupAppDrawer() { + if (mAppDrawer == null) { + FrameLayout view = (FrameLayout) findViewById(R.id.app_drawer_container); + mAppDrawer = new RecyclerView(this); + mAppDrawer.setLayoutManager(new LinearLayoutManager(this)); + if (mAppDrawerAdapter == null) { + initializeAdapter(); + } + mAppDrawer.setHasFixedSize(true); + mAppDrawer.setAdapter(mAppDrawerAdapter); + view.addView(mAppDrawer); + initializeScrubber(); + view.addView(mScrubber); + } + } + /** * Sets the all apps button. This method is called from {@link Hotseat}. */ @@ -3205,7 +3249,7 @@ public class Launcher extends Activity return false; } - boolean startActivitySafely(View v, Intent intent, Object tag) { + public boolean startActivitySafely(View v, Intent intent, Object tag) { boolean success = false; if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) { Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show(); @@ -3594,7 +3638,13 @@ public class Launcher extends Activity final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mWorkspace; - final AppsCustomizeTabHost toView = mAppsCustomizeTabHost; + final View toView; + + if (contentType == AppsCustomizePagedView.ContentType.Applications) { + toView = (FrameLayout) findViewById(R.id.app_drawer_container); + } else { + toView = mAppsCustomizeTabHost; + } final ArrayList<View> layerViews = new ArrayList<View>(); @@ -3616,20 +3666,18 @@ public class Launcher extends Activity final AppsCustomizePagedView content = (AppsCustomizePagedView) toView.findViewById(R.id.apps_customize_pane_content); - final View page = content.getPageAt(content.getCurrentPage()); + final View page = content != null ? content.getPageAt(content.getCurrentPage()) : null; final View revealView = toView.findViewById(R.id.fake_page); final float initialPanelAlpha = 1f; final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets; - if (isWidgetTray) { - revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); - } else { - revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); - } + revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); // Hide the real page background, and swap in the fake one - content.setPageBackgroundsVisible(false); + if (content != null) { + content.setPageBackgroundsVisible(false); + } revealView.setVisibility(View.VISIBLE); // We need to hide this view as the animation start will be posted. revealView.setAlpha(0); @@ -3695,11 +3743,13 @@ public class Launcher extends Activity } View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator); - pageIndicators.setAlpha(0.01f); - ObjectAnimator indicatorsAlpha = - ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f); - indicatorsAlpha.setDuration(revealDuration); - mStateAnimation.play(indicatorsAlpha); + if (pageIndicators != null) { + pageIndicators.setAlpha(0.01f); + ObjectAnimator indicatorsAlpha = + ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f); + indicatorsAlpha.setDuration(revealDuration); + mStateAnimation.play(indicatorsAlpha); + } if (material) { final View allApps = getAllAppsButton(); @@ -3737,7 +3787,9 @@ public class Launcher extends Activity if (page != null) { page.setLayerType(View.LAYER_TYPE_NONE, null); } - content.setPageBackgroundsVisible(true); + if (content != null) { + content.setPageBackgroundsVisible(true); + } // Hide the search bar if (mSearchDropTargetBar != null) { @@ -3830,7 +3882,14 @@ public class Launcher extends Activity final float scaleFactor = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); - final View fromView = mAppsCustomizeTabHost; + final View fromView; + + if (mAppsCustomizeContent.getContentType() != AppsCustomizePagedView.ContentType.Widgets) { + fromView = (FrameLayout) findViewById(R.id.app_drawer_container); + } else { + fromView = mAppsCustomizeTabHost; + } + final View toView = mWorkspace; Animator workspaceAnim = null; final ArrayList<View> layerViews = new ArrayList<View>(); @@ -3856,10 +3915,10 @@ public class Launcher extends Activity final AppsCustomizePagedView content = (AppsCustomizePagedView) fromView.findViewById(R.id.apps_customize_pane_content); - final View page = content.getPageAt(content.getNextPage()); + final View page = content != null ? content.getPageAt(content.getNextPage()) : null; // We need to hide side pages of the Apps / Widget tray to avoid some ugly edge cases - int count = content.getChildCount(); + int count = content != null ? content.getChildCount() : 0; for (int i = 0; i < count; i++) { View child = content.getChildAt(i); if (child != page) { @@ -3872,15 +3931,12 @@ public class Launcher extends Activity // don't perform all these no-op animations. In particularly, this was causing // the all-apps button to pop in and out. if (fromView.getVisibility() == View.VISIBLE) { - AppsCustomizePagedView.ContentType contentType = content.getContentType(); + AppsCustomizePagedView.ContentType contentType = + mAppsCustomizeContent.getContentType(); final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets; - if (isWidgetTray) { - revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); - } else { - revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); - } + revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); int width = revealView.getMeasuredWidth(); int height = revealView.getMeasuredHeight(); @@ -3888,7 +3944,9 @@ public class Launcher extends Activity // Hide the real page background, and swap in the fake one revealView.setVisibility(View.VISIBLE); - content.setPageBackgroundsVisible(false); + if (content != null) { + content.setPageBackgroundsVisible(false); + } final View allAppsButton = getAllAppsButton(); revealView.setTranslationY(0); @@ -3957,12 +4015,14 @@ public class Launcher extends Activity } View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator); - pageIndicators.setAlpha(1f); - ObjectAnimator indicatorsAlpha = - LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 0f); - indicatorsAlpha.setDuration(revealDuration); - indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f)); - mStateAnimation.play(indicatorsAlpha); + if (pageIndicators != null) { + pageIndicators.setAlpha(1f); + ObjectAnimator indicatorsAlpha = + LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 0f); + indicatorsAlpha.setDuration(revealDuration); + indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f)); + mStateAnimation.play(indicatorsAlpha); + } width = revealView.getMeasuredWidth(); @@ -4011,9 +4071,11 @@ public class Launcher extends Activity if (page != null) { page.setLayerType(View.LAYER_TYPE_NONE, null); } - content.setPageBackgroundsVisible(true); + if (content != null) { + content.setPageBackgroundsVisible(true); + } // Unhide side pages - int count = content.getChildCount(); + int count = content != null ? content.getChildCount() : 0; for (int i = 0; i < count; i++) { View child = content.getChildAt(i); child.setVisibility(View.VISIBLE); @@ -4025,7 +4087,9 @@ public class Launcher extends Activity page.setTranslationY(0); page.setAlpha(1); } - content.setCurrentPage(content.getNextPage()); + if (content != null) { + content.setCurrentPage(content.getNextPage()); + } mAppsCustomizeContent.updateCurrentPageScroll(); } @@ -4676,6 +4740,7 @@ public class Launcher extends Activity if (!LauncherAppState.isDisableAllApps() && addedApps != null && mAppsCustomizeContent != null) { mAppsCustomizeContent.addApps(addedApps); + mAppDrawerAdapter.addApps(addedApps); } } @@ -5059,6 +5124,9 @@ public class Launcher extends Activity LauncherModel.getSortedWidgetsAndShortcuts(this)); } } else { + if (mAppDrawerAdapter != null) { + mAppDrawerAdapter.setApps(apps); + } if (mAppsCustomizeContent != null) { mAppsCustomizeContent.setApps(apps); mAppsCustomizeContent.onPackagesUpdated( @@ -5089,6 +5157,7 @@ public class Launcher extends Activity if (!LauncherAppState.isDisableAllApps() && mAppsCustomizeContent != null) { mAppsCustomizeContent.updateApps(apps); + mAppDrawerAdapter.updateApps(apps); } } @@ -5168,6 +5237,7 @@ public class Launcher extends Activity if (!LauncherAppState.isDisableAllApps() && mAppsCustomizeContent != null) { mAppsCustomizeContent.removeApps(appInfos); + mAppDrawerAdapter.removeApps(appInfos); } } @@ -5425,16 +5495,24 @@ public class Launcher extends Activity if (mWorkspace != null) mWorkspace.setAlpha(1f); if (mHotseat != null) mHotseat.setAlpha(1f); if (mPageIndicators != null) mPageIndicators.setAlpha(1f); - if (mSearchDropTargetBar != null) mSearchDropTargetBar.showSearchBar(false); + showSearch(); } void hideWorkspaceSearchAndHotseat() { if (mWorkspace != null) mWorkspace.setAlpha(0f); if (mHotseat != null) mHotseat.setAlpha(0f); if (mPageIndicators != null) mPageIndicators.setAlpha(0f); + hideSearch(); + } + + void hideSearch() { if (mSearchDropTargetBar != null) mSearchDropTargetBar.hideSearchBar(false); } + void showSearch() { + if (mSearchDropTargetBar != null) mSearchDropTargetBar.showSearchBar(false); + } + public ItemInfo createAppDragInfo(Intent appLaunchIntent) { // Called from search suggestion, not supported in other profiles. final UserHandleCompat myUser = UserHandleCompat.myUserHandle(); |