Merge pull request #4104 from ByteHamster/toast-to-snackbar

Replaced some Toasts with Snackbars
This commit is contained in:
H. Lehmann 2020-05-03 17:59:44 +02:00 committed by GitHub
commit c5dcad1722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 22 additions and 23 deletions

View File

@ -366,8 +366,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
DBWriter.addFavoriteItem(feedItem);
isFavorite = true;
invalidateOptionsMenu();
Toast.makeText(this, R.string.added_to_favorites, Toast.LENGTH_SHORT)
.show();
}
break;
case R.id.remove_from_favorites_item:
@ -375,8 +373,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
DBWriter.removeFavoriteItem(feedItem);
isFavorite = false;
invalidateOptionsMenu();
Toast.makeText(this, R.string.removed_from_favorites, Toast.LENGTH_SHORT)
.show();
}
break;
case R.id.disable_sleeptimer_item: // Fall-through

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.adapter;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.text.Layout;
@ -18,6 +19,7 @@ import com.joanzapata.iconify.widget.IconButton;
import com.joanzapata.iconify.widget.IconTextView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedMedia;
@ -35,10 +37,10 @@ import de.danoeh.antennapod.view.viewholder.DownloadItemViewHolder;
public class DownloadLogAdapter extends BaseAdapter {
private static final String TAG = "DownloadLogAdapter";
private final Context context;
private final Activity context;
private final ItemAccess itemAccess;
public DownloadLogAdapter(Context context, ItemAccess itemAccess) {
public DownloadLogAdapter(Activity context, ItemAccess itemAccess) {
super();
this.itemAccess = itemAccess;
this.context = context;
@ -116,7 +118,8 @@ public class DownloadLogAdapter extends BaseAdapter {
}
try {
DownloadRequester.getInstance().downloadMedia(context, true, media.getItem());
Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show();
((MainActivity) context).showSnackbarAbovePlayer(
R.string.status_downloading_label, Toast.LENGTH_SHORT);
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage());

View File

@ -37,8 +37,6 @@ public class CancelDownloadActionButton extends ItemActionButton {
if (UserPreferences.isEnableAutodownload()) {
DBWriter.setFeedItemAutoDownload(media.getItem(), false);
Toast.makeText(context, R.string.download_canceled_autodownload_enabled_msg, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(context, R.string.download_canceled_msg, Toast.LENGTH_LONG).show();
}
}
}

View File

@ -1,7 +1,6 @@
package de.danoeh.antennapod.adapter.actionbutton;
import android.content.Context;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import de.danoeh.antennapod.R;
@ -42,14 +41,12 @@ class MobileDownloadHelper {
private static void addToQueue(Context context, FeedItem item) {
addToQueueTimestamp = System.currentTimeMillis();
DBWriter.addQueueItem(context, item);
Toast.makeText(context, R.string.added_to_queue_label, Toast.LENGTH_SHORT).show();
}
private static void downloadFeedItems(Context context, FeedItem item) {
allowMobileDownloadTimestamp = System.currentTimeMillis();
try {
DownloadRequester.getInstance().downloadMedia(context, true, item);
Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show();
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage());

View File

@ -18,6 +18,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
@ -141,7 +142,7 @@ public class SleepTimerDialog extends DialogFragment {
Button setButton = content.findViewById(R.id.setSleeptimerButton);
setButton.setOnClickListener(v -> {
if (!PlaybackService.isRunning) {
Toast.makeText(getContext(), R.string.no_media_playing_label, Toast.LENGTH_LONG).show();
Snackbar.make(content, R.string.no_media_playing_label, Snackbar.LENGTH_LONG).show();
}
try {
savePreferences();

View File

@ -146,7 +146,8 @@ public abstract class EpisodesListFragment extends Fragment {
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
DBWriter.markAllItemsRead();
Toast.makeText(getActivity(), R.string.mark_all_read_msg, Toast.LENGTH_SHORT).show();
((MainActivity) getActivity()).showSnackbarAbovePlayer(
R.string.mark_all_read_msg, Toast.LENGTH_SHORT);
}
};
markAllReadConfirmationDialog.createNewDialog().show();
@ -160,7 +161,8 @@ public abstract class EpisodesListFragment extends Fragment {
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
DBWriter.removeAllNewFlags();
Toast.makeText(getActivity(), R.string.removed_all_new_flags_msg, Toast.LENGTH_SHORT).show();
((MainActivity) getActivity()).showSnackbarAbovePlayer(
R.string.removed_all_new_flags_msg, Toast.LENGTH_SHORT);
}
};
removeAllNewFlagsConfirmationDialog.createNewDialog().show();

View File

@ -234,7 +234,8 @@ public class FeedInfoFragment extends Fragment {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (feed == null) {
Toast.makeText(getContext(), R.string.please_wait_for_data, Toast.LENGTH_LONG).show();
((MainActivity) getActivity()).showSnackbarAbovePlayer(
R.string.please_wait_for_data, Toast.LENGTH_LONG);
return super.onOptionsItemSelected(item);
}
boolean handled = false;

View File

@ -249,7 +249,8 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
public boolean onOptionsItemSelected(MenuItem item) {
if (!super.onOptionsItemSelected(item)) {
if (feed == null) {
Toast.makeText(getContext(), R.string.please_wait_for_data, Toast.LENGTH_LONG).show();
((MainActivity) getActivity()).showSnackbarAbovePlayer(
R.string.please_wait_for_data, Toast.LENGTH_LONG);
return true;
}
try {

View File

@ -7,6 +7,7 @@ import android.view.View;
import android.widget.ListView;
import android.widget.Toast;
import de.danoeh.antennapod.activity.MainActivity;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@ -108,10 +109,9 @@ public class RunningDownloadsFragment extends ListFragment {
&& UserPreferences.isEnableAutodownload()) {
FeedMedia media = DBReader.getFeedMedia(downloadRequest.getFeedfileId());
DBWriter.setFeedItemAutoDownload(media.getItem(), false);
Toast.makeText(getActivity(), R.string.download_canceled_autodownload_enabled_msg,
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), R.string.download_canceled_msg, Toast.LENGTH_SHORT).show();
((MainActivity) getActivity()).showSnackbarAbovePlayer(
R.string.download_canceled_autodownload_enabled_msg, Toast.LENGTH_SHORT);
}
}
};

View File

@ -8,6 +8,7 @@ import androidx.preference.PreferenceFragmentCompat;
import android.text.Html;
import android.text.format.DateUtils;
import android.widget.Toast;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.core.event.SyncServiceEvent;
@ -91,8 +92,7 @@ public class GpodderPreferencesFragment extends PreferenceFragmentCompat {
});
findPreference(PREF_GPODNET_LOGOUT).setOnPreferenceClickListener(preference -> {
GpodnetPreferences.logout();
Toast toast = Toast.makeText(activity, R.string.pref_gpodnet_logout_toast, Toast.LENGTH_SHORT);
toast.show();
Snackbar.make(getView(), R.string.pref_gpodnet_logout_toast, Snackbar.LENGTH_LONG).show();
updateGpodnetPreferenceScreen();
return true;
});