From 3735eaa88ad0539f93bd53919bc9d02752e7d743 Mon Sep 17 00:00:00 2001 From: aFedasenka Date: Sat, 7 Jul 2012 22:54:47 +0200 Subject: [PATCH] OsmandMonitoringPlugin info control added, new icons added, bufixes --- .../res/drawable-mdpi/monitoring_rec_big.png | Bin 0 -> 3464 bytes .../drawable-mdpi/monitoring_rec_inactive.png | Bin 0 -> 3471 bytes .../drawable-mdpi/monitoring_rec_small.png | Bin 0 -> 3359 bytes OsmAnd/res/values/strings.xml | 3 + .../src/net/osmand/plus/OsmandSettings.java | 2 + .../monitoring/OsmandMonitoringPlugin.java | 136 ++++++++++++------ 6 files changed, 99 insertions(+), 42 deletions(-) create mode 100644 OsmAnd/res/drawable-mdpi/monitoring_rec_big.png create mode 100644 OsmAnd/res/drawable-mdpi/monitoring_rec_inactive.png create mode 100644 OsmAnd/res/drawable-mdpi/monitoring_rec_small.png diff --git a/OsmAnd/res/drawable-mdpi/monitoring_rec_big.png b/OsmAnd/res/drawable-mdpi/monitoring_rec_big.png new file mode 100644 index 0000000000000000000000000000000000000000..b2f1013384a1057715932b50c9913f2d1af7dfdb GIT binary patch literal 3464 zcmV;34R`X1P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?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z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0008INklYo*zPqrn@Md&$ zwA5@iq3b$4&x4c_i9`abszL~XwY9b7N~Q9GbN>7MjW2);g+gg*Y3XAolPPGL2E#DG z7(*C_AcR0s6eJP}P)eaF3aZuW^2*A}698^2_)PP9dwXxp&(FU~r_+Ucy^dzHiIbBP z_`Z)QiV%h&f*=5646f_Kwr!M3rH930@zJHK7#SIvo}8S#zqhvsUDv@FgOsvuW2Kac zq6kt-6pO{j$z*b{EtpcOmdoX7&Uw->3~=RDzg9>Or}3LKXs2!ab`J)LmQjl;vkU$FwZ2`MFl zAb{t2fe^y#1h%%ewl-YXjf4}%{i04@B1)K6NX`6cX#)TrfF}xvh?`)__L|0 zsl~p&zEn?74=AM|gdonuaU58dg+`;XS*z8a+P1xMrKRH-8X9^qF){Hnm&?siN>3Hw z`#vnoviA4)KWLivnlbjH-Rss7{LeIl>2!J~m&@HzRka|5@J-YFZkpy-$8kOb2s%BR xmx5c2pi)Y+Qp!*WaReZ|%#CNj|IOF*cK|d2udmsSb?yKF002ovPDHLkV1lDNhTQ-F literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable-mdpi/monitoring_rec_small.png b/OsmAnd/res/drawable-mdpi/monitoring_rec_small.png new file mode 100644 index 0000000000000000000000000000000000000000..6dcf52c58b5067bad1220f084281192fcbdf7fbb GIT binary patch literal 3359 zcmV+)4dC*LP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p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}+?bsm9<=R2A4+SgOI7~_fN2;zpY--V)qw$B?b zBBA+cRCAW4Im^;~B%--^T#K=o7HVp=SLDiy!RlC(yzZ8k3tf@Oxzgw;!NdfbPNSs~ zcpi8j>Nrp=;@UQjDwhr8ss(#DtcuQ9?0oIajCd>CR|S#3Llsmh0efJ7r^u;LaKtbo zZRK(zNTmoWXBwse@KtGmw$O5`6|w5GSxY?+948d2fDhQezjdLGbH2ayA)QVenGEW> zp@8FXS6alXaxZ-pf zm{ldE%4^k;jOx@H1M6LoV2y>gh(uYO5 z`b35fz>#RB&joV8S8(5}K76J+ScETIdMg0xp!ulC#U?lz7umI>TF$|bX?UDeeGZhj p{0Ob19Tn5-mtPq8|Nevg8UVJeK&|w6`fvaM002ovPDHLkV1j$MQMLd8 literal 0 HcmV?d00001 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 0a3690e617..0294d60dd2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,9 @@ 1. All your modified/created strings are in the top of the file (to make easier find what's translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Info Control + Show monitoring state on the info pane + Allocated memory %1$s MB (Android limit %2$s MB, Dalvik %3$s MB). Allocated memory Total native memory allocated by app %1$s MB (Dalvik %2$s MB, other %3$s MB). diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 43af26f519..0bd1a3f7d0 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -578,6 +578,8 @@ public class OsmandSettings { public final CommonPreference LIVE_MONITORING_URL = new StringPreference("live_monitoring_url", "http://example.com?lat={0}&lon={1}×tamp={2}&hdop={3}&altitude={4}&speed={5}").makeGlobal(); + // this value string is synchronized with settings_pref.xml preference name + public final OsmandPreference SHOW_MONITORING_CONTROL = new BooleanPreference("show_monitoring_control", false).makeProfile(); // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference SHOW_OSM_BUGS = new BooleanPreference("show_osm_bugs", false).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 15ecee685c..8821a16522 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -12,6 +12,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.views.MapInfoLayer; +import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.TextInfoControl; import org.apache.commons.logging.Log; @@ -22,20 +23,31 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.drawable.Drawable; +import android.os.Handler; +import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.view.View; +import android.view.animation.Animation; +import android.view.animation.Interpolator; +import android.view.animation.RotateAnimation; +import android.view.animation.ScaleAnimation; public class OsmandMonitoringPlugin extends OsmandPlugin { private static final String ID = "osmand.monitoring"; private OsmandSettings settings; private OsmandApplication app; - private TextInfoControl monitoringControl; private static final Log log = LogUtil.getLog(OsmandMonitoringPlugin.class); + + private TextInfoControl monitoringControl; + private Drawable monitoring_rec; + private Drawable monitoring; private Paint paintText; private Paint paintSubText; + private MapInfoLayer mapInfoLayer; + private Handler uiHandler; public OsmandMonitoringPlugin(OsmandApplication app) { this.app = app; @@ -54,24 +66,42 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { public String getId() { return ID; } + @Override public String getDescription() { return app.getString(R.string.osmand_monitoring_description); } + @Override public String getName() { return app.getString(R.string.monitor_preferences); } + @Override public void registerLayers(MapActivity activity) { - MapInfoLayer mapInfoLayer = ((MapActivity)activity).getMapLayers().getMapInfoLayer(); - if ((mapInfoLayer != null) && (monitoringControl == null)) - mapInfoLayer.addRightStack(createMonitoringControl(activity)); + //create if needed a textInfoControl + createMonitoringControl(activity); + //if right-stack has already been added -> return; + if (monitoringControl.getParent() != null) { + return; + } + //if right-stack has not yet been added -> add right-stack; + mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); + if (mapInfoLayer != null) { + mapInfoLayer.addRightStack(monitoringControl); + } } @Override - public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter, - Object selectedObj) { + public void updateLayers(OsmandMapTileView mapView, MapActivity activity) { + + registerLayers(activity); + } + + @Override + public void registerMapContextMenuActions(final MapActivity mapActivity, + final double latitude, final double longitude, + ContextMenuAdapter adapter, Object selectedObj) { OnContextMenuClick listener = new OnContextMenuClick() { @Override public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) { @@ -82,7 +112,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { }; adapter.registerItem(R.string.context_menu_item_add_waypoint, R.drawable.list_activities_gpx_waypoint, listener, -1); } - @Override public void settingsActivityCreate(final SettingsActivity activity, PreferenceScreen screen) { @@ -102,11 +131,14 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { cat.setTitle(R.string.save_track_to_gpx); grp.addPreference(cat); - cat.addPreference(activity.createCheckBoxPreference(settings.SAVE_TRACK_TO_GPX, R.string.save_track_to_gpx, + cat.addPreference(activity.createCheckBoxPreference( + settings.SAVE_TRACK_TO_GPX, R.string.save_track_to_gpx, R.string.save_track_to_gpx_descrp)); - - cat.addPreference(activity.createTimeListPreference(settings.SAVE_TRACK_INTERVAL, new int[] { 1, 2, 3, 5, 10, 15, 20, 30 }, - new int[] { 1, 2, 3, 5 }, 1, R.string.save_track_interval, R.string.save_track_interval_descr)); + cat.addPreference(activity.createTimeListPreference( + settings.SAVE_TRACK_INTERVAL, new int[] { 1, 2, 3, 5, 10, 15, + 20, 30 }, new int[] { 1, 2, 3, 5 }, 1, + R.string.save_track_interval, + R.string.save_track_interval_descr)); Preference pref = new Preference(activity); pref.setTitle(R.string.save_current_track); @@ -125,23 +157,35 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { } }); cat.addPreference(pref); + + CheckBoxPreference infoControlPreference = activity + .createCheckBoxPreference(settings.SHOW_MONITORING_CONTROL, + R.string.monitoring_info_control, + R.string.monitoring_info_control_desc); + cat.addPreference(infoControlPreference); cat = new PreferenceCategory(activity); cat.setTitle(R.string.live_monitoring); grp.addPreference(cat); - cat.addPreference(activity.createCheckBoxPreference(settings.LIVE_MONITORING, R.string.live_monitoring, + cat.addPreference(activity.createCheckBoxPreference( + settings.LIVE_MONITORING, R.string.live_monitoring, R.string.live_monitoring_descr)); - cat.addPreference(activity.createEditTextPreference(settings.LIVE_MONITORING_URL, R.string.live_monitoring_url, + cat.addPreference(activity.createEditTextPreference( + settings.LIVE_MONITORING_URL, R.string.live_monitoring_url, R.string.live_monitoring_url_descr)); - - cat.addPreference(activity.createTimeListPreference(settings.LIVE_MONITORING_INTERVAL, new int[] { 1, 2, 3, 5, 10, 15, 20, 30 }, - new int[] { 1, 2, 3, 5 }, 1, R.string.live_monitoring_interval, R.string.live_monitoring_interval_descr)); + cat.addPreference(activity.createTimeListPreference( + settings.LIVE_MONITORING_INTERVAL, new int[] { 1, 2, 3, 5, 10, + 15, 20, 30 }, new int[] { 1, 2, 3, 5 }, 1, + R.string.live_monitoring_interval, + R.string.live_monitoring_interval_descr)); } private void saveCurrentTracks(final SavingTrackHelper helper, final SettingsActivity activity) { - activity.progressDlg = ProgressDialog.show(activity, activity.getString(R.string.saving_gpx_tracks), activity.getString(R.string.saving_gpx_tracks), true); + activity.progressDlg = ProgressDialog.show(activity, + activity.getString(R.string.saving_gpx_tracks), + activity.getString(R.string.saving_gpx_tracks), true); final ProgressDialogImplementation impl = new ProgressDialogImplementation(activity.progressDlg); impl.setRunnable("SavingGPX", new Runnable() { //$NON-NLS-1$ @Override @@ -161,55 +205,63 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { } /** - * @return the control to be added on a MapInfoLayer + * creates (if it wasn't created previously) the control to be added on a MapInfoLayer * that shows a monitoring state (recorded/stopped) */ - private TextInfoControl createMonitoringControl(final MapActivity mapActivity) { + private void createMonitoringControl(final MapActivity mapActivity) { + if (monitoringControl != null) { + monitoringControl.updateInfo(); + return; + } + paintText = new Paint(); paintText.setStyle(Style.FILL_AND_STROKE); paintText.setColor(Color.BLACK); paintText.setTextSize(23 * MapInfoLayer.scaleCoefficient); paintText.setAntiAlias(true); paintText.setStrokeWidth(4); - paintSubText = new Paint(); paintSubText.setStyle(Style.FILL_AND_STROKE); paintSubText.setColor(Color.BLACK); paintSubText.setTextSize(15 * MapInfoLayer.scaleCoefficient); paintSubText.setAntiAlias(true); - final Drawable monitoring_rec = mapActivity.getMapView().getResources().getDrawable(R.drawable.monitoring_rec); - final Drawable monitoring = mapActivity.getMapView().getResources().getDrawable(R.drawable.monitoring); - monitoringControl = new TextInfoControl(mapActivity, 0, paintText, paintSubText) { @Override public boolean updateInfo() { - //TODO - if (settings.SAVE_TRACK_TO_GPX.get()) { - setImageDrawable(monitoring); - return true; - } - setImageDrawable(monitoring_rec); + setText(getMonitoringControlTxt(), null); + setImageDrawable(getMonitoringControlImg(mapActivity)); return true; } }; + monitoringControl.updateInfo(); monitoringControl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Boolean isTrackMonitored = settings.SAVE_TRACK_TO_GPX.get(); + boolean isTrackMonitored = settings.SAVE_TRACK_TO_GPX.get(); settings.SAVE_TRACK_TO_GPX.set(!isTrackMonitored); - if (isTrackMonitored) { - monitoringControl.setImageDrawable(monitoring); - monitoringControl.setText("rec", null); - return; - } - monitoringControl.setImageDrawable(monitoring_rec); - monitoringControl.setText("pause", null); + monitoringControl.updateInfo(); } - }); - monitoringControl.setText("rec", null); - monitoringControl.setImageDrawable(monitoring); - return monitoringControl; + }); } -} + + private String getMonitoringControlTxt() { + if (!settings.SHOW_MONITORING_CONTROL.get()) + return null; + if(settings.SAVE_TRACK_TO_GPX.get()) + return "pause "; + return "record"; + } + + private Drawable getMonitoringControlImg(MapActivity mapActivity) { + if (monitoring_rec == null) + monitoring_rec = mapActivity.getMapView().getResources().getDrawable(R.drawable.monitoring_rec_big); + if (monitoring == null) + monitoring = mapActivity.getMapView().getResources().getDrawable(R.drawable.monitoring_rec_inactive); + if (settings.SAVE_TRACK_TO_GPX.get()) + return monitoring_rec; + return monitoring; + } + +} \ No newline at end of file