/** 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;
  }
示例#2
0
  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));
  }
示例#3
0
  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_shortcuts, R.drawable.ic_launcher_shortcut, ITEM_SHORTCUT));

    mItems.add(
        new ListItem(
            res, R.string.group_widgets, R.drawable.ic_launcher_appwidget, ITEM_APPWIDGET));

    mItems.add(
        new ListItem(
            res, R.string.group_live_folders, R.drawable.ic_launcher_add_folder, ITEM_LIVE_FOLDER));

    mItems.add(
        new ListItem(
            res, R.string.group_wallpapers, R.drawable.ic_launcher_wallpaper, ITEM_WALLPAPER));
  }
示例#4
0
  /**
   * Starts a drag.
   *
   * @param b The bitmap to display as the drag image. It will be re-scaled to the enlarged size.
   * @param dragLayerX The x position in the DragLayer of the left-top of the bitmap.
   * @param dragLayerY The y position in the DragLayer of the left-top of the bitmap.
   * @param source An object representing where the drag originated
   * @param dragInfo The data associated with the object that is being dragged
   * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or {@link
   *     #DRAG_ACTION_COPY}
   * @param dragRegion Coordinates within the bitmap b for the position of item being dragged. Makes
   *     dragging feel more precise, e.g. you can clip out a transparent border
   */
  public void startDrag(
      Bitmap b,
      int dragLayerX,
      int dragLayerY,
      DragSource source,
      Object dragInfo,
      int dragAction,
      Point dragOffset,
      Rect dragRegion,
      float initialDragViewScale) {
    if (PROFILE_DRAWING_DURING_DRAG) {
      android.os.Debug.startMethodTracing("Launcher");
    }

    // Hide soft keyboard, if visible
    if (mInputMethodManager == null) {
      mInputMethodManager =
          (InputMethodManager) mLauncher.getSystemService(Context.INPUT_METHOD_SERVICE);
    }
    mInputMethodManager.hideSoftInputFromWindow(mWindowToken, 0);

    for (DragListener listener : mListeners) {
      listener.onDragStart(source, dragInfo, dragAction);
    }

    final int registrationX = mMotionDownX - dragLayerX;
    final int registrationY = mMotionDownY - dragLayerY;

    final int dragRegionLeft = dragRegion == null ? 0 : dragRegion.left;
    final int dragRegionTop = dragRegion == null ? 0 : dragRegion.top;

    mDragging = true;

    mDragObject = new DropTarget.DragObject();

    mDragObject.dragComplete = false;
    mDragObject.xOffset = mMotionDownX - (dragLayerX + dragRegionLeft);
    mDragObject.yOffset = mMotionDownY - (dragLayerY + dragRegionTop);
    mDragObject.dragSource = source;
    mDragObject.dragInfo = dragInfo;

    final DragView dragView =
        mDragObject.dragView =
            new DragView(
                mLauncher,
                b,
                registrationX,
                registrationY,
                0,
                0,
                b.getWidth(),
                b.getHeight(),
                initialDragViewScale);

    if (dragOffset != null) {
      dragView.setDragVisualizeOffset(new Point(dragOffset));
    }
    if (dragRegion != null) {
      dragView.setDragRegion(new Rect(dragRegion));
    }

    mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    dragView.show(mMotionDownX, mMotionDownY);
    handleMoveEvent(mMotionDownX, mMotionDownY);
  }