tweak - bulk edit UI - show a message after an action is applied.

This commit is contained in:
orionlee 2019-04-05 11:17:54 -07:00
parent 46f7805a96
commit cc43af110a
2 changed files with 41 additions and 7 deletions

View File

@ -6,6 +6,8 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.PluralsRes;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.util.ArrayMap;
@ -501,22 +503,22 @@ public class EpisodesApplyActionFragment extends Fragment {
private void queueChecked() {
DBWriter.addQueueItem(getActivity(), true, checkedIds.toArray());
close();
close(R.plurals.added_to_queue_batch_label, checkedIds.size());
}
private void removeFromQueueChecked() {
DBWriter.removeQueueItem(getActivity(), true, checkedIds.toArray());
close();
close(R.plurals.removed_from_queue_batch_label, checkedIds.size());
}
private void markedCheckedPlayed() {
DBWriter.markItemPlayed(FeedItem.PLAYED, checkedIds.toArray());
close();
close(R.plurals.marked_read_batch_label, checkedIds.size());
}
private void markedCheckedUnplayed() {
DBWriter.markItemPlayed(FeedItem.UNPLAYED, checkedIds.toArray());
close();
close(R.plurals.marked_unread_batch_label, checkedIds.size());
}
private void downloadChecked() {
@ -533,7 +535,7 @@ public class EpisodesApplyActionFragment extends Fragment {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(getActivity(), e.getMessage());
}
close();
close(R.plurals.downloading_batch_label, checkedIds.size());
}
private void deleteChecked() {
@ -543,10 +545,18 @@ public class EpisodesApplyActionFragment extends Fragment {
DBWriter.deleteFeedMediaOfItem(getActivity(), episode.getMedia().getId());
}
}
close();
close(R.plurals.deleted_episode_batch_label, checkedIds.size());
}
private void close() {
private void close(@PluralsRes int msgId, int numItems) {
if (numItems > 0) {
Snackbar.make(getActivity().findViewById(R.id.content),
getResources().getQuantityString(msgId, numItems, numItems),
Snackbar.LENGTH_LONG
)
.setAction(android.R.string.ok, v -> {})
.show();
}
getActivity().getSupportFragmentManager().popBackStack();
}

View File

@ -166,6 +166,10 @@
<!-- actions on feeditems -->
<string name="download_label">Download</string>
<plurals name="downloading_batch_label">
<item quantity="one">Downloading %d episode.</item>
<item quantity="other">Downloading %d episodes.</item>
</plurals>
<string name="play_label">Play</string>
<string name="pause_label">Pause</string>
<string name="stop_label">Stop</string>
@ -174,14 +178,34 @@
<string name="delete_label">Delete</string>
<string name="delete_failed">Unable to delete file. Rebooting the device could help.</string>
<string name="remove_episode_lable">Delete Episode</string>
<plurals name="deleted_episode_batch_label">
<item quantity="one">%d episode deleted.</item>
<item quantity="other">%d episodes deleted.</item>
</plurals>
<string name="mark_as_seen_label">Mark as seen</string>
<string name="marked_as_seen_label">Marked as seen</string>
<string name="mark_read_label">Mark as played</string>
<string name="marked_as_read_label">Marked as played</string>
<plurals name="marked_read_batch_label">
<item quantity="one">%d episode marked as played.</item>
<item quantity="other">%d episodes marked as played.</item>
</plurals>
<string name="mark_unread_label">Mark as unplayed</string>
<plurals name="marked_unread_batch_label">
<item quantity="one">%d episode marked as unplayed.</item>
<item quantity="other">%d episodes marked as unplayed.</item>
</plurals>
<string name="add_to_queue_label">Add to Queue</string>
<string name="added_to_queue_label">Added to Queue</string>
<plurals name="added_to_queue_batch_label">
<item quantity="one">%d episode added to queue.</item>
<item quantity="other">%d episodes added to queue.</item>
</plurals>
<string name="remove_from_queue_label">Remove from Queue</string>
<plurals name="removed_from_queue_batch_label">
<item quantity="one">%d episode removed from queue.</item>
<item quantity="other">%d episodes removed from queue.</item>
</plurals>
<string name="add_to_favorite_label">Add to Favorites</string>
<string name="added_to_favorites">Added to Favorites</string>
<string name="remove_from_favorite_label">Remove from Favorites</string>