This commit is contained in:
Jon Atkins 2013-05-24 15:54:35 +01:00
commit 84e0aeb679
22 changed files with 305 additions and 49 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
mobile/IngressIntelTC/bin
build
localbuildsettings.py
*.pyc

View File

@ -225,7 +225,7 @@ if buildMobile:
except:
pass
shutil.rmtree("mobile/assets/plugins")
shutil.copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins", ignore=shutil.ignore_patterns('*.meta.js', 'force-https*', 'privacy-view*'))
shutil.copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins", ignore=shutil.ignore_patterns('*.meta.js', 'force-https*', 'privacy-view*', 'speech-search*'))
if buildMobile != 'copyonly':

View File

@ -7,23 +7,28 @@ window.setupGeosearch = function() {
var search = $(this).val();
if ( window.search(search) ) return;
e.preventDefault();
});
$('#geosearchwrapper img').click(function(){
map.locate({setView : true, maxZoom: 13});
});
}
window.search = function(search) {
if (!runHooks('geoSearch', search)) {
return;
return true;
}
$.getJSON(NOMINATIM + encodeURIComponent(search), function(data) {
if(!data || !data[0]) return;
if(!data || !data[0]) return true;
var b = data[0].boundingbox;
if(!b) return;
if(!b) return true;
var southWest = new L.LatLng(b[0], b[2]),
northEast = new L.LatLng(b[1], b[3]),
bounds = new L.LatLngBounds(southWest, northEast);
window.map.fitBounds(bounds);
if(window.isSmartphone()) window.smartphone.mapButton.click();
});
e.preventDefault();
});
$('#geosearchwrapper img').click(function(){
map.locate({setView : true, maxZoom: 13});;
});
}

37
mobile/.gitignore vendored
View File

@ -1,11 +1,34 @@
.classpath
.project
.settings/
bin/
gen/
libs/
proguard-project.txt
local.properties
assets/total-conversion-build.user.js
assets/user-location.user.js
assets/plugins/
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
out/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# IntelliJ IDEA user settings
*.iws
.idea/workspace.xml
.idea/tasks.xml
# Proguard logs
proguard_logs/

1
mobile/.idea/.name generated Normal file
View File

@ -0,0 +1 @@
IITC-Mobile

23
mobile/.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,5 @@
<component name="CopyrightManager">
<settings default="">
<module2copyright />
</settings>
</component>

5
mobile/.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

10
mobile/.idea/misc.xml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android 4.2.2 Platform" project-jdk-type="Android SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

9
mobile/.idea/modules.xml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/IITC-Mobile.iml" filepath="$PROJECT_DIR$/IITC-Mobile.iml" />
</modules>
</component>
</project>

5
mobile/.idea/scopes/scope_settings.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

8
mobile/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -24,13 +24,23 @@
android:name="com.cradle.iitc_mobile.IITC_Mobile"
android:theme="@style/AppBaseTheme"
android:label="@string/app_name"
android:launchMode="singleTop"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<!-- Used for Samsung Multi-Window support -->
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
</intent-filter>
<!-- Receives the search request. -->
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
<!-- No category needed, because the Intent will specify this class component-->
</intent-filter>
<!-- Handles the implicit intent to VIEW the www.ingress.com/intel URI -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
@ -46,6 +56,10 @@
android:scheme="http"
android:pathPrefix="/intel"></data>
</intent-filter>
<!-- Points to searchable meta data. -->
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<activity
android:name="com.cradle.iitc_mobile.IITC_Settings"
@ -54,6 +68,7 @@
android:configChanges="orientation|keyboard|keyboardHidden|screenSize">
</activity>
<!-- START Used for Samsung Multi-Window support -->
<uses-library
android:name="com.sec.android.app.multiwindow"
android:required="false"/>
@ -74,7 +89,12 @@
<meta-data
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H"
android:resource="@dimen/app_minimumsize_h"/>
<!-- END Used for Samsung Multi-Window support -->
<!-- Points to searchable activity so the whole app can invoke search. -->
<meta-data
android:name="android.app.default_searchable"
android:value="com.cradle.iitc_mobile.IITC_Mobile"/>
</application>
</manifest>

25
mobile/IITC-Mobile.iml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<notImportedProperties>
<property>MANIFEST_FILE_PATH</property>
<property>RESOURCES_DIR_PATH</property>
<property>ASSETS_DIR_PATH</property>
<property>NATIVE_LIBS_DIR_PATH</property>
</notImportedProperties>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

35
mobile/build.gradle Normal file
View File

@ -0,0 +1,35 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
}
android {
compileSdkVersion 17
buildToolsVersion "17"
defaultConfig {
minSdkVersion 14
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}

25
mobile/mobile.iml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<notImportedProperties>
<property>MANIFEST_FILE_PATH</property>
<property>RESOURCES_DIR_PATH</property>
<property>ASSETS_DIR_PATH</property>
<property>NATIVE_LIBS_DIR_PATH</property>
</notImportedProperties>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,16 @@
# view res/xml/preferences.xml #generated:4
-keep class com.cradle.iitc_mobile.IITC_AboutDialogPreference { <init>(...); }
# view AndroidManifest.xml #generated:23
-keep class com.cradle.iitc_mobile.IITC_Mobile { <init>(...); }
# view AndroidManifest.xml #generated:56
-keep class com.cradle.iitc_mobile.IITC_SearchableActivity { <init>(...); }
# view AndroidManifest.xml #generated:50
-keep class com.cradle.iitc_mobile.IITC_Settings { <init>(...); }
# view res/layout/activity_main.xml #generated:6
-keep class com.cradle.iitc_mobile.IITC_WebView { <init>(...); }
-keep class com.cradle.iitc_mobile.IITC_JSInterface { <init>(...); }

View File

@ -1,5 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/menu_search"
android:title="@string/menu_search"
android:icon="@drawable/action_search"
android:showAsAction="ifRoom|collapseActionView"
android:actionViewClass="android.widget.SearchView" />
<item
android:id="@+id/menu_map"
android:icon="@drawable/location_map"
@ -47,20 +51,20 @@
</item>
</menu>
</item>
<item
android:id="@+id/locate"
android:icon="@drawable/device_access_location_found"
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:title="@string/locate">
</item>
<item
android:id="@+id/layer_chooser"
android:icon="@drawable/ic_layer_chooser"
android:orderInCategory="105"
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:title="@string/layer_chooser">
</item>
<item
android:id="@+id/locate"
android:icon="@drawable/device_access_location_found"
android:orderInCategory="105"
android:showAsAction="ifRoom"
android:title="@string/locate">
</item>
<item
android:id="@+id/reload_button"
android:icon="@drawable/navigation_refresh"

View File

@ -58,4 +58,6 @@
<string name="menu_debug">Debug</string>
<string name="choose_account_to_login">Choose account to login</string>
<string name="login_failed">Login failed.</string>
<string name="search_hint">Search Locations</string>
<string name="menu_search">Search</string>
</resources>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="@string/search_hint"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:voiceLanguageModel="web_search"
android:voiceMaxResults="1">
</searchable>

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import android.app.ActionBar;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -25,6 +26,7 @@ import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.SearchView;
import android.widget.Toast;
public class IITC_Mobile extends Activity {
@ -42,6 +44,7 @@ public class IITC_Mobile extends Activity {
private boolean fullscreen_actionbar = false;
private ActionBar actionBar;
private IITC_DeviceAccountLogin mLogin;
private MenuItem searchMenuItem;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -98,7 +101,7 @@ public class IITC_Mobile extends Activity {
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
Bundle extras) {
}
public void onProviderEnabled(String provider) {
@ -120,8 +123,17 @@ public class IITC_Mobile extends Activity {
fullscreen_actionbar = sharedPref.getBoolean("pref_fullscreen_actionbar", false);
handleIntent(getIntent(), true);
}
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleIntent(intent, false);
}
private void handleIntent(Intent intent, boolean onCreate) {
// load new iitc web view with ingress intel page
Intent intent = getIntent();
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = intent.getData();
@ -133,7 +145,15 @@ public class IITC_Mobile extends Activity {
Log.d("iitcm", "loading url...");
this.loadUrl(url);
}
} else {
} else if (Intent.ACTION_SEARCH.equals(action)) {
String query = intent.getStringExtra(SearchManager.QUERY);
query = query.replace("'", "''");
final SearchView searchView =
(SearchView) searchMenuItem.getActionView();
searchView.setQuery(query, false);
searchView.clearFocus();
iitc_view.loadUrl("javascript:search('" + query + "');");
} else if (onCreate){
this.loadUrl(intel_url);
}
}
@ -238,7 +258,14 @@ public class IITC_Mobile extends Activity {
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
this.searchMenuItem = menu.findItem(R.id.menu_search);
final SearchView searchView =
(SearchView) searchMenuItem.getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
return true;
}
@ -246,63 +273,63 @@ public class IITC_Mobile extends Activity {
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case android.R.id.home :
case android.R.id.home:
iitc_view.loadUrl("javascript: window.show('map');");
actionBar.setTitle(getString(R.string.menu_map));
return true;
case R.id.menu_map :
case R.id.menu_map:
iitc_view.loadUrl("javascript: window.show('map');");
actionBar.setTitle(getString(R.string.menu_map));
return true;
case R.id.reload_button :
case R.id.reload_button:
this.loadUrl(intel_url);
actionBar.setTitle(getString(R.string.menu_map));
return true;
case R.id.toggle_fullscreen :
case R.id.toggle_fullscreen:
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
case R.id.locate :
// get the users current location and focus it on map
case R.id.locate:
iitc_view.loadUrl("javascript: window.show('map');");
iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 15});");
actionBar.setTitle(getString(R.string.menu_map));
return true;
// start settings activity
case R.id.action_settings :
// start settings activity
case R.id.action_settings:
Intent intent = new Intent(this, IITC_Settings.class);
intent.putExtra("iitc_version", iitc_view.getWebViewClient()
.getIITCVersion());
startActivity(intent);
return true;
case R.id.menu_info :
case R.id.menu_info:
iitc_view.loadUrl("javascript: window.show('info');");
actionBar.setTitle(getString(R.string.menu_info));
return true;
case R.id.menu_full :
case R.id.menu_full:
iitc_view.loadUrl("javascript: window.show('full');");
actionBar.setTitle(getString(R.string.menu_full));
return true;
case R.id.menu_compact :
case R.id.menu_compact:
iitc_view.loadUrl("javascript: window.show('compact');");
actionBar.setTitle(getString(R.string.menu_compact));
return true;
case R.id.menu_public :
case R.id.menu_public:
iitc_view.loadUrl("javascript: window.show('public');");
actionBar.setTitle(getString(R.string.menu_public));
return true;
case R.id.menu_faction :
case R.id.menu_faction:
iitc_view.loadUrl("javascript: window.show('faction');");
actionBar.setTitle(getString(R.string.menu_faction));
return true;
case R.id.menu_debug :
case R.id.menu_debug:
iitc_view.loadUrl("javascript: window.show('debug')");
actionBar.setTitle(getString(R.string.menu_debug));
return true;
default :
default:
return super.onOptionsItemSelected(item);
}
}
@ -377,12 +404,12 @@ public class IITC_Mobile extends Activity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_LOGIN :
case REQUEST_LOGIN:
// authentication activity has returned. mLogin will continue authentication
mLogin.onActivityResult(resultCode, data);
break;
default :
default:
super.onActivityResult(requestCode, resultCode, data);
}
}
@ -391,7 +418,7 @@ public class IITC_Mobile extends Activity {
* called by IITC_WebViewClient when the Google login form is opened.
*/
public void onReceivedLoginRequest(IITC_WebViewClient client, WebView view,
String realm, String account, String args) {
String realm, String account, String args) {
mLogin = new IITC_DeviceAccountLogin(this, view, client);
mLogin.startLogin(realm, account, args);
}

View File

@ -26,6 +26,7 @@ public class IITC_WebView extends WebView {
// init web view
private void iitc_init(Context c) {
if ( this.isInEditMode() ) return;
settings = this.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);