Add confirmation dialog for clearing history (#6175)

This commit is contained in:
Vishnu Sanal T 2022-11-06 15:26:01 +05:30 committed by GitHub
parent be8c8cef4d
commit e4d4c69519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.fragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -7,6 +8,7 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.event.playback.PlaybackHistoryEvent;
@ -55,7 +57,20 @@ public class PlaybackHistoryFragment extends EpisodesListFragment {
return true;
}
if (item.getItemId() == R.id.clear_history_item) {
DBWriter.clearPlaybackHistory();
ConfirmationDialog conDialog = new ConfirmationDialog(
getActivity(),
R.string.clear_history_label,
R.string.clear_playback_history_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
DBWriter.clearPlaybackHistory();
}
};
conDialog.createNewDialog().show();
return true;
}
return false;

View File

@ -93,6 +93,7 @@
<!-- Playback history -->
<string name="clear_history_label">Clear History</string>
<string name="clear_playback_history_msg">This will clear the entire playback history. Are you sure you want to proceed?</string>
<!-- Other -->
<string name="confirm_label">Confirm</string>