/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Eclipse Public License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.eclipse.org/org/documents/epl-v10.php * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.ide.common.layout; import static com.android.SdkConstants.ANDROID_URI; import static com.android.SdkConstants.ATTR_LAYOUT_COLUMN; import static com.android.SdkConstants.ATTR_LAYOUT_GRAVITY; import static com.android.SdkConstants.ATTR_LAYOUT_ROW; import static com.android.SdkConstants.ATTR_ORIENTATION; import static com.android.SdkConstants.FQCN_GRID_LAYOUT; import static com.android.SdkConstants.FQCN_SPACE; import static com.android.SdkConstants.FQCN_SPACE_V7; import static com.android.SdkConstants.GRAVITY_VALUE_FILL; import static com.android.SdkConstants.GRAVITY_VALUE_FILL_HORIZONTAL; import static com.android.SdkConstants.GRAVITY_VALUE_FILL_VERTICAL; import static com.android.SdkConstants.GRAVITY_VALUE_LEFT; import static com.android.SdkConstants.GRID_LAYOUT; import static com.android.SdkConstants.VALUE_HORIZONTAL; import static com.android.SdkConstants.VALUE_TRUE; import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.IFeedbackPainter; import com.android.ide.common.api.IGraphics; import com.android.ide.common.api.IMenuCallback; import com.android.ide.common.api.INode; import com.android.ide.common.api.INodeHandler; import com.android.ide.common.api.IViewMetadata; import com.android.ide.common.api.IViewMetadata.FillPreference; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; import com.android.ide.common.api.RuleAction; import com.android.ide.common.api.RuleAction.Choices; import com.android.ide.common.api.SegmentType; import com.android.ide.common.layout.grid.GridDropHandler; import com.android.ide.common.layout.grid.GridLayoutPainter; import com.android.ide.common.layout.grid.GridModel; import com.android.ide.common.layout.grid.GridModel.ViewData; import com.android.utils.Pair; import java.net.URL; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; /** * An {@link IViewRule} for android.widget.GridLayout which provides designtime * interaction with GridLayouts. *
* TODO: *
* Currently, this implementation simply lays out the elements row by row,
* approach #3 above.
*/
@Override
public void onPaste(
@NonNull INode targetNode,
@Nullable Object targetView,
@NonNull IDragElement[] elements) {
DropFeedback feedback = onDropEnter(targetNode, targetView, elements);
if (feedback != null) {
Rect b = targetNode.getBounds();
if (!b.isValid()) {
return;
}
Map