use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class PlaybackVolumeUpdaterTest method updatesPreferencesAndForcesVolumeChangeForLoadedFeedMediaIfPlayerStatusIsPlaying.
@Test
public void updatesPreferencesAndForcesVolumeChangeForLoadedFeedMediaIfPlayerStatusIsPlaying() {
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PLAYING);
FeedMedia feedMedia = mockFeedMedia();
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
FeedPreferences feedPreferences = feedMedia.getItem().getFeed().getPreferences();
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.HEAVY_REDUCTION);
verify(feedPreferences, times(1)).setVolumeAdaptionSetting(VolumeAdaptionSetting.HEAVY_REDUCTION);
verify(mediaPlayer, times(1)).pause(false, false);
verify(mediaPlayer, times(1)).resume();
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class TagSettingsDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
ArrayList<FeedPreferences> feedPreferencesList = (ArrayList<FeedPreferences>) getArguments().getSerializable(ARG_FEED_PREFERENCES);
Set<String> commonTags = new HashSet<>(feedPreferencesList.get(0).getTags());
for (FeedPreferences preference : feedPreferencesList) {
commonTags.retainAll(preference.getTags());
}
displayedTags = new ArrayList<>(commonTags);
displayedTags.remove(FeedPreferences.TAG_ROOT);
viewBinding = EditTagsDialogBinding.inflate(getLayoutInflater());
viewBinding.tagsRecycler.setLayoutManager(new GridLayoutManager(getContext(), 2));
viewBinding.tagsRecycler.addItemDecoration(new ItemOffsetDecoration(getContext(), 4));
adapter = new TagSelectionAdapter();
adapter.setHasStableIds(true);
viewBinding.tagsRecycler.setAdapter(adapter);
viewBinding.rootFolderCheckbox.setChecked(commonTags.contains(FeedPreferences.TAG_ROOT));
viewBinding.newTagButton.setOnClickListener(v -> addTag(viewBinding.newTagEditText.getText().toString().trim()));
loadTags();
viewBinding.newTagEditText.setThreshold(1);
viewBinding.newTagEditText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
viewBinding.newTagEditText.showDropDown();
viewBinding.newTagEditText.requestFocus();
return false;
}
});
if (feedPreferencesList.size() > 1) {
viewBinding.commonTagsInfo.setVisibility(View.VISIBLE);
}
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
dialog.setView(viewBinding.getRoot());
dialog.setTitle(R.string.feed_tags_label);
dialog.setPositiveButton(android.R.string.ok, (d, input) -> {
addTag(viewBinding.newTagEditText.getText().toString().trim());
updatePreferencesTags(feedPreferencesList, commonTags);
});
dialog.setNegativeButton(R.string.cancel_label, null);
return dialog.create();
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class TagSettingsDialog method updatePreferencesTags.
private void updatePreferencesTags(List<FeedPreferences> feedPreferencesList, Set<String> commonTags) {
if (viewBinding.rootFolderCheckbox.isChecked()) {
displayedTags.add(FeedPreferences.TAG_ROOT);
}
for (FeedPreferences preferences : feedPreferencesList) {
preferences.getTags().removeAll(commonTags);
preferences.getTags().addAll(displayedTags);
DBWriter.setFeedPreferences(preferences);
}
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class DownloadAuthenticationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTranslucentTheme());
super.onCreate(savedInstanceState);
Validate.isTrue(getIntent().hasExtra(ARG_DOWNLOAD_REQUEST), "Download request missing");
DownloadRequest request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST);
new AuthenticationDialog(this, R.string.authentication_label, true, "", "") {
@Override
protected void onConfirmed(String username, String password) {
Completable.fromAction(() -> {
request.setUsername(username);
request.setPassword(password);
if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
long mediaId = request.getFeedfileId();
FeedMedia media = DBReader.getFeedMedia(mediaId);
if (media != null) {
FeedPreferences preferences = media.getItem().getFeed().getPreferences();
if (TextUtils.isEmpty(preferences.getPassword()) || TextUtils.isEmpty(preferences.getUsername())) {
preferences.setUsername(username);
preferences.setPassword(password);
DBWriter.setFeedPreferences(preferences);
}
}
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(() -> {
DownloadService.download(DownloadAuthenticationActivity.this, false, request);
finish();
});
}
@Override
protected void onCancelled() {
finish();
}
}.show();
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class RenameItemDialog method renameTag.
private void renameTag(String title) {
if (NavDrawerData.DrawerItem.Type.TAG == drawerItem.type) {
List<FeedPreferences> feedPreferences = new ArrayList<>();
for (NavDrawerData.DrawerItem item : ((NavDrawerData.TagDrawerItem) drawerItem).children) {
feedPreferences.add(((NavDrawerData.FeedDrawerItem) item).feed.getPreferences());
}
for (FeedPreferences preferences : feedPreferences) {
preferences.getTags().remove(drawerItem.getTitle());
preferences.getTags().add(title);
DBWriter.setFeedPreferences(preferences);
}
}
}
Aggregations