Redesigned IITC Mobile to use ActionBar menu instead of web based tabs.

This commit is contained in:
Jon Benson 2013-05-06 22:31:50 +10:00
parent 13bd906a9e
commit 7e2087da63
45 changed files with 150 additions and 44 deletions

View File

@ -473,9 +473,7 @@ window.chat.needMoreMessages = function() {
chat.requestPublic(true); chat.requestPublic(true);
} }
window.chat.chooseAnchor = function(t) {
window.chat.chooser = function(event) {
var t = $(event.target);
var tt = t.text(); var tt = t.text();
var mark = $('#chatinput mark'); var mark = $('#chatinput mark');
@ -524,6 +522,18 @@ window.chat.chooser = function(event) {
chat.needMoreMessages(); chat.needMoreMessages();
} }
window.chat.choose = function(name) {
$('#chat, #chatinput, #updatestatus').show();
$('#map').css('visibility', 'hidden');
var t = $('<a>'+name+'</a>');
window.chat.chooseAnchor(t);
}
window.chat.chooser = function(event) {
var t = $(event.target);
window.chat.chooseAnchor(t);
}
// contains the logic to keep the correct scroll position. // contains the logic to keep the correct scroll position.
window.chat.keepScrollPosition = function(box, scrollBefore, isOldMsgs) { window.chat.keepScrollPosition = function(box, scrollBefore, isOldMsgs) {

View File

@ -80,7 +80,7 @@ window.runOnSmartphonesAfterBoot = function() {
if(!isSmartphone()) return; if(!isSmartphone()) return;
console.warn('running smartphone post boot stuff'); console.warn('running smartphone post boot stuff');
chat.toggle(); //chat.toggle();
smartphone.mapButton.click(); smartphone.mapButton.click();
// disable img full view // disable img full view

View File

@ -16,7 +16,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:theme="@style/AppBaseTheme" android:theme="@style/AppBaseTheme"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,7 +1,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" > android:orientation="vertical">
<com.cradle.iitc_mobile.IITC_WebView <com.cradle.iitc_mobile.IITC_WebView
android:id="@+id/iitc_webview" android:id="@+id/iitc_webview"

View File

@ -1,35 +1,95 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/reload_button"
android:icon="@drawable/ic_menu_refresh"
android:orderInCategory="90"
android:showAsAction="ifRoom"
android:title="@string/reload"></item>
<item android:id="@+id/settings" <item
android:orderInCategory="120" android:id="@+id/menu_map"
android:showAsAction="never" android:icon="@drawable/location_map"
android:title="@string/action_settings"></item> android:orderInCategory="20"
android:showAsAction="always"
<item android:id="@+id/cache_clear" android:title="@string/menu_map">
android:orderInCategory="100" </item>
android:showAsAction="never" <item
android:title="@string/cache_clear"></item> android:id="@+id/menu_info"
android:icon="@drawable/action_about"
<item android:id="@+id/toggle_fullscreen" android:orderInCategory="30"
android:showAsAction="always"
android:title="@string/menu_info">
</item>
<item
android:id="@+id/menu_chat"
android:icon="@drawable/social_group"
android:showAsAction="always"
android:orderInCategory="35"
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
android:id="@+id/locate"
android:icon="@drawable/device_access_location_found"
android:orderInCategory="100" android:orderInCategory="100"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/toggle_fullscreen" android:title="@string/locate">
android:icon="@android:drawable/ic_menu_zoom"></item> </item>
<item
<item android:id="@+id/locate" android:id="@+id/menu_settings"
android:icon="@android:drawable/ic_menu_mylocation" android:icon="@drawable/action_settings"
android:orderInCategory="80" android:orderInCategory="130"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/locate"></item> android:title="@string/action_settings">
<menu>
<item android:id="@+id/info" <item
android:orderInCategory="160" android:id="@+id/reload_button"
android:showAsAction="never" android:icon="@drawable/navigation_refresh"
android:title="@string/action_info"></item> android:orderInCategory="110"
android:showAsAction="ifRoom"
android:title="@string/reload">
</item>
<item
android:id="@+id/toggle_fullscreen"
android:icon="@drawable/av_full_screen"
android:orderInCategory="120"
android:showAsAction="ifRoom"
android:title="@string/toggle_fullscreen">
</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/cache_clear"
android:icon="@drawable/content_remove"
android:orderInCategory="200"
android:showAsAction="never"
android:title="@string/cache_clear">
</item>
</menu>
</item>
</menu> </menu>

View File

@ -3,7 +3,6 @@
<string name="app_name">IITC mobile</string> <string name="app_name">IITC mobile</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="action_info">Info</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="cache_clear">Clear Cache</string> <string name="cache_clear">Clear Cache</string>
@ -47,4 +46,11 @@
Please copy all sources from $IITC_folder/build/mobile/ to /sdcard/IITC_Mobile/dev/.</string> Please copy all sources from $IITC_folder/build/mobile/ to /sdcard/IITC_Mobile/dev/.</string>
<string name="pref_select_iitc">IITC source</string> <string name="pref_select_iitc">IITC source</string>
<string name="menu_chat">Chat</string>
<string name="menu_map">Map</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>
</resources> </resources>

View File

@ -30,6 +30,7 @@ body {
#chatcontrols { #chatcontrols {
height: 38px; height: 38px;
width: 100%; width: 100%;
display: hidden;
} }
/* hide shrink button */ /* hide shrink button */
@ -52,7 +53,6 @@ body {
#chat { #chat {
left:0; left:0;
right:0; right:0;
top:37px !important;
bottom:30px; bottom:30px;
width: auto; width: auto;
} }
@ -74,7 +74,6 @@ body {
} }
#scrollwrapper { #scrollwrapper {
top: 36px;
bottom: 0; bottom: 0;
max-height: none !important; max-height: none !important;
width: 100% !important; width: 100% !important;

View File

@ -3,7 +3,6 @@ package com.cradle.iitc_mobile;
import java.io.IOException; import java.io.IOException;
import com.cradle.iitc_mobile.R; import com.cradle.iitc_mobile.R;
import android.location.Location; import android.location.Location;
import android.location.LocationListener; import android.location.LocationListener;
import android.location.LocationManager; import android.location.LocationManager;
@ -14,6 +13,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.StrictMode; import android.os.StrictMode;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -40,16 +40,23 @@ public class IITC_Mobile extends Activity {
private LocationListener loc_listener = null; private LocationListener loc_listener = null;
private boolean keyboad_open = false; private boolean keyboad_open = false;
private boolean fullscreen_mode = false; private boolean fullscreen_mode = false;
private ActionBar actionBar;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// TODO build an async task for url.openStream() in IITC_WebViewClient // TODO build an async task for url.openStream() in IITC_WebViewClient
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy); StrictMode.setThreadPolicy(policy);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
iitc_view = (IITC_WebView) findViewById(R.id.iitc_webview); iitc_view = (IITC_WebView) findViewById(R.id.iitc_webview);
actionBar = this.getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setTitle(getString(R.string.menu_map));
actionBar.setHomeButtonEnabled(true);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
listener = new OnSharedPreferenceChangeListener() { listener = new OnSharedPreferenceChangeListener() {
@Override @Override
@ -193,7 +200,7 @@ public class IITC_Mobile extends Activity {
// leave fullscreen mode if it is enabled // leave fullscreen mode if it is enabled
if (fullscreen_mode) { if (fullscreen_mode) {
// get back action bar // get back action bar
this.getActionBar().show(); actionBar.show();
// show notification bar again // show notification bar again
WindowManager.LayoutParams attrs = getWindow().getAttributes(); WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags ^= WindowManager.LayoutParams.FLAG_FULLSCREEN; attrs.flags ^= WindowManager.LayoutParams.FLAG_FULLSCREEN;
@ -223,7 +230,7 @@ public class IITC_Mobile extends Activity {
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present. // Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu); getMenuInflater().inflate(R.menu.main, menu);
this.getActionBar().setHomeButtonEnabled(true);
return true; return true;
} }
@ -233,9 +240,15 @@ public class IITC_Mobile extends Activity {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
iitc_view.loadUrl("javascript: window.smartphone.mapButton.click();"); iitc_view.loadUrl("javascript: window.smartphone.mapButton.click();");
actionBar.setTitle(getString(R.string.menu_map));
return true;
case R.id.menu_map:
iitc_view.loadUrl("javascript: window.smartphone.mapButton.click();");
actionBar.setTitle(getString(R.string.menu_map));
return true; return true;
case R.id.reload_button: case R.id.reload_button:
this.loadUrl(intel_url); this.loadUrl(intel_url);
actionBar.setTitle(getString(R.string.menu_map));
return true; return true;
// clear cache // clear cache
case R.id.cache_clear: case R.id.cache_clear:
@ -269,15 +282,33 @@ public class IITC_Mobile extends Activity {
// get the users current location and focus it on map // get the users current location and focus it on map
case R.id.locate: case R.id.locate:
iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 13});"); iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 13});");
actionBar.setTitle(getString(R.string.menu_map));
return true; return true;
// start settings activity // start settings activity
case R.id.settings: case R.id.action_settings:
Intent intent = new Intent(this, IITC_Settings.class); Intent intent = new Intent(this, IITC_Settings.class);
intent.putExtra("iitc_version", iitc_view.getWebViewClient().getIITCVersion()); intent.putExtra("iitc_version", iitc_view.getWebViewClient().getIITCVersion());
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.info: case R.id.menu_info:
iitc_view.loadUrl("javascript: window.smartphone.sideButton.click();"); iitc_view.loadUrl("javascript: window.smartphone.sideButton.click();");
actionBar.setTitle(getString(R.string.menu_info));
return true;
case R.id.menu_full:
iitc_view.loadUrl("javascript: window.chat.choose('full');");
actionBar.setTitle(getString(R.string.menu_full));
return true;
case R.id.menu_compact:
iitc_view.loadUrl("javascript: window.chat.choose('compact');");
actionBar.setTitle(getString(R.string.menu_compact));
return true;
case R.id.menu_public:
iitc_view.loadUrl("javascript: window.chat.choose('public');");
actionBar.setTitle(getString(R.string.menu_public));
return true;
case R.id.menu_faction:
iitc_view.loadUrl("javascript: window.chat.choose('faction');");
actionBar.setTitle(getString(R.string.menu_faction));
return true; return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);