diff options
Diffstat (limited to 'app')
7 files changed, 68 insertions, 10 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java b/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java index a8e93183c..b092264cd 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java @@ -73,9 +73,9 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv // all episodes openNavDrawer(); - solo.clickOnText(solo.getString(R.string.all_episodes_label)); + solo.clickOnText(solo.getString(R.string.new_episodes_label)); solo.waitForView(android.R.id.list); - assertEquals(solo.getString(R.string.all_episodes_label), getActionbarTitle()); + assertEquals(solo.getString(R.string.new_episodes_label), getActionbarTitle()); // queue openNavDrawer(); diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java index 8f1477192..346ef6c18 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java @@ -79,7 +79,7 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity> private void startLocalPlayback() { assertTrue(solo.waitForActivity(MainActivity.class)); openNavDrawer(); - solo.clickOnText(solo.getString(R.string.all_episodes_label)); + solo.clickOnText(solo.getString(R.string.new_episodes_label)); solo.waitForView(android.R.id.list); solo.clickOnView(solo.getView(R.id.butSecondaryAction)); assertTrue(solo.waitForActivity(AudioplayerActivity.class)); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index b3e95f0c0..2efee838d 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -66,8 +66,8 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity public static final String SAVE_TITLE = "title"; - public static final int POS_NEW = 0, - POS_QUEUE = 1, + public static final int POS_QUEUE = 0, + POS_NEW = 1, POS_DOWNLOADS = 2, POS_HISTORY = 3, POS_ADD = 4; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index a0ba0f794..5494869a6 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -25,7 +25,7 @@ public class NavListAdapter extends BaseAdapter { public static final int VIEW_TYPE_SECTION_DIVIDER = 1; public static final int VIEW_TYPE_SUBSCRIPTION = 2; - public static final int[] NAV_TITLES = {R.string.all_episodes_label, R.string.queue_label, R.string.downloads_label, R.string.playback_history_label, R.string.add_feed_label}; + public static final int[] NAV_TITLES = {R.string.queue_label, R.string.new_episodes_label, R.string.downloads_label, R.string.playback_history_label, R.string.add_feed_label}; private final Drawable[] drawables; @@ -132,7 +132,7 @@ public class NavListAdapter extends BaseAdapter { } else { holder.count.setVisibility(View.GONE); } - } else if (NAV_TITLES[position] == R.string.all_episodes_label) { + } else if (NAV_TITLES[position] == R.string.new_episodes_label) { int unreadItems = itemAccess.getNumberOfUnreadItems(); if (unreadItems > 0) { holder.count.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java index 7a05b9370..2d481a7ef 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.adapter; import android.content.Context; +import android.graphics.Color; import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; @@ -11,6 +12,7 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; +import com.nineoldandroids.view.ViewHelper; import com.squareup.picasso.Picasso; import de.danoeh.antennapod.R; @@ -140,6 +142,13 @@ public class NewEpisodesListAdapter extends BaseAdapter { .fit() .into(holder.imageView); + if (item.isRead()) { + // grey it out + ViewHelper.setAlpha(convertView, .2f); + } else { + ViewHelper.setAlpha(convertView, 1.0f); + } + return convertView; } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index 5cafd370e..5601000dc 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -7,8 +7,10 @@ import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v7.widget.SearchView; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -43,6 +45,8 @@ import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.QueueAccess; +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.NavDrawerActivity; @@ -67,6 +71,8 @@ public class NewEpisodesFragment extends Fragment { private TextView txtvEmpty; private ProgressBar progLoading; + private UndoBarController undoBarController; + private List<FeedItem> unreadItems; private List<FeedItem> recentItems; private QueueAccess queueAccess; @@ -134,6 +140,7 @@ public class NewEpisodesFragment extends Fragment { listAdapter = null; activity.set(null); viewsCreated = false; + undoBarController = null; if (downloadObserver != null) { downloadObserver.onPause(); } @@ -224,7 +231,7 @@ public class NewEpisodesFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); - ((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.all_episodes_label); + ((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.new_episodes_label); View root = inflater.inflate(R.layout.new_episodes_fragment, container, false); @@ -243,6 +250,33 @@ public class NewEpisodesFragment extends Fragment { } }); + listView.setRemoveListener(new DragSortListView.RemoveListener() { + @Override + public void remove(int which) { + Log.d(TAG, "remove("+which+")"); + stopItemLoader(); + FeedItem item = (FeedItem) listView.getAdapter().getItem(which); + DBWriter.markItemRead(getActivity(), item.getId(), true); + undoBarController.showUndoBar(false, + getString(R.string.marked_as_read_label), new FeedItemUndoToken(item, + which) + ); + } + }); + + 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; if (!itemsLoaded) { @@ -346,7 +380,7 @@ public class NewEpisodesFragment extends Fragment { private void updateShowOnlyEpisodes() { SharedPreferences prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); - showOnlyNewEpisodes = prefs.getBoolean(PREF_EPISODE_FILTER_BOOL, false); + showOnlyNewEpisodes = prefs.getBoolean(PREF_EPISODE_FILTER_BOOL, true); } private void setShowOnlyNewEpisodes(boolean newVal) { diff --git a/app/src/main/res/layout/new_episodes_fragment.xml b/app/src/main/res/layout/new_episodes_fragment.xml index 19db02f1d..e90171630 100644 --- a/app/src/main/res/layout/new_episodes_fragment.xml +++ b/app/src/main/res/layout/new_episodes_fragment.xml @@ -16,7 +16,8 @@ android:paddingBottom="@dimen/list_vertical_padding" android:clipToPadding="false" dslv:collapsed_height="2dp" - dslv:drag_enabled="false" + dslv:drag_enabled="true" + dslv:drag_handle_id="@id/drag_handle" dslv:drag_scroll_start="0.33" dslv:float_alpha="0.6" dslv:max_drag_scroll_speed="0.5" @@ -49,4 +50,18 @@ tools:layout_height="64dp" 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>
\ No newline at end of file |