made force-https an option in mobile settings. removed plugin from build
This commit is contained in:
parent
530c3cecf1
commit
f6e6b76249
17
build.py
17
build.py
@ -196,15 +196,6 @@ for fn in glob.glob("plugins/*.user.js"):
|
|||||||
metafn = fn.replace('.user.js', '.meta.js')
|
metafn = fn.replace('.user.js', '.meta.js')
|
||||||
saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn))
|
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 we're building mobile too
|
||||||
if buildMobile:
|
if buildMobile:
|
||||||
if buildMobile not in ['debug','release','copyonly']:
|
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")
|
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.
|
# 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")
|
shutil.copy(os.path.join(outDir,"user-location.user.js"), "mobile/assets/user-location.user.js")
|
||||||
|
|
||||||
# also copy plugins
|
# also copy plugins
|
||||||
try:
|
shutil.rmtree("mobile/assets/plugins")
|
||||||
os.makedirs("mobile/assets/plugins")
|
shutil.copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins", ignore=shutil.ignore_patterns('*.meta.js', 'force-https*'))
|
||||||
except:
|
|
||||||
pass
|
|
||||||
copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins")
|
|
||||||
|
|
||||||
|
|
||||||
if buildMobile != 'copyonly':
|
if buildMobile != 'copyonly':
|
||||||
|
2
mobile/.gitignore
vendored
2
mobile/.gitignore
vendored
@ -6,6 +6,6 @@ gen/
|
|||||||
libs/
|
libs/
|
||||||
proguard-project.txt
|
proguard-project.txt
|
||||||
local.properties
|
local.properties
|
||||||
assets/iitc.js
|
assets/total-conversion-build.user.js
|
||||||
assets/user-location.user.js
|
assets/user-location.user.js
|
||||||
assets/plugins/
|
assets/plugins/
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
<string name="pref_force_desktop_sum">Nice for tablets, looks awful on smartphones</string>
|
<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">Display user location</string>
|
||||||
<string name="pref_user_loc_sum">Show users position on map</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_developer_options">Developer options</string>
|
||||||
<string name="pref_enable_dev_mode">Enable developer mode</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.
|
<string name="pref_enable_dev_mode_sum">If enabled, all IITC sources will be loaded from external storage of the Android device.
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
android:key="pref_plugins"
|
android:key="pref_plugins"
|
||||||
android:title="@string/pref_plugins"
|
android:title="@string/pref_plugins"
|
||||||
android:dialogTitle="@string/pref_plugins_title"/>
|
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>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
@ -114,7 +114,6 @@ public class IITC_Mobile extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d("iitcm", "no intent...loading " + intel_url);
|
|
||||||
this.loadUrl(intel_url);
|
this.loadUrl(intel_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,9 +259,8 @@ public class IITC_Mobile extends Activity {
|
|||||||
// plugins are injected onPageFinished
|
// plugins are injected onPageFinished
|
||||||
public void loadUrl(String url) {
|
public void loadUrl(String url) {
|
||||||
url = addUrlParam(url);
|
url = addUrlParam(url);
|
||||||
Log.d("iitcm", "injecting js...");
|
Log.d("iitcm", "injecting main-script...");
|
||||||
injectJS();
|
injectJS();
|
||||||
Log.d("iitcm", "loading url: " + url);
|
|
||||||
iitc_view.loadUrl(url);
|
iitc_view.loadUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,32 +29,30 @@ public class IITC_Settings extends Activity {
|
|||||||
ArrayList<String> asset_values = new ArrayList<String>();
|
ArrayList<String> asset_values = new ArrayList<String>();
|
||||||
|
|
||||||
for (int i = 0; i < asset_array.length ; i++) {
|
for (int i = 0; i < asset_array.length ; i++) {
|
||||||
if (asset_array[i].endsWith("user.js")) {
|
// find user plugin name for user readable entries
|
||||||
// find user plugin name for user readable entries
|
Scanner s = null;
|
||||||
Scanner s = null;
|
String src = "";
|
||||||
String src = "";
|
try {
|
||||||
try {
|
s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A");
|
||||||
s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A");
|
} catch (IOException e2) {
|
||||||
} catch (IOException e2) {
|
// TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
e2.printStackTrace();
|
||||||
e2.printStackTrace();
|
|
||||||
}
|
|
||||||
if (s != null) src = s.hasNext() ? s.next() : "";
|
|
||||||
String header = src.substring(src.indexOf("==UserScript=="), src.indexOf("==/UserScript=="));
|
|
||||||
// remove new line comments and replace with space
|
|
||||||
// this way we get double spaces instead of newline + double slash
|
|
||||||
header = header.replace("\n//", " ");
|
|
||||||
// get a list of key-value...split on multiple spaces
|
|
||||||
String[] attributes = header.split(" +");
|
|
||||||
String plugin_name = "not found";
|
|
||||||
for (int j = 0; j < attributes.length; j++) {
|
|
||||||
// search for name and use the value
|
|
||||||
if (attributes[j].equals("@name")) plugin_name = attributes[j+1];
|
|
||||||
}
|
|
||||||
asset_list.add(plugin_name);
|
|
||||||
// real value
|
|
||||||
asset_values.add(asset_array[i]);
|
|
||||||
}
|
}
|
||||||
|
if (s != null) src = s.hasNext() ? s.next() : "";
|
||||||
|
String header = src.substring(src.indexOf("==UserScript=="), src.indexOf("==/UserScript=="));
|
||||||
|
// remove new line comments and replace with space
|
||||||
|
// this way we get double spaces instead of newline + double slash
|
||||||
|
header = header.replace("\n//", " ");
|
||||||
|
// get a list of key-value...split on multiple spaces
|
||||||
|
String[] attributes = header.split(" +");
|
||||||
|
String plugin_name = "not found";
|
||||||
|
for (int j = 0; j < attributes.length; j++) {
|
||||||
|
// search for name and use the value
|
||||||
|
if (attributes[j].equals("@name")) plugin_name = attributes[j+1];
|
||||||
|
}
|
||||||
|
asset_list.add(plugin_name);
|
||||||
|
// real value
|
||||||
|
asset_values.add(asset_array[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle bundle = getIntent().getExtras();
|
Bundle bundle = getIntent().getExtras();
|
||||||
|
@ -2,8 +2,10 @@ package com.cradle.iitc_mobile;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.WebChromeClient;
|
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() {
|
public IITC_WebViewClient getWebViewClient() {
|
||||||
return this.webclient;
|
return this.webclient;
|
||||||
}
|
}
|
||||||
@ -79,7 +95,7 @@ public class IITC_WebView extends WebView {
|
|||||||
Log.d("iitcm", "not connected to wifi...load tiles from cache");
|
Log.d("iitcm", "not connected to wifi...load tiles from cache");
|
||||||
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
||||||
} else {
|
} 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);
|
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,27 +135,24 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
String[] plugin_array = plugin_list.toArray(new String[0]);
|
String[] plugin_array = plugin_list.toArray(new String[0]);
|
||||||
|
|
||||||
for(int i = 0; i < plugin_list.size(); i++) {
|
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;
|
||||||
Log.d("iitcm", "adding plugin " + plugin_array[i]);
|
String src = "";
|
||||||
Scanner s = null;
|
try {
|
||||||
String src = "";
|
// load plugins from external storage if dev mode are enabled
|
||||||
try {
|
if (dev_enabled) {
|
||||||
// load plugins from external storage if dev mode are enabled
|
File js_file = new File(dev_path + "plugins/" + plugin_array[i]);
|
||||||
if (dev_enabled) {
|
s = new Scanner(js_file).useDelimiter("\\A");
|
||||||
File js_file = new File(dev_path + "plugins/" + plugin_array[i]);
|
|
||||||
s = new Scanner(js_file).useDelimiter("\\A");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
// load plugins from asset folder
|
|
||||||
s = new Scanner(am.open("plugins/" + plugin_array[i])).useDelimiter("\\A");
|
|
||||||
} catch (IOException e2) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e2.printStackTrace();
|
|
||||||
}
|
}
|
||||||
if (s != null) src = s.hasNext() ? s.next() : "";
|
else
|
||||||
view.loadUrl("javascript:" + src);
|
// load plugins from asset folder
|
||||||
|
s = new Scanner(am.open("plugins/" + plugin_array[i])).useDelimiter("\\A");
|
||||||
|
} catch (IOException e2) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (s != null) src = s.hasNext() ? s.next() : "";
|
||||||
|
view.loadUrl("javascript:" + src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user