/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attribtues set containing the Workspace's customization values. */ public Folder(Context context, AttributeSet attrs) { super(context, attrs); setAlwaysDrawnWithCacheEnabled(false); mInflater = LayoutInflater.from(context); mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache(); Resources res = getResources(); mMaxCountX = res.getInteger(R.integer.folder_max_count_x); mMaxCountY = res.getInteger(R.integer.folder_max_count_y); mMaxNumItems = res.getInteger(R.integer.folder_max_num_items); if (mMaxCountX < 0 || mMaxCountY < 0 || mMaxNumItems < 0) { mMaxCountX = LauncherModel.getCellCountX(); mMaxCountY = LauncherModel.getCellCountY(); mMaxNumItems = mMaxCountX * mMaxCountY; } mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration); if (sDefaultFolderName == null) { sDefaultFolderName = res.getString(R.string.folder_name); } if (sHintText == null) { sHintText = res.getString(R.string.folder_hint_text); } mLauncher = (Launcher) context; // We need this view to be focusable in touch mode so that when text editing of the folder // name is complete, we have something to focus on, thus hiding the cursor and giving // reliable behvior when clicking the text field (since it will always gain focus on click). setFocusableInTouchMode(true); mAM = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); }
@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(); }
public void applyFromAppWidgetProviderInfo( AppWidgetProviderInfo info, int maxWidth, int[] cellSpan) { mIsAppWidget = true; final ImageView image = (ImageView) findViewById(R.id.widget_preview); if (maxWidth > -1) { image.setMaxWidth(maxWidth); } image.setContentDescription(info.label); final TextView name = (TextView) findViewById(R.id.widget_name); name.setText(info.label); final TextView dims = (TextView) findViewById(R.id.widget_dims); if (dims != null) { int hSpan = Math.min(cellSpan[0], LauncherModel.getCellCountX()); int vSpan = Math.min(cellSpan[1], LauncherModel.getCellCountY()); dims.setText(String.format(mDimensionsFormatString, hSpan, vSpan)); } }