Fixed Snackbars being covered by audio player
This commit is contained in:
parent
2386684b7f
commit
6edc2417a4
|
@ -415,12 +415,17 @@ public class MainActivity extends CastEnabledActivity {
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(MessageEvent event) {
|
public void onEventMainThread(MessageEvent event) {
|
||||||
Log.d(TAG, "onEvent(" + event + ")");
|
Log.d(TAG, "onEvent(" + event + ")");
|
||||||
View parentLayout = findViewById(R.id.drawer_layout);
|
|
||||||
Snackbar snackbar = Snackbar.make(parentLayout, event.message, Snackbar.LENGTH_SHORT);
|
Snackbar snackbar;
|
||||||
|
if (getBottomSheet().getState() == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
|
snackbar = showSnackbarAbovePlayer(event.message, Snackbar.LENGTH_SHORT);
|
||||||
|
} else {
|
||||||
|
snackbar = Snackbar.make(findViewById(android.R.id.content), event.message, Snackbar.LENGTH_SHORT);
|
||||||
|
snackbar.show();
|
||||||
|
}
|
||||||
if (event.action != null) {
|
if (event.action != null) {
|
||||||
snackbar.setAction(getString(R.string.undo), v -> event.action.run());
|
snackbar.setAction(getString(R.string.undo), v -> event.action.run());
|
||||||
}
|
}
|
||||||
snackbar.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNavIntent() {
|
private void handleNavIntent() {
|
||||||
|
@ -454,4 +459,22 @@ public class MainActivity extends CastEnabledActivity {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
setIntent(intent);
|
setIntent(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Snackbar showSnackbarAbovePlayer(int text, int duration) {
|
||||||
|
Snackbar s = Snackbar.make(findViewById(R.id.main_view), text, duration);
|
||||||
|
if (findViewById(R.id.audioplayerFragment).getVisibility() == View.VISIBLE) {
|
||||||
|
s.setAnchorView(findViewById(R.id.audioplayerFragment));
|
||||||
|
}
|
||||||
|
s.show();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Snackbar showSnackbarAbovePlayer(String text, int duration) {
|
||||||
|
Snackbar s = Snackbar.make(findViewById(R.id.main_view), text, duration);
|
||||||
|
if (findViewById(R.id.audioplayerFragment).getVisibility() == View.VISIBLE) {
|
||||||
|
s.setAnchorView(findViewById(R.id.audioplayerFragment));
|
||||||
|
}
|
||||||
|
s.show();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import androidx.fragment.app.Fragment;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.leinardi.android.speeddial.SpeedDialView;
|
import com.leinardi.android.speeddial.SpeedDialView;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
|
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
|
@ -313,8 +314,7 @@ public class EpisodesApplyActionFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resId != 0) {
|
if (resId != 0) {
|
||||||
Snackbar.make(getActivity().findViewById(android.R.id.content), resId, Snackbar.LENGTH_SHORT)
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(resId, Snackbar.LENGTH_SHORT);
|
||||||
.show();
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -470,12 +470,8 @@ public class EpisodesApplyActionFragment extends Fragment {
|
||||||
|
|
||||||
private void close(@PluralsRes int msgId, int numItems) {
|
private void close(@PluralsRes int msgId, int numItems) {
|
||||||
if (numItems > 0) {
|
if (numItems > 0) {
|
||||||
Snackbar.make(getActivity().findViewById(android.R.id.content),
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(
|
||||||
getResources().getQuantityString(msgId, numItems, numItems),
|
getResources().getQuantityString(msgId, numItems, numItems), Snackbar.LENGTH_LONG);
|
||||||
Snackbar.LENGTH_LONG
|
|
||||||
)
|
|
||||||
.setAction(android.R.string.ok, v -> { })
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
getActivity().getSupportFragmentManager().popBackStack();
|
getActivity().getSupportFragmentManager().popBackStack();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
import de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder;
|
import de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
@ -68,9 +69,8 @@ public class FavoriteEpisodesFragment extends EpisodesListFragment {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
DBWriter.removeFavoriteItem(item);
|
DBWriter.removeFavoriteItem(item);
|
||||||
|
|
||||||
Snackbar snackbar = Snackbar.make(root, getString(R.string.removed_item), Snackbar.LENGTH_LONG);
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.removed_item, Snackbar.LENGTH_LONG)
|
||||||
snackbar.setAction(getString(R.string.undo), v -> DBWriter.addFavoriteItem(item));
|
.setAction(getString(R.string.undo), v -> DBWriter.addFavoriteItem(item));
|
||||||
snackbar.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class FeedInfoFragment extends Fragment {
|
||||||
android.content.ClipboardManager cm = (android.content.ClipboardManager) getContext()
|
android.content.ClipboardManager cm = (android.content.ClipboardManager) getContext()
|
||||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
cm.setPrimaryClip(clipData);
|
cm.setPrimaryClip(clipData);
|
||||||
Snackbar.make(getView(), R.string.copied_url_msg, Snackbar.LENGTH_SHORT).show();
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.copied_url_msg, Snackbar.LENGTH_SHORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,7 +142,8 @@ public class ItemFragment extends Fragment {
|
||||||
&& ObjectsCompat.equals(item.getMedia().getIdentifier(), controller.getMedia().getIdentifier())) {
|
&& ObjectsCompat.equals(item.getMedia().getIdentifier(), controller.getMedia().getIdentifier())) {
|
||||||
controller.seekTo(time);
|
controller.seekTo(time);
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(getView(), R.string.play_this_to_seek_position, Snackbar.LENGTH_LONG).show();
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.play_this_to_seek_position,
|
||||||
|
Snackbar.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerForContextMenu(webvDescription);
|
registerForContextMenu(webvDescription);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
@ -388,11 +389,9 @@ public class QueueFragment extends Fragment {
|
||||||
recyclerAdapter.setLocked(locked);
|
recyclerAdapter.setLocked(locked);
|
||||||
}
|
}
|
||||||
if (locked) {
|
if (locked) {
|
||||||
Snackbar.make(getActivity().findViewById(android.R.id.content),
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.queue_locked, Snackbar.LENGTH_SHORT);
|
||||||
R.string.queue_locked, Snackbar.LENGTH_SHORT).show();
|
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(getActivity().findViewById(android.R.id.content),
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.queue_unlocked, Snackbar.LENGTH_SHORT);
|
||||||
R.string.queue_unlocked, Snackbar.LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,16 +496,16 @@ public class QueueFragment extends Fragment {
|
||||||
final boolean isRead = item.isPlayed();
|
final boolean isRead = item.isPlayed();
|
||||||
DBWriter.markItemPlayed(FeedItem.PLAYED, false, item.getId());
|
DBWriter.markItemPlayed(FeedItem.PLAYED, false, item.getId());
|
||||||
DBWriter.removeQueueItem(getActivity(), true, item);
|
DBWriter.removeQueueItem(getActivity(), true, item);
|
||||||
Snackbar snackbar = Snackbar.make(root, getString(item.hasMedia()
|
|
||||||
? R.string.marked_as_read_label : R.string.marked_as_read_no_media_label),
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(
|
||||||
Snackbar.LENGTH_LONG);
|
item.hasMedia() ? R.string.marked_as_read_label : R.string.marked_as_read_no_media_label,
|
||||||
snackbar.setAction(getString(R.string.undo), v -> {
|
Snackbar.LENGTH_LONG)
|
||||||
DBWriter.addQueueItemAt(getActivity(), item.getId(), position, false);
|
.setAction(getString(R.string.undo), v -> {
|
||||||
if(!isRead) {
|
DBWriter.addQueueItemAt(getActivity(), item.getId(), position, false);
|
||||||
DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId());
|
if (!isRead) {
|
||||||
}
|
DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId());
|
||||||
});
|
}
|
||||||
snackbar.show();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.core.preferences.GpodnetPreferences;
|
import de.danoeh.antennapod.core.preferences.GpodnetPreferences;
|
||||||
|
@ -290,14 +291,14 @@ public class FeedItemMenuHandler {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Snackbar snackbar = Snackbar.make(fragment.getView(), fragment.getString(R.string.removed_new_flag_label),
|
|
||||||
Snackbar.LENGTH_LONG);
|
Snackbar snackbar = ((MainActivity) fragment.getActivity()).showSnackbarAbovePlayer(
|
||||||
snackbar.setAction(fragment.getString(R.string.undo), v -> {
|
R.string.removed_new_flag_label, Snackbar.LENGTH_LONG)
|
||||||
DBWriter.markItemPlayed(FeedItem.NEW, item.getId());
|
.setAction(fragment.getString(R.string.undo), v -> {
|
||||||
// don't forget to cancel the thing that's going to remove the media
|
DBWriter.markItemPlayed(FeedItem.NEW, item.getId());
|
||||||
h.removeCallbacks(r);
|
// don't forget to cancel the thing that's going to remove the media
|
||||||
});
|
h.removeCallbacks(r);
|
||||||
snackbar.show();
|
});
|
||||||
h.postDelayed(r, (int) Math.ceil(snackbar.getDuration() * 1.05f));
|
h.postDelayed(r, (int) Math.ceil(snackbar.getDuration() * 1.05f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import androidx.core.util.Consumer;
|
import androidx.core.util.Consumer;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.core.util.Converter;
|
import de.danoeh.antennapod.core.util.Converter;
|
||||||
|
@ -115,7 +116,9 @@ public class ShownotesWebView extends WebView implements View.OnLongClickListene
|
||||||
android.content.ClipboardManager cm = (android.content.ClipboardManager) getContext()
|
android.content.ClipboardManager cm = (android.content.ClipboardManager) getContext()
|
||||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
cm.setPrimaryClip(clipData);
|
cm.setPrimaryClip(clipData);
|
||||||
Snackbar.make(this, R.string.copied_url_msg, Snackbar.LENGTH_LONG).show();
|
Snackbar s = Snackbar.make(this, R.string.copied_url_msg, Snackbar.LENGTH_LONG);
|
||||||
|
ViewCompat.setElevation(s.getView(), 100);
|
||||||
|
s.show();
|
||||||
break;
|
break;
|
||||||
case R.id.go_to_position_item:
|
case R.id.go_to_position_item:
|
||||||
if (Timeline.isTimecodeLink(selectedUrl) && timecodeSelectedListener != null) {
|
if (Timeline.isTimecodeLink(selectedUrl) && timecodeSelectedListener != null) {
|
||||||
|
|
Loading…
Reference in New Issue