Test tor code
This commit is contained in:
parent
eeb612f9a2
commit
ef255d12ae
|
@ -17,7 +17,7 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||||
|
@ -35,4 +35,5 @@ dependencies {
|
||||||
compile 'com.android.support:recyclerview-v7:23.1.1'
|
compile 'com.android.support:recyclerview-v7:23.1.1'
|
||||||
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'
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import info.guardianproject.netcipher.NetCipher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 14.08.15.
|
* Created by Christian Schabesberger on 14.08.15.
|
||||||
*
|
*
|
||||||
|
@ -37,10 +39,11 @@ public class Downloader {
|
||||||
* @param language the language (usually a 2-character code) to set as the preferred language
|
* @param language the language (usually a 2-character code) to set as the preferred language
|
||||||
* @return the contents of the specified text file*/
|
* @return the contents of the specified text file*/
|
||||||
public static String download(String siteUrl, String language) {
|
public static String download(String siteUrl, String language) {
|
||||||
|
NetCipher.useTor();
|
||||||
String ret = "";
|
String ret = "";
|
||||||
try {
|
try {
|
||||||
URL url = new URL(siteUrl);
|
URL url = new URL(siteUrl);
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
HttpURLConnection con = (HttpURLConnection) NetCipher.getHttpURLConnection(url);
|
||||||
con.setRequestProperty("Accept-Language", language);
|
con.setRequestProperty("Accept-Language", language);
|
||||||
ret = dl(con);
|
ret = dl(con);
|
||||||
}
|
}
|
||||||
|
@ -81,10 +84,11 @@ public class Downloader {
|
||||||
* @return the contents of the specified text file*/
|
* @return the contents of the specified text file*/
|
||||||
public static String download(String siteUrl) {
|
public static String download(String siteUrl) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
|
NetCipher.useTor();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL url = new URL(siteUrl);
|
URL url = new URL(siteUrl);
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
HttpURLConnection con = (HttpURLConnection) NetCipher.getHttpURLConnection(url);
|
||||||
ret = dl(con);
|
ret = dl(con);
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.schabi.newpipe;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
|
@ -25,6 +26,7 @@ import android.widget.Button;
|
||||||
import android.widget.MediaController;
|
import android.widget.MediaController;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
|
import info.guardianproject.netcipher.NetCipher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||||
|
@ -44,7 +46,7 @@ import android.widget.VideoView;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlayVideoActivity extends AppCompatActivity {
|
public class PlayVideoActivity extends AppCompatActivity implements OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
//// TODO: 11.09.15 add "choose stream" menu
|
//// TODO: 11.09.15 add "choose stream" menu
|
||||||
|
|
||||||
|
@ -170,6 +172,9 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
if(prefs.getBoolean(PREF_IS_LANDSCAPE, false) && !isLandscape) {
|
if(prefs.getBoolean(PREF_IS_LANDSCAPE, false) && !isLandscape) {
|
||||||
toggleOrientation();
|
toggleOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTorPreference(prefs);
|
||||||
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,6 +192,13 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
videoView.pause();
|
videoView.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
prefs = getPreferences(Context.MODE_PRIVATE);
|
||||||
|
prefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
@ -348,4 +360,20 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
editor.putBoolean(PREF_IS_LANDSCAPE, isLandscape);
|
editor.putBoolean(PREF_IS_LANDSCAPE, isLandscape);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setTorPreference(SharedPreferences prefs) {
|
||||||
|
if(prefs.getBoolean(getString(R.string.useTor), false)) {
|
||||||
|
NetCipher.useTor();
|
||||||
|
} else {
|
||||||
|
NetCipher.setProxy(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
|
if(key.equals(getString(R.string.useTor))) {
|
||||||
|
setTorPreference(prefs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,4 +63,6 @@
|
||||||
<string name="detailUploaderThumbnailViewDescription">Uploader thumbnail</string>
|
<string name="detailUploaderThumbnailViewDescription">Uploader thumbnail</string>
|
||||||
<string name="detailThumbsDownImgViewDescription">Dislikes</string>
|
<string name="detailThumbsDownImgViewDescription">Dislikes</string>
|
||||||
<string name="detailThumbsUpImgViewDescription">Likes</string>
|
<string name="detailThumbsUpImgViewDescription">Likes</string>
|
||||||
|
<string name="useTor">Use Tor</string>
|
||||||
|
<string name="useTorTitle">Proxy connections via The Onion Router</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -72,5 +72,10 @@
|
||||||
android:summary="@string/autoPlayThroughIntentSummary"
|
android:summary="@string/autoPlayThroughIntentSummary"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="@string/useTor"
|
||||||
|
android:title="@string/useTorTitle"
|
||||||
|
android:defaultValue="false"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in New Issue