history entry: Swap the remove button for a paste button

This commit is contained in:
Jules Aguillon 2024-07-06 22:05:45 +02:00
parent 076177ab45
commit e22fc226a1
2 changed files with 26 additions and 20 deletions

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/clipboard_entry_text" style="@style/clipboardEntry"/> <TextView android:id="@+id/clipboard_entry_text" style="@style/clipboardEntry"/>
<LinearLayout style="@style/clipboardEntryButtons"> <LinearLayout style="@style/clipboardEntryButtons">
<View android:id="@+id/clipboard_entry_paste" style="@style/clipboardEntryButton" android:background="@drawable/ic_clipboard_paste"/>
<View android:id="@+id/clipboard_entry_addpin" style="@style/clipboardEntryButton" android:background="@drawable/ic_clipboard_save"/> <View android:id="@+id/clipboard_entry_addpin" style="@style/clipboardEntryButton" android:background="@drawable/ic_clipboard_save"/>
<View android:id="@+id/clipboard_entry_removehist" style="@style/clipboardEntryButton" android:background="@drawable/ic_delete"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -43,10 +43,10 @@ public final class ClipboardHistoryView extends NonScrollListView
_service.remove_history_entry(clip); _service.remove_history_entry(clip);
} }
/** The history entry at index [pos] is removed from the history. */ /** Send the specified entry to the editor. */
public void remove_entry(int pos) public void paste_entry(int pos)
{ {
_service.remove_history_entry(_history.get(pos)); ClipboardHistoryService.paste(_history.get(pos));
} }
@Override @Override
@ -93,26 +93,32 @@ public final class ClipboardHistoryView extends NonScrollListView
@Override @Override
public void onClick(View v) { pin_entry(pos); } public void onClick(View v) { pin_entry(pos); }
}); });
v.findViewById(R.id.clipboard_entry_removehist).setOnClickListener( v.findViewById(R.id.clipboard_entry_paste).setOnClickListener(
new View.OnClickListener() new View.OnClickListener()
{ {
@Override @Override
public void onClick(View v) public void onClick(View v) { paste_entry(pos); }
{
AlertDialog d = new AlertDialog.Builder(getContext())
.setTitle(R.string.clipboard_remove_confirm)
.setPositiveButton(R.string.clipboard_remove_confirmed,
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface _dialog, int _which)
{
remove_entry(pos);
}
})
.setNegativeButton(android.R.string.cancel, null)
.create();
Utils.show_dialog_on_ime(d, v.getWindowToken());
}
}); });
// v.findViewById(R.id.clipboard_entry_removehist).setOnClickListener(
// new View.OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// AlertDialog d = new AlertDialog.Builder(getContext())
// .setTitle(R.string.clipboard_remove_confirm)
// .setPositiveButton(R.string.clipboard_remove_confirmed,
// new DialogInterface.OnClickListener(){
// public void onClick(DialogInterface _dialog, int _which)
// {
// _service.remove_history_entry(_history.get(pos));
// }
// })
// .setNegativeButton(android.R.string.cancel, null)
// .create();
// Utils.show_dialog_on_ime(d, v.getWindowToken());
// }
// });
return v; return v;
} }
} }