Refactored options menu for sherpafy

This commit is contained in:
Denis 2014-09-03 11:24:40 +03:00
parent f2bae6d33a
commit 361e7ffd65
2 changed files with 20 additions and 18 deletions

View file

@ -761,22 +761,6 @@ public class MapActivityActions implements DialogProvider {
final OsmandApplication app = mapActivity.getMyApplication(); final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app); ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
if (Version.isSherpafy(app)) {
//share my location
optionsMenuHelper.item(R.string.context_menu_item_share_location).icons(
R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_light).listen(new OnContextMenuClick() {
@Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (getMyApplication().getLocationProvider().getLastKnownLocation() != null) {
new ShareLocation(mapActivity).run();
} else {
Toast.makeText(getMyApplication(), R.string.unknown_location, Toast.LENGTH_LONG).show();
}
}
}).reg();
}
// 1. Where am I // 1. Where am I
optionsMenuHelper.item(R.string.where_am_i). optionsMenuHelper.item(R.string.where_am_i).
icons(R.drawable.ic_action_gloc_dark, R.drawable.ic_action_gloc_light) icons(R.drawable.ic_action_gloc_dark, R.drawable.ic_action_gloc_light)
@ -974,6 +958,7 @@ public class MapActivityActions implements DialogProvider {
}).reg(); }).reg();
} }
} }
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper); OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
optionsMenuHelper.item(R.string.exit_Button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light ) optionsMenuHelper.item(R.string.exit_Button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@ -988,6 +973,7 @@ public class MapActivityActions implements DialogProvider {
// app.closeApplication(mapActivity); // app.closeApplication(mapActivity);
} }
}).reg(); }).reg();
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper); getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
return optionsMenuHelper; return optionsMenuHelper;
} }

View file

@ -10,6 +10,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeSet; import java.util.TreeSet;
import android.widget.Toast;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.Location; import net.osmand.Location;
@ -33,6 +34,7 @@ import net.osmand.plus.activities.DownloadIndexActivity;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.activities.SelectedGPXFragment; import net.osmand.plus.activities.SelectedGPXFragment;
import net.osmand.plus.activities.actions.ShareLocation;
import net.osmand.plus.api.FileSettingsAPIImpl; import net.osmand.plus.api.FileSettingsAPIImpl;
import net.osmand.plus.api.SettingsAPI; import net.osmand.plus.api.SettingsAPI;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
@ -538,7 +540,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
} }
}).reg(); }).reg();
} }
adapter.item(R.string.sherpafy_tour_info_txt).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light ).position(adapter.length() - 1) adapter.item(R.string.sherpafy_tour_info_txt).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).position(adapter.length() - 1)
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) { public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
@ -546,7 +548,21 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(newIntent); mapActivity.startActivity(newIntent);
} }
}).reg(); }).reg();
//share my location
adapter.item(R.string.context_menu_item_share_location).icons(
R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_light).listen(new OnContextMenuClick() {
@Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (app.getLocationProvider().getLastKnownLocation() != null) {
new ShareLocation(mapActivity).run();
} else {
Toast.makeText(app, R.string.unknown_location, Toast.LENGTH_LONG).show();
}
}
}).reg();
} }