Merge branch 'master' of https://github.com/jonatkins/ingress-intel-total-conversion
@ -566,8 +566,8 @@ function boot() {
|
|||||||
window.iitcLoaded = true;
|
window.iitcLoaded = true;
|
||||||
window.runHooks('iitcLoaded');
|
window.runHooks('iitcLoaded');
|
||||||
|
|
||||||
if (typeof android !== 'undefined' && android && android.removeSplashScreen) {
|
if (typeof android !== 'undefined' && android && android.bootFinished) {
|
||||||
android.removeSplashScreen();
|
android.bootFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
external/taphold.js
vendored
@ -106,12 +106,16 @@
|
|||||||
$(this).bind((touchSupported ? "touchstart" : "mousedown"), data, startHandler)
|
$(this).bind((touchSupported ? "touchstart" : "mousedown"), data, startHandler)
|
||||||
.bind((touchSupported ? "touchend" : "mouseup"), stopHandler)
|
.bind((touchSupported ? "touchend" : "mouseup"), stopHandler)
|
||||||
.bind((touchSupported ? "touchmove" : "mouseleave"), leaveHandler);
|
.bind((touchSupported ? "touchmove" : "mouseleave"), leaveHandler);
|
||||||
|
if(touchSupported)
|
||||||
|
$(this).bind("touchcancel", leaveHandler);
|
||||||
},
|
},
|
||||||
teardown: function(namespaces)
|
teardown: function(namespaces)
|
||||||
{
|
{
|
||||||
$(this).unbind((touchSupported ? "touchstart" : "mousedown"), startHandler)
|
$(this).unbind((touchSupported ? "touchstart" : "mousedown"), startHandler)
|
||||||
.unbind((touchSupported ? "touchend" : "mouseup"), stopHandler)
|
.unbind((touchSupported ? "touchend" : "mouseup"), stopHandler)
|
||||||
.unbind((touchSupported ? "touchmove" : "mouseleave"), leaveHandler);
|
.unbind((touchSupported ? "touchmove" : "mouseleave"), leaveHandler);
|
||||||
|
if(touchSupported)
|
||||||
|
$(this).unbind("touchcancel", leaveHandler);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.cradle.iitc_mobile"
|
package="com.cradle.iitc_mobile"
|
||||||
android:versionCode="49"
|
android:versionCode="51"
|
||||||
android:versionName="0.6.5">
|
android:versionName="0.7.1">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="14"
|
android:minSdkVersion="14"
|
||||||
@ -18,8 +18,7 @@
|
|||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@drawable/ic_iitcm"
|
android:icon="@drawable/ic_iitcm"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme">
|
||||||
android:uiOptions="splitActionBarWhenNarrow">
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.cradle.iitc_mobile.IITC_Mobile"
|
android:name="com.cradle.iitc_mobile.IITC_Mobile"
|
||||||
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
|
||||||
@ -137,4 +136,4 @@
|
|||||||
android:value="com.cradle.iitc_mobile.IITC_Mobile"/>
|
android:value="com.cradle.iitc_mobile.IITC_Mobile"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
BIN
mobile/res/drawable-hdpi/collections_view_as_list.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
mobile/res/drawable-hdpi/collections_view_as_list_compact.png
Normal file
After Width: | Height: | Size: 435 B |
BIN
mobile/res/drawable-hdpi/drawer_shadow.9.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
mobile/res/drawable-hdpi/ic_debug.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
mobile/res/drawable-hdpi/ic_drawer.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
mobile/res/drawable-hdpi/social_cc_bcc.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
mobile/res/drawable-mdpi/collections_view_as_list.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
mobile/res/drawable-mdpi/collections_view_as_list_compact.png
Normal file
After Width: | Height: | Size: 334 B |
BIN
mobile/res/drawable-mdpi/drawer_shadow.9.png
Normal file
After Width: | Height: | Size: 158 B |
BIN
mobile/res/drawable-mdpi/ic_debug.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
mobile/res/drawable-mdpi/ic_drawer.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
mobile/res/drawable-mdpi/social_cc_bcc.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
mobile/res/drawable-xhdpi/collections_view_as_list.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
mobile/res/drawable-xhdpi/collections_view_as_list_compact.png
Normal file
After Width: | Height: | Size: 450 B |
BIN
mobile/res/drawable-xhdpi/drawer_shadow.9.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
mobile/res/drawable-xhdpi/ic_debug.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
mobile/res/drawable-xhdpi/ic_drawer.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
mobile/res/drawable-xhdpi/social_cc_bcc.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
@ -1,18 +1,45 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_height="fill_parent"
|
android:id="@+id/drawer_layout"
|
||||||
android:orientation="vertical">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.cradle.iitc_mobile.IITC_WebView
|
<com.cradle.iitc_mobile.IITC_WebView
|
||||||
android:id="@+id/iitc_webview"
|
android:id="@+id/iitc_webview"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent" />
|
android:layout_height="match_parent"/>
|
||||||
<ImageView android:id="@+id/imageLoading"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:paddingTop="20dp"
|
|
||||||
android:paddingBottom="20dp"
|
|
||||||
android:background="@android:color/darker_gray"
|
|
||||||
android:src="@drawable/iitc" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
<ImageView
|
||||||
|
android:id="@+id/imageLoading"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:src="@drawable/iitc"
|
||||||
|
tools:ignore="ContentDescription"/>
|
||||||
|
|
||||||
|
<!-- The navigation drawer -->
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/left_drawer"
|
||||||
|
android:layout_width="180dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:background="@color/drawer_background"
|
||||||
|
android:choiceMode="singleChoice"
|
||||||
|
android:divider="@android:color/transparent"
|
||||||
|
android:dividerHeight="0dp"/>
|
||||||
|
|
||||||
|
<!-- The right drawer -->
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/right_drawer"
|
||||||
|
android:layout_width="260dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:background="@color/drawer_background"
|
||||||
|
android:divider="@android:color/transparent"
|
||||||
|
android:dividerHeight="0dp"/>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
10
mobile/res/layout/list_item_narrow.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?android:attr/activatedBackgroundIndicator"
|
||||||
|
android:drawablePadding="?android:attr/listPreferredItemPaddingLeft"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||||
|
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItemSmall"/>
|
11
mobile/res/layout/list_item_selectable.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?android:attr/activatedBackgroundIndicator"
|
||||||
|
android:drawablePadding="?android:attr/listPreferredItemPaddingLeft"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||||
|
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItemSmall"/>
|
40
mobile/res/layout/map_options_header.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="?android:attr/listSeparatorTextViewStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:labelFor="@+id/spinnerHighlighter"
|
||||||
|
android:paddingLeft="5dip"
|
||||||
|
android:text="@string/label_highlighter"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinnerHighlighter"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="?android:attr/listSeparatorTextViewStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:labelFor="@+id/spinnerBaseLayer"
|
||||||
|
android:paddingLeft="5dip"
|
||||||
|
android:text="@string/label_base_layer"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinnerBaseLayer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="?android:attr/listSeparatorTextViewStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="5dip"
|
||||||
|
android:text="@string/label_overlay_layers"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -6,64 +6,24 @@
|
|||||||
android:showAsAction="ifRoom|collapseActionView"
|
android:showAsAction="ifRoom|collapseActionView"
|
||||||
android:actionViewClass="android.widget.SearchView" />
|
android:actionViewClass="android.widget.SearchView" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_info"
|
android:id="@+id/locate"
|
||||||
android:icon="@drawable/action_about"
|
android:icon="@drawable/device_access_location_found"
|
||||||
android:orderInCategory="30"
|
android:orderInCategory="100"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/menu_info">
|
android:title="@string/locate">
|
||||||
</item>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_chat"
|
|
||||||
android:icon="@drawable/social_group"
|
|
||||||
android:orderInCategory="35"
|
|
||||||
android:showAsAction="ifRoom"
|
|
||||||
android:title="@string/menu_chat">
|
|
||||||
<menu>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_full"
|
|
||||||
android:orderInCategory="40"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/menu_full">
|
|
||||||
</item>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_compact"
|
|
||||||
android:orderInCategory="50"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/menu_compact">
|
|
||||||
</item>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_public"
|
|
||||||
android:orderInCategory="60"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/menu_public">
|
|
||||||
</item>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_faction"
|
|
||||||
android:orderInCategory="70"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/menu_faction">
|
|
||||||
</item>
|
|
||||||
</menu>
|
|
||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/layer_chooser"
|
android:id="@+id/layer_chooser"
|
||||||
android:icon="@drawable/ic_layer_chooser"
|
android:icon="@drawable/ic_layer_chooser"
|
||||||
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:orderInCategory="105"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/locate">
|
android:title="@string/layer_chooser">
|
||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/reload_button"
|
android:id="@+id/reload_button"
|
||||||
android:icon="@drawable/navigation_refresh"
|
android:icon="@drawable/navigation_refresh"
|
||||||
android:orderInCategory="110"
|
android:orderInCategory="110"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="never"
|
||||||
android:title="@string/reload">
|
android:title="@string/reload">
|
||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
@ -73,24 +33,17 @@
|
|||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/toggle_fullscreen">
|
android:title="@string/toggle_fullscreen">
|
||||||
</item>
|
</item>
|
||||||
<item
|
|
||||||
android:id="@+id/action_settings"
|
|
||||||
android:icon="@drawable/action_settings"
|
|
||||||
android:orderInCategory="130"
|
|
||||||
android:showAsAction="ifRoom"
|
|
||||||
android:title="@string/action_settings">
|
|
||||||
</item>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_debug"
|
|
||||||
android:icon="@drawable/alerts_and_states_warning"
|
|
||||||
android:orderInCategory="190"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/menu_debug">
|
|
||||||
</item>
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_clear_cookies"
|
android:id="@+id/menu_clear_cookies"
|
||||||
android:orderInCategory="200"
|
android:orderInCategory="130"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/menu_clear_cookies">
|
android:title="@string/menu_clear_cookies">
|
||||||
</item>
|
</item>
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:icon="@drawable/action_settings"
|
||||||
|
android:orderInCategory="200"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/action_settings">
|
||||||
|
</item>
|
||||||
</menu>
|
</menu>
|
@ -7,6 +7,8 @@
|
|||||||
<string name="activity_share">Share using…</string>
|
<string name="activity_share">Share using…</string>
|
||||||
<string name="activity_share_to_clipboard">Copy to clipboard</string>
|
<string name="activity_share_to_clipboard">Copy to clipboard</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
|
<string name="drawer_open">Show navigation menu</string>
|
||||||
|
<string name="drawer_close">Hide navigation menu</string>
|
||||||
<string name="reload">Reload IITC</string>
|
<string name="reload">Reload IITC</string>
|
||||||
<string name="version">Print Version</string>
|
<string name="version">Print Version</string>
|
||||||
<string name="toggle_fullscreen">Toggle fullscreen</string>
|
<string name="toggle_fullscreen">Toggle fullscreen</string>
|
||||||
@ -53,7 +55,17 @@
|
|||||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
PERFORMANCE OF THIS SOFTWARE.]]>
|
PERFORMANCE OF THIS SOFTWARE.]]>
|
||||||
</string>
|
</string>
|
||||||
|
<string name="notice_drawers">
|
||||||
|
<![CDATA[IITCm recently changed its navigation structure. How to use it:<br><br>
|
||||||
|
• Navigation: swipe from the left edge of your screen (or click the app icon) to evoke the Navigation Drawer.
|
||||||
|
Click the app icon again to return to the map.<br><br>
|
||||||
|
• Layers/Highlights: swipe from the right edge of your screen (or click the layer-chooser icon in the ActionBar)
|
||||||
|
to evoke the Layer Drawer]]>
|
||||||
|
</string>
|
||||||
|
<string name="notice_info">
|
||||||
|
<![CDATA[Hint: The info screen will open if you tap and hold a portal for a second.]]>
|
||||||
|
</string>
|
||||||
|
|
||||||
<string name="pref_ui_cat">UI</string>
|
<string name="pref_ui_cat">UI</string>
|
||||||
<string name="pref_misc_cat">Misc</string>
|
<string name="pref_misc_cat">Misc</string>
|
||||||
<string name="pref_plugins">IITC Plugins</string>
|
<string name="pref_plugins">IITC Plugins</string>
|
||||||
@ -63,7 +75,7 @@
|
|||||||
<string name="pref_user_zoom">Show zoom control</string>
|
<string name="pref_user_zoom">Show zoom control</string>
|
||||||
<string name="pref_user_zoom_sum">Shows +/- buttons even on multitouch capable devices.</string>
|
<string name="pref_user_zoom_sum">Shows +/- buttons even on multitouch capable devices.</string>
|
||||||
<string name="pref_fullscreen_actionbar">Hide Action Bar in fullscreen mode</string>
|
<string name="pref_fullscreen_actionbar">Hide Action Bar in fullscreen mode</string>
|
||||||
<string name="pref_fullscreen_actionbar_sum">Nice for screenshots. Note: IITCM cannot be controlled without Action Bar.</string>
|
<string name="pref_fullscreen_actionbar_sum">Nice for screenshots. Note: IITCm can still be controlled via the Navigation Drawers</string>
|
||||||
<string name="pref_force_desktop">Force desktop mode</string>
|
<string name="pref_force_desktop">Force desktop mode</string>
|
||||||
<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_force_https">Force https</string>
|
<string name="pref_force_https">Force https</string>
|
||||||
@ -81,13 +93,6 @@
|
|||||||
<string name="pref_select_iitc">IITC source</string>
|
<string name="pref_select_iitc">IITC source</string>
|
||||||
<string name="pref_select_iitc_sum">Load IITC main script from url or use local script. Currently used source:</string>
|
<string name="pref_select_iitc_sum">Load IITC main script from url or use local script. Currently used source:</string>
|
||||||
|
|
||||||
<string name="menu_chat">Chat</string>
|
|
||||||
<string name="menu_full">Full</string>
|
|
||||||
<string name="menu_compact">Compact</string>
|
|
||||||
<string name="menu_public">Public</string>
|
|
||||||
<string name="menu_faction">Faction</string>
|
|
||||||
<string name="menu_info">Info</string>
|
|
||||||
<string name="menu_debug">Debug</string>
|
|
||||||
<string name="menu_clear_cookies">Clear Cookies</string>
|
<string name="menu_clear_cookies">Clear Cookies</string>
|
||||||
<string name="menu_search">Search</string>
|
<string name="menu_search">Search</string>
|
||||||
<string name="choose_account_to_login">Choose account to login</string>
|
<string name="choose_account_to_login">Choose account to login</string>
|
||||||
@ -100,8 +105,8 @@
|
|||||||
<string name="tab_share">Share</string>
|
<string name="tab_share">Share</string>
|
||||||
<string name="tab_browser">Browser</string>
|
<string name="tab_browser">Browser</string>
|
||||||
|
|
||||||
<string name="base_layers">Base Layers</string>
|
<string name="label_highlighter">Highlighter</string>
|
||||||
<string name="overlay_layers">Overlay Layers</string>
|
<string name="label_base_layer">Base Layer</string>
|
||||||
<string name="toggle_layer_selection">Deselect/Select all</string>
|
<string name="label_overlay_layers">Overlay Layers</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -17,4 +17,6 @@
|
|||||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<color name="drawer_background">#99111111</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -26,7 +26,7 @@
|
|||||||
android:key="pref_fullscreen_actionbar"
|
android:key="pref_fullscreen_actionbar"
|
||||||
android:title="@string/pref_fullscreen_actionbar"
|
android:title="@string/pref_fullscreen_actionbar"
|
||||||
android:summary="@string/pref_fullscreen_actionbar_sum"
|
android:summary="@string/pref_fullscreen_actionbar_sum"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="true" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="pref_force_desktop"
|
android:key="pref_force_desktop"
|
||||||
android:title="@string/pref_force_desktop"
|
android:title="@string/pref_force_desktop"
|
||||||
|
@ -1,158 +0,0 @@
|
|||||||
package com.cradle.iitc_mobile;
|
|
||||||
|
|
||||||
import android.app.ActionBar;
|
|
||||||
import android.app.ActionBar.OnNavigationListener;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
public class IITC_ActionBarHelper implements OnNavigationListener {
|
|
||||||
// Show/hide the up arrow on the very left
|
|
||||||
// getActionBar().setDisplayHomeAsUpEnabled(enabled);
|
|
||||||
|
|
||||||
// Show/hide the activity icon/logo
|
|
||||||
// getActionBar().setDisplayShowHomeEnabled(enabled);
|
|
||||||
|
|
||||||
// Show/hide the activity title
|
|
||||||
// getActionBar().setDisplayShowTitleEnabled(enabled);
|
|
||||||
|
|
||||||
// Makes the icon/title clickable
|
|
||||||
// getActionBar().setHomeButtonEnabled(enabled);
|
|
||||||
|
|
||||||
private class HighlighterAdapter extends ArrayAdapter<String> {
|
|
||||||
public HighlighterAdapter() {
|
|
||||||
super(mIitc, android.R.layout.simple_list_item_1);
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(String object) {
|
|
||||||
super.remove(object); // to avoid duplicates
|
|
||||||
super.add(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
super.clear();
|
|
||||||
add("No Highlights");// Probably must be the same as window._no_highlighter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IITC_Mobile mIitc;
|
|
||||||
private ActionBar mActionBar;
|
|
||||||
private SharedPreferences mPrefs;
|
|
||||||
private HighlighterAdapter mHighlighters;
|
|
||||||
|
|
||||||
private String mActiveHighlighter = null;
|
|
||||||
private boolean mDesktopMode = false;
|
|
||||||
private boolean mFullscreen = false;
|
|
||||||
private boolean mHideInFullscreen = false;
|
|
||||||
private int mPane = android.R.id.home;
|
|
||||||
|
|
||||||
public IITC_ActionBarHelper(IITC_Mobile activity, ActionBar bar) {
|
|
||||||
mIitc = activity;
|
|
||||||
mActionBar = bar;
|
|
||||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
|
||||||
mHighlighters = new HighlighterAdapter();
|
|
||||||
|
|
||||||
mActionBar.setDisplayShowHomeEnabled(true); // show icon
|
|
||||||
mActionBar.setListNavigationCallbacks(mHighlighters, this);
|
|
||||||
|
|
||||||
onPrefChanged(); // also calls updateActionBar()
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateActionBar() {
|
|
||||||
boolean showHighlighter = true;
|
|
||||||
|
|
||||||
if (mDesktopMode) {
|
|
||||||
mActionBar.setDisplayHomeAsUpEnabled(false); // Hide "up" indicator
|
|
||||||
mActionBar.setHomeButtonEnabled(false); // Make icon unclickable
|
|
||||||
mActionBar.setTitle(mIitc.getString(R.string.app_name));
|
|
||||||
} else {
|
|
||||||
if (mPane != android.R.id.home) {
|
|
||||||
mActionBar.setDisplayHomeAsUpEnabled(true); // Show "up" indicator
|
|
||||||
mActionBar.setHomeButtonEnabled(true);// Make icon clickable
|
|
||||||
showHighlighter = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mActionBar.setDisplayHomeAsUpEnabled(false); // Hide "up" indicator
|
|
||||||
mActionBar.setHomeButtonEnabled(false); // Make icon unclickable
|
|
||||||
}
|
|
||||||
mActionBar.setTitle(IITC_Mobile.PANE_TITLES.get(mPane, mIitc.getString(R.string.app_name)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mHighlighters.getCount() < 2) // there should always be "No Highlights"
|
|
||||||
showHighlighter = false;
|
|
||||||
|
|
||||||
if (showHighlighter) {
|
|
||||||
mActionBar.setDisplayShowTitleEnabled(false); // Hide title
|
|
||||||
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
|
|
||||||
setActiveHighlighter(mActiveHighlighter);
|
|
||||||
} else {
|
|
||||||
mActionBar.setDisplayShowTitleEnabled(true); // Show title
|
|
||||||
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
|
||||||
}
|
|
||||||
if (mFullscreen && mHideInFullscreen)
|
|
||||||
mActionBar.hide();
|
|
||||||
else
|
|
||||||
mActionBar.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPortalHighlighter(String name) {
|
|
||||||
mHighlighters.add(name);
|
|
||||||
|
|
||||||
if (name.equals(mActiveHighlighter))
|
|
||||||
setActiveHighlighter(name);
|
|
||||||
|
|
||||||
updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hideInFullscreen() {
|
|
||||||
return mHideInFullscreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onNavigationItemSelected(int position, long itemId) {
|
|
||||||
String name = mHighlighters.getItem(position);
|
|
||||||
mIitc.getWebView().loadUrl("javascript: window.changePortalHighlights('" + name + "')");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPrefChanged() {
|
|
||||||
mDesktopMode = mPrefs.getBoolean("pref_force_desktop", false);
|
|
||||||
mHideInFullscreen = mPrefs.getBoolean("pref_fullscreen_actionbar", false);
|
|
||||||
updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
mHighlighters.clear();
|
|
||||||
mPane = android.R.id.home;
|
|
||||||
updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActiveHighlighter(String name) {
|
|
||||||
mActiveHighlighter = name;
|
|
||||||
|
|
||||||
if (mActionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) {
|
|
||||||
int position = mHighlighters.getPosition(mActiveHighlighter);
|
|
||||||
if (position >= 0 && position < mActionBar.getNavigationItemCount())
|
|
||||||
mActionBar.setSelectedNavigationItem(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFullscreen(boolean fullscreen) {
|
|
||||||
mFullscreen = fullscreen;
|
|
||||||
if (mFullscreen && mHideInFullscreen) {
|
|
||||||
// show a toast with instructions to exit the fullscreen mode again
|
|
||||||
Toast.makeText(mIitc, "Press back button to exit fullscreen", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void switchTo(int button) {
|
|
||||||
mPane = button;
|
|
||||||
updateActionBar();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +1,48 @@
|
|||||||
package com.cradle.iitc_mobile;
|
package com.cradle.iitc_mobile;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.DialogInterface.OnClickListener;
|
|
||||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
|
||||||
import android.webkit.JavascriptInterface;
|
import android.webkit.JavascriptInterface;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.cradle.iitc_mobile.IITC_NavigationHelper.Pane;
|
||||||
import com.cradle.iitc_mobile.share.ShareActivity;
|
import com.cradle.iitc_mobile.share.ShareActivity;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import java.util.Locale;
|
||||||
import org.json.JSONException;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
// provide communication between IITC script and android app
|
// provide communication between IITC script and android app
|
||||||
public class IITC_JSInterface {
|
public class IITC_JSInterface {
|
||||||
|
|
||||||
// context of main activity
|
// context of main activity
|
||||||
private final Context mContext;
|
private IITC_Mobile mIitc;
|
||||||
private final HashMap<String, String> mLayerIds;
|
|
||||||
private boolean[] mOverlayIsActive;
|
|
||||||
private int mActiveBaseLayer;
|
|
||||||
private String[] mOverlayLayers, mBaseLayers;
|
|
||||||
private int mNumBaseLayers;
|
|
||||||
private int mNumOverlayLayers;
|
|
||||||
|
|
||||||
IITC_JSInterface(Context c) {
|
IITC_JSInterface(IITC_Mobile iitc) {
|
||||||
mLayerIds = new HashMap<String, String>();
|
mIitc = iitc;
|
||||||
mContext = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// open dialog to send geo intent for navigation apps like gmaps or waze etc...
|
// open dialog to send geo intent for navigation apps like gmaps or waze etc...
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void intentPosLink(double lat, double lng, int zoom, String title, boolean isPortal) {
|
public void intentPosLink(double lat, double lng, int zoom, String title, boolean isPortal) {
|
||||||
Intent intent = new Intent(mContext, ShareActivity.class);
|
Intent intent = new Intent(mIitc, ShareActivity.class);
|
||||||
intent.putExtra("lat", lat);
|
intent.putExtra("lat", lat);
|
||||||
intent.putExtra("lng", lng);
|
intent.putExtra("lng", lng);
|
||||||
intent.putExtra("zoom", zoom);
|
intent.putExtra("zoom", zoom);
|
||||||
intent.putExtra("title", title);
|
intent.putExtra("title", title);
|
||||||
intent.putExtra("isPortal", isPortal);
|
intent.putExtra("isPortal", isPortal);
|
||||||
mContext.startActivity(intent);
|
mIitc.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// share a string to the IITC share activity. only uses the share tab.
|
// share a string to the IITC share activity. only uses the share tab.
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void shareString(String str) {
|
public void shareString(String str) {
|
||||||
Intent intent = new Intent(mContext, ShareActivity.class);
|
Intent intent = new Intent(mIitc, ShareActivity.class);
|
||||||
intent.putExtra("shareString", str);
|
intent.putExtra("shareString", str);
|
||||||
intent.putExtra("onlyShare", true);
|
intent.putExtra("onlyShare", true);
|
||||||
mContext.startActivity(intent);
|
mIitc.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable javascript injection while spinner is enabled
|
// disable javascript injection while spinner is enabled
|
||||||
@ -68,26 +50,25 @@ public class IITC_JSInterface {
|
|||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void spinnerEnabled(boolean en) {
|
public void spinnerEnabled(boolean en) {
|
||||||
Log.d("iitcm", "disableJS? " + en);
|
Log.d("iitcm", "disableJS? " + en);
|
||||||
((IITC_Mobile) mContext).getWebView().disableJS(en);
|
mIitc.getWebView().disableJS(en);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy link to specific portal to android clipboard
|
// copy link to specific portal to android clipboard
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void copy(String s) {
|
public void copy(String s) {
|
||||||
ClipboardManager clipboard = (ClipboardManager) mContext
|
ClipboardManager clipboard = (ClipboardManager) mIitc
|
||||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("Copied Text ", s);
|
ClipData clip = ClipData.newPlainText("Copied Text ", s);
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
Toast.makeText(mContext, "copied to clipboard", Toast.LENGTH_SHORT)
|
Toast.makeText(mIitc, "copied to clipboard", Toast.LENGTH_SHORT).show();
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public int getVersionCode() {
|
public int getVersionCode() {
|
||||||
int versionCode = 0;
|
int versionCode = 0;
|
||||||
try {
|
try {
|
||||||
PackageInfo pInfo = mContext.getPackageManager()
|
PackageInfo pInfo = mIitc.getPackageManager()
|
||||||
.getPackageInfo(mContext.getPackageName(), 0);
|
.getPackageInfo(mIitc.getPackageName(), 0);
|
||||||
versionCode = pInfo.versionCode;
|
versionCode = pInfo.versionCode;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -97,250 +78,72 @@ public class IITC_JSInterface {
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void switchToPane(final String id) {
|
public void switchToPane(final String id) {
|
||||||
final IITC_Mobile iitcm = (IITC_Mobile) mContext;
|
mIitc.runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
iitcm.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
IITC_ActionBarHelper actionbar = iitcm.getActionBarHelper();
|
Pane pane;
|
||||||
Integer button = IITC_Mobile.PANES.get(id);
|
try {
|
||||||
|
pane = Pane.valueOf(id.toUpperCase(Locale.getDefault()));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
pane = Pane.MAP;
|
||||||
|
}
|
||||||
|
|
||||||
if (button == null)
|
mIitc.setCurrentPane(pane);
|
||||||
button = android.R.id.home;
|
|
||||||
|
|
||||||
actionbar.switchTo(button);
|
|
||||||
iitcm.backStackUpdate(button);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
public void dialogOpened(String id, boolean open) {
|
|
||||||
((IITC_Mobile) mContext).dialogOpened(id, open);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void dialogFocused(String id) {
|
public void dialogFocused(String id) {
|
||||||
((IITC_Mobile) mContext).setFocusedDialog(id);
|
mIitc.setFocusedDialog(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void removeSplashScreen() {
|
public void dialogOpened(String id, boolean open) {
|
||||||
Log.d("iitcm", "removing splash screen");
|
mIitc.dialogOpened(id, open);
|
||||||
final IITC_Mobile iitc = ((IITC_Mobile) mContext);
|
}
|
||||||
|
|
||||||
iitc.runOnUiThread(new Runnable() {
|
@JavascriptInterface
|
||||||
|
public void bootFinished() {
|
||||||
|
Log.d("iitcm", "...boot finished");
|
||||||
|
|
||||||
|
mIitc.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
iitc.findViewById(R.id.iitc_webview).setVisibility(View.VISIBLE);
|
mIitc.setLoadingState(false);
|
||||||
iitc.findViewById(R.id.imageLoading).setVisibility(View.GONE);
|
|
||||||
|
mIitc.getMapSettings().onBootFinished();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// get layers and list them in a dialog
|
// get layers and list them in a dialog
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void setLayers(String base_layer, String overlay_layer) {
|
public void setLayers(final String base_layer, final String overlay_layer) {
|
||||||
|
mIitc.runOnUiThread(new Runnable() {
|
||||||
/*
|
@Override
|
||||||
* the layer strings have a form like:
|
public void run() {
|
||||||
* [{"layerId":27,"name":"MapQuest OSM","active":true},
|
mIitc.getMapSettings().setLayers(base_layer, overlay_layer);
|
||||||
* {"layerId":28,"name":"Default Ingress Map","active":false}]
|
|
||||||
* Put it in a JSONArray and parse it
|
|
||||||
*/
|
|
||||||
JSONArray base_layersJSON = null;
|
|
||||||
JSONArray overlay_layersJSON = null;
|
|
||||||
try {
|
|
||||||
base_layersJSON = new JSONArray(base_layer);
|
|
||||||
overlay_layersJSON = new JSONArray(overlay_layer);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get length and initialize arrays
|
|
||||||
mNumBaseLayers = base_layersJSON.length();
|
|
||||||
mNumOverlayLayers = overlay_layersJSON.length();
|
|
||||||
mOverlayIsActive = new boolean[mNumOverlayLayers];
|
|
||||||
mOverlayLayers = new String[mNumOverlayLayers];
|
|
||||||
mBaseLayers = new String[mNumBaseLayers];
|
|
||||||
mLayerIds.clear();
|
|
||||||
|
|
||||||
// --------------- base layers ------------------------
|
|
||||||
for (int i = 0; i < mNumBaseLayers; ++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 (String b_layer : layers) {
|
|
||||||
String[] values = b_layer.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("\"", "");
|
|
||||||
mLayerIds.put(name, id);
|
|
||||||
this.mBaseLayers[i] = name;
|
|
||||||
if (isActive) mActiveBaseLayer = i;
|
|
||||||
} catch (JSONException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// --------------- overlay layers ------------------------
|
|
||||||
for (int i = 0; i < mNumOverlayLayers; ++i) {
|
|
||||||
try {
|
|
||||||
String layer = overlay_layersJSON.getString(i);
|
|
||||||
layer = layer.replace("{", "");
|
|
||||||
layer = layer.replace("}", "");
|
|
||||||
String[] layers = layer.split(",");
|
|
||||||
String id = "";
|
|
||||||
String name = "";
|
|
||||||
boolean isActive = false;
|
|
||||||
for (String o_layer : layers) {
|
|
||||||
String[] values = o_layer.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("\"", "");
|
|
||||||
mLayerIds.put(name, id);
|
|
||||||
this.mOverlayLayers[i] = name;
|
|
||||||
this.mOverlayIsActive[i] = isActive;
|
|
||||||
} catch (JSONException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// show overlay layers by default
|
|
||||||
showMultiSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void addPortalHighlighter(final String name) {
|
public void addPortalHighlighter(final String name) {
|
||||||
final IITC_Mobile iitc = ((IITC_Mobile) mContext);
|
mIitc.runOnUiThread(new Runnable() {
|
||||||
iitc.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
iitc.getActionBarHelper().addPortalHighlighter(name);
|
mIitc.getMapSettings().addPortalHighlighter(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void setActiveHighlighter(final String name) {
|
public void setActiveHighlighter(final String name) {
|
||||||
final IITC_Mobile iitc = ((IITC_Mobile) mContext);
|
mIitc.runOnUiThread(new Runnable() {
|
||||||
iitc.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
iitc.getActionBarHelper().setActiveHighlighter(name);
|
mIitc.getMapSettings().setActiveHighlighter(name);
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// show all overlay layers in a multi selection list dialog
|
|
||||||
private void showMultiSelection() {
|
|
||||||
// build the layer chooser dialog
|
|
||||||
AlertDialog.Builder d_m = new AlertDialog.Builder(mContext);
|
|
||||||
OnMultiChoiceClickListener m_listener = new OnMultiChoiceClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
|
||||||
// activate clicked layer
|
|
||||||
showLayer(mLayerIds.get(mOverlayLayers[which]), isChecked);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
d_m.setMultiChoiceItems(mOverlayLayers, mOverlayIsActive, m_listener);
|
|
||||||
// switch to base layers
|
|
||||||
d_m.setPositiveButton(R.string.base_layers, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
showSingleSelection();
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
d_m.setNegativeButton(R.string.close, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
d_m.setTitle(R.string.overlay_layers);
|
|
||||||
final AlertDialog dialog = d_m.create();
|
|
||||||
final ListView list = dialog.getListView();
|
|
||||||
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
||||||
boolean disable = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
||||||
int j = 0;
|
|
||||||
for (String layer : mOverlayLayers) {
|
|
||||||
if (!mOverlayLayers[j].contains("DEBUG")) {
|
|
||||||
// uncheck the item + set the boolean in the isActive array
|
|
||||||
mOverlayIsActive[j] = disable;
|
|
||||||
list.setItemChecked(j, disable);
|
|
||||||
showLayer(mLayerIds.get(layer), disable);
|
|
||||||
}
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
disable = !disable;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
// show all base layers in a single selection list dialog
|
|
||||||
private void showSingleSelection() {
|
|
||||||
OnClickListener s_listener = new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// activate clicked layer
|
|
||||||
showLayer(mLayerIds.get(mBaseLayers[which]), true);
|
|
||||||
mActiveBaseLayer = which;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
AlertDialog.Builder d_s = new AlertDialog.Builder(mContext);
|
|
||||||
d_s.setSingleChoiceItems(mBaseLayers, mActiveBaseLayer, s_listener);
|
|
||||||
// switch to overlay layers
|
|
||||||
d_s.setPositiveButton(R.string.overlay_layers, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
showMultiSelection();
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
d_s.setNegativeButton(R.string.close, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
d_s.setTitle(R.string.base_layers);
|
|
||||||
final AlertDialog dialog = d_s.create();
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showLayer(final String id, final boolean enable) {
|
|
||||||
((Activity) mContext).runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
((IITC_Mobile) mContext).getWebView().loadUrl("javascript: " +
|
|
||||||
"window.layerChooser.showLayer("
|
|
||||||
+ id + "," + enable + ");");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
286
mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
package com.cradle.iitc_mobile;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.AdapterView.OnItemLongClickListener;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckedTextView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickListener, OnItemLongClickListener {
|
||||||
|
private class HighlighterAdapter extends ArrayAdapter<String> {
|
||||||
|
private HighlighterComparator mComparator = new HighlighterComparator();
|
||||||
|
|
||||||
|
private HighlighterAdapter(int resource) {
|
||||||
|
super(mIitc, resource);
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(String object) {
|
||||||
|
super.remove(object); // to avoid duplicates
|
||||||
|
super.add(object);
|
||||||
|
super.sort(mComparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
super.clear();
|
||||||
|
add("No Highlights");// Probably must be the same as window._no_highlighter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class HighlighterComparator implements Comparator<String> {
|
||||||
|
@Override
|
||||||
|
public int compare(String lhs, String rhs) {
|
||||||
|
// Move "No Highlights" on top. Sort the rest alphabetically
|
||||||
|
if (lhs.equals("No Highlights"))
|
||||||
|
return -1000;
|
||||||
|
else if (rhs.equals("No Highlights"))
|
||||||
|
return 1000;
|
||||||
|
else
|
||||||
|
return lhs.compareTo(rhs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Layer {
|
||||||
|
boolean active;
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LayerAdapter extends ArrayAdapter<Layer>
|
||||||
|
{
|
||||||
|
public LayerAdapter(int resource) {
|
||||||
|
super(mIitc, resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
Layer item = getItem(position);
|
||||||
|
View view = (TextView) super.getView(position, convertView, parent);
|
||||||
|
|
||||||
|
if (view instanceof CheckedTextView)
|
||||||
|
((CheckedTextView) view).setChecked(item.active);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IITC_Mobile mIitc;
|
||||||
|
|
||||||
|
private ArrayAdapter<String> mHighlighters;
|
||||||
|
private ArrayAdapter<Layer> mBaseLayers;
|
||||||
|
private ArrayAdapter<Layer> mOverlayLayers;
|
||||||
|
|
||||||
|
private Spinner mSpinnerBaseMap;
|
||||||
|
private Spinner mSpinnerHighlighter;
|
||||||
|
private ListView mListViewOverlayLayers;
|
||||||
|
|
||||||
|
private String mActiveHighlighter;
|
||||||
|
private int mActiveLayer;
|
||||||
|
|
||||||
|
private boolean mLoading = true;
|
||||||
|
|
||||||
|
public IITC_MapSettings(IITC_Mobile activity) {
|
||||||
|
mIitc = activity;
|
||||||
|
|
||||||
|
mHighlighters = new HighlighterAdapter(R.layout.list_item_narrow);
|
||||||
|
mBaseLayers = new LayerAdapter(R.layout.list_item_narrow);
|
||||||
|
mOverlayLayers = new LayerAdapter(android.R.layout.simple_list_item_multiple_choice);
|
||||||
|
|
||||||
|
mHighlighters.setDropDownViewResource(R.layout.list_item_selectable);
|
||||||
|
mBaseLayers.setDropDownViewResource(R.layout.list_item_selectable);
|
||||||
|
|
||||||
|
LayoutInflater inflater = (LayoutInflater) mIitc.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
View header = inflater.inflate(R.layout.map_options_header, null);
|
||||||
|
|
||||||
|
mSpinnerHighlighter = (Spinner) header.findViewById(R.id.spinnerHighlighter);
|
||||||
|
mSpinnerBaseMap = (Spinner) header.findViewById(R.id.spinnerBaseLayer);
|
||||||
|
mListViewOverlayLayers = (ListView) mIitc.findViewById(R.id.right_drawer);
|
||||||
|
|
||||||
|
mListViewOverlayLayers.addHeaderView(header);
|
||||||
|
|
||||||
|
mSpinnerHighlighter.setAdapter(mHighlighters);
|
||||||
|
mSpinnerBaseMap.setAdapter(mBaseLayers);
|
||||||
|
mListViewOverlayLayers.setAdapter(mOverlayLayers);
|
||||||
|
|
||||||
|
mSpinnerHighlighter.setOnItemSelectedListener(this);
|
||||||
|
mSpinnerBaseMap.setOnItemSelectedListener(this);
|
||||||
|
mListViewOverlayLayers.setOnItemClickListener(this);
|
||||||
|
mListViewOverlayLayers.setOnItemLongClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLayer(Layer layer) {
|
||||||
|
if (!mLoading)
|
||||||
|
mIitc.getWebView().loadUrl(
|
||||||
|
"javascript: window.layerChooser.showLayer(" + layer.id + "," + layer.active + ");");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPortalHighlighter(String name) {
|
||||||
|
mHighlighters.add(name);
|
||||||
|
|
||||||
|
// to select active highlighter. must be called every time because of sorting
|
||||||
|
setActiveHighlighter(mActiveHighlighter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBootFinished() {
|
||||||
|
mLoading = false;
|
||||||
|
updateLayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
position--; // The ListView header counts as an item as well.
|
||||||
|
|
||||||
|
Layer item = mOverlayLayers.getItem(position);
|
||||||
|
item.active = !item.active;
|
||||||
|
setLayer(item);
|
||||||
|
mOverlayLayers.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
position--; // The ListView header counts as an item as well.
|
||||||
|
boolean active = !mOverlayLayers.getItem(position).active;
|
||||||
|
|
||||||
|
for (int i = 0; i < mOverlayLayers.getCount(); i++) {
|
||||||
|
Layer item = mOverlayLayers.getItem(i);
|
||||||
|
if (item.name.contains("DEBUG")) continue;
|
||||||
|
if (active == item.active) continue; // no need to set same value again
|
||||||
|
item.active = active;
|
||||||
|
setLayer(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
mOverlayLayers.notifyDataSetChanged();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
if (mLoading) return;
|
||||||
|
|
||||||
|
if (parent.equals(mSpinnerHighlighter)) {
|
||||||
|
String name = mHighlighters.getItem(position);
|
||||||
|
mIitc.getWebView().loadUrl("javascript: window.changePortalHighlights('" + name + "')");
|
||||||
|
}
|
||||||
|
else if (parent.equals(mSpinnerBaseMap)) {
|
||||||
|
mBaseLayers.getItem(mActiveLayer).active = false; // set old layer to hidden, but no need to really hide
|
||||||
|
|
||||||
|
Layer layer = mBaseLayers.getItem(position);
|
||||||
|
layer.active = true;
|
||||||
|
setLayer(layer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
mHighlighters.clear();
|
||||||
|
mBaseLayers.clear();
|
||||||
|
mOverlayLayers.clear();
|
||||||
|
|
||||||
|
mIitc.getNavigationHelper().setHighlighter(null);
|
||||||
|
|
||||||
|
mLoading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveHighlighter(String name) {
|
||||||
|
mActiveHighlighter = name;
|
||||||
|
|
||||||
|
int position = mHighlighters.getPosition(mActiveHighlighter);
|
||||||
|
if (position >= 0 && position < mHighlighters.getCount())
|
||||||
|
mSpinnerHighlighter.setSelection(position);
|
||||||
|
|
||||||
|
mIitc.getNavigationHelper().setHighlighter(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
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_layers = null;
|
||||||
|
JSONArray overlay_layers = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
base_layers = new JSONArray(base_layer);
|
||||||
|
overlay_layers = new JSONArray(overlay_layer);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mActiveLayer = 0;
|
||||||
|
mBaseLayers.setNotifyOnChange(false);
|
||||||
|
mBaseLayers.clear();
|
||||||
|
for (int i = 0; i < base_layers.length(); i++) {
|
||||||
|
try {
|
||||||
|
JSONObject layerObj = base_layers.getJSONObject(i);
|
||||||
|
Layer layer = new Layer();
|
||||||
|
|
||||||
|
layer.id = layerObj.getInt("layerId");
|
||||||
|
layer.name = layerObj.getString("name");
|
||||||
|
layer.active = layerObj.getBoolean("active");
|
||||||
|
|
||||||
|
if (layer.active)
|
||||||
|
// getCount() will be the index of the layer we are about to add
|
||||||
|
mActiveLayer = mBaseLayers.getCount();
|
||||||
|
|
||||||
|
mBaseLayers.add(layer);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mBaseLayers.notifyDataSetChanged();
|
||||||
|
mSpinnerBaseMap.setSelection(mActiveLayer);
|
||||||
|
|
||||||
|
mOverlayLayers.setNotifyOnChange(false);
|
||||||
|
mOverlayLayers.clear();
|
||||||
|
for (int i = 0; i < overlay_layers.length(); i++) {
|
||||||
|
try {
|
||||||
|
JSONObject layerObj = overlay_layers.getJSONObject(i);
|
||||||
|
Layer layer = new Layer();
|
||||||
|
|
||||||
|
layer.id = layerObj.getInt("layerId");
|
||||||
|
layer.name = layerObj.getString("name");
|
||||||
|
layer.active = layerObj.getBoolean("active");
|
||||||
|
|
||||||
|
mOverlayLayers.add(layer);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mOverlayLayers.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLayers() {
|
||||||
|
if (!mLoading)
|
||||||
|
mIitc.getWebView().loadUrl("javascript: window.layerChooser.getLayers()");
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -30,10 +29,12 @@ import android.webkit.WebView;
|
|||||||
import android.widget.SearchView;
|
import android.widget.SearchView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.cradle.iitc_mobile.IITC_NavigationHelper.Pane;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.Locale;
|
||||||
import java.util.HashMap;
|
import java.util.Stack;
|
||||||
|
|
||||||
public class IITC_Mobile extends Activity {
|
public class IITC_Mobile extends Activity {
|
||||||
|
|
||||||
@ -52,37 +53,17 @@ public class IITC_Mobile extends Activity {
|
|||||||
private boolean mDesktopMode = false;
|
private boolean mDesktopMode = false;
|
||||||
private boolean mAdvancedMenu = false;
|
private boolean mAdvancedMenu = false;
|
||||||
private boolean mReloadNeeded = false;
|
private boolean mReloadNeeded = false;
|
||||||
private final ArrayList<String> mDialogStack = new ArrayList<String>();
|
private final Stack<String> mDialogStack = new Stack<String>();
|
||||||
private SharedPreferences mSharedPrefs;
|
private SharedPreferences mSharedPrefs;
|
||||||
private IITC_ActionBarHelper mActionBarHelper;
|
private IITC_NavigationHelper mNavigationHelper;
|
||||||
|
private IITC_MapSettings mMapSettings;
|
||||||
|
|
||||||
// Used for custom back stack handling
|
// Used for custom back stack handling
|
||||||
private final ArrayList<Integer> mBackStack = new ArrayList<Integer>();
|
private final Stack<Pane> mBackStack = new Stack<IITC_NavigationHelper.Pane>();
|
||||||
private boolean mBackStackPush = true;
|
private boolean mBackStackPush = true;
|
||||||
private int mCurrentPane = android.R.id.home;
|
private Pane mCurrentPane = Pane.MAP;
|
||||||
private boolean mBackButtonPressed = false;
|
private boolean mBackButtonPressed = false;
|
||||||
|
|
||||||
public static final SparseArray<String> PANE_TITLES = new SparseArray<String>();
|
|
||||||
public static final HashMap<String, Integer> PANES = new HashMap<String, Integer>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
PANES.put("map", android.R.id.home);
|
|
||||||
PANES.put("info", R.id.menu_info);
|
|
||||||
PANES.put("full", R.id.menu_full);
|
|
||||||
PANES.put("compact", R.id.menu_compact);
|
|
||||||
PANES.put("public", R.id.menu_public);
|
|
||||||
PANES.put("faction", R.id.menu_faction);
|
|
||||||
PANES.put("debug", R.id.menu_debug);
|
|
||||||
|
|
||||||
// No need to declare android.R.id.home - that title is default
|
|
||||||
PANE_TITLES.append(R.id.menu_info, "Info");
|
|
||||||
PANE_TITLES.append(R.id.menu_full, "Full");
|
|
||||||
PANE_TITLES.append(R.id.menu_compact, "Compact");
|
|
||||||
PANE_TITLES.append(R.id.menu_public, "Public");
|
|
||||||
PANE_TITLES.append(R.id.menu_faction, "Faction");
|
|
||||||
PANE_TITLES.append(R.id.menu_debug, "Debug");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -94,7 +75,9 @@ public class IITC_Mobile extends Activity {
|
|||||||
mIitcWebView = (IITC_WebView) findViewById(R.id.iitc_webview);
|
mIitcWebView = (IITC_WebView) findViewById(R.id.iitc_webview);
|
||||||
|
|
||||||
// pass ActionBar to helper because we deprecated getActionBar
|
// pass ActionBar to helper because we deprecated getActionBar
|
||||||
mActionBarHelper = new IITC_ActionBarHelper(this, super.getActionBar());
|
mNavigationHelper = new IITC_NavigationHelper(this, super.getActionBar());
|
||||||
|
|
||||||
|
mMapSettings = new IITC_MapSettings(this);
|
||||||
|
|
||||||
// do something if user changed something in the settings
|
// do something if user changed something in the settings
|
||||||
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
@ -104,24 +87,27 @@ public class IITC_Mobile extends Activity {
|
|||||||
SharedPreferences sharedPreferences, String key) {
|
SharedPreferences sharedPreferences, String key) {
|
||||||
if (key.equals("pref_force_desktop")) {
|
if (key.equals("pref_force_desktop")) {
|
||||||
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||||
mActionBarHelper.onPrefChanged();
|
mNavigationHelper.onPrefChanged();
|
||||||
invalidateOptionsMenu();
|
|
||||||
}
|
}
|
||||||
if (key.equals("pref_user_loc"))
|
if (key.equals("pref_user_loc"))
|
||||||
mIsLocEnabled = sharedPreferences.getBoolean("pref_user_loc",
|
mIsLocEnabled = sharedPreferences.getBoolean("pref_user_loc",
|
||||||
false);
|
false);
|
||||||
if (key.equals("pref_fullscreen_actionbar")) {
|
if (key.equals("pref_fullscreen_actionbar")) {
|
||||||
mActionBarHelper.onPrefChanged();
|
mNavigationHelper.onPrefChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (key.equals("pref_advanced_menu")) {
|
if (key.equals("pref_advanced_menu")) {
|
||||||
mAdvancedMenu = sharedPreferences.getBoolean("pref_advanced_menu", false);
|
mAdvancedMenu = sharedPreferences.getBoolean("pref_advanced_menu", false);
|
||||||
|
mNavigationHelper.setDebugMode(mAdvancedMenu);
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
// no reload needed
|
// no reload needed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// no reload needed
|
|
||||||
if (key.equals("pref_press_twice_to_exit") || key.equals("pref_share_selected_tab"))
|
if (key.equals("pref_press_twice_to_exit")
|
||||||
|
|| key.equals("pref_share_selected_tab")
|
||||||
|
|| key.equals("pref_messages"))
|
||||||
|
// no reload needed
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mReloadNeeded = true;
|
mReloadNeeded = true;
|
||||||
@ -224,8 +210,8 @@ public class IITC_Mobile extends Activity {
|
|||||||
(SearchView) mSearchMenuItem.getActionView();
|
(SearchView) mSearchMenuItem.getActionView();
|
||||||
searchView.setQuery(query, false);
|
searchView.setQuery(query, false);
|
||||||
searchView.clearFocus();
|
searchView.clearFocus();
|
||||||
mActionBarHelper.switchTo(android.R.id.home);
|
|
||||||
backStackUpdate(android.R.id.home);
|
switchToPane(Pane.MAP);
|
||||||
mIitcWebView.loadUrl("javascript:search('" + query + "');");
|
mIitcWebView.loadUrl("javascript:search('" + query + "');");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -318,45 +304,63 @@ public class IITC_Mobile extends Activity {
|
|||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
|
mNavigationHelper.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
Log.d("iitcm", "configuration changed...restoring...reset idleTimer");
|
Log.d("iitcm", "configuration changed...restoring...reset idleTimer");
|
||||||
mIitcWebView.loadUrl("javascript: window.idleTime = 0");
|
mIitcWebView.loadUrl("javascript: window.idleTime = 0");
|
||||||
mIitcWebView.loadUrl("javascript: window.renderUpdateStatus()");
|
mIitcWebView.loadUrl("javascript: window.renderUpdateStatus()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
|
super.onPostCreate(savedInstanceState);
|
||||||
|
mNavigationHelper.onPostCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
// we want a self defined behavior for the back button
|
// we want a self defined behavior for the back button
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
// first kill all open iitc dialogs
|
// exit fullscreen mode if it is enabled and action bar is disabled or the back stack is empty
|
||||||
|
if (mFullscreenMode && (mBackStack.isEmpty() || mNavigationHelper.hideInFullscreen())) {
|
||||||
|
toggleFullscreen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// close drawer if opened
|
||||||
|
if (mNavigationHelper.isDrawerOpened()) {
|
||||||
|
mNavigationHelper.closeDrawers();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// kill all open iitc dialogs
|
||||||
if (!mDialogStack.isEmpty()) {
|
if (!mDialogStack.isEmpty()) {
|
||||||
int last = mDialogStack.size() - 1;
|
String id = mDialogStack.pop();
|
||||||
String id = mDialogStack.get(last);
|
|
||||||
mIitcWebView.loadUrl("javascript: " +
|
mIitcWebView.loadUrl("javascript: " +
|
||||||
"var selector = $(window.DIALOGS['" + id + "']); " +
|
"var selector = $(window.DIALOGS['" + id + "']); " +
|
||||||
"selector.dialog('close'); " +
|
"selector.dialog('close'); " +
|
||||||
"selector.remove();");
|
"selector.remove();");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// exit fullscreen mode if it is enabled and action bar is disabled
|
|
||||||
// or the back stack is empty
|
// Pop last item from backstack and pretend the relevant menu item was clicked
|
||||||
if (mFullscreenMode && (mBackStack.isEmpty() || mActionBarHelper.hideInFullscreen())) {
|
if (!mBackStack.isEmpty()) {
|
||||||
this.toggleFullscreen();
|
|
||||||
} else if (!mBackStack.isEmpty()) {
|
|
||||||
// Pop last item from backstack and pretend the relevant menu item was clicked
|
|
||||||
backStackPop();
|
backStackPop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mBackButtonPressed || !mSharedPrefs.getBoolean("pref_press_twice_to_exit", false)) {
|
||||||
|
super.onBackPressed();
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (mBackButtonPressed || !mSharedPrefs.getBoolean("pref_press_twice_to_exit", false))
|
mBackButtonPressed = true;
|
||||||
super.onBackPressed();
|
Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
|
||||||
else {
|
// reset back button after 2 seconds
|
||||||
mBackButtonPressed = true;
|
new Handler().postDelayed(new Runnable() {
|
||||||
Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
|
@Override
|
||||||
// reset back button after 2 seconds
|
public void run() {
|
||||||
new Handler().postDelayed(new Runnable() {
|
mBackButtonPressed = false;
|
||||||
@Override
|
}
|
||||||
public void run() {
|
}, 2000);
|
||||||
mBackButtonPressed = false;
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,31 +368,30 @@ public class IITC_Mobile extends Activity {
|
|||||||
// shouldn't be called when back stack is empty
|
// shouldn't be called when back stack is empty
|
||||||
// catch wrong usage
|
// catch wrong usage
|
||||||
if (mBackStack.isEmpty()) {
|
if (mBackStack.isEmpty()) {
|
||||||
// Empty back stack means we should be at home (ie map) screen
|
mBackStack.push(Pane.MAP);
|
||||||
mActionBarHelper.switchTo(android.R.id.home);
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
int index = mBackStack.size() - 1;
|
|
||||||
int itemId = mBackStack.remove(index);
|
Pane pane = mBackStack.pop();
|
||||||
mBackStackPush = false;
|
mBackStackPush = false;
|
||||||
handleMenuItemSelected(itemId);
|
switchToPane(pane);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void backStackUpdate(int itemId) {
|
public void setCurrentPane(Pane pane) {
|
||||||
// ensure no double adds
|
// ensure no double adds
|
||||||
if (itemId == mCurrentPane) return;
|
if (pane == mCurrentPane) return;
|
||||||
if (itemId == android.R.id.home) {
|
|
||||||
mBackStack.clear();
|
|
||||||
mBackStackPush = true;
|
|
||||||
} else {
|
|
||||||
if (mBackStackPush)
|
|
||||||
mBackStack.add(mCurrentPane);
|
|
||||||
else
|
|
||||||
mBackStackPush = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
mCurrentPane = itemId;
|
if (mBackStackPush)
|
||||||
|
mBackStack.push(mCurrentPane);
|
||||||
|
else
|
||||||
|
mBackStackPush = true;
|
||||||
|
|
||||||
|
mCurrentPane = pane;
|
||||||
|
mNavigationHelper.switchTo(pane);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchToPane(Pane pane) {
|
||||||
|
String name = pane.name().toLowerCase(Locale.getDefault());
|
||||||
|
mIitcWebView.loadUrl("javascript: window.show('" + name + "');");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -397,30 +400,47 @@ public class IITC_Mobile extends Activity {
|
|||||||
getMenuInflater().inflate(R.menu.main, menu);
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
// Get the SearchView and set the searchable configuration
|
// Get the SearchView and set the searchable configuration
|
||||||
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||||
this.mSearchMenuItem = menu.findItem(R.id.menu_search);
|
mSearchMenuItem = menu.findItem(R.id.menu_search);
|
||||||
final SearchView searchView =
|
final SearchView searchView =
|
||||||
(SearchView) mSearchMenuItem.getActionView();
|
(SearchView) mSearchMenuItem.getActionView();
|
||||||
// Assumes current activity is the searchable activity
|
// Assumes current activity is the searchable activity
|
||||||
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
|
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
|
||||||
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
|
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
|
||||||
// enable/disable mDesktopMode menu
|
|
||||||
enableDesktopUI(menu);
|
|
||||||
enableAdvancedMenu(menu);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
// Handle item selection
|
if (mNavigationHelper != null) {
|
||||||
final int itemId = item.getItemId();
|
boolean visible = !mNavigationHelper.isDrawerOpened();
|
||||||
boolean result = handleMenuItemSelected(itemId);
|
|
||||||
return result || super.onOptionsItemSelected(item);
|
for (int i = 0; i < menu.size(); i++)
|
||||||
|
if (menu.getItem(i).getItemId() != R.id.action_settings) {
|
||||||
|
// clear cookies is part of the advanced menu
|
||||||
|
if (menu.getItem(i).getItemId() == R.id.menu_clear_cookies) {
|
||||||
|
menu.getItem(i).setVisible(mAdvancedMenu & visible);
|
||||||
|
} else {
|
||||||
|
menu.getItem(i).setVisible(visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleMenuItemSelected(int itemId) {
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
if (mNavigationHelper.onOptionsItemSelected(item))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Handle item selection
|
||||||
|
final int itemId = item.getItemId();
|
||||||
|
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
mBackStack.clear();
|
||||||
|
mBackStackPush = false;
|
||||||
|
switchToPane(Pane.MAP);
|
||||||
return true;
|
return true;
|
||||||
case R.id.reload_button:
|
case R.id.reload_button:
|
||||||
reloadIITC();
|
reloadIITC();
|
||||||
@ -429,14 +449,10 @@ public class IITC_Mobile extends Activity {
|
|||||||
toggleFullscreen();
|
toggleFullscreen();
|
||||||
return true;
|
return true;
|
||||||
case R.id.layer_chooser:
|
case R.id.layer_chooser:
|
||||||
// Force map view to handle potential issue with back stack
|
mNavigationHelper.openRightDrawer();
|
||||||
if (!mBackStack.isEmpty() && mCurrentPane != android.R.id.home)
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
|
||||||
// the getLayers function calls the setLayers method of IITC_JSInterface
|
|
||||||
mIitcWebView.loadUrl("javascript: window.layerChooser.getLayers()");
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.locate: // get the users current location and focus it on map
|
case R.id.locate: // get the users current location and focus it on map
|
||||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
switchToPane(Pane.MAP);
|
||||||
// get location from network by default
|
// get location from network by default
|
||||||
if (!mIsLocEnabled) {
|
if (!mIsLocEnabled) {
|
||||||
mIitcWebView.loadUrl("javascript: " +
|
mIitcWebView.loadUrl("javascript: " +
|
||||||
@ -455,24 +471,6 @@ public class IITC_Mobile extends Activity {
|
|||||||
.getIITCVersion());
|
.getIITCVersion());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_info:
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('info');");
|
|
||||||
return true;
|
|
||||||
case R.id.menu_full:
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('full');");
|
|
||||||
return true;
|
|
||||||
case R.id.menu_compact:
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('compact');");
|
|
||||||
return true;
|
|
||||||
case R.id.menu_public:
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('public');");
|
|
||||||
return true;
|
|
||||||
case R.id.menu_faction:
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('faction');");
|
|
||||||
return true;
|
|
||||||
case R.id.menu_debug:
|
|
||||||
mIitcWebView.loadUrl("javascript: window.show('debug')");
|
|
||||||
return true;
|
|
||||||
case R.id.menu_clear_cookies:
|
case R.id.menu_clear_cookies:
|
||||||
CookieManager cm = CookieManager.getInstance();
|
CookieManager cm = CookieManager.getInstance();
|
||||||
cm.removeAllCookie();
|
cm.removeAllCookie();
|
||||||
@ -483,10 +481,12 @@ public class IITC_Mobile extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reloadIITC() {
|
public void reloadIITC() {
|
||||||
mActionBarHelper.reset();
|
mNavigationHelper.reset();
|
||||||
|
mMapSettings.reset();
|
||||||
mBackStack.clear();
|
mBackStack.clear();
|
||||||
|
mBackStackPush = true;
|
||||||
// iitc starts on map after reload
|
// iitc starts on map after reload
|
||||||
mCurrentPane = android.R.id.home;
|
mCurrentPane = Pane.MAP;
|
||||||
loadUrl(mIntelUrl);
|
loadUrl(mIntelUrl);
|
||||||
mReloadNeeded = false;
|
mReloadNeeded = false;
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
// inject the iitc-script and load the intel url
|
// inject the iitc-script and load the intel url
|
||||||
// plugins are injected onPageFinished
|
// plugins are injected onPageFinished
|
||||||
public void loadUrl(String url) {
|
public void loadUrl(String url) {
|
||||||
showSplashScreen();
|
setLoadingState(true);
|
||||||
url = addUrlParam(url);
|
url = addUrlParam(url);
|
||||||
loadIITC();
|
loadIITC();
|
||||||
mIitcWebView.loadUrl(url);
|
mIitcWebView.loadUrl(url);
|
||||||
@ -534,7 +534,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
|
|
||||||
public void toggleFullscreen() {
|
public void toggleFullscreen() {
|
||||||
mFullscreenMode = !mFullscreenMode;
|
mFullscreenMode = !mFullscreenMode;
|
||||||
mActionBarHelper.setFullscreen(mFullscreenMode);
|
mNavigationHelper.setFullscreen(mFullscreenMode);
|
||||||
|
|
||||||
// toggle notification bar
|
// toggle notification bar
|
||||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||||
@ -584,18 +584,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
public void loginSucceeded() {
|
public void loginSucceeded() {
|
||||||
// garbage collection
|
// garbage collection
|
||||||
mLogin = null;
|
mLogin = null;
|
||||||
showSplashScreen();
|
setLoadingState(true);
|
||||||
}
|
|
||||||
|
|
||||||
// disable/enable some menu buttons...
|
|
||||||
public void enableDesktopUI(Menu menu) {
|
|
||||||
MenuItem item;
|
|
||||||
item = menu.findItem(R.id.menu_chat);
|
|
||||||
item.setVisible(!mDesktopMode);
|
|
||||||
item = menu.findItem(R.id.menu_info);
|
|
||||||
item.setVisible(!mDesktopMode);
|
|
||||||
item = menu.findItem(R.id.menu_debug);
|
|
||||||
item.setVisible(!mDesktopMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove dialog and add it back again
|
// remove dialog and add it back again
|
||||||
@ -604,37 +593,35 @@ public class IITC_Mobile extends Activity {
|
|||||||
public void setFocusedDialog(String id) {
|
public void setFocusedDialog(String id) {
|
||||||
Log.d("iitcm", "Dialog " + id + " focused");
|
Log.d("iitcm", "Dialog " + id + " focused");
|
||||||
mDialogStack.remove(id);
|
mDialogStack.remove(id);
|
||||||
mDialogStack.add(id);
|
mDialogStack.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// called by the javascript interface
|
// called by the javascript interface
|
||||||
public void dialogOpened(String id, boolean open) {
|
public void dialogOpened(String id, boolean open) {
|
||||||
if (open) {
|
if (open) {
|
||||||
Log.d("iitcm", "Dialog " + id + " added");
|
Log.d("iitcm", "Dialog " + id + " added");
|
||||||
mDialogStack.add(id);
|
mDialogStack.push(id);
|
||||||
} else {
|
} else {
|
||||||
Log.d("iitcm", "Dialog " + id + " closed");
|
Log.d("iitcm", "Dialog " + id + " closed");
|
||||||
mDialogStack.remove(id);
|
mDialogStack.remove(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showSplashScreen() {
|
public void setLoadingState(boolean isLoading) {
|
||||||
if (!mSharedPrefs.getBoolean("pref_disable_splash", false)) {
|
mNavigationHelper.setLoadingState(isLoading);
|
||||||
|
|
||||||
|
if (isLoading && !mSharedPrefs.getBoolean("pref_disable_splash", false)) {
|
||||||
findViewById(R.id.iitc_webview).setVisibility(View.GONE);
|
findViewById(R.id.iitc_webview).setVisibility(View.GONE);
|
||||||
findViewById(R.id.imageLoading).setVisibility(View.VISIBLE);
|
findViewById(R.id.imageLoading).setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
findViewById(R.id.iitc_webview).setVisibility(View.VISIBLE);
|
||||||
|
findViewById(R.id.imageLoading).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableAdvancedMenu(Menu menu) {
|
|
||||||
MenuItem item;
|
|
||||||
item = menu.findItem(R.id.menu_debug);
|
|
||||||
item.setVisible(mAdvancedMenu);
|
|
||||||
item = menu.findItem(R.id.menu_clear_cookies);
|
|
||||||
item.setVisible(mAdvancedMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated ActionBar related stuff should be handled by ActionBarHelper
|
* @deprecated ActionBar related stuff should be handled by IITC_NavigationHelper
|
||||||
|
* @see getNavigationHelper()
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
@ -642,7 +629,11 @@ public class IITC_Mobile extends Activity {
|
|||||||
return super.getActionBar();
|
return super.getActionBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IITC_ActionBarHelper getActionBarHelper() {
|
public IITC_NavigationHelper getNavigationHelper() {
|
||||||
return mActionBarHelper;
|
return mNavigationHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IITC_MapSettings getMapSettings() {
|
||||||
|
return mMapSettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
351
mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java
Normal file
@ -0,0 +1,351 @@
|
|||||||
|
package com.cradle.iitc_mobile;
|
||||||
|
|
||||||
|
import android.app.ActionBar;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.app.ActionBarDrawerToggle;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnItemClickListener {
|
||||||
|
// Show/hide the up arrow on the very left
|
||||||
|
// getActionBar().setDisplayHomeAsUpEnabled(enabled);
|
||||||
|
|
||||||
|
// Show/hide the activity icon/logo
|
||||||
|
// getActionBar().setDisplayShowHomeEnabled(enabled);
|
||||||
|
|
||||||
|
// Show/hide the activity title
|
||||||
|
// getActionBar().setDisplayShowTitleEnabled(enabled);
|
||||||
|
|
||||||
|
// Makes the icon/title clickable
|
||||||
|
// getActionBar().setHomeButtonEnabled(enabled);
|
||||||
|
|
||||||
|
private class NavigationAdapter extends ArrayAdapter<Pane> {
|
||||||
|
public NavigationAdapter() {
|
||||||
|
super(mIitc, R.layout.list_item_selectable);
|
||||||
|
|
||||||
|
add(Pane.MAP);
|
||||||
|
add(Pane.INFO);
|
||||||
|
add(Pane.FULL);
|
||||||
|
add(Pane.COMPACT);
|
||||||
|
add(Pane.PUBLIC);
|
||||||
|
add(Pane.FACTION);
|
||||||
|
|
||||||
|
if (mPrefs.getBoolean("pref_advanced_menu", false))
|
||||||
|
add(Pane.DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
TextView view = (TextView) super.getView(position, convertView, parent);
|
||||||
|
Pane item = getItem(position);
|
||||||
|
if (item == Pane.MAP)
|
||||||
|
view.setText("Map");
|
||||||
|
else
|
||||||
|
view.setText(getPaneTitle(item));
|
||||||
|
|
||||||
|
int icon = 0;
|
||||||
|
switch (item)
|
||||||
|
{
|
||||||
|
case MAP:
|
||||||
|
icon = R.drawable.location_map;
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
icon = R.drawable.action_about;
|
||||||
|
break;
|
||||||
|
case FULL:
|
||||||
|
icon = R.drawable.collections_view_as_list;
|
||||||
|
break;
|
||||||
|
case COMPACT:
|
||||||
|
icon = R.drawable.collections_view_as_list_compact;
|
||||||
|
break;
|
||||||
|
case PUBLIC:
|
||||||
|
icon = R.drawable.social_group;
|
||||||
|
break;
|
||||||
|
case FACTION:
|
||||||
|
icon = R.drawable.social_cc_bcc;
|
||||||
|
break;
|
||||||
|
case DEBUG:
|
||||||
|
icon = R.drawable.ic_debug;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (icon != 0)
|
||||||
|
view.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum Pane {
|
||||||
|
COMPACT, DEBUG, FACTION, FULL, INFO, MAP, PUBLIC
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int NOTICE_DRAWERS = 1 << 0;
|
||||||
|
public static final int NOTICE_INFO = 1 << 1;
|
||||||
|
// next one would be 1<<2; (this results in 1,2,4,8,...)
|
||||||
|
|
||||||
|
private IITC_Mobile mIitc;
|
||||||
|
private ActionBar mActionBar;
|
||||||
|
private SharedPreferences mPrefs;
|
||||||
|
private NavigationAdapter mNavigationAdapter;
|
||||||
|
private DrawerLayout mDrawerLayout;
|
||||||
|
private ListView mDrawerLeft;
|
||||||
|
private View mDrawerRight;
|
||||||
|
|
||||||
|
private boolean mDesktopMode = false;
|
||||||
|
private boolean mFullscreen = false;
|
||||||
|
private boolean mIsLoading;
|
||||||
|
private boolean mHideInFullscreen = false;
|
||||||
|
private Pane mPane = Pane.MAP;
|
||||||
|
private String mHighlighter = null;
|
||||||
|
|
||||||
|
public IITC_NavigationHelper(IITC_Mobile activity, ActionBar bar) {
|
||||||
|
super(activity, (DrawerLayout) activity.findViewById(R.id.drawer_layout),
|
||||||
|
R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
|
||||||
|
|
||||||
|
mIitc = activity;
|
||||||
|
mActionBar = bar;
|
||||||
|
mDrawerLeft = (ListView) activity.findViewById(R.id.left_drawer);
|
||||||
|
mDrawerRight = activity.findViewById(R.id.right_drawer);
|
||||||
|
mDrawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
|
||||||
|
|
||||||
|
mPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
|
|
||||||
|
mActionBar.setDisplayShowHomeEnabled(true); // show icon
|
||||||
|
|
||||||
|
mNavigationAdapter = new NavigationAdapter();
|
||||||
|
mDrawerLeft.setAdapter(mNavigationAdapter);
|
||||||
|
mDrawerLeft.setOnItemClickListener(this);
|
||||||
|
mDrawerLeft.setItemChecked(0, true);
|
||||||
|
mDrawerLayout.setDrawerListener(this);
|
||||||
|
|
||||||
|
onPrefChanged(); // also calls updateActionBar()
|
||||||
|
|
||||||
|
showNotice(NOTICE_DRAWERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNotice(final int which) {
|
||||||
|
if ((mPrefs.getInt("pref_messages", 0) & which) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String text;
|
||||||
|
switch (which) {
|
||||||
|
case NOTICE_DRAWERS:
|
||||||
|
text = mIitc.getText(R.string.notice_drawers).toString();
|
||||||
|
break;
|
||||||
|
case NOTICE_INFO:
|
||||||
|
text = mIitc.getText(R.string.notice_info).toString();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView message = new TextView(mIitc);
|
||||||
|
message.setPadding(20, 20, 20, 20);
|
||||||
|
message.setText(Html.fromHtml(text));
|
||||||
|
|
||||||
|
AlertDialog dialog = new AlertDialog.Builder(mIitc)
|
||||||
|
.setView(message)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setPositiveButton(android.R.string.ok, new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
dialog.setOnDismissListener(new OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
int value = mPrefs.getInt("pref_messages", 0);
|
||||||
|
value |= which;
|
||||||
|
|
||||||
|
mPrefs
|
||||||
|
.edit()
|
||||||
|
.putInt("pref_messages", value)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateActionBar() {
|
||||||
|
int position = mNavigationAdapter.getPosition(mPane);
|
||||||
|
if (position >= 0 && position < mNavigationAdapter.getCount())
|
||||||
|
mDrawerLeft.setItemChecked(position, true);
|
||||||
|
|
||||||
|
if (mDesktopMode) {
|
||||||
|
mActionBar.setDisplayHomeAsUpEnabled(false); // Hide "up" indicator
|
||||||
|
mActionBar.setHomeButtonEnabled(false); // Make icon unclickable
|
||||||
|
mActionBar.setTitle(mIitc.getString(R.string.app_name));
|
||||||
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerLeft);
|
||||||
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerRight);
|
||||||
|
setDrawerIndicatorEnabled(false);
|
||||||
|
} else {
|
||||||
|
if (mIsLoading) {
|
||||||
|
mActionBar.setDisplayHomeAsUpEnabled(false); // Hide "up" indicator
|
||||||
|
mActionBar.setHomeButtonEnabled(false);// Make icon unclickable
|
||||||
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||||
|
setDrawerIndicatorEnabled(false);
|
||||||
|
} else {
|
||||||
|
mActionBar.setDisplayHomeAsUpEnabled(true); // Show "up" indicator
|
||||||
|
mActionBar.setHomeButtonEnabled(true);// Make icon clickable
|
||||||
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
|
||||||
|
|
||||||
|
if (mPane == Pane.MAP || mDrawerLayout.isDrawerOpen(mDrawerLeft))
|
||||||
|
setDrawerIndicatorEnabled(true);
|
||||||
|
else
|
||||||
|
setDrawerIndicatorEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDrawerLayout.isDrawerOpen(mDrawerLeft))
|
||||||
|
mActionBar.setTitle(mIitc.getString(R.string.app_name));
|
||||||
|
else
|
||||||
|
mActionBar.setTitle(getPaneTitle(mPane));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean mapVisible = mDesktopMode || mPane == Pane.MAP;
|
||||||
|
if ("No Highlights".equals(mHighlighter) || isDrawerOpened() || !mapVisible)
|
||||||
|
mActionBar.setSubtitle(null);
|
||||||
|
else
|
||||||
|
mActionBar.setSubtitle(mHighlighter);
|
||||||
|
|
||||||
|
if (mFullscreen && mHideInFullscreen)
|
||||||
|
mActionBar.hide();
|
||||||
|
else
|
||||||
|
mActionBar.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeDrawers() {
|
||||||
|
mDrawerLayout.closeDrawers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPaneTitle(Pane pane)
|
||||||
|
{
|
||||||
|
switch (pane) {
|
||||||
|
case INFO:
|
||||||
|
return "Info";
|
||||||
|
case FULL:
|
||||||
|
return "Full";
|
||||||
|
case COMPACT:
|
||||||
|
return "Compact";
|
||||||
|
case PUBLIC:
|
||||||
|
return "Public";
|
||||||
|
case FACTION:
|
||||||
|
return "Faction";
|
||||||
|
case DEBUG:
|
||||||
|
return "Debug";
|
||||||
|
default:
|
||||||
|
return mIitc.getString(R.string.app_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hideInFullscreen() {
|
||||||
|
return mHideInFullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDrawerOpened() {
|
||||||
|
return mDrawerLayout.isDrawerOpen(mDrawerLeft) || mDrawerLayout.isDrawerOpen(mDrawerRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerClosed(View drawerView) {
|
||||||
|
super.onDrawerClosed(drawerView);
|
||||||
|
|
||||||
|
// delay invalidating to prevent flickering in case another drawer is opened
|
||||||
|
(new Handler()).postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mIitc.invalidateOptionsMenu();
|
||||||
|
updateActionBar();
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerOpened(View drawerView) {
|
||||||
|
super.onDrawerOpened(drawerView);
|
||||||
|
mIitc.invalidateOptionsMenu();
|
||||||
|
updateActionBar();
|
||||||
|
mDrawerLayout.closeDrawer(drawerView.equals(mDrawerLeft) ? mDrawerRight : mDrawerLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
Pane item = mNavigationAdapter.getItem(position);
|
||||||
|
mIitc.switchToPane(item);
|
||||||
|
|
||||||
|
if (item == Pane.INFO)
|
||||||
|
showNotice(NOTICE_INFO);
|
||||||
|
|
||||||
|
mDrawerLayout.closeDrawer(mDrawerLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPostCreate(Bundle savedInstanceState) {
|
||||||
|
// Sync the toggle state after onRestoreInstanceState has occurred.
|
||||||
|
syncState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPrefChanged() {
|
||||||
|
mDesktopMode = mPrefs.getBoolean("pref_force_desktop", false);
|
||||||
|
mHideInFullscreen = mPrefs.getBoolean("pref_fullscreen_actionbar", true);
|
||||||
|
updateActionBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openRightDrawer() {
|
||||||
|
if (mDrawerLayout.getDrawerLockMode(mDrawerRight) == DrawerLayout.LOCK_MODE_UNLOCKED)
|
||||||
|
mDrawerLayout.openDrawer(mDrawerRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
mPane = Pane.MAP;
|
||||||
|
updateActionBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDebugMode(boolean enabled) {
|
||||||
|
mNavigationAdapter.remove(Pane.DEBUG); // avoid duplicates
|
||||||
|
if (enabled)
|
||||||
|
mNavigationAdapter.add(Pane.DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFullscreen(boolean fullscreen) {
|
||||||
|
mFullscreen = fullscreen;
|
||||||
|
if (mFullscreen && mHideInFullscreen) {
|
||||||
|
// show a toast with instructions to exit the fullscreen mode again
|
||||||
|
Toast.makeText(mIitc, "Press back button to exit fullscreen", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateActionBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHighlighter(String name) {
|
||||||
|
mHighlighter = name;
|
||||||
|
updateActionBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoadingState(boolean isLoading) {
|
||||||
|
mIsLoading = isLoading;
|
||||||
|
updateActionBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchTo(Pane pane) {
|
||||||
|
mPane = pane;
|
||||||
|
|
||||||
|
updateActionBar();
|
||||||
|
}
|
||||||
|
}
|
@ -42,7 +42,7 @@ public class IITC_WebView extends WebView {
|
|||||||
+ "/databases/");
|
+ "/databases/");
|
||||||
mSettings.setAppCachePath(this.getContext().getCacheDir()
|
mSettings.setAppCachePath(this.getContext().getCacheDir()
|
||||||
.getAbsolutePath());
|
.getAbsolutePath());
|
||||||
this.mJsInterface = new IITC_JSInterface(mContext);
|
this.mJsInterface = new IITC_JSInterface((IITC_Mobile) mContext);
|
||||||
this.addJavascriptInterface(mJsInterface, "android");
|
this.addJavascriptInterface(mJsInterface, "android");
|
||||||
|
|
||||||
this.setWebChromeClient(new WebChromeClient() {
|
this.setWebChromeClient(new WebChromeClient() {
|
||||||
@ -53,7 +53,7 @@ public class IITC_WebView extends WebView {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onGeolocationPermissionsShowPrompt(String origin,
|
public void onGeolocationPermissionsShowPrompt(String origin,
|
||||||
GeolocationPermissions.Callback callback) {
|
GeolocationPermissions.Callback callback) {
|
||||||
callback.invoke(origin, true, false);
|
callback.invoke(origin, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ public class IITC_WebView extends WebView {
|
|||||||
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
|
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
|
||||||
if (consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR) {
|
if (consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR) {
|
||||||
Log.d("iitcm", consoleMessage.message());
|
Log.d("iitcm", consoleMessage.message());
|
||||||
mJsInterface.removeSplashScreen();
|
((IITC_Mobile) getContext()).setLoadingState(false);
|
||||||
}
|
}
|
||||||
return super.onConsoleMessage(consoleMessage);
|
return super.onConsoleMessage(consoleMessage);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
|
|||||||
int code = response.getStatusLine().getStatusCode();
|
int code = response.getStatusLine().getStatusCode();
|
||||||
if (code != HttpStatus.SC_OK) {
|
if (code != HttpStatus.SC_OK) {
|
||||||
Log.d("iitcm", "received error code: " + code);
|
Log.d("iitcm", "received error code: " + code);
|
||||||
mJsInterface.removeSplashScreen();
|
((IITC_Mobile) mContext).setLoadingState(false);
|
||||||
// TODO: remove when google login issue is fixed
|
// TODO: remove when google login issue is fixed
|
||||||
if (urls[0].contains("uberauth=WILL_NOT_SIGN_IN")) {
|
if (urls[0].contains("uberauth=WILL_NOT_SIGN_IN")) {
|
||||||
return true;
|
return true;
|
||||||
|