Fix issue #485 - Add a delete icon on items + rename menu item

This commit is contained in:
Thomas 2022-11-20 10:20:52 +01:00
parent 0e8354b0c1
commit d76fcd0f7a
3 changed files with 28 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
@ -160,7 +161,19 @@ public class ReorderTabAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
return false;
});
PinnedTimeline item = pinned.pinnedTimelines.get(position);
if (item.type == Timeline.TimeLineEnum.TAG || item.type == Timeline.TimeLineEnum.REMOTE || item.type == Timeline.TimeLineEnum.LIST) {
holder.binding.delete.setVisibility(View.VISIBLE);
} else {
holder.binding.delete.setVisibility(View.GONE);
}
holder.binding.delete.setOnClickListener(v -> {
if (item.type == Timeline.TimeLineEnum.TAG || item.type == Timeline.TimeLineEnum.REMOTE || item.type == Timeline.TimeLineEnum.LIST) {
mUndoListener.onUndo(item, position);
pinned.pinnedTimelines.remove(position);
notifyItemRemoved(position);
}
});
}
@Override

View File

@ -29,6 +29,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<ImageView
android:id="@+id/hide"
android:layout_width="40dp"
@ -39,6 +40,17 @@
android:src="@drawable/ic_baseline_visibility_off_24"
tools:ignore="RtlHardcoded" />
<ImageView
android:id="@+id/delete"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:contentDescription="@string/delete_timeline"
android:scaleType="center"
android:src="@drawable/ic_baseline_delete_24"
android:visibility="gone"
tools:ignore="RtlHardcoded" />
<ImageView
android:id="@+id/handle"
android:layout_width="40dp"

View File

@ -407,7 +407,7 @@
<string name="settings_category_notif_categories">Categories</string>
<string name="move_timeline">Move timeline</string>
<string name="hide_timeline">Hide timeline</string>
<string name="reorder_timelines">Reorder timelines</string>
<string name="reorder_timelines">Manage timelines</string>
<string name="reorder_list_deleted">List permanently deleted</string>
<string name="reorder_instance_removed">Followed instance removed</string>
<string name="reorder_tag_removed">Pinned tag removed</string>
@ -1901,4 +1901,5 @@
<string name="toast_error_add_to_list">The app failed to add the account into the list!</string>
<string name="display_remote_profile">Display remote profile</string>
<string name="toast_fetch_error">The app cannot find remote data!</string>
<string name="delete_timeline">Delete timeline</string>
</resources>