diff --git a/app/src/main/java/net/schueller/peertube/activity/ServerAddressBookActivity.java b/app/src/main/java/net/schueller/peertube/activity/ServerAddressBookActivity.java
index cedc664..9523460 100644
--- a/app/src/main/java/net/schueller/peertube/activity/ServerAddressBookActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/ServerAddressBookActivity.java
@@ -17,8 +17,11 @@
*/
package net.schueller.peertube.activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle;
+import android.provider.SearchRecentSuggestions;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
@@ -44,6 +47,7 @@ import net.schueller.peertube.adapter.ServerListAdapter;
import net.schueller.peertube.database.Server;
import net.schueller.peertube.database.ServerViewModel;
import net.schueller.peertube.fragment.AddServerFragment;
+import net.schueller.peertube.provider.SearchSuggestionsProvider;
import java.util.List;
@@ -118,13 +122,25 @@ public class ServerAddressBookActivity extends CommonActivity implements AddServ
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder,
int direction) {
- int position = viewHolder.getAdapterPosition();
- Server server = adapter.getServerAtPosition(position);
- Toast.makeText(ServerAddressBookActivity.this, "Deleting " +
- server.getServerName(), Toast.LENGTH_LONG).show();
- // Delete the server
- mServerViewModel.delete(server);
+
+ new AlertDialog.Builder(ServerAddressBookActivity.this)
+ .setTitle(getString(R.string.server_book_del_alert_title))
+ .setMessage(getString(R.string.server_book_del_alert_msg))
+ .setPositiveButton(android.R.string.yes, (dialog, which) -> {
+ int position = viewHolder.getAdapterPosition();
+ Server server = adapter.getServerAtPosition(position);
+// Toast.makeText(ServerAddressBookActivity.this, "Deleting " +
+// server.getServerName(), Toast.LENGTH_LONG).show();
+ // Delete the server
+ mServerViewModel.delete(server);
+ })
+ .setNegativeButton(android.R.string.no, (dialog, which) -> {
+ adapter.notifyItemChanged(viewHolder.getAdapterPosition());
+ })
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .show();
+
}
});
helper.attachToRecyclerView(recyclerView);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 82c9ff6..44ebc69 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -361,6 +361,8 @@
pref_token_type
pref_auth_username
pref_auth_password
+ Remove Server
+ Are you sure you want to remove this server from the address book?