From d3cf4fade645118977572b22c638cd8bcd3a470e Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Fri, 12 Mar 2021 12:52:33 +0200 Subject: [PATCH 1/3] wrong recording note button is shown on profile change --- .../src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 6d425ef65e..9861cfd073 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -782,8 +782,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public boolean updateInfo(DrawSettings drawSettings) { boolean recording = isRecording(); - if (!Algorithms.objectEquals(recording, cachedRecording)) { - cachedRecording = recording; + cachedRecording = recording; if (recording) { setText(app.getString(R.string.shared_string_control_stop), null); setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night); @@ -805,7 +804,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { break; } } - } return false; }; }; From 7015e8d25bbbaf98ecc4de0b065ab67f890ba0a3 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Sun, 14 Mar 2021 19:04:27 +0200 Subject: [PATCH 2/3] Update --- .../audionotes/AudioVideoNotesPlugin.java | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 9861cfd073..73d054549d 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -776,36 +776,29 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); if (mapInfoLayer != null) { recordControl = new TextInfoWidget(activity) { - - private Boolean cachedRecording; - @Override public boolean updateInfo(DrawSettings drawSettings) { - boolean recording = isRecording(); - cachedRecording = recording; - if (recording) { - setText(app.getString(R.string.shared_string_control_stop), null); - setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night); + Integer action = AV_DEFAULT_ACTION.get(); + boolean isVideoAction = action.equals(AV_DEFAULT_ACTION_VIDEO); + boolean isTakePictureAction = action.equals(AV_DEFAULT_ACTION_TAKEPICTURE); + boolean isAudioAction = action.equals(AV_DEFAULT_ACTION_AUDIO); + if (isRecording()) { + setText(app.getString(R.string.shared_string_control_stop), null); + setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night); + } else { + setText(app.getString(R.string.shared_string_control_start), null); + if (isVideoAction) { + setIcons(R.drawable.widget_av_video_day, R.drawable.widget_av_video_night); + } else if (isTakePictureAction) { + setIcons(R.drawable.widget_av_photo_day, R.drawable.widget_av_photo_night); + } else if (isAudioAction) { + setIcons(R.drawable.widget_av_audio_day, R.drawable.widget_av_audio_night); } else { - setText(app.getString(R.string.shared_string_control_start), null); - Integer action = AV_DEFAULT_ACTION.get(); - switch (action) { - case AV_DEFAULT_ACTION_VIDEO: - setIcons(R.drawable.widget_av_video_day, R.drawable.widget_av_video_night); - break; - case AV_DEFAULT_ACTION_TAKEPICTURE: - setIcons(R.drawable.widget_av_photo_day, R.drawable.widget_av_photo_night); - break; - case AV_DEFAULT_ACTION_AUDIO: - setIcons(R.drawable.widget_av_audio_day, R.drawable.widget_av_audio_night); - break; - default: - setIcons(R.drawable.widget_icon_av_inactive_day, R.drawable.widget_icon_av_inactive_night); - break; - } + setIcons(R.drawable.widget_icon_av_inactive_day, R.drawable.widget_icon_av_inactive_night); } + } return false; - }; + } }; recordControl.setOnClickListener(new View.OnClickListener() { @Override From a0ce545636b9ae66fa9fed17469aa74a8e3b9b2b Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 15 Mar 2021 10:36:28 +0200 Subject: [PATCH 3/3] Review --- .../audionotes/AudioVideoNotesPlugin.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 73d054549d..43a5179d9b 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -776,25 +776,36 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); if (mapInfoLayer != null) { recordControl = new TextInfoWidget(activity) { + + private Integer cachedAction; + private Boolean cachedRecording; + @Override public boolean updateInfo(DrawSettings drawSettings) { + boolean recording = isRecording(); Integer action = AV_DEFAULT_ACTION.get(); - boolean isVideoAction = action.equals(AV_DEFAULT_ACTION_VIDEO); - boolean isTakePictureAction = action.equals(AV_DEFAULT_ACTION_TAKEPICTURE); - boolean isAudioAction = action.equals(AV_DEFAULT_ACTION_AUDIO); - if (isRecording()) { - setText(app.getString(R.string.shared_string_control_stop), null); - setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night); - } else { - setText(app.getString(R.string.shared_string_control_start), null); - if (isVideoAction) { - setIcons(R.drawable.widget_av_video_day, R.drawable.widget_av_video_night); - } else if (isTakePictureAction) { - setIcons(R.drawable.widget_av_photo_day, R.drawable.widget_av_photo_night); - } else if (isAudioAction) { - setIcons(R.drawable.widget_av_audio_day, R.drawable.widget_av_audio_night); + if (!Algorithms.objectEquals(recording, cachedAction) || !Algorithms.objectEquals(action, cachedRecording)) { + cachedAction = action; + cachedRecording = recording; + if (recording) { + setText(app.getString(R.string.shared_string_control_stop), null); + setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night); } else { - setIcons(R.drawable.widget_icon_av_inactive_day, R.drawable.widget_icon_av_inactive_night); + setText(app.getString(R.string.shared_string_control_start), null); + switch (action) { + case AV_DEFAULT_ACTION_VIDEO: + setIcons(R.drawable.widget_av_video_day, R.drawable.widget_av_video_night); + break; + case AV_DEFAULT_ACTION_TAKEPICTURE: + setIcons(R.drawable.widget_av_photo_day, R.drawable.widget_av_photo_night); + break; + case AV_DEFAULT_ACTION_AUDIO: + setIcons(R.drawable.widget_av_audio_day, R.drawable.widget_av_audio_night); + break; + default: + setIcons(R.drawable.widget_icon_av_inactive_day, R.drawable.widget_icon_av_inactive_night); + break; + } } } return false;