Merge branch 'newnavigation' of git://github.com/fkloft/ingress-intel-total-conversion into fkloft-newnavigation
This commit is contained in:
commit
40263a858e
@ -18,8 +18,7 @@
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_iitcm"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme"
|
||||
android:uiOptions="splitActionBarWhenNarrow">
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="com.cradle.iitc_mobile.IITC_Mobile"
|
||||
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
|
||||
|
Binary file not shown.
BIN
mobile/res/drawable-hdpi/drawer_shadow.9.png
Normal file
BIN
mobile/res/drawable-hdpi/drawer_shadow.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 171 B |
BIN
mobile/res/drawable-hdpi/ic_drawer.png
Normal file
BIN
mobile/res/drawable-hdpi/ic_drawer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
mobile/res/drawable-mdpi/drawer_shadow.9.png
Normal file
BIN
mobile/res/drawable-mdpi/drawer_shadow.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 158 B |
BIN
mobile/res/drawable-mdpi/ic_drawer.png
Normal file
BIN
mobile/res/drawable-mdpi/ic_drawer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
mobile/res/drawable-xhdpi/drawer_shadow.9.png
Normal file
BIN
mobile/res/drawable-xhdpi/drawer_shadow.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 182 B |
BIN
mobile/res/drawable-xhdpi/ic_drawer.png
Normal file
BIN
mobile/res/drawable-xhdpi/ic_drawer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -1,18 +1,32 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.cradle.iitc_mobile.IITC_WebView
|
||||
android:id="@+id/iitc_webview"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_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" />
|
||||
<com.cradle.iitc_mobile.IITC_WebView
|
||||
android:id="@+id/iitc_webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</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"/>
|
||||
|
||||
<!-- The navigation drawer -->
|
||||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:background="#111"
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="0dp"/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
11
mobile/res/layout/list_item_selectable.xml
Normal file
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"/>
|
@ -5,46 +5,6 @@
|
||||
android:orderInCategory="10"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:actionViewClass="android.widget.SearchView" />
|
||||
<item
|
||||
android:id="@+id/menu_info"
|
||||
android:icon="@drawable/action_about"
|
||||
android:orderInCategory="30"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menu_info">
|
||||
</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
|
||||
android:id="@+id/layer_chooser"
|
||||
android:icon="@drawable/ic_layer_chooser"
|
||||
@ -63,7 +23,7 @@
|
||||
android:id="@+id/reload_button"
|
||||
android:icon="@drawable/navigation_refresh"
|
||||
android:orderInCategory="110"
|
||||
android:showAsAction="ifRoom"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/reload">
|
||||
</item>
|
||||
<item
|
||||
@ -77,15 +37,8 @@
|
||||
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">
|
||||
android:title="@string/action_settings">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/menu_clear_cookies"
|
||||
|
@ -7,6 +7,8 @@
|
||||
<string name="activity_share">Share using…</string>
|
||||
<string name="activity_share_to_clipboard">Copy to clipboard</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="version">Print Version</string>
|
||||
<string name="toggle_fullscreen">Toggle fullscreen</string>
|
||||
@ -81,13 +83,6 @@
|
||||
<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="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_search">Search</string>
|
||||
<string name="choose_account_to_login">Choose account to login</string>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -18,12 +18,14 @@ import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.cradle.iitc_mobile.IITC_NavigationHelper.Pane;
|
||||
import com.cradle.iitc_mobile.share.ShareActivity;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
// provide communication between IITC script and android app
|
||||
public class IITC_JSInterface {
|
||||
@ -102,14 +104,14 @@ public class IITC_JSInterface {
|
||||
iitcm.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IITC_ActionBarHelper actionbar = iitcm.getActionBarHelper();
|
||||
Integer button = IITC_Mobile.PANES.get(id);
|
||||
Pane pane;
|
||||
try {
|
||||
pane = Pane.valueOf(id.toUpperCase(Locale.getDefault()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
pane = Pane.MAP;
|
||||
}
|
||||
|
||||
if (button == null)
|
||||
button = android.R.id.home;
|
||||
|
||||
actionbar.switchTo(button);
|
||||
iitcm.backStackUpdate(button);
|
||||
iitcm.setCurrentPane(pane);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -132,8 +134,7 @@ public class IITC_JSInterface {
|
||||
iitc.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
iitc.findViewById(R.id.iitc_webview).setVisibility(View.VISIBLE);
|
||||
iitc.findViewById(R.id.imageLoading).setVisibility(View.GONE);
|
||||
iitc.setLoadingState(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -236,7 +237,7 @@ public class IITC_JSInterface {
|
||||
iitc.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
iitc.getActionBarHelper().addPortalHighlighter(name);
|
||||
iitc.getNavigationHelper().addPortalHighlighter(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -247,7 +248,7 @@ public class IITC_JSInterface {
|
||||
iitc.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
iitc.getActionBarHelper().setActiveHighlighter(name);
|
||||
iitc.getNavigationHelper().setActiveHighlighter(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -27,13 +27,16 @@ import android.view.WindowManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.cradle.iitc_mobile.IITC_NavigationHelper.Pane;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Stack;
|
||||
|
||||
public class IITC_Mobile extends Activity {
|
||||
|
||||
@ -52,37 +55,16 @@ public class IITC_Mobile extends Activity {
|
||||
private boolean mDesktopMode = false;
|
||||
private boolean mAdvancedMenu = 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 IITC_ActionBarHelper mActionBarHelper;
|
||||
private IITC_NavigationHelper mNavigationHelper;
|
||||
|
||||
// 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 int mCurrentPane = android.R.id.home;
|
||||
private Pane mCurrentPane = Pane.MAP;
|
||||
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
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -92,9 +74,10 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
mIitcWebView = (IITC_WebView) findViewById(R.id.iitc_webview);
|
||||
|
||||
// pass ActionBar to helper because we deprecated getActionBar
|
||||
mActionBarHelper = new IITC_ActionBarHelper(this, super.getActionBar());
|
||||
mNavigationHelper = new IITC_NavigationHelper(this, super.getActionBar(),
|
||||
(ListView) findViewById(R.id.left_drawer),
|
||||
(DrawerLayout) findViewById(R.id.drawer_layout));
|
||||
|
||||
// do something if user changed something in the settings
|
||||
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
@ -104,18 +87,19 @@ public class IITC_Mobile extends Activity {
|
||||
SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals("pref_force_desktop")) {
|
||||
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||
mActionBarHelper.onPrefChanged();
|
||||
mNavigationHelper.onPrefChanged();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
if (key.equals("pref_user_loc"))
|
||||
mIsLocEnabled = sharedPreferences.getBoolean("pref_user_loc",
|
||||
false);
|
||||
if (key.equals("pref_fullscreen_actionbar")) {
|
||||
mActionBarHelper.onPrefChanged();
|
||||
mNavigationHelper.onPrefChanged();
|
||||
return;
|
||||
}
|
||||
if (key.equals("pref_advanced_menu")) {
|
||||
mAdvancedMenu = sharedPreferences.getBoolean("pref_advanced_menu", false);
|
||||
mNavigationHelper.setDebugMode(mAdvancedMenu);
|
||||
invalidateOptionsMenu();
|
||||
// no reload needed
|
||||
return;
|
||||
@ -224,8 +208,8 @@ public class IITC_Mobile extends Activity {
|
||||
(SearchView) mSearchMenuItem.getActionView();
|
||||
searchView.setQuery(query, false);
|
||||
searchView.clearFocus();
|
||||
mActionBarHelper.switchTo(android.R.id.home);
|
||||
backStackUpdate(android.R.id.home);
|
||||
|
||||
switchToPane(Pane.MAP);
|
||||
mIitcWebView.loadUrl("javascript:search('" + query + "');");
|
||||
return;
|
||||
}
|
||||
@ -318,18 +302,25 @@ public class IITC_Mobile extends Activity {
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
mNavigationHelper.onConfigurationChanged(newConfig);
|
||||
|
||||
Log.d("iitcm", "configuration changed...restoring...reset idleTimer");
|
||||
mIitcWebView.loadUrl("javascript: window.idleTime = 0");
|
||||
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
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// first kill all open iitc dialogs
|
||||
if (!mDialogStack.isEmpty()) {
|
||||
int last = mDialogStack.size() - 1;
|
||||
String id = mDialogStack.get(last);
|
||||
String id = mDialogStack.pop();
|
||||
mIitcWebView.loadUrl("javascript: " +
|
||||
"var selector = $(window.DIALOGS['" + id + "']); " +
|
||||
"selector.dialog('close'); " +
|
||||
@ -338,7 +329,7 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
// exit fullscreen mode if it is enabled and action bar is disabled
|
||||
// or the back stack is empty
|
||||
if (mFullscreenMode && (mBackStack.isEmpty() || mActionBarHelper.hideInFullscreen())) {
|
||||
if (mFullscreenMode && (mBackStack.isEmpty() || mNavigationHelper.hideInFullscreen())) {
|
||||
this.toggleFullscreen();
|
||||
} else if (!mBackStack.isEmpty()) {
|
||||
// Pop last item from backstack and pretend the relevant menu item was clicked
|
||||
@ -364,31 +355,30 @@ public class IITC_Mobile extends Activity {
|
||||
// shouldn't be called when back stack is empty
|
||||
// catch wrong usage
|
||||
if (mBackStack.isEmpty()) {
|
||||
// Empty back stack means we should be at home (ie map) screen
|
||||
mActionBarHelper.switchTo(android.R.id.home);
|
||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
||||
return;
|
||||
mBackStack.push(Pane.MAP);
|
||||
}
|
||||
int index = mBackStack.size() - 1;
|
||||
int itemId = mBackStack.remove(index);
|
||||
|
||||
Pane pane = mBackStack.pop();
|
||||
mBackStackPush = false;
|
||||
handleMenuItemSelected(itemId);
|
||||
switchToPane(pane);
|
||||
}
|
||||
|
||||
public void backStackUpdate(int itemId) {
|
||||
public void setCurrentPane(Pane pane) {
|
||||
// ensure no double adds
|
||||
if (itemId == mCurrentPane) return;
|
||||
if (itemId == android.R.id.home) {
|
||||
mBackStack.clear();
|
||||
mBackStackPush = true;
|
||||
} else {
|
||||
if (mBackStackPush)
|
||||
mBackStack.add(mCurrentPane);
|
||||
else
|
||||
mBackStackPush = true;
|
||||
}
|
||||
if (pane == mCurrentPane) return;
|
||||
|
||||
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
|
||||
@ -397,30 +387,32 @@ public class IITC_Mobile extends Activity {
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
// Get the SearchView and set the searchable configuration
|
||||
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 =
|
||||
(SearchView) mSearchMenuItem.getActionView();
|
||||
// Assumes current activity is the searchable activity
|
||||
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
|
||||
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
|
||||
|
||||
// enable/disable mDesktopMode menu
|
||||
enableDesktopUI(menu);
|
||||
enableAdvancedMenu(menu);
|
||||
MenuItem item = menu.findItem(R.id.menu_clear_cookies);
|
||||
item.setVisible(mAdvancedMenu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (mNavigationHelper.onOptionsItemSelected(item))
|
||||
return true;
|
||||
|
||||
// Handle item selection
|
||||
final int itemId = item.getItemId();
|
||||
boolean result = handleMenuItemSelected(itemId);
|
||||
return result || super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public boolean handleMenuItemSelected(int itemId) {
|
||||
switch (itemId) {
|
||||
case android.R.id.home:
|
||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
||||
mBackStack.clear();
|
||||
mBackStackPush = false;
|
||||
switchToPane(Pane.MAP);
|
||||
return true;
|
||||
case R.id.reload_button:
|
||||
reloadIITC();
|
||||
@ -430,13 +422,13 @@ public class IITC_Mobile extends Activity {
|
||||
return true;
|
||||
case R.id.layer_chooser:
|
||||
// Force map view to handle potential issue with back stack
|
||||
if (!mBackStack.isEmpty() && mCurrentPane != android.R.id.home)
|
||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
||||
if (!mBackStack.isEmpty() && mCurrentPane != Pane.MAP)
|
||||
switchToPane(Pane.MAP);
|
||||
// the getLayers function calls the setLayers method of IITC_JSInterface
|
||||
mIitcWebView.loadUrl("javascript: window.layerChooser.getLayers()");
|
||||
return true;
|
||||
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
|
||||
if (!mIsLocEnabled) {
|
||||
mIitcWebView.loadUrl("javascript: " +
|
||||
@ -455,24 +447,6 @@ public class IITC_Mobile extends Activity {
|
||||
.getIITCVersion());
|
||||
startActivity(intent);
|
||||
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:
|
||||
CookieManager cm = CookieManager.getInstance();
|
||||
cm.removeAllCookie();
|
||||
@ -483,10 +457,11 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
|
||||
public void reloadIITC() {
|
||||
mActionBarHelper.reset();
|
||||
mNavigationHelper.reset();
|
||||
mBackStack.clear();
|
||||
mBackStackPush = true;
|
||||
// iitc starts on map after reload
|
||||
mCurrentPane = android.R.id.home;
|
||||
mCurrentPane = Pane.MAP;
|
||||
loadUrl(mIntelUrl);
|
||||
mReloadNeeded = false;
|
||||
}
|
||||
@ -512,7 +487,7 @@ public class IITC_Mobile extends Activity {
|
||||
// inject the iitc-script and load the intel url
|
||||
// plugins are injected onPageFinished
|
||||
public void loadUrl(String url) {
|
||||
showSplashScreen();
|
||||
setLoadingState(true);
|
||||
url = addUrlParam(url);
|
||||
loadIITC();
|
||||
mIitcWebView.loadUrl(url);
|
||||
@ -534,7 +509,7 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
public void toggleFullscreen() {
|
||||
mFullscreenMode = !mFullscreenMode;
|
||||
mActionBarHelper.setFullscreen(mFullscreenMode);
|
||||
mNavigationHelper.setFullscreen(mFullscreenMode);
|
||||
|
||||
// toggle notification bar
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
@ -584,18 +559,7 @@ public class IITC_Mobile extends Activity {
|
||||
public void loginSucceeded() {
|
||||
// garbage collection
|
||||
mLogin = null;
|
||||
showSplashScreen();
|
||||
}
|
||||
|
||||
// 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);
|
||||
setLoadingState(true);
|
||||
}
|
||||
|
||||
// remove dialog and add it back again
|
||||
@ -604,37 +568,35 @@ public class IITC_Mobile extends Activity {
|
||||
public void setFocusedDialog(String id) {
|
||||
Log.d("iitcm", "Dialog " + id + " focused");
|
||||
mDialogStack.remove(id);
|
||||
mDialogStack.add(id);
|
||||
mDialogStack.push(id);
|
||||
}
|
||||
|
||||
// called by the javascript interface
|
||||
public void dialogOpened(String id, boolean open) {
|
||||
if (open) {
|
||||
Log.d("iitcm", "Dialog " + id + " added");
|
||||
mDialogStack.add(id);
|
||||
mDialogStack.push(id);
|
||||
} else {
|
||||
Log.d("iitcm", "Dialog " + id + " closed");
|
||||
mDialogStack.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void showSplashScreen() {
|
||||
if (!mSharedPrefs.getBoolean("pref_disable_splash", false)) {
|
||||
public void setLoadingState(boolean isLoading) {
|
||||
mNavigationHelper.setLoadingState(isLoading);
|
||||
|
||||
if (isLoading && !mSharedPrefs.getBoolean("pref_disable_splash", false)) {
|
||||
findViewById(R.id.iitc_webview).setVisibility(View.GONE);
|
||||
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
|
||||
@Override
|
||||
@ -642,7 +604,7 @@ public class IITC_Mobile extends Activity {
|
||||
return super.getActionBar();
|
||||
}
|
||||
|
||||
public IITC_ActionBarHelper getActionBarHelper() {
|
||||
return mActionBarHelper;
|
||||
public IITC_NavigationHelper getNavigationHelper() {
|
||||
return mNavigationHelper;
|
||||
}
|
||||
}
|
||||
|
315
mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java
Normal file
315
mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java
Normal file
@ -0,0 +1,315 @@
|
||||
package com.cradle.iitc_mobile;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.ActionBar.OnNavigationListener;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
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 OnNavigationListener, 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 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 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:
|
||||
case COMPACT:
|
||||
case PUBLIC:
|
||||
case FACTION:
|
||||
icon = R.drawable.social_group;
|
||||
break;
|
||||
}
|
||||
|
||||
if (icon != 0)
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Pane {
|
||||
COMPACT, DEBUG, FACTION, FULL, INFO, MAP, PUBLIC
|
||||
}
|
||||
|
||||
private IITC_Mobile mIitc;
|
||||
private ActionBar mActionBar;
|
||||
private SharedPreferences mPrefs;
|
||||
private HighlighterAdapter mHighlighters;
|
||||
private NavigationAdapter mNavigationAdapter;
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private ListView mDrawerList;
|
||||
|
||||
private String mActiveHighlighter = null;
|
||||
private boolean mDesktopMode = false;
|
||||
private boolean mDrawerOpened;
|
||||
private boolean mFullscreen = false;
|
||||
private boolean mIsLoading;
|
||||
private boolean mHideInFullscreen = false;
|
||||
private Pane mPane = Pane.MAP;
|
||||
|
||||
public IITC_NavigationHelper(IITC_Mobile activity, ActionBar bar, ListView drawerList, DrawerLayout drawerLayout) {
|
||||
super(activity, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
|
||||
|
||||
mIitc = activity;
|
||||
mActionBar = bar;
|
||||
mDrawerList = drawerList;
|
||||
mDrawerLayout = drawerLayout;
|
||||
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
mHighlighters = new HighlighterAdapter();
|
||||
|
||||
mActionBar.setDisplayShowHomeEnabled(true); // show icon
|
||||
mActionBar.setListNavigationCallbacks(mHighlighters, this);
|
||||
|
||||
mNavigationAdapter = new NavigationAdapter();
|
||||
mDrawerList.setAdapter(mNavigationAdapter);
|
||||
mDrawerList.setOnItemClickListener(this);
|
||||
mDrawerList.setItemChecked(0, true);
|
||||
mDrawerLayout.setDrawerListener(this);
|
||||
|
||||
onPrefChanged(); // also calls updateActionBar()
|
||||
}
|
||||
|
||||
private void updateActionBar() {
|
||||
boolean showHighlighter = true;
|
||||
|
||||
int position = mNavigationAdapter.getPosition(mPane);
|
||||
if (position >= 0 && position < mNavigationAdapter.getCount())
|
||||
mDrawerList.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);
|
||||
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)
|
||||
setDrawerIndicatorEnabled(false);
|
||||
else
|
||||
setDrawerIndicatorEnabled(true);
|
||||
}
|
||||
|
||||
if (mPane != Pane.MAP)
|
||||
showHighlighter = false;
|
||||
|
||||
mActionBar.setTitle(getPaneTitle(mPane));
|
||||
}
|
||||
|
||||
if (mHighlighters.getCount() < 2) // there should always be "No Highlights"
|
||||
showHighlighter = false;
|
||||
|
||||
if(mDrawerOpened)
|
||||
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 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
// TODO change menu? (via invalidateOptionsMenu)
|
||||
super.onDrawerClosed(drawerView);
|
||||
mDrawerOpened = false;
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
// TODO change menu? (via invalidateOptionsMenu)
|
||||
super.onDrawerOpened(drawerView);
|
||||
mDrawerOpened=true;
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Pane item = mNavigationAdapter.getItem(position);
|
||||
mIitc.switchToPane(item);
|
||||
mDrawerLayout.closeDrawer(mDrawerList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(int position, long itemId) {
|
||||
String name = mHighlighters.getItem(position);
|
||||
mIitc.getWebView().loadUrl("javascript: window.changePortalHighlights('" + name + "')");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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", false);
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
mHighlighters.clear();
|
||||
mPane = Pane.MAP;
|
||||
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 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 setLoadingState(boolean isLoading) {
|
||||
mIsLoading = isLoading;
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
public void switchTo(Pane pane) {
|
||||
mPane = pane;
|
||||
|
||||
updateActionBar();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user