(4)Launcher客制化之 workspace长按事件弹出Widgets界面

来源:互联网 发布:php ajax返回html标签 编辑:程序博客网 时间:2024/04/28 01:59

转帖请注明:来自http://blog.csdn.net/xufeifandj

同样修改lancher.java里面文件

OnLongclick事件,因为workspace注册了Launcher,OnLongClick事情。Launcher实现了长按的事件。

因此在 注释掉,进入设置界面代码,替换为,跳转到 Widgets里面即可。直接看代码。

 public boolean onLongClick(View v) {
        if (!isDraggingEnabled()) return false;
        if (isWorkspaceLocked()) return false;
        if (mState != State.WORKSPACE) return false;
        if (v instanceof Workspace) {
        //修改长按显示widgets
            showAllApps(true, AppsCustomizePagedView.ContentType.Widgets, true);
            return true;

//            if (!mWorkspace.isInOverviewMode()) {
//                if (mWorkspace.enterOverviewMode()) {
//                    mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
//                            HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); 
//                  
//                    return true;
//                } else {
//                    return false;
//                }
//            }
        }


        if (!(v instanceof CellLayout)) {
            v = (View) v.getParent().getParent();
        }


        resetAddInfo();
        CellLayout.CellInfo longClickCellInfo = (CellLayout.CellInfo) v.getTag();
        // This happens when long clicking an item with the dpad/trackball
        if (longClickCellInfo == null) {
            return true;
        }


        // The hotseat touch handling does not go through Workspace, and we always allow long press
        // on hotseat items.
        final View itemUnderLongClick = longClickCellInfo.cell;
        boolean allowLongPress = isHotseatLayout(v) || mWorkspace.allowLongPress();
        if (allowLongPress && !mDragController.isDragging()) {
            if (itemUnderLongClick == null) {
                // User long pressed on empty space
//                mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
//                        HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
//                // Disabling reordering until we sort out some issues.
//                if (mWorkspace.isInOverviewMode()) {
//                    mWorkspace.startReordering(v);
//                } else {
//                    mWorkspace.enterOverviewMode();
//                }
            //修改长按显示widgets
                showAllApps(true, AppsCustomizePagedView.ContentType.Widgets, true);


            } else {
                if (!(itemUnderLongClick instanceof Folder)) {
                    // User long pressed on an item
                    mWorkspace.startDrag(longClickCellInfo);
                }
            }
        }
        return true;
    }

0 0
原创粉丝点击