Merge branch 'master' of https://github.com/jonatkins/ingress-intel-total-conversion
This commit is contained in:
commit
cacd90c1eb
@ -17,7 +17,7 @@ Debugging
|
|||||||
|
|
||||||
If you want to debug the APK, I suggest [reading up on Google’s documentation](https://developer.android.com/index.html).
|
If you want to debug the APK, I suggest [reading up on Google’s documentation](https://developer.android.com/index.html).
|
||||||
|
|
||||||
Debugging IITC(M) **after** it has booted is relatively easy: you can switch to the “debug” tab, which is a low end developer console. It renders all calls to `console.*`, so you can use it just like you expect. It may be easier to develop in a desktop browser. Set it up like explained [in the normal hacking guide](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/HACKING.md), but fake your user agent or modify the detection in `code/smartphone.js` and `main.js`. The device ID is printed to the debug console on IITC boot.
|
Debugging IITC(M) **after** it has booted is relatively easy: you can switch to the “debug” tab, which is a low end developer console. It renders all calls to `console.*`, so you can use it just like you expect. It may be easier to develop in a desktop browser. Set it up like explained [in the normal hacking guide](https://github.com/jonatkins/ingress-intel-total-conversion/blob/master/HACKING.md), but fake your user agent or modify the detection in `code/smartphone.js` and `main.js`. The device ID is printed to the debug console on IITC boot.
|
||||||
|
|
||||||
Debugging IITC(M) **before** it has booted requires the Android Developer Tools. Connecting your device and running `adb logcat` should print the debug log to your computer until the low-end dev console mentioned above is available.
|
Debugging IITC(M) **before** it has booted requires the Android Developer Tools. Connecting your device and running `adb logcat` should print the debug log to your computer until the low-end dev console mentioned above is available.
|
||||||
|
|
||||||
@ -29,4 +29,4 @@ Building the APK
|
|||||||
Set the ANDROID_HOME environment variable:
|
Set the ANDROID_HOME environment variable:
|
||||||
```export ANDROID_HOME=/path/to/android_sdk```
|
```export ANDROID_HOME=/path/to/android_sdk```
|
||||||
Then build the app via the build.py script ```./build.py mobile```
|
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
|
- 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 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)
|
- 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
|
- possibility to use a custom IITC script source
|
||||||
|
|
||||||
- a click on Portal link copies it to clipboard
|
- 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...
|
- more features will be added soon...
|
||||||
|
|
||||||
**The App only works with Android 4.0+**
|
**The App only works with Android 4.0+**
|
||||||
|
@ -24,11 +24,11 @@ public class IITC_JSInterface {
|
|||||||
// context of main activity
|
// context of main activity
|
||||||
Context context;
|
Context context;
|
||||||
HashMap<String, String> layer_ids;
|
HashMap<String, String> layer_ids;
|
||||||
boolean[] active_array;
|
boolean[] overlay_is_active;
|
||||||
String[] all_layers;
|
int active_base_layer;
|
||||||
|
String[] overlay_layers, base_layers;
|
||||||
int num_base_layers;
|
int num_base_layers;
|
||||||
int num_overlay_layers;
|
int num_overlay_layers;
|
||||||
int active_base_layer;
|
|
||||||
|
|
||||||
IITC_JSInterface(Context c) {
|
IITC_JSInterface(Context c) {
|
||||||
layer_ids = new HashMap<String, String>();
|
layer_ids = new HashMap<String, String>();
|
||||||
@ -64,27 +64,71 @@ public class IITC_JSInterface {
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get layers and list them in a dialog
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void setLayers(String base_layers, String overlay_layers) {
|
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 base_layersJSON = null;
|
||||||
JSONArray overlay_layersJSON = null;
|
JSONArray overlay_layersJSON = null;
|
||||||
|
Log.d("iitcm", base_layer);
|
||||||
try {
|
try {
|
||||||
base_layersJSON = new JSONArray(base_layers);
|
base_layersJSON = new JSONArray(base_layer);
|
||||||
overlay_layersJSON = new JSONArray(overlay_layers);
|
overlay_layersJSON = new JSONArray(overlay_layer);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get length and initialize arrays
|
||||||
num_base_layers = base_layersJSON.length();
|
num_base_layers = base_layersJSON.length();
|
||||||
num_overlay_layers = overlay_layersJSON.length();
|
num_overlay_layers = overlay_layersJSON.length();
|
||||||
int total_lenght = num_base_layers + num_overlay_layers;
|
overlay_is_active = new boolean[num_overlay_layers];
|
||||||
active_array = new boolean[total_lenght];
|
overlay_layers = new String[num_overlay_layers];
|
||||||
all_layers = new String[total_lenght];
|
base_layers = new String[num_base_layers];
|
||||||
layer_ids.clear();
|
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 ------------------------
|
// --------------- overlay layers ------------------------
|
||||||
for (int i = 0; i < overlay_layersJSON.length(); ++i) {
|
for (int i = 0; i < num_overlay_layers; ++i) {
|
||||||
try {
|
try {
|
||||||
String layer = overlay_layersJSON.getString(i);
|
String layer = overlay_layersJSON.getString(i);
|
||||||
layer = layer.replace("{", "");
|
layer = layer.replace("{", "");
|
||||||
@ -101,67 +145,80 @@ public class IITC_JSInterface {
|
|||||||
}
|
}
|
||||||
name = name.replace("\"", "");
|
name = name.replace("\"", "");
|
||||||
layer_ids.put(name, id);
|
layer_ids.put(name, id);
|
||||||
all_layers[i] = name;
|
this.overlay_layers[i] = name;
|
||||||
active_array[i] = isActive;
|
this.overlay_is_active[i] = isActive;
|
||||||
} catch (JSONException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------- base layers ------------------------
|
|
||||||
for (int i = 0; i < base_layersJSON.length(); ++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);
|
|
||||||
all_layers[i + num_overlay_layers] = name;
|
|
||||||
active_array[i + num_overlay_layers] = isActive;
|
|
||||||
if (isActive) active_base_layer = i + num_overlay_layers;
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// show overlay layers by default
|
||||||
|
show_multi_selection();
|
||||||
|
}
|
||||||
|
|
||||||
|
// show all overlay layers in a multi selection list dialog
|
||||||
|
private void show_multi_selection() {
|
||||||
// build the layer chooser dialog
|
// build the layer chooser dialog
|
||||||
AlertDialog.Builder d = new AlertDialog.Builder(context);
|
AlertDialog.Builder d_m = new AlertDialog.Builder(context);
|
||||||
OnMultiChoiceClickListener m_listener = new OnMultiChoiceClickListener() {
|
OnMultiChoiceClickListener m_listener = new OnMultiChoiceClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||||
// activate clicked layer
|
// activate clicked layer
|
||||||
((IITC_Mobile) context).getWebView().loadUrl("javascript: window.layerChooser.showLayer("
|
((IITC_Mobile) context).getWebView().loadUrl("javascript: window.layerChooser.showLayer("
|
||||||
+ layer_ids.get(all_layers[which]) + ","
|
+ layer_ids.get(overlay_layers[which]) + ","
|
||||||
+ active_array[which] + ");");
|
+ overlay_is_active[which] + ");");
|
||||||
// disable old base layer...we can only have one active base layer
|
|
||||||
if (which >= num_overlay_layers) {
|
|
||||||
active_array[active_base_layer] = false;
|
|
||||||
((AlertDialog) dialog).getListView().setItemChecked(active_base_layer, false);
|
|
||||||
active_base_layer = which;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
d.setMultiChoiceItems(all_layers, active_array , m_listener);
|
|
||||||
d.setPositiveButton("Close", new OnClickListener() {
|
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) {
|
||||||
|
show_single_selection();
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d_m.setNegativeButton("Close", new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
d.show();
|
d_m.setTitle("Overlay Layers");
|
||||||
|
d_m.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// show all base layers in a single selection list dialog
|
||||||
|
private void show_single_selection() {
|
||||||
|
OnClickListener s_listener = new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// activate clicked layer
|
||||||
|
((IITC_Mobile) context).getWebView().loadUrl("javascript: window.layerChooser.showLayer("
|
||||||
|
+ layer_ids.get(base_layers[which]) + ","
|
||||||
|
+ true + ");");
|
||||||
|
active_base_layer = which;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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) {
|
||||||
|
show_multi_selection();
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d_s.setNegativeButton("Close", new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d_s.setTitle("Base Layers");
|
||||||
|
d_s.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,6 +262,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
toggleFullscreen();
|
toggleFullscreen();
|
||||||
return true;
|
return true;
|
||||||
case R.id.layer_chooser:
|
case R.id.layer_chooser:
|
||||||
|
// the getLayers function calls the setLayers method of IITC_JSInterface
|
||||||
iitc_view.loadUrl("javascript: window.layerChooser.getLayers()");
|
iitc_view.loadUrl("javascript: window.layerChooser.getLayers()");
|
||||||
return true;
|
return true;
|
||||||
// get the users current location and focus it on map
|
// get the users current location and focus it on map
|
||||||
|
Loading…
x
Reference in New Issue
Block a user