2016-01-01 22:16:41 +01:00
|
|
|
package org.schabi.newpipe;
|
|
|
|
|
|
|
|
import android.app.Application;
|
2016-01-01 23:04:29 +01:00
|
|
|
import android.content.Context;
|
2016-01-01 22:16:41 +01:00
|
|
|
|
2016-02-05 17:09:29 +01:00
|
|
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
|
|
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
|
|
|
|
2016-09-13 22:36:47 +02:00
|
|
|
import org.acra.ACRA;
|
|
|
|
import org.acra.config.ACRAConfiguration;
|
|
|
|
import org.acra.config.ACRAConfigurationException;
|
|
|
|
import org.acra.config.ConfigurationBuilder;
|
|
|
|
import org.acra.sender.ReportSenderFactory;
|
2016-09-27 22:59:04 +02:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2016-09-13 23:39:32 +02:00
|
|
|
import org.schabi.newpipe.report.AcraReportSenderFactory;
|
|
|
|
import org.schabi.newpipe.report.ErrorActivity;
|
2016-08-02 21:17:54 +02:00
|
|
|
import org.schabi.newpipe.settings.SettingsActivity;
|
|
|
|
|
2016-01-01 22:16:41 +01:00
|
|
|
import info.guardianproject.netcipher.NetCipher;
|
|
|
|
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
|
|
|
|
2016-01-05 21:41:55 +01:00
|
|
|
/**
|
|
|
|
* Copyright (C) Hans-Christoph Steiner 2016 <hans@eds.org>
|
|
|
|
* App.java is part of NewPipe.
|
|
|
|
*
|
|
|
|
* NewPipe is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* NewPipe is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-01-01 22:16:41 +01:00
|
|
|
public class App extends Application {
|
2016-09-13 22:36:47 +02:00
|
|
|
private static final String TAG = App.class.toString();
|
2016-01-01 22:16:41 +01:00
|
|
|
|
2016-01-01 23:04:29 +01:00
|
|
|
private static boolean useTor;
|
|
|
|
|
2016-09-13 22:36:47 +02:00
|
|
|
final Class<? extends ReportSenderFactory>[] reportSenderFactoryClasses
|
|
|
|
= new Class[]{AcraReportSenderFactory.class};
|
|
|
|
|
2016-01-01 22:16:41 +01:00
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
2016-09-13 22:36:47 +02:00
|
|
|
// init crashreport
|
|
|
|
try {
|
|
|
|
final ACRAConfiguration acraConfig = new ConfigurationBuilder(this)
|
|
|
|
.setReportSenderFactoryClasses(reportSenderFactoryClasses)
|
|
|
|
.build();
|
|
|
|
ACRA.init(this, acraConfig);
|
|
|
|
} catch(ACRAConfigurationException ace) {
|
|
|
|
ace.printStackTrace();
|
|
|
|
ErrorActivity.reportError(this, ace, null, null,
|
|
|
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,"none",
|
|
|
|
"Could not initialize ACRA crash report", R.string.app_ui_crash));
|
|
|
|
}
|
2016-01-04 00:10:51 +01:00
|
|
|
|
2016-09-27 22:59:04 +02:00
|
|
|
//init NewPipe
|
2016-12-07 22:09:24 +01:00
|
|
|
NewPipe.init(Downloader.getInstance());
|
2016-09-27 22:59:04 +02:00
|
|
|
|
2016-02-05 17:09:29 +01:00
|
|
|
// Initialize image loader
|
|
|
|
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
|
|
|
|
ImageLoader.getInstance().init(config);
|
|
|
|
|
2016-07-25 12:11:55 +02:00
|
|
|
/*
|
2016-01-04 00:10:51 +01:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
2016-01-05 20:56:40 +01:00
|
|
|
if(prefs.getBoolean(getString(R.string.use_tor_key), false)) {
|
2016-01-04 00:10:51 +01:00
|
|
|
OrbotHelper.requestStartTor(this);
|
|
|
|
configureTor(true);
|
|
|
|
} else {
|
|
|
|
configureTor(false);
|
2016-07-25 12:11:55 +02:00
|
|
|
}*/
|
|
|
|
configureTor(false);
|
2016-01-05 21:11:15 +01:00
|
|
|
|
|
|
|
// DO NOT REMOVE THIS FUNCTION!!!
|
|
|
|
// Otherwise downloadPathPreference has invalid value.
|
|
|
|
SettingsActivity.initSettings(this);
|
2016-01-01 22:16:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the proxy settings based on whether Tor should be enabled or not.
|
|
|
|
*/
|
2016-03-25 19:01:22 +01:00
|
|
|
public static void configureTor(boolean enabled) {
|
2016-01-01 23:04:29 +01:00
|
|
|
useTor = enabled;
|
2016-01-01 22:16:41 +01:00
|
|
|
if (useTor) {
|
|
|
|
NetCipher.useTor();
|
|
|
|
} else {
|
|
|
|
NetCipher.setProxy(null);
|
|
|
|
}
|
|
|
|
}
|
2016-01-01 23:04:29 +01:00
|
|
|
|
2016-03-25 19:01:22 +01:00
|
|
|
public static void checkStartTor(Context context) {
|
2016-01-01 23:04:29 +01:00
|
|
|
if (useTor) {
|
|
|
|
OrbotHelper.requestStartTor(context);
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 22:47:21 +01:00
|
|
|
|
2016-03-25 19:01:22 +01:00
|
|
|
public static boolean isUsingTor() {
|
2016-01-02 22:47:21 +01:00
|
|
|
return useTor;
|
|
|
|
}
|
2016-01-01 22:16:41 +01:00
|
|
|
}
|