private void setupContentDimensions(int count) {
    ArrayList<View> list = getItemsInReadingOrder();

    int countX = mContent.getCountX();
    int countY = mContent.getCountY();
    boolean done = false;

    while (!done) {
      int oldCountX = countX;
      int oldCountY = countY;
      if (countX * countY < count) {
        // Current grid is too small, expand it
        if ((countX <= countY || countY == mMaxCountY) && countX < mMaxCountX) {
          countX++;
        } else if (countY < mMaxCountY) {
          countY++;
        }
        if (countY == 0) countY++;
      } else if ((countY - 1) * countX >= count && countY >= countX) {
        countY = Math.max(0, countY - 1);
      } else if ((countX - 1) * countY >= count) {
        countX = Math.max(0, countX - 1);
      }
      done = countX == oldCountX && countY == oldCountY;
    }
    mContent.setGridSize(countX, countY);
    arrangeChildren(list);
  }
示例#2
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    mContent = (CellLayout) findViewById(R.id.folder_content);
    mContent.setGridSize(0, 0);
    mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
    mFolderName = (FolderEditText) findViewById(R.id.folder_name);
    mFolderName.setFolder(this);
    mFolderName.setOnFocusChangeListener(this);

    // 算出TextView最终需要多大,以便可以给它腾出适合大小的地方
    int measureSpec = MeasureSpec.UNSPECIFIED;
    mFolderName.measure(measureSpec, measureSpec);
    mFolderNameHeight = mFolderName.getMeasuredHeight();

    // We disable action mode for now since it messes up the view on phones
    // 暂时禁止action mode,因为它有可能会情致view混乱
    mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(
        mFolderName.getInputType()
            | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
  }
示例#3
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    mContent = (CellLayout) findViewById(R.id.folder_content);
    mContent.setGridSize(0, 0);
    mContent.getChildrenLayout().setMotionEventSplittingEnabled(false);
    mFolderName = (FolderEditText) findViewById(R.id.folder_name);
    mFolderName.setFolder(this);
    mFolderName.setOnFocusChangeListener(this);

    // We find out how tall the text view wants to be (it is set to wrap_content), so that
    // we can allocate the appropriate amount of space for it.
    int measureSpec = MeasureSpec.UNSPECIFIED;
    mFolderName.measure(measureSpec, measureSpec);
    mFolderNameHeight = mFolderName.getMeasuredHeight();

    // We disable action mode for now since it messes up the view on phones
    mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(
        mFolderName.getInputType()
            | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
  }
示例#4
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    mAllAppsButtonRank = grid.hotseatAllAppsRank;
    mContent = (CellLayout) findViewById(R.id.layout);
    if (grid.isLandscape && !grid.isLargeTablet()) {
      mContent.setGridSize(1, (int) grid.numHotseatIcons);
    } else {
      mContent.setGridSize((int) grid.numHotseatIcons, 1);
    }
    mContent.setIsHotseat(true);

    resetLayout();
  }
示例#5
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    if (mCellCountX < 0) mCellCountX = LauncherModel.getCellCountX();
    if (mCellCountY < 0) mCellCountY = LauncherModel.getCellCountY();
    mContent = (CellLayout) findViewById(R.id.layout);
    mContent.setGridSize(mCellCountX, mCellCountY);
    mContent.setIsHotseat(true);

    resetLayout();
  }
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    if (mCellCountX < 0) mCellCountX = DEFAULT_CELL_COUNT_X;
    if (mCellCountY < 0) mCellCountY = DEFAULT_CELL_COUNT_Y;
    mContent = (CellLayout) findViewById(R.id.layout);
    mContent.setGridSize(mCellCountX, mCellCountY);
    mContent.setIsHotseat(true);

    resetLayout();
  }
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    mScrollView = (ScrollView) findViewById(R.id.scroll_view);
    mContent = (CellLayout) findViewById(R.id.folder_content);

    mFocusIndicatorHandler = new FocusIndicatorView(getContext());
    mContent.addView(mFocusIndicatorHandler, 0);
    mFocusIndicatorHandler.getLayoutParams().height = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;
    mFocusIndicatorHandler.getLayoutParams().width = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    mContent.setCellDimensions(grid.folderCellWidthPx, grid.folderCellHeightPx);
    mContent.setGridSize(0, 0);
    mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
    mContent.setInvertIfRtl(true);
    mFolderName = (FolderEditText) findViewById(R.id.folder_name);
    mFolderName.setFolder(this);
    if (mLauncher.getLockWorkspace()) {
      mFolderName.setKeyListener(null);
      mFolderName.setFocusable(false);
    } else {
      mFolderName.setOnFocusChangeListener(this);
    }

    // We find out how tall the text view wants to be (it is set to wrap_content), so that
    // we can allocate the appropriate amount of space for it.
    int measureSpec = MeasureSpec.UNSPECIFIED;
    mFolderName.measure(measureSpec, measureSpec);
    mFolderNameHeight = mFolderName.getMeasuredHeight();

    // We disable action mode for now since it messes up the view on phones
    mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(
        mFolderName.getInputType()
            | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView);

    boolean hideFolderName =
        SettingsProvider.getBoolean(mLauncher, SettingsProvider.HIDE_FOLDER_NAME, false);
    if (hideFolderName) {
      mFolderName.setVisibility(View.GONE);
      mFolderNameHeight = 0;
    }
  }