mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-21 13:54:34 +01:00
Allow deleting tag by holding (#7565)
This commit is contained in:
parent
8285cafa63
commit
fd72f86417
@ -2,6 +2,7 @@ package de.danoeh.antennapod.ui.screen.drawer;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
@ -32,7 +33,10 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.EpisodeCleanupAlgorithmFactory;
|
||||
import de.danoeh.antennapod.storage.database.DBWriter;
|
||||
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.ui.screen.subscriptions.FeedMenuHandler;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@ -204,6 +208,25 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.rename_folder_item) {
|
||||
new RenameFeedDialog(getActivity(), drawerItem).show();
|
||||
return true;
|
||||
} else if (itemId == R.id.delete_folder_item) {
|
||||
ConfirmationDialog dialog = new ConfirmationDialog(
|
||||
getContext(), R.string.delete_tag_label,
|
||||
getString(R.string.delete_tag_confirmation, drawerItem.getTitle())) {
|
||||
|
||||
@Override
|
||||
public void onConfirmButtonPressed(DialogInterface dialog) {
|
||||
List<NavDrawerData.DrawerItem> feeds = ((NavDrawerData.TagDrawerItem) drawerItem).getChildren();
|
||||
|
||||
for (NavDrawerData.DrawerItem feed : feeds) {
|
||||
FeedPreferences preferences = ((NavDrawerData.FeedDrawerItem) feed).feed.getPreferences();
|
||||
preferences.getTags().remove(drawerItem.getTitle());
|
||||
DBWriter.setFeedPreferences(preferences);
|
||||
}
|
||||
}
|
||||
};
|
||||
dialog.createNewDialog().show();
|
||||
|
||||
return true;
|
||||
}
|
||||
return super.onContextItemSelected(item);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.danoeh.antennapod.ui.screen.subscriptions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -20,6 +21,9 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.storage.database.DBWriter;
|
||||
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.ui.screen.AddFeedFragment;
|
||||
import de.danoeh.antennapod.ui.screen.SearchFragment;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager;
|
||||
@ -348,9 +352,30 @@ public class SubscriptionFragment extends Fragment
|
||||
return false;
|
||||
}
|
||||
int itemId = item.getItemId();
|
||||
if (drawerItem.type == NavDrawerData.DrawerItem.Type.TAG && itemId == R.id.rename_folder_item) {
|
||||
new RenameFeedDialog(getActivity(), drawerItem).show();
|
||||
return true;
|
||||
if (drawerItem.type == NavDrawerData.DrawerItem.Type.TAG) {
|
||||
if (itemId == R.id.rename_folder_item) {
|
||||
new RenameFeedDialog(getActivity(), drawerItem).show();
|
||||
return true;
|
||||
} else if (itemId == R.id.delete_folder_item) {
|
||||
ConfirmationDialog dialog = new ConfirmationDialog(
|
||||
getContext(), R.string.delete_tag_label,
|
||||
getString(R.string.delete_tag_confirmation, drawerItem.getTitle())) {
|
||||
|
||||
@Override
|
||||
public void onConfirmButtonPressed(DialogInterface dialog) {
|
||||
List<NavDrawerData.DrawerItem> feeds = ((NavDrawerData.TagDrawerItem) drawerItem).getChildren();
|
||||
|
||||
for (NavDrawerData.DrawerItem feed : feeds) {
|
||||
FeedPreferences preferences = ((NavDrawerData.FeedDrawerItem) feed).feed.getPreferences();
|
||||
preferences.getTags().remove(drawerItem.getTitle());
|
||||
DBWriter.setFeedPreferences(preferences);
|
||||
}
|
||||
}
|
||||
};
|
||||
dialog.createNewDialog().show();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Feed feed = ((NavDrawerData.FeedDrawerItem) drawerItem).feed;
|
||||
|
@ -4,4 +4,8 @@
|
||||
android:id="@+id/rename_folder_item"
|
||||
android:menuCategory="container"
|
||||
android:title="@string/rename_tag_label" />
|
||||
<item
|
||||
android:id="@+id/delete_folder_item"
|
||||
android:menuCategory="container"
|
||||
android:title="@string/delete_tag_label" />
|
||||
</menu>
|
@ -213,6 +213,8 @@
|
||||
<string name="edit_tags">Edit tags</string>
|
||||
<string name="add_tag">Add tag</string>
|
||||
<string name="rename_tag_label">Rename tag</string>
|
||||
<string name="delete_tag_label">Delete tag</string>
|
||||
<string name="delete_tag_confirmation">Please confirm that you want to delete the tag \"%1$s\".</string>
|
||||
<string name="confirm_mobile_feed_refresh_dialog_message">Refreshing podcasts over mobile data connection is disabled in the settings.\n\nDo you want to refresh anyway?</string>
|
||||
<string name="confirm_mobile_feed_refresh_dialog_message_vpn">Your VPN app pretends to be a mobile network (metered connection). Refreshing podcasts over mobile data connection is disabled in the settings.\n\nDo you want to refresh anyway? If you want this problem to be fixed, contact the creators of your VPN app.</string>
|
||||
<string name="delete_downloads_played">Delete played</string>
|
||||
|
Loading…
Reference in New Issue
Block a user