Ejemplo n.º 1
0
  @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;
    }
  }
Ejemplo n.º 2
0
  @Override
  public void onDragStart(DragSource source, Object info, int dragAction) {
    final ItemInfo item = (ItemInfo) info;
    if (item != null) {
      mLauncher.switchScreenMode(true);
      mTrashMode = true;
      createAnimations();

      final int paddingTop =
          ((ViewGroup) mLauncher.getWindow().getDecorView()).getChildAt(0).getPaddingTop();
      final int[] location = mLocation;
      getLocationOnScreen(location);
      mRegion.set(
          location[0],
          location[1] - paddingTop,
          location[0] + mRight - mLeft,
          location[1] + mBottom - mTop - paddingTop);
      mDragController.setDeleteRegion(mRegion);
      mTransition.resetTransition();
      startAnimation(mInAnimation);
      // mHandle.startAnimation(mHandleOutAnimation);
      setVisibility(VISIBLE);
    }
  }