Can now undo swipe to mark as read.
Behavior isn't ideal when the user is displaying all the items in their feed. (you can swipe new and read items and they don't go away (obviously)).
This commit is contained in:
parent
b8d25d4123
commit
c277166f77
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -45,6 +46,7 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||||
import de.danoeh.antennapod.core.util.QueueAccess;
|
import de.danoeh.antennapod.core.util.QueueAccess;
|
||||||
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
|
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
|
||||||
|
import de.danoeh.antennapod.core.util.gui.UndoBarController;
|
||||||
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||||
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
|
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
|
||||||
|
|
||||||
|
@ -68,6 +70,8 @@ public class NewEpisodesFragment extends Fragment {
|
||||||
private TextView txtvEmpty;
|
private TextView txtvEmpty;
|
||||||
private ProgressBar progLoading;
|
private ProgressBar progLoading;
|
||||||
|
|
||||||
|
private UndoBarController undoBarController;
|
||||||
|
|
||||||
private List<FeedItem> unreadItems;
|
private List<FeedItem> unreadItems;
|
||||||
private List<FeedItem> recentItems;
|
private List<FeedItem> recentItems;
|
||||||
private QueueAccess queueAccess;
|
private QueueAccess queueAccess;
|
||||||
|
@ -135,6 +139,7 @@ public class NewEpisodesFragment extends Fragment {
|
||||||
listAdapter = null;
|
listAdapter = null;
|
||||||
activity.set(null);
|
activity.set(null);
|
||||||
viewsCreated = false;
|
viewsCreated = false;
|
||||||
|
undoBarController = null;
|
||||||
if (downloadObserver != null) {
|
if (downloadObserver != null) {
|
||||||
downloadObserver.onPause();
|
downloadObserver.onPause();
|
||||||
}
|
}
|
||||||
|
@ -262,6 +267,10 @@ public class NewEpisodesFragment extends Fragment {
|
||||||
stopItemLoader();
|
stopItemLoader();
|
||||||
FeedItem item = (FeedItem) listView.getAdapter().getItem(which);
|
FeedItem item = (FeedItem) listView.getAdapter().getItem(which);
|
||||||
DBWriter.markItemRead(getActivity(), item.getId(), true);
|
DBWriter.markItemRead(getActivity(), item.getId(), true);
|
||||||
|
undoBarController.showUndoBar(false,
|
||||||
|
getString(R.string.marked_as_read_label), new FeedItemUndoToken(item,
|
||||||
|
which)
|
||||||
|
);
|
||||||
// TODO: provide undo?
|
// TODO: provide undo?
|
||||||
/*
|
/*
|
||||||
undoBarController.showUndoBar(false,
|
undoBarController.showUndoBar(false,
|
||||||
|
@ -272,6 +281,19 @@ public class NewEpisodesFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
undoBarController = new UndoBarController(root.findViewById(R.id.undobar), new UndoBarController.UndoListener() {
|
||||||
|
@Override
|
||||||
|
public void onUndo(Parcelable token) {
|
||||||
|
// Perform the undo
|
||||||
|
FeedItemUndoToken undoToken = (FeedItemUndoToken) token;
|
||||||
|
if (token != null) {
|
||||||
|
long itemId = undoToken.getFeedItemId();
|
||||||
|
int position = undoToken.getPosition();
|
||||||
|
DBWriter.markItemRead(getActivity(), itemId, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
final int secondColor = (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) ? R.color.swipe_refresh_secondary_color_dark : R.color.swipe_refresh_secondary_color_light;
|
final int secondColor = (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) ? R.color.swipe_refresh_secondary_color_dark : R.color.swipe_refresh_secondary_color_light;
|
||||||
|
|
||||||
if (!itemsLoaded) {
|
if (!itemsLoaded) {
|
||||||
|
|
|
@ -50,4 +50,18 @@
|
||||||
tools:layout_height="64dp"
|
tools:layout_height="64dp"
|
||||||
tools:background="@android:color/holo_red_light"/>
|
tools:background="@android:color/holo_red_light"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/undobar"
|
||||||
|
style="@style/UndoBar">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/undobar_message"
|
||||||
|
style="@style/UndoBarMessage"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/undobar_button"
|
||||||
|
style="@style/UndoBarButton"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -100,6 +100,7 @@
|
||||||
<string name="remove_episode_lable">Remove episode</string>
|
<string name="remove_episode_lable">Remove episode</string>
|
||||||
<string name="mark_read_label">Mark as read</string>
|
<string name="mark_read_label">Mark as read</string>
|
||||||
<string name="mark_unread_label">Mark as unread</string>
|
<string name="mark_unread_label">Mark as unread</string>
|
||||||
|
<string name="marked_as_read_label">Marked as read</string>
|
||||||
<string name="add_to_queue_label">Add to Queue</string>
|
<string name="add_to_queue_label">Add to Queue</string>
|
||||||
<string name="remove_from_queue_label">Remove from Queue</string>
|
<string name="remove_from_queue_label">Remove from Queue</string>
|
||||||
<string name="visit_website_label">Visit Website</string>
|
<string name="visit_website_label">Visit Website</string>
|
||||||
|
|
Loading…
Reference in New Issue