Tweaks on new drawers
This commit is contained in:
parent
2d16e8492c
commit
5dc3e8923c
@ -21,6 +21,28 @@ import org.json.JSONObject;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickListener, OnItemLongClickListener {
|
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> {
|
private class HighlighterComparator implements Comparator<String> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(String lhs, String rhs) {
|
public int compare(String lhs, String rhs) {
|
||||||
@ -75,28 +97,6 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
|||||||
private String mActiveHighlighter;
|
private String mActiveHighlighter;
|
||||||
private int mActiveLayer;
|
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) {
|
public IITC_MapSettings(IITC_Mobile activity) {
|
||||||
mIitc = activity;
|
mIitc = activity;
|
||||||
|
|
||||||
@ -126,8 +126,9 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
|||||||
mListViewOverlayLayers.setOnItemLongClickListener(this);
|
mListViewOverlayLayers.setOnItemLongClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLayers() {
|
private void setLayer(Layer layer) {
|
||||||
mIitc.getWebView().loadUrl("javascript: window.layerChooser.getLayers()");
|
mIitc.getWebView().loadUrl(
|
||||||
|
"javascript: window.layerChooser.showLayer(" + layer.id + "," + layer.active + ");");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPortalHighlighter(String name) {
|
public void addPortalHighlighter(String name) {
|
||||||
@ -137,6 +138,60 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
|||||||
setActiveHighlighter(name);
|
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) {
|
public void setActiveHighlighter(String name) {
|
||||||
mActiveHighlighter = name;
|
mActiveHighlighter = name;
|
||||||
|
|
||||||
@ -208,56 +263,7 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
|
|||||||
mOverlayLayers.notifyDataSetChanged();
|
mOverlayLayers.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLayer(Layer layer) {
|
public void updateLayers() {
|
||||||
mIitc.getWebView().loadUrl(
|
mIitc.getWebView().loadUrl("javascript: window.layerChooser.getLayers()");
|
||||||
"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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,6 +465,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
|
|
||||||
public void reloadIITC() {
|
public void reloadIITC() {
|
||||||
mNavigationHelper.reset();
|
mNavigationHelper.reset();
|
||||||
|
mMapSettings.reset();
|
||||||
mBackStack.clear();
|
mBackStack.clear();
|
||||||
mBackStackPush = true;
|
mBackStackPush = true;
|
||||||
// iitc starts on map after reload
|
// iitc starts on map after reload
|
||||||
|
@ -89,7 +89,6 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
|||||||
private View mDrawerRight;
|
private View mDrawerRight;
|
||||||
|
|
||||||
private boolean mDesktopMode = false;
|
private boolean mDesktopMode = false;
|
||||||
private boolean mDrawerOpened;
|
|
||||||
private boolean mFullscreen = false;
|
private boolean mFullscreen = false;
|
||||||
private boolean mIsLoading;
|
private boolean mIsLoading;
|
||||||
private boolean mHideInFullscreen = false;
|
private boolean mHideInFullscreen = false;
|
||||||
@ -179,19 +178,18 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDrawerOpened() {
|
|
||||||
return mDrawerOpened;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hideInFullscreen() {
|
public boolean hideInFullscreen() {
|
||||||
return mHideInFullscreen;
|
return mHideInFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDrawerOpened() {
|
||||||
|
return mDrawerLayout.isDrawerOpen(mDrawerLeft) || mDrawerLayout.isDrawerOpen(mDrawerRight);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerClosed(View drawerView) {
|
public void onDrawerClosed(View drawerView) {
|
||||||
// TODO change menu? (via invalidateOptionsMenu)
|
// TODO change menu? (via invalidateOptionsMenu)
|
||||||
super.onDrawerClosed(drawerView);
|
super.onDrawerClosed(drawerView);
|
||||||
mDrawerOpened = false;
|
|
||||||
updateActionBar();
|
updateActionBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,8 +197,8 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
|||||||
public void onDrawerOpened(View drawerView) {
|
public void onDrawerOpened(View drawerView) {
|
||||||
// TODO change menu? (via invalidateOptionsMenu)
|
// TODO change menu? (via invalidateOptionsMenu)
|
||||||
super.onDrawerOpened(drawerView);
|
super.onDrawerOpened(drawerView);
|
||||||
mDrawerOpened = true;
|
|
||||||
updateActionBar();
|
updateActionBar();
|
||||||
|
mDrawerLayout.closeDrawer(drawerView.equals(mDrawerLeft) ? mDrawerRight : mDrawerLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -221,8 +219,11 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
|||||||
updateActionBar();
|
updateActionBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openRightDrawer() {
|
||||||
|
mDrawerLayout.openDrawer(mDrawerRight);
|
||||||
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
// TODO mHighlighters.clear();
|
|
||||||
mPane = Pane.MAP;
|
mPane = Pane.MAP;
|
||||||
updateActionBar();
|
updateActionBar();
|
||||||
}
|
}
|
||||||
@ -253,9 +254,4 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
|||||||
|
|
||||||
updateActionBar();
|
updateActionBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openRightDrawer() {
|
|
||||||
// TODO should close left drawer
|
|
||||||
mDrawerLayout.openDrawer(mDrawerRight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user