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:
parent
d3879a0398
commit
5663e543a4
4 changed files with 29 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,6 +187,12 @@ public class PlayVideoActivity extends AppCompatActivity {
|
|||
videoView.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
App.checkStartTor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
|
|
@ -113,6 +113,12 @@ public class VideoItemDetailActivity extends AppCompatActivity {
|
|||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
App.checkStartTor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putString(VideoItemDetailFragment.VIDEO_URL, videoUrl);
|
||||
|
|
|
@ -175,6 +175,12 @@ public class VideoItemListActivity extends AppCompatActivity
|
|||
PreferenceManager.setDefaultValues(this, R.xml.settings_screen, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
App.checkStartTor(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback method from {@link VideoItemListFragment.Callbacks}
|
||||
* indicating that the item with the given ID was selected.
|
||||
|
|
Loading…
Reference in a new issue