diff options
author | ByteHamster <info@bytehamster.com> | 2022-01-03 14:26:56 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-01-03 14:26:56 +0100 |
commit | 413df734953dbfbaffac312745f7a467c3ec41ff (patch) | |
tree | c1045571d718d65cdd2144751f409073effb9c41 /core/src | |
parent | 9e42e103a902b4da411a1d737f0fd97d40df64ce (diff) | |
parent | 83f564ffcae24fe2ee56303b6b09e963948d18bf (diff) | |
download | AntennaPod-413df734953dbfbaffac312745f7a467c3ec41ff.zip |
Merge branch 'master' into develop
Diffstat (limited to 'core/src')
9 files changed, 170 insertions, 47 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 22378e01a..805956094 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -1529,8 +1529,8 @@ public class PlaybackService extends MediaBrowserServiceCompat { */ private void pauseIfPauseOnDisconnect() { Log.d(TAG, "pauseIfPauseOnDisconnect()"); + transientPause = (mediaPlayer.getPlayerStatus() == PlayerStatus.PLAYING); if (UserPreferences.isPauseOnHeadsetDisconnect() && !isCasting()) { - transientPause = true; mediaPlayer.pause(!UserPreferences.isPersistNotify(), false); } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java index 2cb99559a..412914329 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java @@ -354,42 +354,13 @@ public final class DBTasks { */ private static FeedItem searchFeedItemGuessDuplicate(List<FeedItem> items, FeedItem searchItem) { for (FeedItem item : items) { - if ((item.getMedia() != null) - && (searchItem.getMedia() != null) - && !TextUtils.isEmpty(item.getMedia().getStreamUrl()) - && !TextUtils.isEmpty(searchItem.getMedia().getStreamUrl()) - && TextUtils.equals(item.getMedia().getStreamUrl(), searchItem.getMedia().getStreamUrl())) { + if (FeedItemDuplicateGuesser.seemDuplicates(item, searchItem)) { return item; - } else if (titlesLookSimilar(item.getTitle(), searchItem.getTitle())) { - if (searchItem.getPubDate() == null || item.getPubDate() == null) { - continue; - } - long dateOriginal = item.getPubDate().getTime(); - long dateNew = searchItem.getPubDate().getTime(); - if (Math.abs(dateOriginal - dateNew) < 7L * 24L * 3600L * 1000L) { // Same week - return item; - } } } return null; } - private static boolean titlesLookSimilar(String title1, String title2) { - if (TextUtils.isEmpty(title1) || TextUtils.isEmpty(title2)) { - return false; - } - return canonicalizeTitle(title1).equals(canonicalizeTitle(title2)); - } - - private static String canonicalizeTitle(String title) { - return title - .trim() - .replace('“', '"') - .replace('”', '"') - .replace('„', '"') - .replace('—', '-'); - } - /** * Adds new Feeds to the database or updates the old versions if they already exists. If another Feed with the same * identifying value already exists, this method will add new FeedItems from the new Feed to the existing Feed. diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedItemDuplicateGuesser.java b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedItemDuplicateGuesser.java new file mode 100644 index 000000000..35d77ae4a --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedItemDuplicateGuesser.java @@ -0,0 +1,70 @@ +package de.danoeh.antennapod.core.storage; + +import android.text.TextUtils; +import de.danoeh.antennapod.model.feed.FeedItem; +import de.danoeh.antennapod.model.feed.FeedMedia; + +import java.text.DateFormat; +import java.util.Locale; + +/** + * Publishers sometimes mess up their feed by adding episodes twice or by changing the ID of existing episodes. + * This class tries to guess if publishers actually meant another episode, + * even if their feed explicitly says that the episodes are different. + */ +public class FeedItemDuplicateGuesser { + public static boolean seemDuplicates(FeedItem item1, FeedItem item2) { + if (sameAndNotEmpty(item1.getItemIdentifier(), item2.getItemIdentifier())) { + return true; + } + FeedMedia media1 = item1.getMedia(); + FeedMedia media2 = item2.getMedia(); + if (media1 == null || media2 == null) { + return false; + } + if (sameAndNotEmpty(media1.getStreamUrl(), media2.getStreamUrl())) { + return true; + } + return titlesLookSimilar(item1, item2) + && datesLookSimilar(item1, item2) + && durationsLookSimilar(media1, media2) + && TextUtils.equals(media1.getMime_type(), media2.getMime_type()); + } + + private static boolean sameAndNotEmpty(String string1, String string2) { + if (TextUtils.isEmpty(string1) || TextUtils.isEmpty(string2)) { + return false; + } + return string1.equals(string2); + } + + private static boolean datesLookSimilar(FeedItem item1, FeedItem item2) { + if (item1.getPubDate() == null || item2.getPubDate() == null) { + return false; + } + DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); // MM/DD/YY + String dateOriginal = dateFormat.format(item2.getPubDate()); + String dateNew = dateFormat.format(item1.getPubDate()); + return TextUtils.equals(dateOriginal, dateNew); // Same date; time is ignored. + } + + private static boolean durationsLookSimilar(FeedMedia media1, FeedMedia media2) { + return Math.abs(media1.getDuration() - media2.getDuration()) < 10 * 60L * 1000L; + } + + private static boolean titlesLookSimilar(FeedItem item1, FeedItem item2) { + return sameAndNotEmpty(canonicalizeTitle(item1.getTitle()), canonicalizeTitle(item2.getTitle())); + } + + private static String canonicalizeTitle(String title) { + if (title == null) { + return ""; + } + return title + .trim() + .replace('“', '"') + .replace('”', '"') + .replace('„', '"') + .replace('—', '-'); + } +} diff --git a/core/src/main/res/values-ast/strings.xml b/core/src/main/res/values-ast/strings.xml index d26ff2455..53df745ac 100644 --- a/core/src/main/res/values-ast/strings.xml +++ b/core/src/main/res/values-ast/strings.xml @@ -26,6 +26,7 @@ <string name="download_statistics_label">Descargues</string> <string name="notification_pref_fragment">Avisos</string> <!--Google Assistant--> + <string name="app_action_not_found">Nun s\'atopó «%1$s»</string> <!--SwipeActions--> <string name="swipeactions_label">Aiciones al eslizar</string> <string name="swipeactions_summary">Escueyi qué asocede al eslizar un episodiu que tea nuna llista</string> @@ -574,6 +575,7 @@ <string name="sort_old_new">Vieyo \u2192 Nuevo</string> <!--Rating dialog--> <string name="rating_title" tools:ignore="UnusedResources">¿Préstate AntennaPod?</string> + <string name="rating_message" tools:ignore="UnusedResources">Agradecemos que valores AntennaPod, si tienes tiempu.</string> <string name="rating_never_label" tools:ignore="UnusedResources">Non, nin</string> <string name="rating_later_label" tools:ignore="UnusedResources">Recordámelo dempués</string> <string name="rating_now_label" tools:ignore="UnusedResources">Sí, ho</string> diff --git a/core/src/main/res/values-br/strings.xml b/core/src/main/res/values-br/strings.xml index 5f9257611..b6ba9acf4 100644 --- a/core/src/main/res/values-br/strings.xml +++ b/core/src/main/res/values-br/strings.xml @@ -29,6 +29,12 @@ <!--Google Assistant--> <string name="app_action_not_found">N\'eo ket bet kavet \"%1$s\"</string> <!--SwipeActions--> + <string name="swipeactions_label">Gwezhiadoù Lamprañ</string> + <string name="swipeactions_summary">Dibab petra c\'hoarvez pa vez riklet un degouezh el listenn </string> + <string name="swipe_right">Lamprañ Dehoù</string> + <string name="swipe_left">Lamprañ Gleizh</string> + <string name="enable_swipeactions">Kas war-raok an ober dre al lamprañ evit ar skramm-mañ</string> + <string name="change_setting">Cheñch</string> <!--Statistics fragment--> <string name="total_time_listened_to_podcasts">Padelezh ar rannoù lennet:</string> <string name="statistics_details_dialog">%1$d war %2$d rann kroget.\n\nLennet %3$s war %4$s.</string> @@ -90,6 +96,7 @@ <string name="auto_download_label">Pellgargañ emgefreek</string> <string name="auto_delete_label">Dilemel ar rannoù ent emgefreek</string> <string name="feed_volume_reduction">Izelaat an ampled</string> + <string name="feed_volume_reduction_summary">Lakaat da vann ar son evit an degouezh-mañ eus ar podskign-mañ: %1$s</string> <string name="feed_volume_reduction_off">hini ebet</string> <string name="feed_volume_reduction_light">izel</string> <string name="feed_volume_reduction_heavy">pounner</string> @@ -160,6 +167,7 @@ <string name="share_website_url_label">Ere al lec\'hienn</string> <string name="share_feed_url_label">Ere ar podskignad</string> <string name="feed_delete_confirmation_msg">Kadarnait e fell deoc\'h dilemel ar podskignad \"%1$s\" hag e holl rannoù pellgarget.</string> + <string name="feed_delete_confirmation_msg_batch">Mar-plij, kadarn ez peus c\'hoant lemel kuit ar podskign dibabed hag an hollad a degouezhioù (o kontañ ar re bellgarged)</string> <string name="feed_delete_confirmation_local_msg">Kadarnait e fell deoc\'h dilemel ar podskignad \"%1$s\". Ne vo ket dilamet ar restroù e-barzh an teuliad lec\'hel.</string> <string name="feed_remover_msg">O tilemel ar podskignad</string> <string name="load_complete_feed">Hizivaat ar podskignad a-bezh</string> @@ -171,6 +179,7 @@ <string name="open_podcast">Digeriñ ar podskignad</string> <string name="please_wait_for_data">Gortozit dibenn pellgargadur ar roadennoù</string> <string name="updates_disabled_label">Diweredekaet eo bet an hizivadennoù</string> + <string name="add_to_folder">Ouzhpennañ er restr</string> <!--actions on feeditems--> <string name="download_label">Pellgargañ</string> <plurals name="downloading_batch_label"> @@ -196,6 +205,8 @@ <string name="remove_new_flag_label">Tennañ ar merk \"nevez\"</string> <string name="removed_new_flag_label">Tennet eo bet ar merk \"nevez\"</string> <string name="mark_read_label">Merkañ evel lennet</string> + <string name="marked_as_played_label">Lakaet war-well evel lennet</string> + <string name="marked_as_unplayed_label">Lakaet war-well evel lakaet da baouez</string> <string name="mark_read_no_media_label">Merkañ evel lennet</string> <string name="play_this_to_seek_position">Evit kemmañ al lec\'hiadur e rankit lenn ar rann</string> <plurals name="marked_read_batch_label"> @@ -274,6 +285,7 @@ <item quantity="many">%d a bellgargadurioù a chom</item> <item quantity="other">%d pellgargadur a chom</item> </plurals> + <string name="completing">O ouzhpennañ...</string> <string name="download_notification_title">O pellgargañ roadennoù ar podskignad</string> <string name="download_log_title_unknown">Titl dianav</string> <string name="download_type_feed">Lanv</string> @@ -549,6 +561,7 @@ <string name="licenses_summary">AntennaPod a ra gant meziantoù all</string> <!--Search--> <string name="search_status_no_results">N\'eus bet kavet disoc\'h ebet</string> + <string name="type_to_search">Ouzhpennan ur reked evit klask</string> <string name="search_label">Klask</string> <string name="no_results_for_query">N\'eus bet kavet disoc\'h ebet evit \"%1$s\"</string> <!--Synchronization--> diff --git a/core/src/main/res/values-ko/strings.xml b/core/src/main/res/values-ko/strings.xml index bd838ae96..c15ee70f5 100644 --- a/core/src/main/res/values-ko/strings.xml +++ b/core/src/main/res/values-ko/strings.xml @@ -13,6 +13,7 @@ <string name="new_label">최신</string> <string name="settings_label">설정</string> <string name="downloads_label">다운로드</string> + <string name="open_autodownload_settings">설정 열기</string> <string name="downloads_completed_label">완료</string> <string name="downloads_log_label">기록</string> <string name="subscriptions_label">구독</string> diff --git a/core/src/main/res/values-ru/strings.xml b/core/src/main/res/values-ru/strings.xml index 0a5db8d1e..0c11dfaa9 100644 --- a/core/src/main/res/values-ru/strings.xml +++ b/core/src/main/res/values-ru/strings.xml @@ -615,19 +615,19 @@ <string name="time_minutes">мин</string> <string name="time_hours">ч</string> <plurals name="time_seconds_quantified"> - <item quantity="one">1 секунда</item> + <item quantity="one">%d секунда</item> <item quantity="few">%d секунды</item> <item quantity="many">%d секунд</item> <item quantity="other">%d секунды</item> </plurals> <plurals name="time_minutes_quantified"> - <item quantity="one">1 минута</item> + <item quantity="one">%d минута</item> <item quantity="few">%d минуты</item> <item quantity="many">%d минут</item> <item quantity="other">%d минуты</item> </plurals> <plurals name="time_hours_quantified"> - <item quantity="one">1 час</item> + <item quantity="one">%d час</item> <item quantity="few">%d часа</item> <item quantity="many">%d часов</item> <item quantity="other">%d часа</item> diff --git a/core/src/main/res/values-sv/strings.xml b/core/src/main/res/values-sv/strings.xml index 659bd1c2e..b77439c5a 100644 --- a/core/src/main/res/values-sv/strings.xml +++ b/core/src/main/res/values-sv/strings.xml @@ -10,7 +10,7 @@ <string name="all_episodes_short_label">Alla</string> <string name="new_episodes_label">Nytt</string> <string name="favorite_episodes_label">Favoriter</string> - <string name="new_label">Nya</string> + <string name="new_label">Ny</string> <string name="settings_label">Inställningar</string> <string name="downloads_label">Nedladdningar</string> <string name="open_autodownload_settings">Öppna Inställningar</string> @@ -21,7 +21,7 @@ <string name="cancel_download_label">Avbryt nedladdning</string> <string name="playback_history_label">Uppspelningshistorik</string> <string name="gpodnet_main_label">gpodder.net</string> - <string name="episode_cache_full_title">Episodcachen är full</string> + <string name="episode_cache_full_title">Episod-cachen är full</string> <string name="episode_cache_full_message">Episodcachens gräns har nåtts. Du kan öka cachens storlek i inställningarna.</string> <string name="playback_statistics_label">Uppspelning</string> <string name="download_statistics_label">Nedladdningar</string> @@ -31,8 +31,8 @@ <!--SwipeActions--> <string name="swipeactions_label">Svepåtgärder</string> <string name="swipeactions_summary">Välj vad som händer när du sveper över en episod i en lista</string> - <string name="swipe_right">Svepning Höger</string> - <string name="swipe_left">Svepning Vänster</string> + <string name="swipe_right">Svepning höger</string> + <string name="swipe_left">Svepning vänster</string> <string name="enable_swipeactions">Aktivera svepåtgärder för denna skärm</string> <string name="change_setting">Ändra</string> <!--Statistics fragment--> @@ -79,7 +79,7 @@ <string name="no">Nej</string> <string name="reset">Återställ</string> <string name="url_label">URL</string> - <string name="support_funding_label">Support</string> + <string name="support_funding_label">Stöd</string> <string name="support_podcast">Stöd denna Podcast</string> <string name="error_label">Fel</string> <string name="error_msg_prefix">Ett fel inträffade:</string> @@ -88,13 +88,13 @@ <string name="chapters_label">Kapitel</string> <string name="chapter_duration">Längd: %1$s</string> <string name="description_label">Beskrivning</string> - <string name="shownotes_label">Avsnittsanteckningar<br></string> + <string name="shownotes_label">Avsnittsanteckningar</string> <string name="shownotes_contentdescription">svep upp för att läsa avsnittsanteckningar</string> <string name="episodes_suffix">\u0020episoder</string> <string name="close_label">Stäng</string> <string name="retry_label">Försök igen</string> <string name="auto_download_label">Inkludera i automatiska nedladdningar</string> - <string name="auto_delete_label">Automatisk episodborttagning</string> + <string name="auto_delete_label">Automatisk episodränsning</string> <string name="feed_volume_reduction">Volymreducering</string> <string name="feed_volume_reduction_summary">Sänk volymen för episoder av denna podcast: %1$s</string> <string name="feed_volume_reduction_off">Av</string> @@ -133,7 +133,7 @@ <item quantity="other">%2$s har %1$d nya episoder</item> </plurals> <plurals name="new_episode_notification_title"> - <item quantity="one">Nya Episoder</item> + <item quantity="one">Ny episod</item> <item quantity="other">Nya episoder</item> </plurals> <string name="new_episode_notification_group_text">Dina prenumerationer har nya episoder.</string> @@ -141,10 +141,10 @@ <string name="mark_all_read_label">Markera alla som spelade</string> <string name="mark_all_read_msg">Markera alla episoder som spelade</string> <string name="mark_all_read_confirmation_msg">Bekräfta att du verkligen vill markera alla episoder som spelade.</string> - <string name="mark_all_read_feed_confirmation_msg">Bekräfta att du vill markera alla episider i denna podcast som spelade.</string> + <string name="mark_all_read_feed_confirmation_msg">Bekräfta att du verkligen vill markera alla episider i denna podcast som spelade.</string> <string name="remove_all_new_flags_label">Ta bort alla \"ny\"-flaggor</string> <string name="removed_all_new_flags_msg">Tog bort alla \"ny\"-flaggor</string> - <string name="remove_all_new_flags_confirmation_msg">Bekräfta att du vill ta bort alla \"ny\"-flaggor från alla episoder.</string> + <string name="remove_all_new_flags_confirmation_msg">Bekräfta att du verkligen vill ta bort alla \"ny\"-flaggor från alla episoder.</string> <string name="show_info_label">Visa information</string> <string name="show_feed_settings_label">Visa podcastinställningar</string> <string name="feed_settings_label">Podcastinställningar</string> @@ -194,7 +194,7 @@ <string name="mark_read_label">Markera som spelad</string> <string name="marked_as_played_label">Markera som spelad</string> <string name="marked_as_unplayed_label">Markera som ospelad</string> - <string name="mark_read_no_media_label">Markera som spelad</string> + <string name="mark_read_no_media_label">Markera som läst</string> <string name="play_this_to_seek_position">Spela episoden för att kunna hoppa till olika positioner</string> <plurals name="marked_read_batch_label"> <item quantity="one">1%d episod markerad som spelad.</item> @@ -207,7 +207,7 @@ <item quantity="other">1%d episoder markerade som ospelade.</item> </plurals> <string name="add_to_queue_label">Lägg till i kön</string> - <string name="added_to_queue_label">Lägg till i Kö</string> + <string name="added_to_queue_label">Tillagd i kön</string> <plurals name="added_to_queue_batch_label"> <item quantity="one">1%d episod tillagd i kön.</item> <item quantity="other">1%d episoder tillagda i kön.</item> @@ -288,7 +288,7 @@ <string name="error_file_not_found">Filen hittades inte</string> <string name="no_media_label">Artikeln innehåller ingen mediafil</string> <!--Queue operations--> - <string name="lock_queue">Lås Kön</string> + <string name="lock_queue">Lås kön</string> <string name="queue_locked">Kön låst</string> <string name="queue_unlocked">Kön upplåst</string> <string name="queue_lock_warning">Om du låser kön kan du inte längre svepa eller ordna om episoder.</string> diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/FeedItemDuplicateGuesserTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/FeedItemDuplicateGuesserTest.java new file mode 100644 index 000000000..ac7cdee1f --- /dev/null +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/FeedItemDuplicateGuesserTest.java @@ -0,0 +1,66 @@ +package de.danoeh.antennapod.core.storage; + +import de.danoeh.antennapod.model.feed.FeedItem; +import de.danoeh.antennapod.model.feed.FeedMedia; +import org.junit.Test; + +import java.util.Date; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Test class for {@link FeedItemDuplicateGuesser}. + */ +public class FeedItemDuplicateGuesserTest { + private static final long MINUTES = 1000 * 60; + private static final long DAYS = 24 * 60 * MINUTES; + + @Test + public void testSameId() { + assertTrue(FeedItemDuplicateGuesser.seemDuplicates( + item("id", "Title1", "example.com/episode1", 0, 5 * MINUTES, "audio/*"), + item("id", "Title2", "example.com/episode2", 0, 20 * MINUTES, "video/*"))); + } + + @Test + public void testDuplicateDownloadUrl() { + assertTrue(FeedItemDuplicateGuesser.seemDuplicates( + item("id1", "Title1", "example.com/episode", 0, 5 * MINUTES, "audio/*"), + item("id2", "Title2", "example.com/episode", 0, 5 * MINUTES, "audio/*"))); + assertFalse(FeedItemDuplicateGuesser.seemDuplicates( + item("id1", "Title1", "example.com/episode1", 0, 5 * MINUTES, "audio/*"), + item("id2", "Title2", "example.com/episode2", 0, 5 * MINUTES, "audio/*"))); + } + + @Test + public void testOtherAttributes() { + assertTrue(FeedItemDuplicateGuesser.seemDuplicates( + item("id1", "Title", "example.com/episode1", 10, 5 * MINUTES, "audio/*"), + item("id2", "Title", "example.com/episode2", 10, 5 * MINUTES, "audio/*"))); + assertTrue(FeedItemDuplicateGuesser.seemDuplicates( + item("id1", "Title", "example.com/episode1", 10, 5 * MINUTES, "audio/*"), + item("id2", "Title", "example.com/episode2", 20, 6 * MINUTES, "audio/*"))); + assertFalse(FeedItemDuplicateGuesser.seemDuplicates( + item("id1", "Title", "example.com/episode1", 10, 5 * MINUTES, "audio/*"), + item("id2", "Title", "example.com/episode2", 10, 5 * MINUTES, "video/*"))); + assertFalse(FeedItemDuplicateGuesser.seemDuplicates( + item("id1", "Title", "example.com/episode1", 5 * DAYS, 5 * MINUTES, "audio/*"), + item("id2", "Title", "example.com/episode2", 2 * DAYS, 5 * MINUTES, "audio/*"))); + } + + @Test + public void testNoMediaType() { + assertTrue(FeedItemDuplicateGuesser.seemDuplicates( + item("id1", "Title", "example.com/episode1", 2 * DAYS, 5 * MINUTES, ""), + item("id2", "Title", "example.com/episode2", 2 * DAYS, 5 * MINUTES, ""))); + } + + private FeedItem item(String guid, String title, String downloadUrl, + long date, long duration, String mime) { + FeedItem item = new FeedItem(0, title, guid, "link", new Date(date), FeedItem.PLAYED, null); + FeedMedia media = new FeedMedia(item, downloadUrl, duration, mime); + item.setMedia(media); + return item; + } +}
\ No newline at end of file |