diff --git a/app/build.gradle b/app/build.gradle index 7dd15e3413..fcf4fcc251 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,6 +9,7 @@ android { minSdkVersion 14 targetSdkVersion 25 versionCode 3 + buildConfigField 'String', 'YOUTUBE_API_KEY', '"AIzaSyDAOcAgAAd098p_FLIePaQNKPTpcyhUGBA"'; } buildTypes { release { diff --git a/app/src/extra/java/free/rm/skytube/gui/businessobjects/YouTubePlayer.java b/app/src/extra/java/free/rm/skytube/gui/businessobjects/YouTubePlayer.java index 46aa1f6185..118a2e664e 100644 --- a/app/src/extra/java/free/rm/skytube/gui/businessobjects/YouTubePlayer.java +++ b/app/src/extra/java/free/rm/skytube/gui/businessobjects/YouTubePlayer.java @@ -25,6 +25,7 @@ import android.preference.PreferenceManager; import android.util.Log; +import free.rm.skytube.BuildConfig; import free.rm.skytube.R; import free.rm.skytube.businessobjects.YouTubeVideo; import free.rm.skytube.gui.activities.YouTubePlayerActivity; @@ -72,7 +73,7 @@ private static boolean useOfficialYouTubePlayer(Context context) { private static void launchOfficialYouTubePlayer(String videoId, Context context) { try { // try to start the YouTube standalone player - Intent intent = com.google.android.youtube.player.YouTubeStandalonePlayer.createVideoIntent((Activity) context, context.getString(R.string.API_KEY), videoId); + Intent intent = com.google.android.youtube.player.YouTubeStandalonePlayer.createVideoIntent((Activity) context, BuildConfig.YOUTUBE_API_KEY, videoId); context.startActivity(intent); } catch (Exception e) { String errorMsg = context.getString(R.string.launch_offical_player_error); diff --git a/app/src/main/java/free/rm/skytube/businessobjects/CheckChannelActivity.java b/app/src/main/java/free/rm/skytube/businessobjects/CheckChannelActivity.java index 856a67d38e..132f63f202 100644 --- a/app/src/main/java/free/rm/skytube/businessobjects/CheckChannelActivity.java +++ b/app/src/main/java/free/rm/skytube/businessobjects/CheckChannelActivity.java @@ -27,8 +27,7 @@ import java.io.IOException; import java.util.List; -import free.rm.skytube.R; -import free.rm.skytube.gui.app.SkyTubeApp; +import free.rm.skytube.BuildConfig; /** * Check if there has been an activity (e.g. a new video has been published) on the given channel. @@ -45,7 +44,7 @@ public void init() throws IOException { this.activitiesList = YouTubeAPI.create().activities() .list("snippet") .setFields("items(snippet/publishedAt)") - .setKey(SkyTubeApp.getStr(R.string.API_KEY)) + .setKey(BuildConfig.YOUTUBE_API_KEY) .setMaxResults(MAX_RESULTS); } diff --git a/app/src/main/java/free/rm/skytube/businessobjects/GetCommentThreads.java b/app/src/main/java/free/rm/skytube/businessobjects/GetCommentThreads.java index 87d3b3a68d..a0044dc50d 100644 --- a/app/src/main/java/free/rm/skytube/businessobjects/GetCommentThreads.java +++ b/app/src/main/java/free/rm/skytube/businessobjects/GetCommentThreads.java @@ -27,8 +27,7 @@ import java.util.ArrayList; import java.util.List; -import free.rm.skytube.R; -import free.rm.skytube.gui.app.SkyTubeApp; +import free.rm.skytube.BuildConfig; /** * Queries the YouTube service and gets the comments of a video. @@ -49,7 +48,7 @@ public void init(String videoId) throws IOException { this.commentsList = YouTubeAPI.create().commentThreads() .list("snippet, replies") .setFields("items(snippet, replies), nextPageToken") - .setKey(SkyTubeApp.getStr(R.string.API_KEY)) + .setKey(BuildConfig.YOUTUBE_API_KEY) .setVideoId(videoId) .setTextFormat("plainText") .setMaxResults(MAX_RESULTS) diff --git a/app/src/main/java/free/rm/skytube/businessobjects/GetFeaturedVideos.java b/app/src/main/java/free/rm/skytube/businessobjects/GetFeaturedVideos.java index e2ee0a8b36..4e084854bb 100644 --- a/app/src/main/java/free/rm/skytube/businessobjects/GetFeaturedVideos.java +++ b/app/src/main/java/free/rm/skytube/businessobjects/GetFeaturedVideos.java @@ -26,8 +26,7 @@ import java.io.IOException; import java.util.List; -import free.rm.skytube.R; -import free.rm.skytube.gui.app.SkyTubeApp; +import free.rm.skytube.BuildConfig; /** * Get today's featured YouTube videos. @@ -48,7 +47,7 @@ public void init() throws IOException { videosList.setFields("items(id, snippet/defaultAudioLanguage, snippet/defaultLanguage, snippet/publishedAt, snippet/title, snippet/channelId, snippet/channelTitle," + "snippet/thumbnails/high, contentDetails/duration, statistics)," + "nextPageToken"); - videosList.setKey(SkyTubeApp.getStr(R.string.API_KEY)); + videosList.setKey(BuildConfig.YOUTUBE_API_KEY); videosList.setChart("mostPopular"); videosList.setRegionCode(getPreferredRegion()); videosList.setMaxResults(MAX_RESULTS); diff --git a/app/src/main/java/free/rm/skytube/businessobjects/GetYouTubeVideoBySearch.java b/app/src/main/java/free/rm/skytube/businessobjects/GetYouTubeVideoBySearch.java index a06f271f1b..2d466972c5 100644 --- a/app/src/main/java/free/rm/skytube/businessobjects/GetYouTubeVideoBySearch.java +++ b/app/src/main/java/free/rm/skytube/businessobjects/GetYouTubeVideoBySearch.java @@ -26,8 +26,7 @@ import java.io.IOException; import java.util.List; -import free.rm.skytube.R; -import free.rm.skytube.gui.app.SkyTubeApp; +import free.rm.skytube.BuildConfig; /** * Get videos corresponding to the user's query (refer to {@link #setQuery(String)}). @@ -46,7 +45,7 @@ public class GetYouTubeVideoBySearch extends GetYouTubeVideos { public void init() throws IOException { videosList = YouTubeAPI.create().search().list("id"); videosList.setFields("items(id/videoId), nextPageToken"); - videosList.setKey(SkyTubeApp.getStr(R.string.API_KEY)); + videosList.setKey(BuildConfig.YOUTUBE_API_KEY); videosList.setType("video"); //videosList.setRegionCode(getPreferredRegion()); // there is a bug in V3 API, so this does not work: https://code.google.com/p/gdata-issues/issues/detail?id=6383 and https://code.google.com/p/gdata-issues/issues/detail?id=6913 videosList.setSafeSearch("none"); diff --git a/app/src/main/java/free/rm/skytube/businessobjects/YouTubeChannel.java b/app/src/main/java/free/rm/skytube/businessobjects/YouTubeChannel.java index d357527ca7..52e936babf 100644 --- a/app/src/main/java/free/rm/skytube/businessobjects/YouTubeChannel.java +++ b/app/src/main/java/free/rm/skytube/businessobjects/YouTubeChannel.java @@ -31,6 +31,7 @@ import java.io.Serializable; import java.util.List; +import free.rm.skytube.BuildConfig; import free.rm.skytube.R; import free.rm.skytube.businessobjects.db.SubscriptionsDb; import free.rm.skytube.gui.app.SkyTubeApp; @@ -80,7 +81,7 @@ public void init(String channelId, boolean isUserSubscribed) throws IOException channelInfo.setFields("items(id, snippet/title, snippet/description, snippet/thumbnails/default," + "statistics/subscriberCount, brandingSettings/image/bannerTabletHdImageUrl)," + "nextPageToken"); - channelInfo.setKey(SkyTubeApp.getStr(R.string.API_KEY)); + channelInfo.setKey(BuildConfig.YOUTUBE_API_KEY); channelInfo.setId(channelId); // get this channel's info from the remote YouTube server diff --git a/app/src/main/res/values/strings_api_key.xml b/app/src/main/res/values/strings_api_key.xml deleted file mode 100644 index 37ace78a74..0000000000 --- a/app/src/main/res/values/strings_api_key.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - AIzaSyDAOcAgAAd098p_FLIePaQNKPTpcyhUGBA - \ No newline at end of file