clipboard: Confirmation dialog before deletion

Prevent accidentally deleting a saved clipboard.
This commit is contained in:
Jules Aguillon 2024-06-21 00:42:55 +02:00
parent 700b7e9d19
commit 8d29d80fce
18 changed files with 60 additions and 1 deletions

View File

@ -117,4 +117,6 @@ Tato aplikace neobsahuje žádné reklamy, nevyužívá připojení k síti a je
<string name="key_descr_end">End</string> <string name="key_descr_end">End</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ Diese App enthält keine Werbung, benötigt keinen Netzwerkzugriff und ist quell
<string name="key_descr_end">Ende</string> <string name="key_descr_end">Ende</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ La misma no contiene ningún anuncio/publicidad, no realiza peticiones de red y
<string name="key_descr_end">Fin</string> <string name="key_descr_end">Fin</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ This application contains no ads, doesn't make any network requests and is Open
<!-- <string name="key_descr_end">End</string> --> <!-- <string name="key_descr_end">End</string> -->
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ Cette application ne contient pas de publicité, n'accède pas au réseau et est
<string name="key_descr_end">Fin</string> <string name="key_descr_end">Fin</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ This application contains no ads, doesn't make any network requests and is Open
<!-- <string name="key_descr_end">End</string> --> <!-- <string name="key_descr_end">End</string> -->
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ This application contains no ads, doesn't make any network requests and is Open
<!-- <string name="key_descr_end">End</string> --> <!-- <string name="key_descr_end">End</string> -->
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -119,4 +119,6 @@ Tagad lieliski piemērota izmantošanai ikdienā.
<string name="key_descr_end">Beigas</string> <string name="key_descr_end">Beigas</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ Aplikacja nie zawiera reklam, nie żąda dostępu do internetu, a jej kod źród
<string name="key_descr_end">End</string> <string name="key_descr_end">End</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ Este aplicativo não contém anúncios, não faz nenhuma solicitação de rede e
<string name="key_descr_end">End</string> <string name="key_descr_end">End</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ Această aplicație nu conține publicitate, nu folosește rețeaua deloc și e
<!-- <string name="key_descr_end">End</string> --> <!-- <string name="key_descr_end">End</string> -->
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@
<string name="key_descr_end">End</string> <string name="key_descr_end">End</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ Bu uygulama açık kaynaklıdır. Reklam içermez ve internete bağlanmaz."</str
<string name="key_descr_end">SON(Sağ yön tuşu)</string> <string name="key_descr_end">SON(Sağ yön tuşu)</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@
<string name="key_descr_end">End</string> <string name="key_descr_end">End</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ Bây giờ đã hoàn hảo cho việc sử dụng hàng ngày.
<!-- <string name="key_descr_end">End</string> --> <!-- <string name="key_descr_end">End</string> -->
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@
<string name="key_descr_end">End</string> <string name="key_descr_end">End</string>
<!-- <string name="clipboard_history_heading">Recently copied text</string> --> <!-- <string name="clipboard_history_heading">Recently copied text</string> -->
<!-- <string name="clipboard_pin_heading">Pinned</string> --> <!-- <string name="clipboard_pin_heading">Pinned</string> -->
<!-- <string name="clipboard_remove_confirm">Remove this saved clipboard?</string> -->
<!-- <string name="clipboard_remove_confirmed">Yes</string> -->
</resources> </resources>

View File

@ -117,4 +117,6 @@ This application contains no ads, doesn't make any network requests and is Open
<string name="key_descr_end">End</string> <string name="key_descr_end">End</string>
<string name="clipboard_history_heading">Recently copied text</string> <string name="clipboard_history_heading">Recently copied text</string>
<string name="clipboard_pin_heading">Pinned</string> <string name="clipboard_pin_heading">Pinned</string>
<string name="clipboard_remove_confirm">Remove this saved clipboard?</string>
<string name="clipboard_remove_confirmed">Yes</string>
</resources> </resources>

View File

@ -1,10 +1,14 @@
package juloo.keyboard2; package juloo.keyboard2;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
@ -115,7 +119,28 @@ public final class ClipboardPinView extends NonScrollListView
new View.OnClickListener() new View.OnClickListener()
{ {
@Override @Override
public void onClick(View v) { remove_entry(pos); } public void onClick(View v)
{
// Confirmation dialog for removing a clip
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();
// https://stackoverflow.com/questions/3494476/android-ime-how-to-show-a-pop-up-dialog
Window dw = d.getWindow();
WindowManager.LayoutParams lp = dw.getAttributes();
lp.token = v.getWindowToken();
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
dw.setAttributes(lp);
dw.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
d.show();
}
}); });
return v; return v;
} }