From 88a6865f06cc224a4a7fc694ef6fb549a9a2cb96 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 24 Aug 2015 14:44:29 +0300 Subject: [PATCH] Move builds to drawer --- .../plus/activities/MapActivityActions.java | 4 ++++ .../plus/activities/SettingsActivity.java | 20 ++++------------- .../development/OsmandDevelopmentPlugin.java | 22 +++++++++++++++++++ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 69ec54b7fb..3ea2fbb446 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -30,10 +30,12 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.Version; import net.osmand.plus.activities.actions.OsmAndDialogs; import net.osmand.plus.activities.actions.ShareLocation; import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; +import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; @@ -49,6 +51,7 @@ import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; +import android.preference.Preference; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -674,6 +677,7 @@ public class MapActivityActions implements DialogProvider { //////////// Others OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper); + // optionsMenuHelper.item(R.string.shared_string_exit).iconColor(R.drawable.ic_action_quit_dark ) // .listen(new OnContextMenuClick() { // @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index 0fca10dcdb..845a72a552 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -36,7 +36,6 @@ public class SettingsActivity extends SettingsBaseActivity { private Preference general; private Preference routing; private Preference about; - private Preference version; private Preference help; @@ -64,15 +63,7 @@ public class SettingsActivity extends SettingsBaseActivity { startActivity(new Intent(this, SettingsNavigationActivity.class)); } } - if ((Version.isDeveloperVersion(getMyApplication())) && - OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null){ - version = new Preference(this); - version.setOnPreferenceClickListener(this); - version.setSummary(R.string.version_settings_descr); - version.setTitle(R.string.version_settings); - version.setKey("version"); - screen.addPreference(version); - } + about = new Preference(this); about.setOnPreferenceClickListener(this); about.setSummary(R.string.about_settings_descr); @@ -95,18 +86,15 @@ public class SettingsActivity extends SettingsBaseActivity { if (preference == general) { startActivity(new Intent(this, SettingsGeneralActivity.class)); return true; - } else if (preference == help) { - startActivity(new Intent(this, HelpActivity.class)); - return true; } else if (preference == routing) { startActivity(new Intent(this, SettingsNavigationActivity.class)); return true; + } else if (preference == help) { + startActivity(new Intent(this, HelpActivity.class)); + return true; } else if (preference == about) { showAboutDialog(getMyApplication()); return true; - } else if (preference == version){ - final Intent mapIntent = new Intent(this, ContributionVersionActivity.class); - this.startActivityForResult(mapIntent, 0); } else { super.onPreferenceClick(preference); } diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index 33b5c617e1..dcd44ae2de 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -1,14 +1,20 @@ package net.osmand.plus.development; +import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; +import net.osmand.plus.Version; +import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; +import net.osmand.plus.activities.ContributionVersionActivity; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.mapwidgets.TextInfoWidget; import android.app.Activity; +import android.content.Intent; +import android.widget.ArrayAdapter; public class OsmandDevelopmentPlugin extends OsmandPlugin { private static final String ID = "osmand.development"; @@ -38,6 +44,22 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { registerWidget(activity); } + @Override + public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) { + if (Version.isDeveloperVersion(mapActivity.getMyApplication())) { + helper.item(R.string.version_settings).iconColor(R.drawable.ic_action_gabout_dark) + .listen(new OnContextMenuClick() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + final Intent mapIntent = new Intent(mapActivity, ContributionVersionActivity.class); + mapActivity.startActivityForResult(mapIntent, 0); + return true; + } + }).reg(); + } + + } + @Override public void updateLayers(OsmandMapTileView mapView, MapActivity activity) { if(isActive()) {