diff --git a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index 3b76ebb668..c9974dd2c9 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -95,7 +95,9 @@ import net.osmand.aidlapi.mapmarker.RemoveMapMarkersParams; import net.osmand.aidlapi.quickaction.QuickActionParams; import net.osmand.aidlapi.quickaction.QuickActionInfoParams; + import net.osmand.aidlapi.lock.SetLockStateParams; + import net.osmand.aidlapi.events.AKeyEventsParams; // NOTE: Add new methods at the end of file!!! @@ -843,11 +845,12 @@ interface IOsmAndAidlInterface { boolean executeQuickAction(in QuickActionParams params); boolean getQuickActionsInfo(out List quickActions); + /** * Toggle Lock/Unlock screen. */ - boolean setLockState(in SetLockStateParams params); + /** * Method to register for key events. * diff --git a/OsmAnd-api/src/net/osmand/aidlapi/events/AKeyEventsParams.java b/OsmAnd-api/src/net/osmand/aidlapi/events/AKeyEventsParams.java index 814eb6dfac..83c4d4368e 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/events/AKeyEventsParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/events/AKeyEventsParams.java @@ -10,61 +10,64 @@ import java.util.ArrayList; public class AKeyEventsParams extends AidlParams { - private long callbackId = -1L; - private boolean subscribeToUpdates = true; - private ArrayList keyEventList; + private long callbackId = -1L; + private boolean subscribeToUpdates = true; + private ArrayList keyEventList; - public AKeyEventsParams() { } + public AKeyEventsParams() { + } - protected AKeyEventsParams(Parcel in) { - readFromParcel(in); - } + protected AKeyEventsParams(Parcel in) { + readFromParcel(in); + } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public AKeyEventsParams createFromParcel(Parcel in) { - return new AKeyEventsParams(in); - } + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + @Override + public AKeyEventsParams createFromParcel(Parcel in) { + return new AKeyEventsParams(in); + } - @Override - public AKeyEventsParams[] newArray(int size) { - return new AKeyEventsParams[size]; - } - }; + @Override + public AKeyEventsParams[] newArray(int size) { + return new AKeyEventsParams[size]; + } + }; - public long getCallbackId() { - return callbackId; - } + public long getCallbackId() { + return callbackId; + } - public void setCallbackId(long callbackId) { - this.callbackId = callbackId; - } + public void setCallbackId(long callbackId) { + this.callbackId = callbackId; + } - public void setSubscribeToUpdates(boolean subscribeToUpdates) { - this.subscribeToUpdates = subscribeToUpdates; - } + public void setSubscribeToUpdates(boolean subscribeToUpdates) { + this.subscribeToUpdates = subscribeToUpdates; + } - public boolean isSubscribeToUpdates() { - return subscribeToUpdates; - } - public void setKeyEventList( ArrayList keyEventList){ - this.keyEventList=keyEventList; - } - public ArrayList getKeyEventList() { - return keyEventList; - } + public boolean isSubscribeToUpdates() { + return subscribeToUpdates; + } - @Override - protected void readFromBundle(Bundle bundle) { - callbackId = bundle.getLong("callbackId"); - subscribeToUpdates = bundle.getBoolean("subscribeToUpdates"); - keyEventList = bundle.getIntegerArrayList("keyEventList"); - } + public void setKeyEventList(ArrayList keyEventList) { + this.keyEventList = keyEventList; + } - @Override - public void writeToBundle(Bundle bundle) { - bundle.putLong("callbackId", callbackId); - bundle.putBoolean("subscribeToUpdates", subscribeToUpdates); - bundle.putIntegerArrayList("keyEventList", keyEventList); - } + public ArrayList getKeyEventList() { + return keyEventList; + } + + @Override + protected void readFromBundle(Bundle bundle) { + callbackId = bundle.getLong("callbackId"); + subscribeToUpdates = bundle.getBoolean("subscribeToUpdates"); + keyEventList = bundle.getIntegerArrayList("keyEventList"); + } + + @Override + public void writeToBundle(Bundle bundle) { + bundle.putLong("callbackId", callbackId); + bundle.putBoolean("subscribeToUpdates", subscribeToUpdates); + bundle.putIntegerArrayList("keyEventList", keyEventList); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index fe22bd289a..cc526f75ae 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -2358,7 +2358,6 @@ public class OsmandAidlApi { a.points, a.wptPoints, a.wptCategoryNames); } - private Map> keyEventCallbacks = new ConcurrentHashMap<>(); public boolean onKeyEvent(KeyEvent event) { diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 56806b2385..8d38f4e87c 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -15,7 +15,6 @@ import net.osmand.PlatformUtil; import net.osmand.aidl.OsmandAidlApi.GpxBitmapCreatedCallback; import net.osmand.aidl.OsmandAidlApi.OsmandAppInitCallback; import net.osmand.aidl.OsmandAidlApi.SearchCompleteCallback; -import net.osmand.aidlapi.lock.SetLockStateParams; import net.osmand.aidlapi.IOsmAndAidlCallback; import net.osmand.aidlapi.IOsmAndAidlInterface; import net.osmand.aidlapi.calculateroute.CalculateRouteParams; @@ -28,6 +27,7 @@ import net.osmand.aidlapi.customization.OsmandSettingsInfoParams; import net.osmand.aidlapi.customization.OsmandSettingsParams; import net.osmand.aidlapi.customization.ProfileSettingsParams; import net.osmand.aidlapi.customization.SetWidgetsParams; +import net.osmand.aidlapi.events.AKeyEventsParams; import net.osmand.aidlapi.favorite.AFavorite; import net.osmand.aidlapi.favorite.AddFavoriteParams; import net.osmand.aidlapi.favorite.RemoveFavoriteParams; @@ -46,6 +46,7 @@ import net.osmand.aidlapi.gpx.RemoveGpxParams; import net.osmand.aidlapi.gpx.ShowGpxParams; import net.osmand.aidlapi.gpx.StartGpxRecordingParams; import net.osmand.aidlapi.gpx.StopGpxRecordingParams; +import net.osmand.aidlapi.lock.SetLockStateParams; import net.osmand.aidlapi.map.ALatLon; import net.osmand.aidlapi.map.SetMapLocationParams; import net.osmand.aidlapi.maplayer.AddMapLayerParams; @@ -88,8 +89,8 @@ import net.osmand.aidlapi.search.SearchParams; import net.osmand.aidlapi.search.SearchResult; import net.osmand.aidlapi.tiles.ASqliteDbFile; import net.osmand.data.LatLon; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java index acb1ac6e46..66bfc93a7b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java @@ -62,10 +62,8 @@ public class MapActivityKeyListener implements KeyEvent.Callback { } } else if (mapScrollHelper.isScrollingDirectionKeyCode(keyCode)) { return mapScrollHelper.onKeyDown(keyCode, event); - } else if(app.getAidlApi().onKeyEvent(event)) { - return true; } - return false; + return app.getAidlApi().onKeyEvent(event); } @Override @@ -125,12 +123,10 @@ public class MapActivityKeyListener implements KeyEvent.Callback { mapActivity.changeZoom(1); return true; } - } else if (app.getAidlApi().onKeyEvent(event)){ + } else if (OsmandPlugin.onMapActivityKeyUp(mapActivity, keyCode)) { return true; - } else{ - return OsmandPlugin.onMapActivityKeyUp(mapActivity, keyCode); } - return false; + return app.getAidlApi().onKeyEvent(event); } @Override