mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-04 07:18:21 +03:00
53 lines
1.4 KiB
Java
53 lines
1.4 KiB
Java
package org.schabi.newpipe;
|
|
|
|
import android.app.Application;
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.preference.PreferenceManager;
|
|
|
|
import info.guardianproject.netcipher.NetCipher;
|
|
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
|
|
|
public class App extends Application {
|
|
|
|
private static boolean useTor;
|
|
|
|
@Override
|
|
public void onCreate() {
|
|
super.onCreate();
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
if(prefs.getBoolean(getString(R.string.use_tor_key), false)) {
|
|
OrbotHelper.requestStartTor(this);
|
|
configureTor(true);
|
|
} else {
|
|
configureTor(false);
|
|
}
|
|
|
|
// DO NOT REMOVE THIS FUNCTION!!!
|
|
// Otherwise downloadPathPreference has invalid value.
|
|
SettingsActivity.initSettings(this);
|
|
}
|
|
|
|
/**
|
|
* Set the proxy settings based on whether Tor should be enabled or not.
|
|
*/
|
|
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);
|
|
}
|
|
}
|
|
|
|
static boolean isUsingTor() {
|
|
return useTor;
|
|
}
|
|
}
|