static FolderIcon fromXml( int resId, Launcher launcher, ViewGroup group, FolderInfo folderInfo, IconCache iconCache) { FolderIcon icon = (FolderIcon) LayoutInflater.from(launcher).inflate(resId, group, false); icon.mFolderName = (BubbleTextView) icon.findViewById(R.id.folder_icon_name); icon.mFolderName.setText(folderInfo.title); icon.mPreviewBackground = (ImageView) icon.findViewById(R.id.preview_background); icon.setTag(folderInfo); icon.setOnClickListener(launcher); icon.mInfo = folderInfo; icon.mLauncher = launcher; icon.setContentDescription( String.format(launcher.getString(R.string.folder_name_format), folderInfo.title)); Folder folder = Folder.fromXml(launcher); folder.setDragController(launcher.getDragController()); folder.setFolderIcon(icon); folder.bind(folderInfo); icon.mFolder = folder; icon.mFolderRingAnimator = new FolderRingAnimator(launcher, icon); folderInfo.addListener(icon); return icon; }
public boolean onLongClick(View v) { // Return if workspace is locked if (mLauncher.getLockWorkspace()) return false; // Return if global dragging is not enabled if (!mLauncher.isDraggingEnabled()) return true; Object tag = v.getTag(); if (tag instanceof ShortcutInfo) { ShortcutInfo item = (ShortcutInfo) tag; if (!v.isInTouchMode()) { return false; } mLauncher.getWorkspace().beginDragShared(v, this); mCurrentDragInfo = item; mEmptyCell[0] = item.cellX; mEmptyCell[1] = item.cellY; mCurrentDragView = v; mContent.removeView(mCurrentDragView); mInfo.remove(mCurrentDragInfo); mDragInProgress = true; mItemAddedBackToSelfViaIcon = false; } return true; }
// attempts to move toward a location // depending on the playstyle and unit type, it will avoid towers or other unit types public Boolean moveTo(Direction direction) throws GameActionException { if (!this.robot.robotController.canMove(direction)) return false; RobotType type = this.robot.type; Boolean moveAroundHQ = !this.robot.canAttackInHQRange(this.robot.unitController.enemyTowers().length); Boolean moveAroundTowers = !this.robot.canAttackInTowerRange(); if (type == Missile.type()) moveAroundTowers = false; if (type == Launcher.type()) moveAroundTowers = true; Boolean moveAroundMilitary = false; if (UnitController.isUnitTypeMiner(type) && !this.robot.currentPlaystyle().shouldGoAllOut()) moveAroundMilitary = true; else if (type == Drone.type()) moveAroundMilitary = true; else if (type == Launcher.type()) moveAroundMilitary = true; if (this.canMoveSafely(direction, moveAroundHQ, moveAroundTowers, moveAroundMilitary)) { this.robot.robotController.move(direction); return true; } return false; }
/** * Gives us the choice between setPower(), or setSpeed(). It allowed us to test which one we * should use. */ public static void test() { /* * First, get the values from the user by displaying the instructions on * the screen. If the user agrees with the parameters set in the menu, * proceed to the launching. If not, display the menu again. */ while (!mainMenu.summarizeLauncher()) { if (mainMenu.display()) { launcherPower = mainMenu.askForPower(); } else { launcherSpeed = mainMenu.askForSpeed(); } launcherDelay = mainMenu.askForDelay(); } LCD.clearDisplay(); LCD.drawString(" Shooting ", 0, 0); if (launcherPower != -1) { launcher.chainFireAtPower(launcherPower, launcherDelay); } else { launcher.chainFireAtSpeed(launcherSpeed, launcherDelay); } LCD.clearDisplay(); }
@Override public void onClick(View v) { int id = v.getId(); if (id == R.id.cling_dismiss_migration_use_default) { // Disable the migration cling dismissMigrationCling(); } else if (id == R.id.cling_dismiss_migration_copy_apps) { // Copy the shortcuts from the old database LauncherModel model = mLauncher.getModel(); model.resetLoadedState(false, true); model.startLoader( false, PagedView.INVALID_RESTORE_PAGE, LauncherModel.LOADER_FLAG_CLEAR_WORKSPACE | LauncherModel.LOADER_FLAG_MIGRATE_SHORTCUTS); // Set the flag to skip the folder cling String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = mLauncher.getSharedPreferences(spKey, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean(Launcher.USER_HAS_MIGRATED, true); editor.apply(); // Disable the migration cling dismissMigrationCling(); } else if (id == R.id.cling_dismiss_longpress_info) { dismissLongPressCling(); } }
@SuppressWarnings("unused") private void deleteFromAllApps(ItemInfo itemInfo) { // TODO Auto-generated method stub if (itemInfo instanceof ApplicationInfoEx) { ApplicationInfoEx appInfo = (ApplicationInfoEx) itemInfo; if (appInfo.isSysApp) { Toast.makeText(mLauncher, R.string.delete_error_system_app, Toast.LENGTH_SHORT).show(); return; } } switch (itemInfo.itemType) { case Applications.APPS_TYPE_APP: case Applications.APPS_TYPE_FOLDERAPP: String pkgName = ((ApplicationInfoEx) itemInfo).intent.getComponent().getPackageName(); Uri uri = Uri.parse("package:" + pkgName); Intent intent = new Intent(Intent.ACTION_DELETE, uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mLauncher.startActivity(intent); mLauncher.switchScreenMode(false); break; case Applications.APPS_TYPE_FOLDER: mLauncher.deleteFolderInAllApps((ApplicationFolderInfo) itemInfo); break; } }
public boolean onLongClick(View v) { // 返回是否全局拖动被禁止,如果是,则不执行下面的动作 if (!mLauncher.isDraggingEnabled()) return true; Object tag = v.getTag(); if (tag instanceof ShortcutInfo) { ShortcutInfo item = (ShortcutInfo) tag; if (!v.isInTouchMode()) { return false; } mLauncher.dismissFolderCling(null); mLauncher.getWorkspace().onDragStartedWithItem(v); mLauncher.getWorkspace().beginDragShared(v, this); // 此处发起拖动 mIconDrawable = ((TextView) v).getCompoundDrawables()[1]; mCurrentDragInfo = item; mEmptyCell[0] = item.cellX; mEmptyCell[1] = item.cellY; mCurrentDragView = v; mContent.removeView(mCurrentDragView); mInfo.remove(mCurrentDragInfo); mDragInProgress = true; mItemAddedBackToSelfViaIcon = false; } return true; }
private boolean handleTouchDown(MotionEvent ev, boolean intercept) { Rect hitRect = new Rect(); int x = (int) ev.getX(); int y = (int) ev.getY(); for (AppWidgetResizeFrame child : mResizeFrames) { child.getHitRect(hitRect); if (hitRect.contains(x, y)) { if (child.beginResizeIfPointInRegion(x - child.getLeft(), y - child.getTop())) { mCurrentResizeFrame = child; mXDown = x; mYDown = y; requestDisallowInterceptTouchEvent(true); return true; } } } Folder currentFolder = mLauncher.getWorkspace().getOpenFolder(); if (currentFolder != null && !mLauncher.isFolderClingVisible() && intercept) { if (currentFolder.isEditingName()) { if (!isEventOverFolderTextRegion(currentFolder, ev)) { currentFolder.dismissEditingName(); return true; } } getDescendantRectRelativeToSelf(currentFolder, hitRect); if (!isEventOverFolder(currentFolder, ev)) { mLauncher.closeFolder(); return true; } } return false; }
/** Returns whether the clings are enabled or should be shown */ private boolean areClingsEnabled() { if (DISABLE_CLINGS) { return false; } // disable clings when running in a test harness if (ActivityManager.isRunningInTestHarness()) return false; // Disable clings for accessibility when explore by touch is enabled final AccessibilityManager a11yManager = (AccessibilityManager) mLauncher.getSystemService(Launcher.ACCESSIBILITY_SERVICE); if (a11yManager.isTouchExplorationEnabled()) { return false; } // Restricted secondary users (child mode) will potentially have very few apps // seeded when they start up for the first time. Clings won't work well with that boolean supportsLimitedUsers = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2; Account[] accounts = AccountManager.get(mLauncher).getAccounts(); if (supportsLimitedUsers && accounts.length == 0) { UserManager um = (UserManager) mLauncher.getSystemService(Context.USER_SERVICE); Bundle restrictions = um.getUserRestrictions(); if (restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) { return false; } } if (Settings.Secure.getInt(mLauncher.getContentResolver(), SKIP_FIRST_USE_HINTS, 0) == 1) { return false; } return true; }
public void testConfigure_Valid() throws Exception { launcher.configure(getConfigPath("valid-launch.conf")); Class mainClass = launcher.getMainClass(); assertNotNull(mainClass); assertEquals("a.A", mainClass.getName()); assertEquals("app", launcher.getMainRealm().getId()); }
/** * Shows the migration cling. * * <p>This flow is mutually exclusive with showFirstRunCling, and only runs if this Launcher * package was not preinstalled and there exists a db to migrate from. */ public void showMigrationCling() { mLauncher.hideWorkspaceSearchAndHotseat(); ViewGroup root = (ViewGroup) mLauncher.findViewById(R.id.launcher); View inflated = mInflater.inflate(R.layout.migration_cling, root); inflated.findViewById(R.id.cling_dismiss_migration_copy_apps).setOnClickListener(this); inflated.findViewById(R.id.cling_dismiss_migration_use_default).setOnClickListener(this); }
public void testLaunch_ClassNotFound() throws Exception { launcher.configure(getConfigPath("launch-noclass.conf")); try { launcher.launch(new String[] {}); fail("throw ClassNotFoundException"); } catch (ClassNotFoundException e) { // expected and correct } }
public void testLaunch_NoSuchMethod() throws Exception { launcher.configure(getConfigPath("launch-nomethod.conf")); try { launcher.launch(new String[] {}); fail("should have thrown NoSuchMethodException"); } catch (NoSuchMethodException e) { // expected and correct } }
/** 以图标为中心,中心对齐,比如缩放时要以中心对齐 */ private void centerAboutIcon() { DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); int height = getPaddingTop() + getPaddingBottom() + mContent.getDesiredHeight() + mFolderNameHeight; DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer); float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect); int centerX = (int) (mTempRect.left + mTempRect.width() * scale / 2); int centerY = (int) (mTempRect.top + mTempRect.height() * scale / 2); int centeredLeft = centerX - width / 2; int centeredTop = centerY - height / 2; int currentPage = mLauncher.getWorkspace().getCurrentPage(); // In case the workspace is scrolling, we need to use the final scroll // to compute // the folders bounds. // 如果workspace正在滚动,就强制滚动到最后以计算最终的位置 mLauncher.getWorkspace().setFinalScrollForPageChange(currentPage); // We first fetch the currently visible CellLayoutChildren // 首先获取可见CellLayoutChildren CellLayout currentLayout = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPage); ShortcutAndWidgetContainer boundingLayout = currentLayout.getShortcutsAndWidgets(); Rect bounds = new Rect(); parent.getDescendantRectRelativeToSelf(boundingLayout, bounds); // We reset the workspaces scroll // 强制重置workspace的滚动状态 mLauncher.getWorkspace().resetFinalScrollForPageChange(currentPage); // 重新调整folder的边界,如果有需要的话,比如实际内容比folder要更大或者更小 int left = Math.min(Math.max(bounds.left, centeredLeft), bounds.left + bounds.width() - width); int top = Math.min(Math.max(bounds.top, centeredTop), bounds.top + bounds.height() - height); // 如果实际内容比folder要更大或者更小,那么调整为实际大小 if (width >= bounds.width()) { left = bounds.left + (bounds.width() - width) / 2; } if (height >= bounds.height()) { top = bounds.top + (bounds.height() - height) / 2; } int folderPivotX = width / 2 + (centeredLeft - left); int folderPivotY = height / 2 + (centeredTop - top); // 设置Folder的锚点 setPivotX(folderPivotX); setPivotY(folderPivotY); mFolderIconPivotX = (int) (mFolderIcon.getMeasuredWidth() * (1.0f * folderPivotX / width)); mFolderIconPivotY = (int) (mFolderIcon.getMeasuredHeight() * (1.0f * folderPivotY / height)); lp.width = width; lp.height = height; lp.x = left; lp.y = top; }
private void centerAboutIcon() { DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer); int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); int height = getFolderHeight(); float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); int centerX = (int) (mTempRect.left + mTempRect.width() * scale / 2); int centerY = (int) (mTempRect.top + mTempRect.height() * scale / 2); int centeredLeft = centerX - width / 2; int centeredTop = centerY - height / 2; int currentPage = mLauncher.getWorkspace().getNextPage(); // In case the workspace is scrolling, we need to use the final scroll to compute // the folders bounds. mLauncher.getWorkspace().setFinalScrollForPageChange(currentPage); // We first fetch the currently visible CellLayoutChildren CellLayout currentLayout = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPage); ShortcutAndWidgetContainer boundingLayout = currentLayout.getShortcutsAndWidgets(); Rect bounds = new Rect(); parent.getDescendantRectRelativeToSelf(boundingLayout, bounds); // We reset the workspaces scroll mLauncher.getWorkspace().resetFinalScrollForPageChange(currentPage); // We need to bound the folder to the currently visible CellLayoutChildren int left = Math.min(Math.max(bounds.left, centeredLeft), bounds.left + bounds.width() - width); int top = Math.min(Math.max(bounds.top, centeredTop), bounds.top + bounds.height() - height); if (grid.isPhone() && (grid.availableWidthPx - width) < grid.iconSizePx) { // Center the folder if it is full (on phones only) left = (grid.availableWidthPx - width) / 2; } else if (width >= bounds.width()) { // If the folder doesn't fit within the bounds, center it about the desired bounds left = bounds.left + (bounds.width() - width) / 2; } if (height >= bounds.height()) { top = bounds.top + (bounds.height() - height) / 2; } int folderPivotX = width / 2 + (centeredLeft - left); int folderPivotY = height / 2 + (centeredTop - top); setPivotX(folderPivotX); setPivotY(folderPivotY); mFolderIconPivotX = (int) (mFolderIcon.getMeasuredWidth() * (1.0f * folderPivotX / width)); mFolderIconPivotY = (int) (mFolderIcon.getMeasuredHeight() * (1.0f * folderPivotY / height)); lp.width = width; lp.height = height; lp.x = left; lp.y = top; }
/** @param args */ public static void main(String[] args) { Launcher l = new Launcher( "C:\\work\\ws\\runtime-New_configuration\\Bxxx\\src", "B", "C:\\work\\ws\\runtime-New_configuration\\B\\src", "C:\\work\\ws\\runtime-New_configuration\\B\\gen-src", "C:\\work\\ws\\runtime-New_configuration\\B"); l.codegen(); }
public AddAdapter(Launcher launcher) { super(); mInflater = (LayoutInflater) launcher.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Create default actions Resources res = launcher.getResources(); mItems.add( new ListItem( res, R.string.group_wallpapers, R.mipmap.ic_launcher_wallpaper, ITEM_WALLPAPER)); }
private void centerAboutIcon() { DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); int height = getPaddingTop() + getPaddingBottom() + mContent.getDesiredHeight() + mFolderNameHeight; DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer); parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect); int centerX = mTempRect.centerX(); int centerY = mTempRect.centerY(); int centeredLeft = centerX - width / 2; int centeredTop = centerY - height / 2; // We first fetch the currently visible CellLayoutChildren CellLayout currentPage = mLauncher.getWorkspace().getCurrentDropLayout(); CellLayoutChildren boundingLayout = currentPage.getChildrenLayout(); Rect bounds = new Rect(); parent.getDescendantRectRelativeToSelf(boundingLayout, bounds); // We need to bound the folder to the currently visible CellLayoutChildren int left = Math.min(Math.max(bounds.left, centeredLeft), bounds.left + bounds.width() - width); int top = Math.min(Math.max(bounds.top, centeredTop), bounds.top + bounds.height() - height); // If the folder doesn't fit within the bounds, center it about the desired bounds if (width >= bounds.width()) { left = bounds.left + (bounds.width() - width) / 2; } if (height >= bounds.height()) { top = bounds.top + (bounds.height() - height) / 2; } int folderPivotX = width / 2 + (centeredLeft - left); int folderPivotY = height / 2 + (centeredTop - top); setPivotX(folderPivotX); setPivotY(folderPivotY); int folderIconPivotX = (int) (mFolderIcon.getMeasuredWidth() * (1.0f * folderPivotX / width)); int folderIconPivotY = (int) (mFolderIcon.getMeasuredHeight() * (1.0f * folderPivotY / height)); mFolderIcon.setPivotX(folderIconPivotX); mFolderIcon.setPivotY(folderIconPivotY); if (mMode == PARTIAL_GROW) { lp.width = width; lp.height = height; lp.x = left; lp.y = top; } else { mNewSize.set(left, top, left + width, top + height); } }
@Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); if (mInScrollArea && !LauncherApplication.isScreenLarge()) { Workspace workspace = mLauncher.getWorkspace(); int width = workspace.getWidth(); Rect childRect = new Rect(); getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect); int page = workspace.getNextPage(); final boolean isRtl = isLayoutDirectionRtl(); CellLayout leftPage = (CellLayout) workspace.getChildAt(isRtl ? page + 1 : page - 1); CellLayout rightPage = (CellLayout) workspace.getChildAt(isRtl ? page - 1 : page + 1); if (leftPage != null && leftPage.getIsDragOverlapping()) { mLeftHoverDrawable.setBounds( 0, childRect.top, mLeftHoverDrawable.getIntrinsicWidth(), childRect.bottom); mLeftHoverDrawable.draw(canvas); } else if (rightPage != null && rightPage.getIsDragOverlapping()) { mRightHoverDrawable.setBounds( width - mRightHoverDrawable.getIntrinsicWidth(), childRect.top, width, childRect.bottom); mRightHoverDrawable.draw(canvas); } } }
/** * Launch the game, and imitate what would happen in a typical game. * * @throws InterruptedException Since we're sleeping in this test. */ @Test public void storyTwoTest() throws InterruptedException { Game game = launcher.getGame(); Player player = game.getPlayers().get(0); // start cleanly. assertFalse(game.isInProgress()); game.start(); assertTrue(game.isInProgress()); assertEquals(0, player.getScore()); // scenario 2.1: player moves one step to the right and gets 10 points game.move(player, Direction.EAST); assertEquals(10, player.getScore()); // scenario 2.2: player moves back to the left (empty sqare) and the score doesn't change; game.move(player, Direction.WEST); assertEquals(10, player.getScore()); // scenario 2.4: try to move downwards and the movement fails game.move(player, Direction.SOUTH); assertEquals(0, Direction.SOUTH.getDeltaX()); game.stop(); assertFalse(game.isInProgress()); }
protected Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) { DragLayer dragLayer = mLauncher.getDragLayer(); // Find the rect to animate to (the view is center aligned) Rect to = new Rect(); dragLayer.getViewRectRelativeToSelf(this, to); final int width = drawableWidth; final int height = drawableHeight; final int left; final int right; if (Utilities.isRtl(getResources())) { right = to.right - getPaddingRight(); left = right - width; } else { left = to.left + getPaddingLeft(); right = left + width; } final int top = to.top + (getMeasuredHeight() - height) / 2; final int bottom = top + height; to.set(left, top, right, bottom); // Center the destination rect about the trash icon final int xOffset = (int) -(viewWidth - width) / 2; final int yOffset = (int) -(viewHeight - height) / 2; to.offset(xOffset, yOffset); return to; }
public void completeDragExit() { mLauncher.closeFolder(); mCurrentDragInfo = null; mCurrentDragView = null; mSuppressOnAdd = false; mRearrangeOnClose = true; }
private void onFinishedAnimation(int newScreen) { final boolean toLeft = newScreen > mCurrentScreen; final boolean toRight = newScreen < mCurrentScreen; final boolean changed = newScreen != mCurrentScreen; mCurrentScreen = newScreen; mIndicator.setLevel(mCurrentScreen, mItemCount); Launcher.setScreen(mCurrentScreen); mNextScreen = INVALID_SCREEN; fillToGalleryRight(); fillToGalleryLeft(); if (toLeft) { detachOffScreenChildren(true); } else if (toRight) { detachOffScreenChildren(false); } if (changed) { /* * setSelectedPositionInt( newScreen ); setNextSelectedPositionInt( newScreen ); checkSelectionChanged(); * * if( mPageChangeListener != null ) mPageChangeListener.onPageChanged( newScreen, mItemCount ); */ } clearChildrenCache(); }
public void onDrop(DragObject d) { ShortcutInfo item; if (d.dragInfo instanceof ApplicationInfo) { // 如果是来自“所有程序”界面,那么复制这个item item = ((ApplicationInfo) d.dragInfo).makeShortcut(); item.spanX = 1; item.spanY = 1; } else { item = (ShortcutInfo) d.dragInfo; } // Dragged from self onto self, currently this is the only path // possible, however // we keep this as a distinct code path. // 这个判断应该不可能出现别的情况,当前手动对象当然应该是这个d,这是过于谨慎的判断 if (item == mCurrentDragInfo) { ShortcutInfo si = (ShortcutInfo) mCurrentDragView.getTag(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mCurrentDragView.getLayoutParams(); si.cellX = lp.cellX = mEmptyCell[0]; si.cellX = lp.cellY = mEmptyCell[1]; mContent.addViewToCellLayout(mCurrentDragView, -1, (int) item.id, lp, true); if (d.dragView.hasDrawn()) { mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, mCurrentDragView); } else { d.deferDragViewCleanupPostAnimation = false; mCurrentDragView.setVisibility(VISIBLE); } mItemsInvalidated = true; // 拖进来后重新设置Folder的大小 setupContentDimensions(getItemCount()); mSuppressOnAdd = true; } mInfo.add(item); }
public void onDrop(DragObject d) { ShortcutInfo item; if (d.dragInfo instanceof ApplicationInfo) { // Came from all apps -- make a copy item = ((ApplicationInfo) d.dragInfo).makeShortcut(); item.spanX = 1; item.spanY = 1; } else { item = (ShortcutInfo) d.dragInfo; } // Dragged from self onto self, currently this is the only path possible, however // we keep this as a distinct code path. if (item == mCurrentDragInfo) { ShortcutInfo si = (ShortcutInfo) mCurrentDragView.getTag(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mCurrentDragView.getLayoutParams(); si.cellX = lp.cellX = mEmptyCell[0]; si.cellX = lp.cellY = mEmptyCell[1]; mContent.addViewToCellLayout(mCurrentDragView, -1, (int) item.id, lp, true); if (d.dragView.hasDrawn()) { mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, mCurrentDragView); } else { mCurrentDragView.setVisibility(VISIBLE); } mItemsInvalidated = true; setupContentDimensions(getItemCount()); mSuppressOnAdd = true; } mInfo.add(item); }
static Rect getWidgetSizeRanges(Launcher launcher, int spanX, int spanY, Rect rect) { if (rect == null) { rect = new Rect(); } Rect landMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.LANDSCAPE); Rect portMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.PORTRAIT); final float density = launcher.getResources().getDisplayMetrics().density; // Compute landscape size int cellWidth = landMetrics.left; int cellHeight = landMetrics.top; int widthGap = landMetrics.right; int heightGap = landMetrics.bottom; int landWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density); int landHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density); // Compute portrait size cellWidth = portMetrics.left; cellHeight = portMetrics.top; widthGap = portMetrics.right; heightGap = portMetrics.bottom; int portWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density); int portHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density); rect.set(portWidth, landHeight, landWidth, portHeight); return rect; }
/* * <p> * An required extension is missing, if an ExtensionInstallationProvider is * registered, delegate the installation of that particular extension to it. * </p> * * @param reqInfo Missing extension information * @param instInfo Older installed version information * * @return true if the installation is successful */ protected boolean installExtension(ExtensionInfo reqInfo, ExtensionInfo instInfo) throws ExtensionInstallationException { Vector currentProviders; synchronized (providers) { currentProviders = (Vector) providers.clone(); } for (Enumeration e = currentProviders.elements(); e.hasMoreElements(); ) { ExtensionInstallationProvider eip = (ExtensionInstallationProvider) e.nextElement(); if (eip != null) { // delegate the installation to the provider if (eip.installExtension(reqInfo, instInfo)) { debug(reqInfo.name + " installation successful"); Launcher.ExtClassLoader cl = (Launcher.ExtClassLoader) Launcher.getLauncher().getClassLoader().getParent(); addNewExtensionsToClassLoader(cl); return true; } } } // We have tried all of our providers, noone could install this // extension, we just return failure at this point debug(reqInfo.name + " installation failed"); return false; }
private void setFolderIcon(Object dragInfo) { if (mIsFolderIconMode) { return; } if (dragInfo instanceof UserFolderInfo) { // it is a foler icon return return; } final ShortcutInfo info = (ShortcutInfo) getTag(); if (info.container >= 0) { // i am in a folder return return; } final Bitmap mFolderIcon = info.getIcon(mLauncher.getIconCache()); mContent.setCompoundDrawablesWithIntrinsicBounds( null, new FastBitmapDrawable( Utilities.makeGridFolderIcons(new Bitmap[] {mFolderIcon}, getContext())), null, null); showUninstallBtn(false); mIsFolderIconMode = true; }
@Override public void onStop() { super.onStop(); final LauncherModel model = Launcher.getModel(); model.loadApplications(false, activeLauncher, false); }
LiveFolderAdapter(Launcher launcher, LiveFolderInfo info, Cursor cursor) { super(launcher, cursor, true); mIsList = info.displayMode == LiveFolders.DISPLAY_MODE_LIST; mInflater = LayoutInflater.from(launcher); mLauncher = launcher; mLauncher.startManagingCursor(getCursor()); }