Skip to content

Commit

Permalink
feat: long click to delete clipboard item
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinityLoop1308 committed Jul 2, 2022
1 parent 7cacd64 commit 9fb5c3d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public void add(@NonNull DbBean clipboardBean) {
db.close();
}

/** 删除记录 * */
public void delete(@NonNull String str) {
helper = new DbHelper(Trime.getService(), "clipboard.db");
SQLiteDatabase db = helper.getWritableDatabase();
db.delete("t_data", "text=?", new String[] {str});
db.close();
}

public List<SimpleKeyBean> getAllSimpleBean(int size) {

List<SimpleKeyBean> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.android.flexbox.FlexboxLayoutManager;
import com.osfans.trime.R;
import com.osfans.trime.data.Config;
import com.osfans.trime.data.db.clipboard.ClipboardDao;
import java.util.List;

public class ClipboardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Expand Down Expand Up @@ -124,9 +125,9 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int in
itemViewHold.listItemLayout.setOnLongClickListener(
view -> {
int position = itemViewHold.getLayoutPosition();
// TODO 长按删除、编辑剪贴板
// 当文本较长时,目前样式只缩略显示为 3 行,长按时 toast 消息可以预览全文,略有用处。
ToastUtils.showShort(list.get(position).getText());
ClipboardDao.get().delete(list.get(position).getText());
notifyItemRemoved(position);
ToastUtils.showShort(R.string.delete_done);
return true;
});

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
<string name="pref_keyboard__candidate">候选栏</string>
<string name="keyboard__candidate_page_size">每页显示候选词数量</string>
<string name="copy_done">已复制</string>
<string name="delete_done">已删除</string>
<string-array name="keyboard__candidate_page_size_entries" >
<item name="10000">不超出候选栏</item>
<item name="10001">接近于候选栏</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
<string name="pref_keyboard__candidate">候選欄</string>
<string name="keyboard__candidate_page_size">每頁顯示候選詞數量</string>
<string name="copy_done">已複製</string>
<string name="delete_done">已刪除</string>
<string-array name="keyboard__candidate_page_size_entries" >
<item name="10000">不超出候選欄</item>
<item name="10001">接近於候選欄</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
<string name="pref_keyboard__candidate">Candidate</string>
<string name="keyboard__candidate_page_size">Candidate item count for each page</string>
<string name="copy_done">Copied to clipboard!</string>
<string name="delete_done">Deleted</string>
<string-array name="keyboard__candidate_page_size_entries" >
<item name="10000">Less than candidate</item>
<item name="10001">close to candidate</item>
Expand Down

0 comments on commit 9fb5c3d

Please sign in to comment.