some comments and update README+HACKING
This commit is contained in:
parent
115727bf34
commit
74a77d874f
@ -29,4 +29,4 @@ Building the APK
|
||||
Set the ANDROID_HOME environment variable:
|
||||
```export ANDROID_HOME=/path/to/android_sdk```
|
||||
Then build the app via the build.py script ```./build.py mobile```
|
||||
- **Eclipse:** Just import this project and klick the build button. Ensure that you have iitc.js in your assets folder. This is automatically created, when executing ```./build.py mobile```. Otherwise, just copy the IITC script to the assets folder and rename it to iitc.js
|
||||
- **Eclipse:** Just import this project and klick the build button. Ensure that you have total-conversion-build.user.js and user-location.user.js in your assets folder. This is automatically created, when executing ```./build.py mobile```. Otherwise, just copy the scripts to the assets folder.
|
||||
|
@ -7,16 +7,24 @@ The Android App behaves like the desktop version, but uses the mobile view, whic
|
||||
|
||||
- plugin support
|
||||
|
||||
- support for unofficial plugins. just copy the *.user.js file to ```<storage_path>/IITC_Mobile/plugins/``` and they should be parsed on start-up
|
||||
|
||||
- in-app layer chooser
|
||||
|
||||
- in-app IITC buttons
|
||||
|
||||
- show users current location
|
||||
|
||||
- a geo intent is sent, when a portals Map link is clicked (lets you navigate to portals)
|
||||
|
||||
- a geolocate button (you have to enable GPS satellites + location access to use this feature)
|
||||
|
||||
- toggle between desktop and mobile view (nice for tablets)
|
||||
|
||||
- possibility to use a custom IITC script source
|
||||
|
||||
- a click on Portal link copies it to clipboard
|
||||
|
||||
- developer mode: all script source will be loaded from ```<storage_path>/IITC_Mobile/dev/```
|
||||
|
||||
- more features will be added soon...
|
||||
|
||||
**The App only works with Android 4.0+**
|
||||
|
@ -64,11 +64,18 @@ public class IITC_JSInterface {
|
||||
.show();
|
||||
}
|
||||
|
||||
// get layers and list them in a dialog
|
||||
@JavascriptInterface
|
||||
public void setLayers(String base_layer, String overlay_layer) {
|
||||
|
||||
/*
|
||||
* the layer strings have a form like:
|
||||
* [{"layerId":27,"name":"MapQuest OSM","active":true},{"layerId":28,"name":"Default Ingress Map","active":false}]
|
||||
* Put it in a JSONArray and parse it
|
||||
*/
|
||||
JSONArray base_layersJSON = null;
|
||||
JSONArray overlay_layersJSON = null;
|
||||
Log.d("iitcm", base_layer);
|
||||
try {
|
||||
base_layersJSON = new JSONArray(base_layer);
|
||||
overlay_layersJSON = new JSONArray(overlay_layer);
|
||||
@ -84,6 +91,42 @@ public class IITC_JSInterface {
|
||||
base_layers = new String[num_base_layers];
|
||||
layer_ids.clear();
|
||||
|
||||
// --------------- base layers ------------------------
|
||||
for (int i = 0; i < num_base_layers; ++i) {
|
||||
try {
|
||||
String layer = base_layersJSON.getString(i);
|
||||
layer = layer.replace("{", "");
|
||||
layer = layer.replace("}", "");
|
||||
/*
|
||||
* we now should have a string like
|
||||
* ["layerId":27,"name":"MapQuest OSM","active":true]
|
||||
* split it on ,
|
||||
*/
|
||||
String[] layers = layer.split(",");
|
||||
/*
|
||||
* we should have 3 strings in a form like
|
||||
* "name":"MapQuest OSM"
|
||||
* get the values and get rid of the quotation marks
|
||||
*/
|
||||
String id = "";
|
||||
String name = "";
|
||||
boolean isActive = false;
|
||||
for (int j = 0; j < layers.length; ++j) {
|
||||
String[] values = layers[j].split(":");
|
||||
if (values[0].contains("active")) isActive = values[1].equals("true");
|
||||
if (values[0].contains("layerId")) id = values[1];
|
||||
if (values[0].contains("name")) name = values[1];
|
||||
}
|
||||
name = name.replace("\"", "");
|
||||
layer_ids.put(name, id);
|
||||
this.base_layers[i] = name;
|
||||
if (isActive) active_base_layer = i;
|
||||
} catch (JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------- overlay layers ------------------------
|
||||
for (int i = 0; i < num_overlay_layers; ++i) {
|
||||
try {
|
||||
@ -109,32 +152,6 @@ public class IITC_JSInterface {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------- base layers ------------------------
|
||||
for (int i = 0; i < num_base_layers; ++i) {
|
||||
try {
|
||||
String layer = base_layersJSON.getString(i);
|
||||
layer = layer.replace("{", "");
|
||||
layer = layer.replace("}", "");
|
||||
String[] layers = layer.split(",");
|
||||
String id = "";
|
||||
String name = "";
|
||||
boolean isActive = false;
|
||||
for (int j = 0; j < layers.length; ++j) {
|
||||
String[] values = layers[j].split(":");
|
||||
if (values[0].contains("active")) isActive = values[1].equals("true");
|
||||
if (values[0].contains("layerId")) id = values[1];
|
||||
if (values[0].contains("name")) name = values[1];
|
||||
}
|
||||
name = name.replace("\"", "");
|
||||
layer_ids.put(name, id);
|
||||
this.base_layers[i] = name;
|
||||
if (isActive) active_base_layer = i;
|
||||
} catch (JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// show overlay layers by default
|
||||
show_multi_selection();
|
||||
}
|
||||
@ -155,6 +172,7 @@ public class IITC_JSInterface {
|
||||
};
|
||||
|
||||
d_m.setMultiChoiceItems(overlay_layers, overlay_is_active , m_listener);
|
||||
// switch to base layers
|
||||
d_m.setPositiveButton("Base Layers", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@ -186,6 +204,7 @@ public class IITC_JSInterface {
|
||||
};
|
||||
AlertDialog.Builder d_s = new AlertDialog.Builder(context);
|
||||
d_s.setSingleChoiceItems(base_layers, active_base_layer, s_listener);
|
||||
// switch to overlay layers
|
||||
d_s.setPositiveButton("Overlay Layers", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -262,6 +262,7 @@ public class IITC_Mobile extends Activity {
|
||||
toggleFullscreen();
|
||||
return true;
|
||||
case R.id.layer_chooser:
|
||||
// the getLayers function calls the setLayers method of IITC_JSInterface
|
||||
iitc_view.loadUrl("javascript: window.layerChooser.getLayers()");
|
||||
return true;
|
||||
// get the users current location and focus it on map
|
||||
|
Loading…
x
Reference in New Issue
Block a user