whenever an Activity resumes and tor is enabled, request it start

This makes sure that Orbot is running when the user expects it to be. If
NewPipe is configured to use Tor, then going to a NewPipe screen should
ensure Tor is running.
This commit is contained in:
Hans-Christoph Steiner 2016-01-01 23:04:29 +01:00
parent d3879a0398
commit 5663e543a4
4 changed files with 29 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package org.schabi.newpipe;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@ -9,6 +10,8 @@ import info.guardianproject.netcipher.proxy.OrbotHelper;
public class App extends Application {
private static boolean useTor;
@Override
public void onCreate() {
super.onCreate();
@ -22,11 +25,18 @@ public class App extends Application {
/**
* Set the proxy settings based on whether Tor should be enabled or not.
*/
static void configureTor(boolean useTor) {
static void configureTor(boolean enabled) {
useTor = enabled;
if (useTor) {
NetCipher.useTor();
} else {
NetCipher.setProxy(null);
}
}
static void checkStartTor(Context context) {
if (useTor) {
OrbotHelper.requestStartTor(context);
}
}
}