Add "Remove all from inbox" to subscription overflow menu (#7252)

This commit is contained in:
André 2024-06-18 22:57:54 +02:00 committed by GitHub
parent 8da45100d4
commit ee3c1646f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
@ -22,6 +23,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
@ -257,6 +259,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
viewBinding.toolbar.getMenu().findItem(R.id.refresh_item).setVisible(false);
viewBinding.toolbar.getMenu().findItem(R.id.rename_item).setVisible(false);
viewBinding.toolbar.getMenu().findItem(R.id.remove_feed).setVisible(false);
viewBinding.toolbar.getMenu().findItem(R.id.remove_all_inbox_item).setVisible(false);
viewBinding.toolbar.getMenu().findItem(R.id.action_search).setVisible(false);
}
}
@ -303,6 +306,8 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
// Make sure fragment is hidden before actually starting to delete
getActivity().getSupportFragmentManager().executePendingTransactions();
});
} else if (item.getItemId() == R.id.remove_all_inbox_item) {
showRemoveAllDialog();
} else if (item.getItemId() == R.id.action_search) {
((MainActivity) getActivity()).loadChildFragment(SearchFragment.newInstance(feed.getId(), feed.getTitle()));
} else {
@ -555,6 +560,20 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
}
}
private void showRemoveAllDialog() {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
builder.setTitle(R.string.remove_all_inbox_label);
builder.setMessage(R.string.remove_all_inbox_confirmation_msg);
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
dialog.dismiss();
DBWriter.removeFeedNewFlag(feedID);
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.removed_all_inbox_msg, Toast.LENGTH_SHORT);
});
builder.setNegativeButton(R.string.cancel_label, null);
builder.show();
}
private void loadFeedImage() {
Glide.with(this)
.load(feed.getImageUrl())

View File

@ -42,6 +42,13 @@
custom:showAsAction="never"
android:title="@string/share_label" />
<item
android:id="@+id/remove_all_inbox_item"
android:title="@string/remove_all_inbox_label"
android:menuCategory="container"
custom:showAsAction="collapseActionView"
android:icon="@drawable/ic_check"/>
<item
android:id="@+id/rename_item"
android:menuCategory="container"
@ -57,4 +64,4 @@
custom:showAsAction="collapseActionView">
</item>
</menu>
</menu>