Merge branch 'newnavigation' of git://github.com/fkloft/ingress-intel-total-conversion into fkloft-newnavigation
This commit is contained in:
commit
594af139be
@ -5,20 +5,20 @@
|
||||
android:orderInCategory="10"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:actionViewClass="android.widget.SearchView" />
|
||||
<item
|
||||
android:id="@+id/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="100"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/locate">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/layer_chooser"
|
||||
android:icon="@drawable/ic_layer_chooser"
|
||||
android:orderInCategory="105"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/layer_chooser">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/reload_button"
|
||||
android:icon="@drawable/navigation_refresh"
|
||||
@ -33,17 +33,17 @@
|
||||
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="never"
|
||||
android:title="@string/action_settings">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/menu_clear_cookies"
|
||||
android:orderInCategory="200"
|
||||
android:orderInCategory="130"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/menu_clear_cookies">
|
||||
</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>
|
@ -21,6 +21,28 @@ 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) {
|
||||
@ -75,28 +97,6 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
||||
private String mActiveHighlighter;
|
||||
private int mActiveLayer;
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
public IITC_MapSettings(IITC_Mobile activity) {
|
||||
mIitc = activity;
|
||||
|
||||
@ -126,8 +126,9 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
||||
mListViewOverlayLayers.setOnItemLongClickListener(this);
|
||||
}
|
||||
|
||||
public void updateLayers() {
|
||||
mIitc.getWebView().loadUrl("javascript: window.layerChooser.getLayers()");
|
||||
private void setLayer(Layer layer) {
|
||||
mIitc.getWebView().loadUrl(
|
||||
"javascript: window.layerChooser.showLayer(" + layer.id + "," + layer.active + ");");
|
||||
}
|
||||
|
||||
public void addPortalHighlighter(String name) {
|
||||
@ -137,6 +138,60 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
||||
setActiveHighlighter(name);
|
||||
}
|
||||
|
||||
@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 (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();
|
||||
}
|
||||
|
||||
public void setActiveHighlighter(String name) {
|
||||
mActiveHighlighter = name;
|
||||
|
||||
@ -208,56 +263,7 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
||||
mOverlayLayers.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void updateLayer(Layer layer) {
|
||||
mIitc.getWebView().loadUrl(
|
||||
"javascript: window.layerChooser.showLayer(" + layer.id + "," + layer.active + ");");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
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;
|
||||
updateLayer(layer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@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;
|
||||
updateLayer(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;
|
||||
updateLayer(item);
|
||||
}
|
||||
|
||||
mOverlayLayers.notifyDataSetChanged();
|
||||
|
||||
return true;
|
||||
public void updateLayers() {
|
||||
mIitc.getWebView().loadUrl("javascript: window.layerChooser.getLayers()");
|
||||
}
|
||||
}
|
||||
|
@ -465,6 +465,7 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
public void reloadIITC() {
|
||||
mNavigationHelper.reset();
|
||||
mMapSettings.reset();
|
||||
mBackStack.clear();
|
||||
mBackStackPush = true;
|
||||
// iitc starts on map after reload
|
||||
|
@ -89,7 +89,6 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
||||
private View mDrawerRight;
|
||||
|
||||
private boolean mDesktopMode = false;
|
||||
private boolean mDrawerOpened;
|
||||
private boolean mFullscreen = false;
|
||||
private boolean mIsLoading;
|
||||
private boolean mHideInFullscreen = false;
|
||||
@ -179,19 +178,18 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDrawerOpened() {
|
||||
return mDrawerOpened;
|
||||
}
|
||||
|
||||
public boolean hideInFullscreen() {
|
||||
return mHideInFullscreen;
|
||||
}
|
||||
|
||||
public boolean isDrawerOpened() {
|
||||
return mDrawerLayout.isDrawerOpen(mDrawerLeft) || mDrawerLayout.isDrawerOpen(mDrawerRight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
// TODO change menu? (via invalidateOptionsMenu)
|
||||
super.onDrawerClosed(drawerView);
|
||||
mDrawerOpened = false;
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
@ -199,8 +197,8 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
// TODO change menu? (via invalidateOptionsMenu)
|
||||
super.onDrawerOpened(drawerView);
|
||||
mDrawerOpened = true;
|
||||
updateActionBar();
|
||||
mDrawerLayout.closeDrawer(drawerView.equals(mDrawerLeft) ? mDrawerRight : mDrawerLeft);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -221,8 +219,11 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
public void openRightDrawer() {
|
||||
mDrawerLayout.openDrawer(mDrawerRight);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
// TODO mHighlighters.clear();
|
||||
mPane = Pane.MAP;
|
||||
updateActionBar();
|
||||
}
|
||||
@ -253,9 +254,4 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
||||
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
public void openRightDrawer() {
|
||||
// TODO should close left drawer
|
||||
mDrawerLayout.openDrawer(mDrawerRight);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user