2012-02-12 07:23:29 +01:00
|
|
|
|
2015-06-05 23:09:10 +02:00
|
|
|
package org.torproject.android;
|
2014-04-25 18:44:21 +02:00
|
|
|
|
2015-06-05 23:09:10 +02:00
|
|
|
import android.annotation.TargetApi;
|
2015-06-05 21:19:57 +02:00
|
|
|
import android.app.Activity;
|
2012-02-12 07:23:29 +01:00
|
|
|
import android.app.Application;
|
2015-06-05 23:09:10 +02:00
|
|
|
import android.content.Intent;
|
2012-02-12 07:23:29 +01:00
|
|
|
import android.content.res.Configuration;
|
2015-06-05 23:09:10 +02:00
|
|
|
import android.os.Build;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Log;
|
2012-02-12 07:23:29 +01:00
|
|
|
|
2015-06-17 18:06:23 +02:00
|
|
|
import org.torproject.android.service.TorServiceConstants;
|
|
|
|
|
2015-06-05 21:19:57 +02:00
|
|
|
import info.guardianproject.util.Languages;
|
|
|
|
|
2015-06-17 18:06:23 +02:00
|
|
|
import java.io.File;
|
2015-06-05 23:09:10 +02:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2015-03-28 05:39:58 +01:00
|
|
|
public class OrbotApp extends Application implements OrbotConstants
|
2012-02-12 07:23:29 +01:00
|
|
|
{
|
|
|
|
|
2015-06-05 23:09:10 +02:00
|
|
|
private Locale locale;
|
|
|
|
|
2015-06-17 18:06:23 +02:00
|
|
|
public static File appBinHome;
|
|
|
|
public static File appCacheHome;
|
|
|
|
|
|
|
|
public static File fileTor;
|
|
|
|
public static File filePolipo;
|
|
|
|
public static File fileObfsclient;
|
|
|
|
public static File fileMeekclient;
|
|
|
|
public static File fileXtables;
|
|
|
|
public static File fileTorRc;
|
2016-01-04 07:38:36 +01:00
|
|
|
public static File filePdnsd;
|
|
|
|
|
2015-06-17 18:06:23 +02:00
|
|
|
|
2015-06-05 23:09:10 +02:00
|
|
|
@Override
|
2012-02-12 07:23:29 +01:00
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
2015-06-09 04:57:42 +02:00
|
|
|
Prefs.setContext(this);
|
2012-02-12 07:23:29 +01:00
|
|
|
|
2016-01-20 22:52:59 +01:00
|
|
|
Languages.setup(OrbotMainActivity.class, R.string.menu_settings);
|
|
|
|
Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
|
2015-06-17 18:06:23 +02:00
|
|
|
|
|
|
|
appBinHome = getDir(TorServiceConstants.DIRECTORY_TOR_BINARY,Application.MODE_PRIVATE);
|
|
|
|
appCacheHome = getDir(TorServiceConstants.DIRECTORY_TOR_DATA,Application.MODE_PRIVATE);
|
|
|
|
|
|
|
|
fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY);
|
|
|
|
filePolipo = new File(appBinHome, TorServiceConstants.POLIPO_ASSET_KEY);
|
|
|
|
fileObfsclient = new File(appBinHome, TorServiceConstants.OBFSCLIENT_ASSET_KEY);
|
|
|
|
fileMeekclient = new File(appBinHome, TorServiceConstants.MEEK_ASSET_KEY);
|
|
|
|
fileXtables = new File(appBinHome, TorServiceConstants.IPTABLES_ASSET_KEY);
|
|
|
|
fileTorRc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY);
|
2016-01-04 07:38:36 +01:00
|
|
|
filePdnsd = new File(appBinHome, TorServiceConstants.PDNSD_ASSET_KEY);
|
|
|
|
|
|
|
|
|
2015-12-30 19:21:33 +01:00
|
|
|
|
2012-02-12 07:23:29 +01:00
|
|
|
}
|
2015-06-05 23:09:10 +02:00
|
|
|
|
2012-02-12 07:23:29 +01:00
|
|
|
@Override
|
2015-06-05 23:09:10 +02:00
|
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
2012-02-12 07:23:29 +01:00
|
|
|
super.onConfigurationChanged(newConfig);
|
2015-06-05 23:09:10 +02:00
|
|
|
Log.i(TAG, "onConfigurationChanged " + newConfig.locale.getLanguage());
|
2016-01-20 22:52:59 +01:00
|
|
|
Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
|
2015-06-05 23:09:10 +02:00
|
|
|
}
|
2016-01-20 22:52:59 +01:00
|
|
|
|
2015-06-05 23:09:10 +02:00
|
|
|
public static void forceChangeLanguage(Activity activity) {
|
|
|
|
Intent intent = activity.getIntent();
|
|
|
|
if (intent == null) // when launched as LAUNCHER
|
|
|
|
intent = new Intent(activity, OrbotMainActivity.class);
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
|
|
activity.finish();
|
|
|
|
activity.overridePendingTransition(0, 0);
|
|
|
|
activity.startActivity(intent);
|
|
|
|
activity.overridePendingTransition(0, 0);
|
2012-02-12 07:23:29 +01:00
|
|
|
}
|
2015-06-05 21:19:57 +02:00
|
|
|
|
|
|
|
public static Languages getLanguages(Activity activity) {
|
2016-01-20 22:52:59 +01:00
|
|
|
return Languages.get(activity);
|
2015-06-05 21:19:57 +02:00
|
|
|
}
|
2012-02-12 07:23:29 +01:00
|
|
|
}
|