diff --git a/app/build.gradle b/app/build.gradle index 44565fa..47f694f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.github.kotvertolet.youtubeaudioplayer" minSdkVersion 19 targetSdkVersion 29 - versionCode 3 - versionName "1.1.2" + versionCode 4 + versionName "1.1.3" multiDexEnabled true vectorDrawables.useSupportLibrary = true } @@ -39,12 +39,12 @@ dependencies { // Core implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.preference:preference:1.1.0' + implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' // Support - implementation 'com.google.android.material:material:1.2.0-alpha05' + implementation 'com.google.android.material:material:1.3.0-alpha02' // Retrofit implementation "com.squareup.retrofit2:retrofit:2.7.2" @@ -86,6 +86,9 @@ dependencies { // Multidex implementation 'com.android.support:multidex:1.0.3' + // Ripple for API <21 + //implementation 'com.balysv:material-ripple:1.0.2' + // YoutubeJExtractor - implementation 'com.github.kotvertolet:youtube-jextractor:0.2.5' + implementation 'com.github.kotvertolet:youtube-jextractor:0.3.1' } \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/App.java b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/App.java index 0468c88..24b1ff8 100644 --- a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/App.java +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/App.java @@ -93,6 +93,11 @@ public void onCreate() { cachingTasksManager = new CachingTasksManager(); } + @Override + public void onTerminate() { + super.onTerminate(); + } + public DownloadNotificationHelper getDownloadNotificationHelper() { if (downloadNotificationHelper == null) { downloadNotificationHelper = diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/activities/splash/SplashActivity.java b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/activities/splash/SplashActivity.java index b7e3949..b392a21 100644 --- a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/activities/splash/SplashActivity.java +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/activities/splash/SplashActivity.java @@ -41,16 +41,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { utils = new CommonUtils(); sharedPreferences = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE); presenter = new SplashActivityPresenterImpl(this); - } - @Override - protected void onPostResume() { boolean noRecommendations = sharedPreferences.getBoolean(Constants.PREFERENCE_NO_RECOMMENDATIONS, false); if (noRecommendations) { presenter.loadRecents(new HashMap<>()); } else { presenter.loadYoutubeRecommendations(); } + } + + @Override + protected void onPostResume() { super.onPostResume(); } diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/PlaylistWithSongs.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/PlaylistWithSongs.kt new file mode 100644 index 0000000..c9600cc --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/PlaylistWithSongs.kt @@ -0,0 +1,16 @@ +package com.github.kotvertolet.youtubeaudioplayer.data + +import com.github.kotvertolet.youtubeaudioplayer.db.dto.PlaylistDto +import com.github.kotvertolet.youtubeaudioplayer.db.dto.YoutubeSongDto + +class PlaylistWithSongs { + var playlist: PlaylistDto? = null + var songs: List? = null + + constructor() + constructor(playlist: PlaylistDto?, songs: List?) { + this.playlist = playlist + this.songs = songs + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/ContentDetails.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/ContentDetails.kt new file mode 100644 index 0000000..f876d64 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/ContentDetails.kt @@ -0,0 +1,38 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class ContentDetails { + @SerializedName("duration") + var duration: String? = null + + @SerializedName("licensedContent") + var isLicensedContent = false + + @SerializedName("caption") + var caption: String? = null + + @SerializedName("definition") + var definition: String? = null + + @SerializedName("regionRestriction") + var regionRestriction: RegionRestriction? = null + + @SerializedName("projection") + var projection: String? = null + + @SerializedName("dimension") + var dimension: String? = null + + override fun toString(): String { + return "ContentDetails{" + + "duration = '" + duration + '\'' + + ",licensedContent = '" + isLicensedContent + '\'' + + ",caption = '" + caption + '\'' + + ",definition = '" + definition + '\'' + + ",regionRestriction = '" + regionRestriction + '\'' + + ",projection = '" + projection + '\'' + + ",dimension = '" + dimension + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/High.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/High.kt new file mode 100644 index 0000000..d8c1359 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/High.kt @@ -0,0 +1,22 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class High { + @SerializedName("width") + var width = 0 + + @SerializedName("url") + var url: String? = null + + @SerializedName("height") + var height = 0 + + override fun toString(): String { + return "High{" + + "width = '" + width + '\'' + + ",url = '" + url + '\'' + + ",height = '" + height + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Id.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Id.kt new file mode 100644 index 0000000..9392c21 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Id.kt @@ -0,0 +1,27 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Id { + @SerializedName("kind") + var kind: String? = null + + @SerializedName("videoId") + var videoId: String + + constructor(videoId: String) { + this.videoId = videoId + } + + constructor(kind: String?, videoId: String) { + this.kind = kind + this.videoId = videoId + } + + override fun toString(): String { + return "Id{" + + "kind = '" + kind + '\'' + + ",videoId = '" + videoId + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/JsonMemberDefault.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/JsonMemberDefault.kt new file mode 100644 index 0000000..3f30b6e --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/JsonMemberDefault.kt @@ -0,0 +1,22 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class JsonMemberDefault { + @SerializedName("width") + var width = 0 + + @SerializedName("url") + var url: String? = null + + @SerializedName("height") + var height = 0 + + override fun toString(): String { + return "JsonMemberDefault{" + + "width = '" + width + '\'' + + ",url = '" + url + '\'' + + ",height = '" + height + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Localized.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Localized.kt new file mode 100644 index 0000000..8d5de80 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Localized.kt @@ -0,0 +1,18 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Localized { + @SerializedName("description") + var description: String? = null + + @SerializedName("title") + var title: String? = null + + override fun toString(): String { + return "Localized{" + + "description = '" + description + '\'' + + ",title = '" + title + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Maxres.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Maxres.kt new file mode 100644 index 0000000..3df8fd0 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Maxres.kt @@ -0,0 +1,22 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Maxres { + @SerializedName("width") + var width = 0 + + @SerializedName("url") + var url: String? = null + + @SerializedName("height") + var height = 0 + + override fun toString(): String { + return "Maxres{" + + "width = '" + width + '\'' + + ",url = '" + url + '\'' + + ",height = '" + height + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Medium.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Medium.kt new file mode 100644 index 0000000..6ea34c0 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Medium.kt @@ -0,0 +1,22 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Medium { + @SerializedName("width") + var width = 0 + + @SerializedName("url") + var url: String? = null + + @SerializedName("height") + var height = 0 + + override fun toString(): String { + return "Medium{" + + "width = '" + width + '\'' + + ",url = '" + url + '\'' + + ",height = '" + height + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/PageInfo.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/PageInfo.kt new file mode 100644 index 0000000..1585128 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/PageInfo.kt @@ -0,0 +1,18 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class PageInfo { + @SerializedName("totalResults") + var totalResults = 0 + + @SerializedName("resultsPerPage") + var resultsPerPage = 0 + + override fun toString(): String { + return "PageInfo{" + + "totalResults = '" + totalResults + '\'' + + ",resultsPerPage = '" + resultsPerPage + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/RegionRestriction.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/RegionRestriction.kt new file mode 100644 index 0000000..815fba5 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/RegionRestriction.kt @@ -0,0 +1,14 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class RegionRestriction { + @SerializedName("allowed") + var allowed: List? = null + + override fun toString(): String { + return "RegionRestriction{" + + "allowed = '" + allowed + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/ResourceId.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/ResourceId.kt new file mode 100644 index 0000000..13e7c51 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/ResourceId.kt @@ -0,0 +1,18 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class ResourceId { + @SerializedName("kind") + var kind: String? = null + + @SerializedName("videoId") + var videoId: String? = null + + override fun toString(): String { + return "ResourceId{" + + "kind = '" + kind + '\'' + + ",videoId = '" + videoId + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Snippet.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Snippet.kt new file mode 100644 index 0000000..dc263d7 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Snippet.kt @@ -0,0 +1,54 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Snippet { + @SerializedName("publishedAt") + var publishedAt: String? = null + + @SerializedName("localized") + var localized: Localized? = null + + @SerializedName("description") + var description: String? = null + + @SerializedName("title") + var title: String? = null + + @SerializedName("thumbnails") + var thumbnails: Thumbnails? = null + + @SerializedName("channelId") + var channelId: String? = null + + @SerializedName("categoryId") + var categoryId: String? = null + + @SerializedName("channelTitle") + var channelTitle: String? = null + + @SerializedName("tags") + var tags: List? = null + + @SerializedName("liveBroadcastContent") + var liveBroadcastContent: String? = null + + //TODO: Only for playlist + @SerializedName("resourceId") + var resourceId: ResourceId? = null + + override fun toString(): String { + return "Snippet{" + + "publishedAt = '" + publishedAt + '\'' + + ",localized = '" + localized + '\'' + + ",description = '" + description + '\'' + + ",title = '" + title + '\'' + + ",thumbnails = '" + thumbnails + '\'' + + ",channelId = '" + channelId + '\'' + + ",categoryId = '" + categoryId + '\'' + + ",channelTitle = '" + channelTitle + '\'' + + ",tags = '" + tags + '\'' + + ",liveBroadcastContent = '" + liveBroadcastContent + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Standard.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Standard.kt new file mode 100644 index 0000000..608501b --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Standard.kt @@ -0,0 +1,22 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Standard { + @SerializedName("width") + var width = 0 + + @SerializedName("url") + var url: String? = null + + @SerializedName("height") + var height = 0 + + override fun toString(): String { + return "Standard{" + + "width = '" + width + '\'' + + ",url = '" + url + '\'' + + ",height = '" + height + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Statistics.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Statistics.kt new file mode 100644 index 0000000..ee02094 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Statistics.kt @@ -0,0 +1,30 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Statistics { + @SerializedName("dislikeCount") + var dislikeCount: String? = null + + @SerializedName("likeCount") + var likeCount: String? = null + + @SerializedName("viewCount") + var viewCount: String? = null + + @SerializedName("favoriteCount") + var favoriteCount: String? = null + + @SerializedName("commentCount") + var commentCount: String? = null + + override fun toString(): String { + return "Statistics{" + + ",dislikeCount = '" + dislikeCount + '\'' + + ",likeCount = '" + likeCount + '\'' + + ",viewCount = '" + viewCount + '\'' + + ",favoriteCount = '" + favoriteCount + '\'' + + ",commentCount = '" + commentCount + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Thumbnails.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Thumbnails.kt new file mode 100644 index 0000000..f28ea15 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/Thumbnails.kt @@ -0,0 +1,30 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class Thumbnails { + @SerializedName("standard") + var standard: Standard? = null + + @SerializedName("default") + var jsonMemberDefault: JsonMemberDefault? = null + + @SerializedName("high") + var high: High? = null + + @SerializedName("maxres") + var maxres: Maxres? = null + + @SerializedName("medium") + var medium: Medium? = null + + override fun toString(): String { + return "Thumbnails{" + + "standard = '" + standard + '\'' + + ",default = '" + jsonMemberDefault + '\'' + + ",high = '" + high + '\'' + + ",maxres = '" + maxres + '\'' + + ",medium = '" + medium + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/VideoDataItem.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/VideoDataItem.kt new file mode 100644 index 0000000..a181a51 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/VideoDataItem.kt @@ -0,0 +1,34 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class VideoDataItem { + @SerializedName("snippet") + var snippet: Snippet? = null + + @SerializedName("kind") + var kind: String? = null + + @SerializedName("etag") + var etag: String? = null + + @SerializedName("id") + var id: String? = null + + @SerializedName("contentDetails") + var contentDetails: ContentDetails? = null + + @SerializedName("statistics") + var statistics: Statistics? = null + + + override fun toString(): String { + return "VideoDataItem{" + + "snippet = '" + snippet + '\'' + + ",kind = '" + kind + '\'' + + ",etag = '" + etag + '\'' + + ",id = '" + id + '\'' + + ",contentDetails = '" + contentDetails + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/YoutubeVideoListResponse.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/YoutubeVideoListResponse.kt new file mode 100644 index 0000000..39a25d1 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtube/videos/list/YoutubeVideoListResponse.kt @@ -0,0 +1,30 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list + +import com.google.gson.annotations.SerializedName + +class YoutubeVideoListResponse { + + @SerializedName("nextPageToken") + var nextPageToken: String? = null + + @SerializedName("kind") + var kind: String? = null + + @SerializedName("pageInfo") + var pageInfo: PageInfo? = null + + @SerializedName("etag") + var etag: String? = null + + @SerializedName("items") + var items: List? = null + + override fun toString(): String { + return "YoutubeVideoListResponse{" + + "kind = '" + kind + '\'' + + ",pageInfo = '" + pageInfo + '\'' + + ",etag = '" + etag + '\'' + + ",items = '" + items + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtubeVideoInfo/ContentDetails.kt b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtubeVideoInfo/ContentDetails.kt new file mode 100644 index 0000000..3cd0093 --- /dev/null +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/data/models/youtubeVideoInfo/ContentDetails.kt @@ -0,0 +1,34 @@ +package com.github.kotvertolet.youtubeaudioplayer.data.models.youtubeVideoInfo + +import com.google.gson.annotations.SerializedName + +class ContentDetails { + @SerializedName("duration") + var duration: String? = null + + @SerializedName("licensedContent") + var isLicensedContent = false + + @SerializedName("caption") + var caption: String? = null + + @SerializedName("definition") + var definition: String? = null + + @SerializedName("projection") + var projection: String? = null + + @SerializedName("dimension") + var dimension: String? = null + + override fun toString(): String { + return "ContentDetails{" + + "duration = '" + duration + '\'' + + ",licensedContent = '" + isLicensedContent + '\'' + + ",caption = '" + caption + '\'' + + ",definition = '" + definition + '\'' + + ",projection = '" + projection + '\'' + + ",dimension = '" + dimension + '\'' + + "}" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/tasks/AudioStreamExtractionAsyncTask.java b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/tasks/AudioStreamExtractionAsyncTask.java index 6f4d0d2..25beb6d 100644 --- a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/tasks/AudioStreamExtractionAsyncTask.java +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/tasks/AudioStreamExtractionAsyncTask.java @@ -1,6 +1,7 @@ package com.github.kotvertolet.youtubeaudioplayer.tasks; import android.os.AsyncTask; +import android.util.Log; import com.github.kotvertolet.youtubeaudioplayer.App; import com.github.kotvertolet.youtubeaudioplayer.activities.main.MainActivity; @@ -10,6 +11,7 @@ import com.github.kotvertolet.youtubeaudioplayer.custom.exceptions.UserFriendlyException; import com.github.kotvertolet.youtubeaudioplayer.db.dto.YoutubeSongDto; import com.github.kotvertolet.youtubeaudioplayer.utilities.AudioStreamsUtils; +import com.github.kotvertolet.youtubejextractor.models.AdaptiveAudioStream; import com.github.kotvertolet.youtubejextractor.models.StreamItem; import com.github.kotvertolet.youtubejextractor.models.youtube.videoData.YoutubeVideoData; @@ -17,6 +19,7 @@ public class AudioStreamExtractionAsyncTask extends AsyncTask> { + private final static String TAG = AudioStreamExtractionAsyncTask.class.getSimpleName(); private WeakReference presenter; private WeakReference view; private AudioStreamsUtils audioStreamsUtils; @@ -44,6 +47,7 @@ protected void onPreExecute() { protected AsyncTaskResult doInBackground(String... params) { AsyncTaskResult taskResult; try { + Log.i(TAG, "Extracting data for video id: " + params[0]); YoutubeVideoData youtubeVideoData = audioStreamsUtils.extractYoutubeVideoData(params[0]); StreamItem streamItem = audioStreamsUtils.getAudioStreamForVideo(youtubeVideoData, ((MainActivity) view.get())); model.setStreamUrl(streamItem.getUrl()); diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/AudioStreamsUtils.java b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/AudioStreamsUtils.java index 0c7dd62..57be03a 100644 --- a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/AudioStreamsUtils.java +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/AudioStreamsUtils.java @@ -33,10 +33,10 @@ public YoutubeVideoData extractYoutubeVideoData(String videoId) throws UserFrien } // TODO: Do this in a good way catch (ExtractionException e) { - throw new UserFriendlyException(R.string.generic_error_message, + throw new UserFriendlyException(R.string.audio_extraction_failed_error_message, e.getMessage()); } catch (YoutubeRequestException e) { - throw new UserFriendlyException(R.string.generic_error_message, + throw new UserFriendlyException(R.string.youtube_request_failed_error_message, e.getMessage()); } return youtubeVideoData; diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeApiKeysProvider.java b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeApiKeysProvider.java index c3415ae..3c3d164 100644 --- a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeApiKeysProvider.java +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeApiKeysProvider.java @@ -1,6 +1,7 @@ package com.github.kotvertolet.youtubeaudioplayer.utilities; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -11,10 +12,23 @@ public class YoutubeApiKeysProvider { private Iterator iter; private YoutubeApiKeysProvider() { + youtubeApiKeys.add("AIzaSyA1dZ5u9JC9j8HpzBVNw8BwrNLDTDkqS3I"); + youtubeApiKeys.add("AIzaSyAUA1FFr5YKMcy_zjSDdGZFfIlKugxVgSM"); + youtubeApiKeys.add("AIzaSyAAXQD3_VR0dnLSHSYKOWUBHss9m27oBcc"); + youtubeApiKeys.add("AIzaSyCuCljT7hV44ZIoqXfilkztwdq1ZomhLFw"); + youtubeApiKeys.add("AIzaSyBnNjcvvkAKbifj3Yw2nmrzMJUALoNHxXM"); + youtubeApiKeys.add("AIzaSyBlOh7WHHYbelElphSoUAvCahpjo_zQom0"); + youtubeApiKeys.add("AIzaSyBp_5QruvEa4PiIWb788N-5_GuSCW_j7pc"); + youtubeApiKeys.add("AIzaSyDpTO_uR7-11s1FF9xQoru7f1i-M6dZiME"); + youtubeApiKeys.add("AIzaSyDFdPe9ROdCxClxT1cPQXSyYh705Z9N6FU"); + youtubeApiKeys.add("AIzaSyCHxTxxmay9TD7izuLBQYrOGSrupura_tQ"); + youtubeApiKeys.add("AIzaSyABcQuDwbl-3g-TxTgm4KBLACqpTAvGMg8"); + youtubeApiKeys.add("AIzaSyAhqowApJizByAN-iXRJLIeXV21U_F1Fnk"); if (youtubeApiKeys.size() == 0) { throw new Error("Add youtube data api keys first!"); } iter = youtubeApiKeys.iterator(); + Collections.shuffle(youtubeApiKeys); } public static YoutubeApiKeysProvider getInstance() { diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeRecommendationsFetchUtils.java b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeRecommendationsFetchUtils.java index d24cf17..9979467 100644 --- a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeRecommendationsFetchUtils.java +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/YoutubeRecommendationsFetchUtils.java @@ -6,6 +6,7 @@ import com.github.kotvertolet.youtubeaudioplayer.App; import com.github.kotvertolet.youtubeaudioplayer.activities.splash.SplashActivityContract; +import com.github.kotvertolet.youtubeaudioplayer.custom.exceptions.UserFriendlyRuntimeException; import com.github.kotvertolet.youtubeaudioplayer.custom.exceptions.VideoIsDeletedException; import com.github.kotvertolet.youtubeaudioplayer.data.dataSource.RemoteDataSource; import com.github.kotvertolet.youtubeaudioplayer.data.models.youtube.videos.list.Snippet; @@ -48,11 +49,17 @@ public YoutubeRecommendationsFetchUtils(CommonUtils commonUtils, SplashActivityC @SuppressLint("CheckResult") public void fetchYoutubeRecommendations() { Maybe topTracks = - remoteDataSource.getTopTracksPlaylist().subscribeOn(Schedulers.newThread()); + remoteDataSource.getTopTracksPlaylist().subscribeOn(Schedulers.newThread()).doOnError(error -> { + throw new Exception(error); + }); Maybe mostViewed = - remoteDataSource.getMostViewedPlaylist().subscribeOn(Schedulers.newThread()); + remoteDataSource.getMostViewedPlaylist().subscribeOn(Schedulers.newThread()).doOnError(error -> { + throw new Exception(error); + }); Maybe newMusicThisWeek = - remoteDataSource.getNewMusicThisWeekPlaylist().subscribeOn(Schedulers.newThread()); + remoteDataSource.getNewMusicThisWeekPlaylist().subscribeOn(Schedulers.newThread()).doOnError(error -> { + throw new Exception(error); + }); Maybe.zip(topTracks, mostViewed, newMusicThisWeek, (topTracksResponse, mostViewedResponse, newMusicResponse) -> { HashMap> rawRecommendations = new HashMap<>(); diff --git a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/common/Constants.java b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/common/Constants.java index 49ce7dd..0f2d212 100644 --- a/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/common/Constants.java +++ b/app/src/main/java/com/github/kotvertolet/youtubeaudioplayer/utilities/common/Constants.java @@ -2,9 +2,6 @@ public class Constants { - //TODO: Put Youtube Data API v3 key here - //public final static String YOUTUBE_API_KEY = "AIzaSyBnNjcvvkAKbifj3Yw2nmrzMJUALoNHxXM"; - public static final String APP_NAME = "Youtube audio player"; public static final int PLAYBACK_PROGRESS_CHANGED = 5; public static final int PLAYER_ERROR = 6; diff --git a/app/src/main/res/drawable/drawable-hdpi/ic_download.png b/app/src/main/res/drawable/drawable-hdpi/ic_download.png new file mode 100644 index 0000000..fa3ebbb Binary files /dev/null and b/app/src/main/res/drawable/drawable-hdpi/ic_download.png differ diff --git a/app/src/main/res/drawable/drawable-hdpi/ic_download_done.png b/app/src/main/res/drawable/drawable-hdpi/ic_download_done.png new file mode 100644 index 0000000..fa0ec9d Binary files /dev/null and b/app/src/main/res/drawable/drawable-hdpi/ic_download_done.png differ diff --git a/app/src/main/res/drawable/drawable-mdpi/ic_download.png b/app/src/main/res/drawable/drawable-mdpi/ic_download.png new file mode 100644 index 0000000..c8a2039 Binary files /dev/null and b/app/src/main/res/drawable/drawable-mdpi/ic_download.png differ diff --git a/app/src/main/res/drawable/drawable-mdpi/ic_download_done.png b/app/src/main/res/drawable/drawable-mdpi/ic_download_done.png new file mode 100644 index 0000000..08073a2 Binary files /dev/null and b/app/src/main/res/drawable/drawable-mdpi/ic_download_done.png differ diff --git a/app/src/main/res/drawable/drawable-xhdpi/ic_download.png b/app/src/main/res/drawable/drawable-xhdpi/ic_download.png new file mode 100644 index 0000000..671e0b3 Binary files /dev/null and b/app/src/main/res/drawable/drawable-xhdpi/ic_download.png differ diff --git a/app/src/main/res/drawable/drawable-xhdpi/ic_download_done.png b/app/src/main/res/drawable/drawable-xhdpi/ic_download_done.png new file mode 100644 index 0000000..2339c0b Binary files /dev/null and b/app/src/main/res/drawable/drawable-xhdpi/ic_download_done.png differ diff --git a/app/src/main/res/drawable/drawable-xxhdpi/ic_download.png b/app/src/main/res/drawable/drawable-xxhdpi/ic_download.png new file mode 100644 index 0000000..4e04a30 Binary files /dev/null and b/app/src/main/res/drawable/drawable-xxhdpi/ic_download.png differ diff --git a/app/src/main/res/drawable/drawable-xxhdpi/ic_download_done.png b/app/src/main/res/drawable/drawable-xxhdpi/ic_download_done.png new file mode 100644 index 0000000..b631a00 Binary files /dev/null and b/app/src/main/res/drawable/drawable-xxhdpi/ic_download_done.png differ diff --git a/app/src/main/res/drawable/drawable-xxxhdpi/ic_download.png b/app/src/main/res/drawable/drawable-xxxhdpi/ic_download.png new file mode 100644 index 0000000..f9bfb5e Binary files /dev/null and b/app/src/main/res/drawable/drawable-xxxhdpi/ic_download.png differ diff --git a/app/src/main/res/drawable/drawable-xxxhdpi/ic_download_done.png b/app/src/main/res/drawable/drawable-xxxhdpi/ic_download_done.png new file mode 100644 index 0000000..52fe8f6 Binary files /dev/null and b/app/src/main/res/drawable/drawable-xxxhdpi/ic_download_done.png differ diff --git a/app/src/main/res/drawable/ic_download.png b/app/src/main/res/drawable/ic_download.png new file mode 100644 index 0000000..fa3ebbb Binary files /dev/null and b/app/src/main/res/drawable/ic_download.png differ diff --git a/app/src/main/res/drawable/ic_download_done.png b/app/src/main/res/drawable/ic_download_done.png new file mode 100644 index 0000000..fa0ec9d Binary files /dev/null and b/app/src/main/res/drawable/ic_download_done.png differ diff --git a/app/src/main/res/drawable/ripple.xml b/app/src/main/res/drawable/ripple.xml index 8a554a0..981a189 100644 --- a/app/src/main/res/drawable/ripple.xml +++ b/app/src/main/res/drawable/ripple.xml @@ -2,4 +2,4 @@ \ No newline at end of file + tools:targetApi="lollipop" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_playlist_creation_dialog.xml b/app/src/main/res/layout/layout_playlist_creation_dialog.xml index 889590e..0829c79 100644 --- a/app/src/main/res/layout/layout_playlist_creation_dialog.xml +++ b/app/src/main/res/layout/layout_playlist_creation_dialog.xml @@ -15,22 +15,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Playlist name" /> - - - - - - - - - - - - - -