Skip to content
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

added delete Entity button #15

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions app/src/main/java/team/uptech/motionviews/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ public void onClick(View view) {
startTextEntityEditing();
}
});
findViewById(R.id.text_entity_delete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deleteTextEntity();
}
});
}

private void deleteTextEntity() {
TextEntity textEntity = currentTextEntity();
if (textEntity != null) {
motionView.deleteEntity(textEntity);
}
}

private void increaseTextEntitySize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ public void addEntity(@Nullable MotionEntity entity) {
}
}

public void deleteEntity(@Nullable MotionEntity entity) {
if (entity != null) {
entities.remove(entity);
selectEntity(null, true);
}
}

public void addEntityAndPosition(@Nullable MotionEntity entity) {
if (entity != null) {
initEntityBorder(entity);
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable-anydpi/ic_mode_delete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path android:pathData="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" android:fillColor="#FF000000"/>
<path android:pathData="M0 0h24v24H0z"/>
</vector>

8 changes: 8 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
android:src="@drawable/ic_mode_edit"
/>

<ImageButton
android:id="@+id/text_entity_delete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_mode_delete"
/>

</LinearLayout>

</RelativeLayout>