diff --git a/README.md b/README.md
index f78725338..987327ab8 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
Screenshots • Description • Features • Updates • Contribution • Donate • License
-Website • Blog • Press
+Website • Blog • FAQ • Press
WARNING: THIS IS A BETA VERSION, THEREFORE YOU MAY ENCOUNTER BUGS. IF YOU DO, OPEN AN ISSUE VIA OUR GITHUB REPOSITORY.
diff --git a/app/build.gradle b/app/build.gradle
index f7017a6df..77b27f50a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,8 +11,8 @@ android {
applicationId "org.schabi.newpipe"
minSdkVersion 19
targetSdkVersion 28
- versionCode 800
- versionName "0.18.0"
+ versionCode 830
+ versionName "0.18.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
@@ -53,6 +53,7 @@ ext {
okHttpLibVersion = '3.12.6'
icepickLibVersion = '3.2.0'
stethoLibVersion = '1.5.0'
+ markwonVersion = '4.2.1'
}
dependencies {
@@ -62,7 +63,7 @@ dependencies {
exclude module: 'support-annotations'
})
- implementation 'com.github.TeamNewPipe:NewPipeExtractor:8e53fda'
+ implementation 'com.github.TeamNewPipe:NewPipeExtractor:fc9f031'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'
@@ -94,7 +95,7 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
- implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
+ implementation 'org.ocpsoft.prettytime:prettytime:4.0.3.Final'
implementation "androidx.room:room-runtime:${roomDbLibVersion}"
implementation "androidx.room:room-rxjava2:${roomDbLibVersion}"
@@ -108,4 +109,7 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:${okHttpLibVersion}"
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stethoLibVersion}"
+
+ implementation "io.noties.markwon:core:${markwonVersion}"
+ implementation "io.noties.markwon:linkify:${markwonVersion}"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9052dabab..f27f4bad0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -112,7 +112,7 @@
+ android:label="@string/recaptcha"/>
+
diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java
index 7f050e6c7..dae143b6c 100644
--- a/app/src/main/java/org/schabi/newpipe/App.java
+++ b/app/src/main/java/org/schabi/newpipe/App.java
@@ -99,7 +99,7 @@ public class App extends Application {
NewPipe.init(getDownloader(),
Localization.getPreferredLocalization(this),
Localization.getPreferredContentCountry(this));
- Localization.init();
+ Localization.init(getApplicationContext());
StateSaver.init(this);
initNotificationChannel();
diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java
index 90d299c7f..7cd620faa 100644
--- a/app/src/main/java/org/schabi/newpipe/MainActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java
@@ -31,7 +31,6 @@ import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
-import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
@@ -56,7 +55,6 @@ import androidx.fragment.app.FragmentManager;
import com.google.android.material.navigation.NavigationView;
import org.schabi.newpipe.extractor.NewPipe;
-import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
@@ -67,6 +65,7 @@ import org.schabi.newpipe.fragments.list.search.SearchFragment;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.util.Constants;
import org.schabi.newpipe.util.KioskTranslator;
+import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PeertubeHelper;
import org.schabi.newpipe.util.PermissionHelper;
@@ -78,6 +77,8 @@ import org.schabi.newpipe.util.ThemeHelper;
import java.util.ArrayList;
import java.util.List;
+import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
+
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release");
@@ -113,9 +114,9 @@ public class MainActivity extends AppCompatActivity {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
TLSSocketFactoryCompat.setAsDefault();
}
-
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
+ assureCorrectAppLanguage(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@@ -419,6 +420,8 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onResume() {
+ assureCorrectAppLanguage(this);
+ Localization.init(getApplicationContext()); //change the date format to match the selected language on resume
super.onResume();
// close drawer on return, and don't show animation, so its looks like the drawer isn't open
@@ -449,6 +452,16 @@ public class MainActivity extends AppCompatActivity {
sharedPreferences.edit().putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false).apply();
NavigationHelper.openMainActivity(this);
}
+
+ if (sharedPreferences.getBoolean(Constants.KEY_ENABLE_WATCH_HISTORY, true)) {
+ if (DEBUG) Log.d(TAG, "do not show History-menu as its disabled in settings");
+ drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(true);
+ }
+
+ if (!sharedPreferences.getBoolean(Constants.KEY_ENABLE_WATCH_HISTORY, true)) {
+ if (DEBUG) Log.d(TAG, "show History-menu as its enabled in settings");
+ drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(false);
+ }
}
@Override
@@ -551,8 +564,6 @@ public class MainActivity extends AppCompatActivity {
if (!(fragment instanceof SearchFragment)) {
findViewById(R.id.toolbar).findViewById(R.id.toolbar_search_container).setVisibility(View.GONE);
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.main_menu, menu);
}
ActionBar actionBar = getSupportActionBar();
@@ -574,14 +585,6 @@ public class MainActivity extends AppCompatActivity {
case android.R.id.home:
onHomeButtonPressed();
return true;
- case R.id.action_show_downloads:
- return NavigationHelper.openDownloads(this);
- case R.id.action_history:
- NavigationHelper.openStatisticFragment(getSupportFragmentManager());
- return true;
- case R.id.action_settings:
- NavigationHelper.openSettings(this);
- return true;
default:
return super.onOptionsItemSelected(item);
}
diff --git a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
index 0a2d51b53..d72f729b5 100644
--- a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
@@ -1,20 +1,25 @@
package org.schabi.newpipe;
-import android.app.Activity;
import android.content.Intent;
-import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import androidx.core.app.NavUtils;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
+
+import android.util.Log;
+import android.view.Menu;
import android.view.MenuItem;
import android.webkit.CookieManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
+import org.schabi.newpipe.util.ThemeHelper;
+
+import javax.annotation.Nonnull;
+
/*
* Created by beneth on 06.12.16.
*
@@ -37,48 +42,46 @@ import android.webkit.WebViewClient;
public class ReCaptchaActivity extends AppCompatActivity {
public static final int RECAPTCHA_REQUEST = 10;
public static final String RECAPTCHA_URL_EXTRA = "recaptcha_url_extra";
-
public static final String TAG = ReCaptchaActivity.class.toString();
public static final String YT_URL = "https://www.youtube.com";
- private String url;
+ private WebView webView;
+ private String foundCookies = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
+ ThemeHelper.setTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recaptcha);
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- url = getIntent().getStringExtra(RECAPTCHA_URL_EXTRA);
+ String url = getIntent().getStringExtra(RECAPTCHA_URL_EXTRA);
if (url == null || url.isEmpty()) {
url = YT_URL;
}
-
- // Set return to Cancel by default
+ // set return to Cancel by default
setResult(RESULT_CANCELED);
- Toolbar toolbar = findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setTitle(R.string.reCaptcha_title);
- actionBar.setDisplayShowTitleEnabled(true);
- }
+ webView = findViewById(R.id.reCaptchaWebView);
- WebView myWebView = findViewById(R.id.reCaptchaWebView);
-
- // Enable Javascript
- WebSettings webSettings = myWebView.getSettings();
+ // enable Javascript
+ WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
- ReCaptchaWebViewClient webClient = new ReCaptchaWebViewClient(this);
- myWebView.setWebViewClient(webClient);
+ webView.setWebViewClient(new WebViewClient() {
+ @Override
+ public void onPageFinished(WebView view, String url) {
+ super.onPageFinished(view, url);
+ handleCookies(url);
+ }
+ });
- // Cleaning cache, history and cookies from webView
- myWebView.clearCache(true);
- myWebView.clearHistory();
+ // cleaning cache, history and cookies from webView
+ webView.clearCache(true);
+ webView.clearHistory();
android.webkit.CookieManager cookieManager = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.removeAllCookies(aBoolean -> {});
@@ -86,77 +89,82 @@ public class ReCaptchaActivity extends AppCompatActivity {
cookieManager.removeAllCookie();
}
- myWebView.loadUrl(url);
+ webView.loadUrl(url);
}
- private class ReCaptchaWebViewClient extends WebViewClient {
- private final Activity context;
- private String mCookies;
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_recaptcha, menu);
- ReCaptchaWebViewClient(Activity ctx) {
- context = ctx;
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(false);
+ actionBar.setTitle(R.string.title_activity_recaptcha);
+ actionBar.setSubtitle(R.string.subtitle_activity_recaptcha);
}
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- // TODO: Start Loader
- super.onPageStarted(view, url, favicon);
- }
+ return true;
+ }
- @Override
- public void onPageFinished(WebView view, String url) {
- String cookies = CookieManager.getInstance().getCookie(url);
-
- // TODO: Stop Loader
-
- // find cookies : s_gl & goojf and Add cookies to Downloader
- if (find_access_cookies(cookies)) {
- // Give cookies to Downloader class
- DownloaderImpl.getInstance().setCookies(mCookies);
-
- // Closing activity and return to parent
- setResult(RESULT_OK);
- finish();
- }
- }
-
- private boolean find_access_cookies(String cookies) {
- boolean ret = false;
- String c_s_gl = "";
- String c_goojf = "";
-
- String[] parts = cookies.split("; ");
- for (String part : parts) {
- if (part.trim().startsWith("s_gl")) {
- c_s_gl = part.trim();
- }
- if (part.trim().startsWith("goojf")) {
- c_goojf = part.trim();
- }
- }
- if (c_s_gl.length() > 0 && c_goojf.length() > 0) {
- ret = true;
- //mCookies = c_s_gl + "; " + c_goojf;
- // Youtube seems to also need the other cookies:
- mCookies = cookies;
- }
-
- return ret;
- }
+ @Override
+ public void onBackPressed() {
+ saveCookiesAndFinish();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
- case android.R.id.home: {
- Intent intent = new Intent(this, org.schabi.newpipe.MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- NavUtils.navigateUpTo(this, intent);
+ case R.id.menu_item_done:
+ saveCookiesAndFinish();
return true;
- }
default:
return false;
}
}
+
+ private void saveCookiesAndFinish() {
+ handleCookies(webView.getUrl()); // try to get cookies of unclosed page
+ if (!foundCookies.isEmpty()) {
+ // give cookies to Downloader class
+ DownloaderImpl.getInstance().setCookies(foundCookies);
+ setResult(RESULT_OK);
+ }
+
+ Intent intent = new Intent(this, org.schabi.newpipe.MainActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ NavUtils.navigateUpTo(this, intent);
+ }
+
+
+
+ private void handleCookies(String url) {
+ String cookies = CookieManager.getInstance().getCookie(url);
+ if (MainActivity.DEBUG) Log.d(TAG, "handleCookies: url=" + url + "; cookies=" + (cookies == null ? "null" : cookies));
+ if (cookies == null) return;
+
+ addYoutubeCookies(cookies);
+ // add other methods to extract cookies here
+ }
+
+ private void addYoutubeCookies(@Nonnull String cookies) {
+ if (cookies.contains("s_gl=") || cookies.contains("goojf=") || cookies.contains("VISITOR_INFO1_LIVE=")) {
+ // youtube seems to also need the other cookies:
+ addCookie(cookies);
+ }
+ }
+
+ private void addCookie(String cookie) {
+ if (foundCookies.contains(cookie)) {
+ return;
+ }
+
+ if (foundCookies.isEmpty() || foundCookies.endsWith("; ")) {
+ foundCookies += cookie;
+ } else if (foundCookies.endsWith(";")) {
+ foundCookies += " " + cookie;
+ } else {
+ foundCookies += "; " + cookie;
+ }
+ }
}
diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java
index 2326e795e..edfc54375 100644
--- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java
@@ -22,27 +22,30 @@ import android.widget.TextView;
import org.schabi.newpipe.BuildConfig;
import org.schabi.newpipe.R;
-import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ThemeHelper;
+import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
+
public class AboutActivity extends AppCompatActivity {
/**
* List of all software components
*/
private static final SoftwareComponent[] SOFTWARE_COMPONENTS = new SoftwareComponent[]{
- new SoftwareComponent("Giga Get", "2014", "Peter Cai", "https://github.com/PaperAirplane-Dev-Team/GigaGet", StandardLicenses.GPL2),
- new SoftwareComponent("NewPipe Extractor", "2017", "Christian Schabesberger", "https://github.com/TeamNewPipe/NewPipeExtractor", StandardLicenses.GPL3),
+ new SoftwareComponent("Giga Get", "2014 - 2015", "Peter Cai", "https://github.com/PaperAirplane-Dev-Team/GigaGet", StandardLicenses.GPL2),
+ new SoftwareComponent("NewPipe Extractor", "2017 - 2020", "Christian Schabesberger", "https://github.com/TeamNewPipe/NewPipeExtractor", StandardLicenses.GPL3),
new SoftwareComponent("Jsoup", "2017", "Jonathan Hedley", "https://github.com/jhy/jsoup", StandardLicenses.MIT),
new SoftwareComponent("Rhino", "2015", "Mozilla", "https://www.mozilla.org/rhino/", StandardLicenses.MPL2),
new SoftwareComponent("ACRA", "2013", "Kevin Gaudin", "http://www.acra.ch", StandardLicenses.APACHE2),
new SoftwareComponent("Universal Image Loader", "2011 - 2015", "Sergey Tarasevich", "https://github.com/nostra13/Android-Universal-Image-Loader", StandardLicenses.APACHE2),
- new SoftwareComponent("CircleImageView", "2014 - 2017", "Henning Dodenhof", "https://github.com/hdodenhof/CircleImageView", StandardLicenses.APACHE2),
+ new SoftwareComponent("CircleImageView", "2014 - 2020", "Henning Dodenhof", "https://github.com/hdodenhof/CircleImageView", StandardLicenses.APACHE2),
new SoftwareComponent("NoNonsense-FilePicker", "2016", "Jonas Kalderstam", "https://github.com/spacecowboy/NoNonsense-FilePicker", StandardLicenses.MPL2),
- new SoftwareComponent("ExoPlayer", "2014-2017", "Google Inc", "https://github.com/google/ExoPlayer", StandardLicenses.APACHE2),
- new SoftwareComponent("RxAndroid", "2015", "The RxAndroid authors", "https://github.com/ReactiveX/RxAndroid", StandardLicenses.APACHE2),
- new SoftwareComponent("RxJava", "2016-present", "RxJava Contributors", "https://github.com/ReactiveX/RxJava", StandardLicenses.APACHE2),
- new SoftwareComponent("RxBinding", "2015", "Jake Wharton", "https://github.com/JakeWharton/RxBinding", StandardLicenses.APACHE2)
+ new SoftwareComponent("ExoPlayer", "2014 - 2020", "Google Inc", "https://github.com/google/ExoPlayer", StandardLicenses.APACHE2),
+ new SoftwareComponent("RxAndroid", "2015 - 2018", "The RxAndroid authors", "https://github.com/ReactiveX/RxAndroid", StandardLicenses.APACHE2),
+ new SoftwareComponent("RxJava", "2016 - 2020", "RxJava Contributors", "https://github.com/ReactiveX/RxJava", StandardLicenses.APACHE2),
+ new SoftwareComponent("RxBinding", "2015 - 2018", "Jake Wharton", "https://github.com/JakeWharton/RxBinding", StandardLicenses.APACHE2),
+ new SoftwareComponent("PrettyTime", "2012 - 2020", "Lincoln Baxter, III", "https://github.com/ocpsoft/prettytime", StandardLicenses.APACHE2),
+ new SoftwareComponent("Markwon", "2017 - 2020", "Noties", "https://github.com/noties/Markwon", StandardLicenses.APACHE2)
};
/**
@@ -62,8 +65,10 @@ public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ assureCorrectAppLanguage(this);
super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this);
+ this.setTitle(getString(R.string.title_activity_about));
setContentView(R.layout.activity_about);
@@ -99,11 +104,6 @@ public class AboutActivity extends AppCompatActivity {
case android.R.id.home:
finish();
return true;
- case R.id.action_settings:
- NavigationHelper.openSettings(this);
- return true;
- case R.id.action_show_downloads:
- return NavigationHelper.openDownloads(this);
}
return super.onOptionsItemSelected(item);
diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
index eeafc1f57..9a11b19cc 100644
--- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
+++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
@@ -3,6 +3,7 @@ package org.schabi.newpipe.about;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.res.Resources;
import android.os.AsyncTask;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
@@ -14,6 +15,8 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
+import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
+
public class LicenseFragmentHelper extends AsyncTask