made force-https an option in mobile settings. removed plugin from build

This commit is contained in:
Philipp Schaefer 2013-05-03 23:53:46 +02:00
parent 530c3cecf1
commit f6e6b76249
8 changed files with 67 additions and 64 deletions

View File

@ -196,15 +196,6 @@ for fn in glob.glob("plugins/*.user.js"):
metafn = fn.replace('.user.js', '.meta.js')
saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn))
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
# if we're building mobile too
if buildMobile:
if buildMobile not in ['debug','release','copyonly']:
@ -228,13 +219,9 @@ if buildMobile:
shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/total-conversion-build.user.js")
# copy the user location script into the mobile folder.
shutil.copy(os.path.join(outDir,"user-location.user.js"), "mobile/assets/user-location.user.js")
# also copy plugins
try:
os.makedirs("mobile/assets/plugins")
except:
pass
copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins")
shutil.rmtree("mobile/assets/plugins")
shutil.copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins", ignore=shutil.ignore_patterns('*.meta.js', 'force-https*'))
if buildMobile != 'copyonly':

2
mobile/.gitignore vendored
View File

@ -6,6 +6,6 @@ gen/
libs/
proguard-project.txt
local.properties
assets/iitc.js
assets/total-conversion-build.user.js
assets/user-location.user.js
assets/plugins/

View File

@ -37,6 +37,8 @@
<string name="pref_force_desktop_sum">Nice for tablets, looks awful on smartphones</string>
<string name="pref_user_loc">Display user location</string>
<string name="pref_user_loc_sum">Show users position on map</string>
<string name="pref_force_https">Force https</string>
<string name="pref_force_https_sum">Disabling may improve performance</string>
<string name="pref_developer_options">Developer options</string>
<string name="pref_enable_dev_mode">Enable developer mode</string>
<string name="pref_enable_dev_mode_sum">If enabled, all IITC sources will be loaded from external storage of the Android device.

View File

@ -36,6 +36,11 @@
android:key="pref_plugins"
android:title="@string/pref_plugins"
android:dialogTitle="@string/pref_plugins_title"/>
<CheckBoxPreference
android:key="pref_force_https"
android:title="@string/pref_force_https"
android:summary="@string/pref_force_https_sum"
android:defaultValue="true" />
</PreferenceCategory>
<PreferenceCategory

View File

@ -114,7 +114,6 @@ public class IITC_Mobile extends Activity {
}
}
else {
Log.d("iitcm", "no intent...loading " + intel_url);
this.loadUrl(intel_url);
}
}
@ -260,9 +259,8 @@ public class IITC_Mobile extends Activity {
// plugins are injected onPageFinished
public void loadUrl(String url) {
url = addUrlParam(url);
Log.d("iitcm", "injecting js...");
Log.d("iitcm", "injecting main-script...");
injectJS();
Log.d("iitcm", "loading url: " + url);
iitc_view.loadUrl(url);
}

View File

@ -29,7 +29,6 @@ public class IITC_Settings extends Activity {
ArrayList<String> asset_values = new ArrayList<String>();
for (int i = 0; i < asset_array.length ; i++) {
if (asset_array[i].endsWith("user.js")) {
// find user plugin name for user readable entries
Scanner s = null;
String src = "";
@ -55,7 +54,6 @@ public class IITC_Settings extends Activity {
// real value
asset_values.add(asset_array[i]);
}
}
Bundle bundle = getIntent().getExtras();
bundle.putStringArray("ASSETS", (String[]) asset_list.toArray(new String[0]));

View File

@ -2,8 +2,10 @@ package com.cradle.iitc_mobile;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.util.Log;
import android.webkit.WebChromeClient;
@ -65,6 +67,20 @@ public class IITC_WebView extends WebView {
}
//----------------------------------------------------------------
@Override
public void loadUrl(String url) {
if (!url.startsWith("javascript:")) {
// force https if enabled in settings
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
if (sharedPref.getBoolean("pref_force_https", true))
url = url.replace("http://", "https://");
else
url = url.replace("https://", "http://");
Log.d("iitcm", "loading url: " + url);
}
super.loadUrl(url);
}
public IITC_WebViewClient getWebViewClient() {
return this.webclient;
}
@ -79,7 +95,7 @@ public class IITC_WebView extends WebView {
Log.d("iitcm", "not connected to wifi...load tiles from cache");
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
} else {
Log.d("iitcm", "connected to wifi...load tiles network");
Log.d("iitcm", "connected to wifi...load tiles from network");
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
}
}

View File

@ -135,8 +135,6 @@ public class IITC_WebViewClient extends WebViewClient {
String[] plugin_array = plugin_list.toArray(new String[0]);
for(int i = 0; i < plugin_list.size(); i++) {
if (plugin_array[i].endsWith("user.js"));
{
Log.d("iitcm", "adding plugin " + plugin_array[i]);
Scanner s = null;
String src = "";
@ -157,7 +155,6 @@ public class IITC_WebViewClient extends WebViewClient {
view.loadUrl("javascript:" + src);
}
}
}
// inject the user location script if enabled in settings
if (sharedPref.getBoolean("pref_user_loc", false))