1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Merge pull request #51 from Soofe/master

Fixed some typos and removed unused imports.
This commit is contained in:
Christian Schabesberger 2015-10-17 17:22:21 +02:00
commit 173eaa8cf8
11 changed files with 58 additions and 97 deletions

View File

@ -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();

View File

@ -1,7 +1,5 @@
package org.schabi.newpipe;
import android.graphics.Bitmap;
/**
* Created by Christian Schabesberger on 10.08.15.
*

View File

@ -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 {

View File

@ -1,7 +1,5 @@
package org.schabi.newpipe;
import android.graphics.Bitmap;
import java.util.Vector;
/**

View File

@ -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;
}

View File

@ -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;
/**

View File

@ -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) {

View File

@ -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;
/**

View File

@ -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 exist 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.
}
}

View File

@ -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 = "";

View File

@ -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.