From c068f08ff8d7173837672fc072ce78ef5e16d637 Mon Sep 17 00:00:00 2001 From: Soofe Date: Thu, 15 Oct 2015 23:25:53 +0200 Subject: [PATCH 1/2] Fixed some typos and removed unused imports. --- .../org/schabi/newpipe/ActionBarHandler.java | 24 ++++----- .../java/org/schabi/newpipe/Extractor.java | 2 - .../org/schabi/newpipe/PlayVideoActivity.java | 17 +++---- .../java/org/schabi/newpipe/SearchEngine.java | 2 - .../java/org/schabi/newpipe/VideoInfo.java | 6 +-- .../newpipe/VideoItemDetailActivity.java | 13 +---- .../newpipe/VideoItemDetailFragment.java | 7 +-- .../schabi/newpipe/VideoItemListActivity.java | 9 +--- .../schabi/newpipe/VideoItemListFragment.java | 11 ++-- .../newpipe/youtube/YoutubeExtractor.java | 51 +++++++++---------- .../newpipe/youtube/YoutubeSearchEngine.java | 13 +++-- 11 files changed, 58 insertions(+), 97 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java index fdf02301e..56f78d0d6 100644 --- a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java +++ b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java @@ -1,13 +1,11 @@ package org.schabi.newpipe; -import android.app.DownloadManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; -import android.preference.Preference; import android.preference.PreferenceManager; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBar; @@ -19,8 +17,6 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.widget.ArrayAdapter; -import java.io.File; - /** * Created by Christian Schabesberger on 18.08.15. * @@ -48,7 +44,7 @@ public class ActionBarHandler { private static ActionBarHandler handler = null; private Context context = null; - private String webisteUrl = ""; + private String websiteUrl = ""; private AppCompatActivity activity; private VideoInfo.VideoStream[] videoStreams = null; private VideoInfo.AudioStream audioStream = null; @@ -64,7 +60,7 @@ public class ActionBarHandler { return handler; } - class ForamatItemSelectListener implements ActionBar.OnNavigationListener { + class FormatItemSelectListener implements ActionBar.OnNavigationListener { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { selectFormatItem((int)itemId); @@ -98,7 +94,7 @@ public class ActionBarHandler { if(activity != null) { ActionBar ab = activity.getSupportActionBar(); ab.setListNavigationCallbacks(itemAdapter - ,new ForamatItemSelectListener()); + ,new FormatItemSelectListener()); ab.setSelectedNavigationItem(defaultResolutionPos); } @@ -114,9 +110,9 @@ public class ActionBarHandler { } } else if(preferedFormat.equals("m4a")){ for(VideoInfo.AudioStream s : audioStreams) { - Log.d(TAG, VideoInfo.getMimeById(s.format) + " : " + Integer.toString(s.bandWidth)); + Log.d(TAG, VideoInfo.getMimeById(s.format) + " : " + Integer.toString(s.bandwidth)); if(s.format == VideoInfo.I_M4A && - (audioStream == null || audioStream.bandWidth > s.bandWidth)) { + (audioStream == null || audioStream.bandwidth > s.bandwidth)) { audioStream = s; Log.d(TAG, "last choosen"); } @@ -162,7 +158,7 @@ public class ActionBarHandler { if(!videoTitle.isEmpty()) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); - intent.putExtra(Intent.EXTRA_TEXT, webisteUrl); + intent.putExtra(Intent.EXTRA_TEXT, websiteUrl); intent.setType("text/plain"); context.startActivity(Intent.createChooser(intent, context.getString(R.string.shareDialogTitle))); } @@ -192,7 +188,7 @@ public class ActionBarHandler { } public void setVideoInfo(String websiteUrl, String videoTitle) { - this.webisteUrl = websiteUrl; + this.websiteUrl = websiteUrl; this.videoTitle = videoTitle; } @@ -239,7 +235,7 @@ public class ActionBarHandler { Intent intent = new Intent(context, PlayVideoActivity.class); intent.putExtra(PlayVideoActivity.VIDEO_TITLE, videoTitle); intent.putExtra(PlayVideoActivity.STREAM_URL, videoStreams[selectedStream].url); - intent.putExtra(PlayVideoActivity.VIDEO_URL, webisteUrl); + intent.putExtra(PlayVideoActivity.VIDEO_URL, websiteUrl); context.startActivity(intent); } } @@ -267,7 +263,7 @@ public class ActionBarHandler { if(!videoTitle.isEmpty()) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); - intent.setData(Uri.parse(webisteUrl)); + intent.setData(Uri.parse(websiteUrl)); context.startActivity(Intent.createChooser(intent, context.getString(R.string.chooseBrowser))); } @@ -278,7 +274,7 @@ public class ActionBarHandler { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setPackage(KORE_PACKET); - intent.setData(Uri.parse(webisteUrl.replace("https", "http"))); + intent.setData(Uri.parse(websiteUrl.replace("https", "http"))); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/org/schabi/newpipe/Extractor.java b/app/src/main/java/org/schabi/newpipe/Extractor.java index b07e263b8..102a39494 100644 --- a/app/src/main/java/org/schabi/newpipe/Extractor.java +++ b/app/src/main/java/org/schabi/newpipe/Extractor.java @@ -1,7 +1,5 @@ package org.schabi.newpipe; -import android.graphics.Bitmap; - /** * Created by Christian Schabesberger on 10.08.15. * diff --git a/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java b/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java index 7f71ef334..07a5886aa 100644 --- a/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java +++ b/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java @@ -5,7 +5,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.res.Configuration; -import android.content.res.Resources; import android.media.MediaPlayer; import android.net.Uri; import android.os.Build; @@ -19,15 +18,11 @@ import android.view.Display; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.Surface; import android.view.View; import android.view.WindowManager; import android.widget.Button; -import android.widget.FrameLayout; -import android.widget.LinearLayout; import android.widget.MediaController; import android.widget.ProgressBar; -import android.widget.SeekBar; import android.widget.VideoView; /** @@ -84,7 +79,7 @@ public class PlayVideoActivity extends AppCompatActivity { setContentView(R.layout.activity_play_video); isLandscape = checkIfLandscape(); - hasSoftKeys = checkIfhasSoftKeys(); + hasSoftKeys = checkIfHasSoftKeys(); actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); @@ -203,10 +198,10 @@ public class PlayVideoActivity extends AppCompatActivity { if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { isLandscape = true; - adjustMediaControllMetrics(); + adjustMediaControlMetrics(); } else if (config.orientation == Configuration.ORIENTATION_PORTRAIT){ isLandscape = false; - adjustMediaControllMetrics(); + adjustMediaControlMetrics(); } } @@ -229,7 +224,7 @@ public class PlayVideoActivity extends AppCompatActivity { uiIsHidden = false; mediaController.show(100000); actionBar.show(); - adjustMediaControllMetrics(); + adjustMediaControlMetrics(); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @@ -259,7 +254,7 @@ public class PlayVideoActivity extends AppCompatActivity { WindowManager.LayoutParams.FLAG_FULLSCREEN); } - private void adjustMediaControllMetrics() { + private void adjustMediaControlMetrics() { MediaController.LayoutParams mediaControllerLayout = new MediaController.LayoutParams(MediaController.LayoutParams.MATCH_PARENT, MediaController.LayoutParams.WRAP_CONTENT); @@ -274,7 +269,7 @@ public class PlayVideoActivity extends AppCompatActivity { mediaController.setLayoutParams(mediaControllerLayout); } - private boolean checkIfhasSoftKeys(){ + private boolean checkIfHasSoftKeys(){ if(Build.VERSION.SDK_INT >= 17) { return getNavigationBarHeight() != 0 || getNavigationBarWidth() != 0; } else { diff --git a/app/src/main/java/org/schabi/newpipe/SearchEngine.java b/app/src/main/java/org/schabi/newpipe/SearchEngine.java index e7f861fcd..5d986f2a4 100644 --- a/app/src/main/java/org/schabi/newpipe/SearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/SearchEngine.java @@ -1,7 +1,5 @@ package org.schabi.newpipe; -import android.graphics.Bitmap; - import java.util.Vector; /** diff --git a/app/src/main/java/org/schabi/newpipe/VideoInfo.java b/app/src/main/java/org/schabi/newpipe/VideoInfo.java index 9b75be802..5181b6d8b 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoInfo.java +++ b/app/src/main/java/org/schabi/newpipe/VideoInfo.java @@ -110,13 +110,13 @@ public class VideoInfo { } public static class AudioStream { - public AudioStream(String url, int format, int bandWidth, int samplingRate) { + public AudioStream(String url, int format, int bandwidth, int samplingRate) { this.url = url; this.format = format; - this.bandWidth = bandWidth; this.samplingRate = samplingRate; + this.bandwidth = bandwidth; this.samplingRate = samplingRate; } public String url = ""; public int format = -1; - public int bandWidth = -1; + public int bandwidth = -1; public int samplingRate = -1; } diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java index cc0c95edf..7675b312a 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java @@ -1,22 +1,13 @@ package org.schabi.newpipe; -import android.content.ContentProviderOperation; -import android.content.res.Configuration; -import android.os.Build; -import android.preference.PreferenceManager; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.app.NavUtils; -import android.util.DisplayMetrics; -import android.util.Log; +import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.WindowManager; - -import org.schabi.newpipe.youtube.YoutubeExtractor; /** diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index 41594b1e8..e4ea1f7f7 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -3,13 +3,11 @@ package org.schabi.newpipe; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.media.Image; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; import android.support.design.widget.FloatingActionButton; import android.support.v4.app.Fragment; -import android.support.v7.app.ActionBar; import android.text.Html; import android.text.method.LinkMovementMethod; import android.util.DisplayMetrics; @@ -17,14 +15,11 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.GridLayout; import android.widget.ImageView; -import android.widget.ListView; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; - import java.net.URL; import java.util.Vector; @@ -216,7 +211,7 @@ public class VideoItemDetailFragment extends Fragment { thumbnailView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.not_available_monkey)); break; default: - Log.e(TAG, "Video Availeble Status not known."); + Log.e(TAG, "Video Available Status not known."); } if(autoPlayEnabled) { diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java index ce2da6cb3..483261f76 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java @@ -2,21 +2,14 @@ package org.schabi.newpipe; import android.content.Context; import android.content.Intent; -import android.content.res.Configuration; -import android.os.Build; import android.os.Bundle; -import android.os.Environment; -import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; -import android.util.DisplayMetrics; -import android.util.Log; +import android.support.v7.widget.SearchView; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; -import android.support.v7.widget.SearchView; import android.widget.ImageView; /** diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java index c924aa227..200994773 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java @@ -13,7 +13,6 @@ import android.widget.ListView; import android.widget.Toast; import java.net.URL; -import java.util.List; import java.util.Vector; @@ -54,14 +53,14 @@ public class VideoItemListFragment extends ListFragment { private class ResultRunnable implements Runnable { private SearchEngine.Result result; - private int reuqestId; + private int requestId; public ResultRunnable(SearchEngine.Result result, int requestId) { this.result = result; - this.reuqestId = requestId; + this.requestId = requestId; } @Override public void run() { - updateListOnResult(result, reuqestId); + updateListOnResult(result, requestId); } } @@ -213,7 +212,7 @@ public class VideoItemListFragment extends ListFragment { loadThumbsThread = new Thread(loadThumbsRunnable); loadThumbsThread.start(); } catch(java.lang.IllegalStateException e) { - Log.w(TAG, "Trying to set value while activity is not existing anymore."); + Log.w(TAG, "Trying to set value while activity doesn't anymore."); } catch(Exception e) { e.printStackTrace(); } @@ -230,7 +229,7 @@ public class VideoItemListFragment extends ListFragment { } if(searchThread != null) { searchRunnable.terminate(); - // No need to join, since we don't realy terminate the thread. We just demand + // No need to join, since we don't really terminate the thread. We just demand // it to post its result runnable into the gui main loop. } } diff --git a/app/src/main/java/org/schabi/newpipe/youtube/YoutubeExtractor.java b/app/src/main/java/org/schabi/newpipe/youtube/YoutubeExtractor.java index f7188d8af..6b8ef314b 100644 --- a/app/src/main/java/org/schabi/newpipe/youtube/YoutubeExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/youtube/YoutubeExtractor.java @@ -1,30 +1,29 @@ package org.schabi.newpipe.youtube; -import org.jsoup.nodes.Element; -import org.schabi.newpipe.Downloader; -import org.schabi.newpipe.Extractor; -import org.schabi.newpipe.VideoInfo; import android.util.Log; import android.util.Xml; +import org.json.JSONObject; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.parser.Parser; +import org.mozilla.javascript.Context; +import org.mozilla.javascript.Function; +import org.mozilla.javascript.ScriptableObject; +import org.schabi.newpipe.Downloader; +import org.schabi.newpipe.Extractor; +import org.schabi.newpipe.VideoInfo; +import org.schabi.newpipe.VideoInfoItem; +import org.xmlpull.v1.XmlPullParser; + import java.io.StringReader; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.Vector; -import java.util.regex.Pattern; import java.util.regex.Matcher; -import org.json.JSONObject; - -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.parser.Parser; - -import org.mozilla.javascript.Context; -import org.mozilla.javascript.Function; -import org.mozilla.javascript.ScriptableObject; -import org.schabi.newpipe.VideoInfoItem; -import org.xmlpull.v1.XmlPullParser; +import java.util.regex.Pattern; /** * Created by Christian Schabesberger on 06.08.15. @@ -48,8 +47,6 @@ import org.xmlpull.v1.XmlPullParser; public class YoutubeExtractor implements Extractor { - - private static final String TAG = YoutubeExtractor.class.toString(); // These lists only contain itag formats that are supported by the common Android Video player. @@ -93,7 +90,7 @@ public class YoutubeExtractor implements Extractor { } } - private String decryptoinCode = ""; + private String decryptionCode = ""; private static final String DECRYPTION_FUNC_NAME="decrypt"; @Override @@ -189,12 +186,12 @@ public class YoutubeExtractor implements Extractor { if(playerUrl.startsWith("//")) { playerUrl = "https:" + playerUrl; } - if(decryptoinCode.isEmpty()) { - decryptoinCode = loadDecryptioinCode(playerUrl); + if(decryptionCode.isEmpty()) { + decryptionCode = loadDecryptionCode(playerUrl); } // extract audio - videoInfo.audioStreams = parseDashManifest(dashManifest, decryptoinCode); + videoInfo.audioStreams = parseDashManifest(dashManifest, decryptionCode); //------------------------------------ // extract video stream url @@ -213,10 +210,10 @@ public class YoutubeExtractor implements Extractor { // if video has a signature: decrypt it and add it to the url if(tags.get("s") != null) { - if(decryptoinCode.isEmpty()) { - decryptoinCode = loadDecryptioinCode(playerUrl); + if(decryptionCode.isEmpty()) { + decryptionCode = loadDecryptionCode(playerUrl); } - streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptoinCode); + streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptionCode); } if(resolveFormat(itag) != -1) { @@ -236,7 +233,7 @@ public class YoutubeExtractor implements Extractor { } //------------------------------- - // extrating from html page + // extracting from html page //------------------------------- @@ -438,7 +435,7 @@ public class YoutubeExtractor implements Extractor { return retval; } - private String loadDecryptioinCode(String playerUrl) { + private String loadDecryptionCode(String playerUrl) { String playerCode = Downloader.download(playerUrl); String decryptionFuncName = ""; String decryptionFunc = ""; diff --git a/app/src/main/java/org/schabi/newpipe/youtube/YoutubeSearchEngine.java b/app/src/main/java/org/schabi/newpipe/youtube/YoutubeSearchEngine.java index 395a3d768..841d0a89b 100644 --- a/app/src/main/java/org/schabi/newpipe/youtube/YoutubeSearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/youtube/YoutubeSearchEngine.java @@ -1,18 +1,17 @@ package org.schabi.newpipe.youtube; -import org.schabi.newpipe.Downloader; -import org.schabi.newpipe.SearchEngine; -import org.schabi.newpipe.VideoInfoItem; - import android.net.Uri; import android.util.Log; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; +import org.schabi.newpipe.Downloader; +import org.schabi.newpipe.SearchEngine; +import org.schabi.newpipe.VideoInfoItem; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Created by Christian Schabesberger on 09.08.15. From 342807e26aae15373f82a1c1061268463040e325 Mon Sep 17 00:00:00 2001 From: Soofe Date: Thu, 15 Oct 2015 23:58:14 +0200 Subject: [PATCH 2/2] Update VideoItemListFragment.java --- app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java index 200994773..950c29f54 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java @@ -212,7 +212,7 @@ public class VideoItemListFragment extends ListFragment { loadThumbsThread = new Thread(loadThumbsRunnable); loadThumbsThread.start(); } catch(java.lang.IllegalStateException e) { - Log.w(TAG, "Trying to set value while activity doesn't anymore."); + Log.w(TAG, "Trying to set value while activity doesn't exist anymore."); } catch(Exception e) { e.printStackTrace(); }