-
Notifications
You must be signed in to change notification settings - Fork 11
ADFA-2023 | Refactor layout positioning and drop/restore workflow #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
069fd0d
feat(layouteditor): persist widget position on drop; save translation…
jatezzz 5a091ae
refactor: Resolving BOT comments
jatezzz 13adc61
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 3754b95
refactor: increase decimal places
jatezzz 31274b1
Merge remote-tracking branch 'origin/feature/ADFA-1428-persist-drop-p…
jatezzz e8b4512
refactor: view parent
jatezzz 2df1d2a
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 61c678a
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz dff47a2
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 8acec24
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 9a7a957
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 92c400a
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz fced360
refactor(layouteditor): Use ConstraintSet margins for view positioning
jatezzz ec3f84a
Merge remote-tracking branch 'origin/feature/ADFA-1428-persist-drop-p…
jatezzz 454ee63
FIX: Store and display properly widget positions, must fix jump at drop
jatezzz ebf8312
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 7adf837
refactor(layout): extract constraint utilities and centralize positio…
jatezzz 4cf90e7
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz ca55551
refactor(layout): optimize constraint batching and fix existing view …
jatezzz d0982d6
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 50e90c2
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz c93cffe
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 6973871
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 05776a4
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz c0501ee
Merge branch 'stage' into feature/ADFA-1428-persist-drop-position-tra…
jatezzz 3d24aec
refactor(layouteditor): extract positioning utils; add drop/restore h…
jatezzz ad0fb66
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz cdc680a
feat(LayoutEditor): add support for widgets positioning in GridLayout…
jatezzz 6088d74
fix indent
jatezzz 96beccb
refactor(positioning): Optimize view restore to update only the moved…
jatezzz 5c26121
fix(positioning): Fix indentation
jatezzz 1cc283b
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz 798e588
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz efdb90a
Merge remote-tracking branch 'origin/stage' into feat/ADFA-2023-multi…
jatezzz 7129d21
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz b0d285e
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz 2d2a7e6
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz a40258d
fix(layouteditor): Use android:layout_margin for universal ViewGroup …
jatezzz 7801048
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz 80071b3
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz 2203cbe
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz c3a5c2a
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz bd70bd7
feat(layout-editor): add widget id sanitization for switch
jatezzz 975bdd2
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz ec03c68
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz 7fb5464
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz e77015c
feat(layouteditor): add include marker support and update default wid…
jatezzz 9484bc7
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz ee44fa0
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz c967721
fix: re-initialize AttributeInitializer on layout load to update map …
jatezzz 8d131a5
Merge branch 'stage' into feat/ADFA-2023-multi-layout-drop-support
jatezzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...in/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutDropHandler.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package org.appdevforall.codeonthego.layouteditor.editor.positioning | ||
|
|
||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import android.widget.FrameLayout | ||
| import android.widget.GridLayout | ||
| import android.widget.LinearLayout | ||
| import android.widget.RelativeLayout | ||
| import androidx.constraintlayout.widget.ConstraintLayout | ||
| import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
| import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap | ||
|
|
||
|
|
||
| /** | ||
| * Updates the stored attributes for a [child] view after it is "dropped" | ||
| * at a new position (x, y) within its parent [ViewGroup]. | ||
| * | ||
| * This function orchestrates the process of: | ||
| * 1. Calculating the final, clamped coordinates in Dp. | ||
| * 2. Clearing any previous positioning attributes to prevent conflicts. | ||
| * 3. Applying the correct new attributes based on the parent's layout type. | ||
| * | ||
| * @param child The view being positioned. | ||
| * @param x The raw target X coordinate in container pixels. | ||
| * @param y The raw target Y coordinate in container pixels. | ||
| */ | ||
| fun positionAtDrop(child: View, x: Float, y: Float, viewAttributeMap: HashMap<View, AttributeMap>) { | ||
| val container = child.parent as? ViewGroup ?: return | ||
|
|
||
| val density = container.resources.displayMetrics.density | ||
| val coords = calculateDropCoordinatesInDp(container, child, x, y, density) | ||
|
|
||
| val attributes = viewAttributeMap[child] ?: return | ||
|
|
||
| clearPositioningAttributes(attributes) | ||
jatezzz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| applyLayoutAttributes(container, child, attributes, coords, x, y, viewAttributeMap) | ||
| } | ||
|
|
||
| /** | ||
| * Acts as a "dynamic mapper" or "strategy" function. | ||
| * It detects the type of the [container] and calls the appropriate | ||
| * helper function to apply layout-specific attributes. | ||
| * | ||
| * @param container The parent ViewGroup. | ||
| * @param attributes The AttributeMap for the child view. | ||
| * @param coords The final Dp coordinates to apply. | ||
| */ | ||
| internal fun applyLayoutAttributes( | ||
| container: ViewGroup, | ||
| child: View, | ||
| attributes: AttributeMap, | ||
| coords: DpCoordinates, | ||
jatezzz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| x: Float, | ||
| y: Float, | ||
| fullAttributeMap: HashMap<View, AttributeMap> | ||
| ) { | ||
| when (container) { | ||
| is ConstraintLayout -> applyConstraintLayoutAttributes(attributes, coords) | ||
| is FrameLayout, is CoordinatorLayout -> applyGravityMarginAttributes(attributes, coords) | ||
| is RelativeLayout -> applyRelativeLayoutAttributes(attributes, coords) | ||
| is LinearLayout -> applyDragReorder(container, child, x, y) | ||
| is GridLayout -> applyGridLayoutAttributes(container, child, attributes, x, y, fullAttributeMap) | ||
| else -> applyGenericLayoutAttributes(attributes, coords) | ||
jatezzz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.