diff options
Diffstat (limited to 'app')
8 files changed, 77 insertions, 3 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java b/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java index 78b807710..d02efa521 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java @@ -44,7 +44,7 @@ public class DBTestUtils { PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); for (int i = 0; i < numFeeds; i++) { - Feed f = new Feed(0, null, "feed " + i, "link" + i, "descr", null, null, + Feed f = new Feed(0, null, "feed " + i, null, "link" + i, "descr", null, null, null, null, "id" + i, null, null, "url" + i, false, new FlattrStatus(), false, null, null, false); f.setItems(new ArrayList<>()); for (int j = 0; j < numItems; j++) { 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 1e03f99fa..41ed963c2 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -54,6 +54,7 @@ import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.Flavors; import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.dialog.RatingDialog; +import de.danoeh.antennapod.dialog.RenameFeedDialog; import de.danoeh.antennapod.fragment.AddFeedFragment; import de.danoeh.antennapod.fragment.DownloadsFragment; import de.danoeh.antennapod.fragment.EpisodesFragment; @@ -577,6 +578,9 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi case R.id.mark_all_read_item: DBWriter.markFeedRead(feed.getId()); return true; + case R.id.rename_item: + new RenameFeedDialog(this, feed).show(); + return true; case R.id.remove_item: final FeedRemover remover = new FeedRemover(this, feed) { @Override diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerInfoActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerInfoActivity.java index 4a24f0329..51afe1ef7 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerInfoActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerInfoActivity.java @@ -49,6 +49,7 @@ import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.playback.Playable; import de.danoeh.antennapod.core.util.playback.PlaybackController; +import de.danoeh.antennapod.dialog.RenameFeedDialog; import de.danoeh.antennapod.fragment.AddFeedFragment; import de.danoeh.antennapod.fragment.ChaptersFragment; import de.danoeh.antennapod.fragment.CoverFragment; @@ -374,6 +375,9 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem case R.id.mark_all_read_item: DBWriter.markFeedRead(feed.getId()); return true; + case R.id.rename_item: + new RenameFeedDialog(this, feed).show(); + return true; case R.id.remove_item: final FeedRemover remover = new FeedRemover(this, feed) { @Override diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java new file mode 100644 index 000000000..31a544582 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java @@ -0,0 +1,44 @@ +package de.danoeh.antennapod.dialog; + +import android.app.Activity; +import android.text.InputType; + +import com.afollestad.materialdialogs.MaterialDialog; + +import java.lang.ref.WeakReference; + +import de.danoeh.antennapod.core.feed.Feed; +import de.danoeh.antennapod.core.storage.DBWriter; + +public class RenameFeedDialog { + + private final WeakReference<Activity> activityRef; + private final Feed feed; + + public RenameFeedDialog(Activity activity, Feed feed) { + this.activityRef = new WeakReference<>(activity); + this.feed = feed; + } + + public void show() { + Activity activity = activityRef.get(); + if(activity == null) { + return; + } + new MaterialDialog.Builder(activity) + .title(de.danoeh.antennapod.core.R.string.rename_feed_label) + .inputType(InputType.TYPE_CLASS_TEXT) + .input(feed.getTitle(), feed.getTitle(), true, (dialog, input) -> { + feed.setCustomTitle(input.toString()); + DBWriter.setFeedCustomTitle(feed); + dialog.dismiss(); + }) + .neutralText(de.danoeh.antennapod.core.R.string.reset) + .onNeutral((dialog, which) -> dialog.getInputEditText().setText(feed.getFeedTitle())) + .negativeText(de.danoeh.antennapod.core.R.string.cancel_label) + .onNegative((dialog, which) -> dialog.dismiss()) + .autoDismiss(false) + .show(); + } + +} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 13f5481e9..2b5a7390b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -67,6 +67,7 @@ import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil; import de.danoeh.antennapod.dialog.EpisodesApplyActionFragment; +import de.danoeh.antennapod.dialog.RenameFeedDialog; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; import de.danoeh.antennapod.menuhandler.FeedMenuHandler; import de.danoeh.antennapod.menuhandler.MenuItemUtils; @@ -106,6 +107,7 @@ public class ItemlistFragment extends ListFragment { private boolean isUpdatingFeed; + private TextView txtvTitle; private IconTextView txtvFailure; private TextView txtvInformation; @@ -248,6 +250,9 @@ public class ItemlistFragment extends ListFragment { .newInstance(feed.getItems()); ((MainActivity)getActivity()).loadChildFragment(fragment); return true; + case R.id.rename_item: + new RenameFeedDialog(getActivity(), feed).show(); + return true; case R.id.remove_item: final FeedRemover remover = new FeedRemover( getActivity(), feed) { @@ -415,6 +420,7 @@ public class ItemlistFragment extends ListFragment { public void update(EventDistributor eventDistributor, Integer arg) { if ((EVENTS & arg) != 0) { Log.d(TAG, "Received contentUpdate Intent. arg " + arg); + refreshHeaderView(); loadItems(); updateProgressBarVisibility(); } @@ -469,6 +475,7 @@ public class ItemlistFragment extends ListFragment { } else { txtvFailure.setVisibility(View.GONE); } + txtvTitle.setText(feed.getTitle()); if(feed.getItemFilter() != null) { FeedItemFilter filter = feed.getItemFilter(); if(filter.getValues().length > 0) { @@ -498,7 +505,7 @@ public class ItemlistFragment extends ListFragment { View header = inflater.inflate(R.layout.feeditemlist_header, lv, false); lv.addHeaderView(header); - TextView txtvTitle = (TextView) header.findViewById(R.id.txtvTitle); + txtvTitle = (TextView) header.findViewById(R.id.txtvTitle); TextView txtvAuthor = (TextView) header.findViewById(R.id.txtvAuthor); ImageView imgvBackground = (ImageView) header.findViewById(R.id.imgvBackground); ImageView imgvCover = (ImageView) header.findViewById(R.id.imgvCover); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java index 3ddd5245a..01119bcff 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -26,6 +26,7 @@ import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.FeedItemUtil; +import de.danoeh.antennapod.dialog.RenameFeedDialog; import rx.Observable; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; @@ -102,7 +103,7 @@ public class SubscriptionFragment extends Fragment { if(subscription != null) { subscription.unsubscribe(); } - subscription = Observable.fromCallable(() -> DBReader.getNavDrawerData()) + subscription = Observable.fromCallable(DBReader::getNavDrawerData) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { @@ -164,6 +165,9 @@ public class SubscriptionFragment extends Fragment { .subscribe(result -> loadSubscriptions(), error -> Log.e(TAG, Log.getStackTraceString(error))); return true; + case R.id.rename_item: + new RenameFeedDialog(getActivity(), feed).show(); + return true; case R.id.remove_item: final FeedRemover remover = new FeedRemover(getContext(), feed) { @Override diff --git a/app/src/main/res/menu/feedlist.xml b/app/src/main/res/menu/feedlist.xml index ed03c08d6..0646dc70f 100644 --- a/app/src/main/res/menu/feedlist.xml +++ b/app/src/main/res/menu/feedlist.xml @@ -66,6 +66,12 @@ </item> <item + android:id="@+id/rename_item" + android:menuCategory="container" + android:title="@string/rename_feed_label" + custom:showAsAction="never" /> + + <item android:id="@+id/remove_item" android:icon="?attr/content_discard" android:menuCategory="container" diff --git a/app/src/main/res/menu/nav_feed_context.xml b/app/src/main/res/menu/nav_feed_context.xml index 4bf067d25..4da40441f 100644 --- a/app/src/main/res/menu/nav_feed_context.xml +++ b/app/src/main/res/menu/nav_feed_context.xml @@ -12,6 +12,11 @@ android:title="@string/mark_all_read_label" /> <item + android:id="@+id/rename_item" + android:menuCategory="container" + android:title="@string/rename_feed_label" /> + + <item android:id="@+id/remove_item" android:menuCategory="container" android:title="@string/remove_feed_label" /> |