Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions catroid/src/main/java/org/catrobat/catroid/content/Script.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public abstract class Script implements Serializable, Cloneable {

protected List<Brick> brickList = new ArrayList<>();
protected boolean commentedOut = false;
private transient boolean collapsed = false;

@XStreamAsAttribute
protected float posX;
Expand All @@ -71,6 +72,7 @@ public Script clone() throws CloneNotSupportedException {
}

clone.commentedOut = commentedOut;
clone.collapsed = false;
clone.scriptBrick = null;
clone.posX = posX;
clone.posY = posY;
Expand Down Expand Up @@ -109,6 +111,14 @@ public void setCommentedOut(boolean commentedOut) {
}
}

public boolean isCollapsed() {
return collapsed;
}

public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}

public void setParents() {
ScriptBrick scriptBrick = getScriptBrick();
scriptBrick.setParent(null);
Expand Down Expand Up @@ -145,8 +155,14 @@ public void addBrick(int position, Brick brick) {

public void addToFlatList(List<Brick> bricks) {
bricks.add(getScriptBrick());
for (Brick brick : brickList) {
brick.addToFlatList(bricks);
if (!collapsed) {
for (Brick brick : brickList) {
brick.addToFlatList(bricks);
}
} else {
for (int i = 0; i < Math.min(3, brickList.size()); i++) {
bricks.add(brickList.get(i));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public abstract class BrickBaseType implements Brick {

protected boolean commentedOut;

protected transient boolean collapsed;

protected UUID brickId = UUID.randomUUID();

@Override
Expand All @@ -66,6 +68,14 @@ public void setCommentedOut(boolean commentedOut) {
this.commentedOut = commentedOut;
}

public boolean isCollapsed() {
return collapsed;
}

public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}

@Nullable
@Override
public CheckBox getCheckBox() {
Expand All @@ -79,6 +89,7 @@ public Brick clone() throws CloneNotSupportedException {
clone.checkbox = null;
clone.parent = null;
clone.commentedOut = commentedOut;
clone.collapsed = false;
clone.brickId = UUID.randomUUID();
return clone;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public void setUndoMenuItemVisibility(boolean isVisible) {
public boolean onPrepareOptionsMenu(Menu menu) {
if (getCurrentFragment() instanceof ScriptFragment) {
menu.findItem(R.id.comment_in_out).setVisible(true);
menu.findItem(R.id.collapse_expand).setVisible(true);
showUndo(isUndoMenuItemVisible);
} else if (getCurrentFragment() instanceof LookListFragment) {
showUndo(isUndoMenuItemVisible);
Expand Down
6 changes: 6 additions & 0 deletions catroid/src/main/java/org/catrobat/catroid/ui/UiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
return R.drawable.ic_library_add_small;
case R.string.menu_rate_us:
return R.drawable.ic_star_rate;
case R.string.brick_context_dialog_collapse_script:

Check warning

Code scanning / Android Lint

Checks use of resource IDs in places requiring constants Warning

Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements
case R.string.brick_context_dialog_collapse_brick:

Check warning on line 105 in catroid/src/main/java/org/catrobat/catroid/ui/UiUtils.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge the previous cases into this one using comma-separated label.

See more on https://sonarcloud.io/project/issues?id=Catrobat_Catroid&issues=AZ2OwcHnVfXNdCGJpqD4&open=AZ2OwcHnVfXNdCGJpqD4&pullRequest=5196
return R.drawable.ic_collapse;
case R.string.brick_context_dialog_expand_script:

Check warning

Code scanning / Android Lint

Checks use of resource IDs in places requiring constants Warning

Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements
case R.string.brick_context_dialog_expand_brick:

Check warning on line 108 in catroid/src/main/java/org/catrobat/catroid/ui/UiUtils.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge the previous cases into this one using comma-separated label.

See more on https://sonarcloud.io/project/issues?id=Catrobat_Catroid&issues=AZ2OwcHnVfXNdCGJpqD5&open=AZ2OwcHnVfXNdCGJpqD5&pullRequest=5196
return R.drawable.ic_expand;
default:
return R.drawable.ic_placeholder;
}
Expand Down
Loading
Loading