Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8bf7a1a9db
|
@ -8,8 +8,8 @@ android {
|
||||||
applicationId "org.schabi.newpipe"
|
applicationId "org.schabi.newpipe"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 20
|
versionCode 21
|
||||||
versionName "0.8.6"
|
versionName "0.8.7"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -32,10 +32,10 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'com.android.support:appcompat-v7:25.0.0'
|
compile 'com.android.support:appcompat-v7:25.1.0'
|
||||||
compile 'com.android.support:support-v4:25.0.0'
|
compile 'com.android.support:support-v4:25.1.0'
|
||||||
compile 'com.android.support:design:25.0.0'
|
compile 'com.android.support:design:25.1.0'
|
||||||
compile 'com.android.support:recyclerview-v7:25.0.0'
|
compile 'com.android.support:recyclerview-v7:25.1.0'
|
||||||
compile 'org.jsoup:jsoup:1.8.3'
|
compile 'org.jsoup:jsoup:1.8.3'
|
||||||
compile 'org.mozilla:rhino:1.7.7'
|
compile 'org.mozilla:rhino:1.7.7'
|
||||||
compile 'info.guardianproject.netcipher:netcipher:1.2'
|
compile 'info.guardianproject.netcipher:netcipher:1.2'
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
|
@ -34,6 +35,8 @@ import android.webkit.WebViewClient;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
public class ReCaptchaActivity extends AppCompatActivity {
|
public class ReCaptchaActivity extends AppCompatActivity {
|
||||||
|
public static final int RECAPTCHA_REQUEST = 10;
|
||||||
|
|
||||||
public static final String TAG = ReCaptchaActivity.class.toString();
|
public static final String TAG = ReCaptchaActivity.class.toString();
|
||||||
public static final String YT_URL = "https://www.youtube.com";
|
public static final String YT_URL = "https://www.youtube.com";
|
||||||
|
|
||||||
|
@ -42,6 +45,9 @@ public class ReCaptchaActivity extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_recaptcha);
|
setContentView(R.layout.activity_recaptcha);
|
||||||
|
|
||||||
|
// Set return to Cancel by default
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setTitle(R.string.reCaptcha_title);
|
actionBar.setTitle(R.string.reCaptcha_title);
|
||||||
|
@ -80,19 +86,26 @@ public class ReCaptchaActivity extends AppCompatActivity {
|
||||||
context = ctx;
|
context = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||||
|
// TODO: Start Loader
|
||||||
|
super.onPageStarted(view, url, favicon);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
String cookies = CookieManager.getInstance().getCookie(url);
|
String cookies = CookieManager.getInstance().getCookie(url);
|
||||||
|
|
||||||
|
// TODO: Stop Loader
|
||||||
|
|
||||||
// find cookies : s_gl & goojf and Add cookies to Downloader
|
// find cookies : s_gl & goojf and Add cookies to Downloader
|
||||||
if (find_access_cookies(cookies)) {
|
if (find_access_cookies(cookies)) {
|
||||||
// Give cookies to Downloader class
|
// Give cookies to Downloader class
|
||||||
Downloader.setCookies(mCookies);
|
Downloader.setCookies(mCookies);
|
||||||
|
|
||||||
// Closing activity and return to parent.
|
// Closing activity and return to parent
|
||||||
Intent intent = new Intent(context, org.schabi.newpipe.MainActivity.class);
|
setResult(RESULT_OK);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
finish();
|
||||||
NavUtils.navigateUpTo(context, intent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
|
@ -44,6 +44,7 @@ public class StreamInfoWorker {
|
||||||
public interface OnStreamInfoReceivedListener {
|
public interface OnStreamInfoReceivedListener {
|
||||||
void onReceive(StreamInfo info);
|
void onReceive(StreamInfo info);
|
||||||
void onError(int messageId);
|
void onError(int messageId);
|
||||||
|
void onReCaptchaException();
|
||||||
void onBlockedByGemaError();
|
void onBlockedByGemaError();
|
||||||
void onContentErrorWithMessage(int messageId);
|
void onContentErrorWithMessage(int messageId);
|
||||||
void onContentError();
|
void onContentError();
|
||||||
|
@ -107,6 +108,13 @@ public class StreamInfoWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// These errors render the stream information unusable.
|
// These errors render the stream information unusable.
|
||||||
|
} catch (ReCaptchaException e) {
|
||||||
|
h.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
onStreamInfoReceivedListener.onReCaptchaException();
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
h.post(new Runnable() {
|
h.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,9 +123,8 @@ public class StreamInfoWorker {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
} catch (YoutubeStreamExtractor.DecryptException de) {
|
||||||
// custom service related exceptions
|
// custom service related exceptions
|
||||||
catch (YoutubeStreamExtractor.DecryptException de) {
|
|
||||||
h.post(new Runnable() {
|
h.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Vector;
|
||||||
|
|
||||||
import org.schabi.newpipe.ActivityCommunicator;
|
import org.schabi.newpipe.ActivityCommunicator;
|
||||||
import org.schabi.newpipe.ChannelActivity;
|
import org.schabi.newpipe.ChannelActivity;
|
||||||
|
import org.schabi.newpipe.ReCaptchaActivity;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo;
|
import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo;
|
||||||
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
||||||
|
@ -59,6 +60,9 @@ import org.schabi.newpipe.player.BackgroundPlayer;
|
||||||
import org.schabi.newpipe.player.PlayVideoActivity;
|
import org.schabi.newpipe.player.PlayVideoActivity;
|
||||||
import org.schabi.newpipe.player.ExoPlayerActivity;
|
import org.schabi.newpipe.player.ExoPlayerActivity;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
import static org.schabi.newpipe.ReCaptchaActivity.RECAPTCHA_REQUEST;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||||
|
@ -579,11 +583,6 @@ public class VideoItemDetailFragment extends Fragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
|
||||||
* fragment (e.g. upon screen orientation changes).
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -604,6 +603,17 @@ public class VideoItemDetailFragment extends Fragment {
|
||||||
postNewErrorToast(messageId);
|
postNewErrorToast(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReCaptchaException() {
|
||||||
|
Toast.makeText(getActivity(), R.string.recaptcha_request_toast,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
// Starting ReCaptcha Challenge Activity
|
||||||
|
startActivityForResult(
|
||||||
|
new Intent(getActivity(), ReCaptchaActivity.class),
|
||||||
|
RECAPTCHA_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockedByGemaError() {
|
public void onBlockedByGemaError() {
|
||||||
onErrorBlockedByGema();
|
onErrorBlockedByGema();
|
||||||
|
@ -793,4 +803,23 @@ public class VideoItemDetailFragment extends Fragment {
|
||||||
VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
|
VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
|
||||||
activity.startActivity(detailIntent);
|
activity.startActivity(detailIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case RECAPTCHA_REQUEST:
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
String videoUrl = getArguments().getString(VIDEO_URL);
|
||||||
|
StreamInfoWorker siw = StreamInfoWorker.getInstance();
|
||||||
|
siw.search(streamingServiceId, videoUrl, getActivity());
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "ReCaptcha failed");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Request code from activity not supported [" + requestCode + "]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
@ -28,6 +29,9 @@ import org.schabi.newpipe.detail.VideoItemDetailActivity;
|
||||||
import org.schabi.newpipe.detail.VideoItemDetailFragment;
|
import org.schabi.newpipe.detail.VideoItemDetailFragment;
|
||||||
import org.schabi.newpipe.info_list.InfoListAdapter;
|
import org.schabi.newpipe.info_list.InfoListAdapter;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
import static org.schabi.newpipe.ReCaptchaActivity.RECAPTCHA_REQUEST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 02.08.16.
|
* Created by Christian Schabesberger on 02.08.16.
|
||||||
*
|
*
|
||||||
|
@ -68,7 +72,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
inputManager.hideSoftInputFromWindow(
|
inputManager.hideSoftInputFromWindow(
|
||||||
a.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
a.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||||
} catch(NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ErrorActivity.reportError(a, e, null,
|
ErrorActivity.reportError(a, e, null,
|
||||||
a.findViewById(android.R.id.content),
|
a.findViewById(android.R.id.content),
|
||||||
|
@ -82,7 +86,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
// onQueryTextSubmit to trigger twice when focus is not cleared.
|
// onQueryTextSubmit to trigger twice when focus is not cleared.
|
||||||
// See: http://stackoverflow.com/questions/17874951/searchview-onquerytextsubmit-runs-twice-while-i-pressed-once
|
// See: http://stackoverflow.com/questions/17874951/searchview-onquerytextsubmit-runs-twice-while-i-pressed-once
|
||||||
a.getCurrentFocus().clearFocus();
|
a.getCurrentFocus().clearFocus();
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
View bg = a.findViewById(R.id.mainBG);
|
View bg = a.findViewById(R.id.mainBG);
|
||||||
|
@ -92,7 +96,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
if(!newText.isEmpty()) {
|
if (!newText.isEmpty()) {
|
||||||
searchSuggestions(newText);
|
searchSuggestions(newText);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -133,13 +137,13 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if(savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
searchQuery = savedInstanceState.getString(QUERY);
|
searchQuery = savedInstanceState.getString(QUERY);
|
||||||
streamingServiceId = savedInstanceState.getInt(STREAMING_SERVICE);
|
streamingServiceId = savedInstanceState.getInt(STREAMING_SERVICE);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
streamingServiceId = NewPipe.getIdOfService("Youtube");
|
streamingServiceId = NewPipe.getIdOfService("Youtube");
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ErrorActivity.reportError(getActivity(), e, null,
|
ErrorActivity.reportError(getActivity(), e, null,
|
||||||
getActivity().findViewById(android.R.id.content),
|
getActivity().findViewById(android.R.id.content),
|
||||||
|
@ -180,9 +184,11 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
public void onReCaptchaChallenge() {
|
public void onReCaptchaChallenge() {
|
||||||
Toast.makeText(getActivity(), "ReCaptcha Challenge requested",
|
Toast.makeText(getActivity(), "ReCaptcha Challenge requested",
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
// Starting ReCaptcha Challenge Activity
|
// Starting ReCaptcha Challenge Activity
|
||||||
Intent i = new Intent(getActivity(), ReCaptchaActivity.class);
|
startActivityForResult(
|
||||||
getActivity().startActivity(i);
|
new Intent(getActivity(), ReCaptchaActivity.class),
|
||||||
|
RECAPTCHA_REQUEST);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -216,14 +222,13 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||||
int pastVisiblesItems, visibleItemCount, totalItemCount;
|
int pastVisiblesItems, visibleItemCount, totalItemCount;
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
super.onScrolled(recyclerView, dx, dy);
|
||||||
if(dy > 0) //check for scroll down
|
if (dy > 0) //check for scroll down
|
||||||
{
|
{
|
||||||
visibleItemCount = streamInfoListLayoutManager.getChildCount();
|
visibleItemCount = streamInfoListLayoutManager.getChildCount();
|
||||||
totalItemCount = streamInfoListLayoutManager.getItemCount();
|
totalItemCount = streamInfoListLayoutManager.getItemCount();
|
||||||
pastVisiblesItems = streamInfoListLayoutManager.findFirstVisibleItemPosition();
|
pastVisiblesItems = streamInfoListLayoutManager.findFirstVisibleItemPosition();
|
||||||
|
|
||||||
if ( (visibleItemCount + pastVisiblesItems) >= totalItemCount && !isLoading)
|
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount && !isLoading) {
|
||||||
{
|
|
||||||
pageNumber++;
|
pageNumber++;
|
||||||
search(searchQuery, pageNumber);
|
search(searchQuery, pageNumber);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +269,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
searchView.setSuggestionsAdapter(suggestionListAdapter);
|
searchView.setSuggestionsAdapter(suggestionListAdapter);
|
||||||
searchView.setOnSuggestionListener(new SearchSuggestionListener(searchView, suggestionListAdapter));
|
searchView.setOnSuggestionListener(new SearchSuggestionListener(searchView, suggestionListAdapter));
|
||||||
searchView.setOnQueryTextListener(new SearchQueryListener());
|
searchView.setOnQueryTextListener(new SearchQueryListener());
|
||||||
if(searchQuery != null && !searchQuery.isEmpty()) {
|
if (searchQuery != null && !searchQuery.isEmpty()) {
|
||||||
searchView.setQuery(searchQuery, false);
|
searchView.setQuery(searchQuery, false);
|
||||||
searchView.setIconifiedByDefault(false);
|
searchView.setIconifiedByDefault(false);
|
||||||
}
|
}
|
||||||
|
@ -289,4 +294,23 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
Thread suggestionThread = new Thread(suggestionSearchRunnable);
|
Thread suggestionThread = new Thread(suggestionSearchRunnable);
|
||||||
suggestionThread.start();
|
suggestionThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case RECAPTCHA_REQUEST:
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
if (searchQuery.length() != 0) {
|
||||||
|
search(searchQuery);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "ReCaptcha failed");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Request code from activity not supported [" + requestCode + "]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,6 +271,7 @@
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="reCaptchaActivity">reCAPTCHA</string>
|
<string name="reCaptchaActivity">reCAPTCHA</string>
|
||||||
<string name="reCaptcha_title">reCAPTCHA Challenge</string>
|
<string name="reCaptcha_title">reCAPTCHA Challenge</string>
|
||||||
|
<string name="recaptcha_request_toast">reCAPTCHA Challenge requested</string>
|
||||||
|
|
||||||
<!-- End of GigaGet's Strings -->
|
<!-- End of GigaGet's Strings -->
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue