Add aidl getAppInfo
This commit is contained in:
parent
7c45f6cc68
commit
a60a85d156
6 changed files with 152 additions and 10 deletions
|
@ -100,6 +100,8 @@ import net.osmand.aidlapi.lock.SetLockStateParams;
|
|||
|
||||
import net.osmand.aidlapi.events.AKeyEventsParams;
|
||||
|
||||
import net.osmand.aidlapi.info.AppInfoParams;
|
||||
|
||||
// NOTE: Add new methods at the end of file!!!
|
||||
|
||||
interface IOsmAndAidlInterface {
|
||||
|
@ -860,4 +862,6 @@ interface IOsmAndAidlInterface {
|
|||
* @params keyEventList (List<Integer>) - list of requested key events
|
||||
*/
|
||||
long registerForKeyEvents(in AKeyEventsParams params, IOsmAndAidlCallback callback);
|
||||
|
||||
AppInfoParams getAppInfo();
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidlapi.info;
|
||||
|
||||
parcelable AppInfoParams;
|
86
OsmAnd-api/src/net/osmand/aidlapi/info/AppInfoParams.java
Normal file
86
OsmAnd-api/src/net/osmand/aidlapi/info/AppInfoParams.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package net.osmand.aidlapi.info;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
import net.osmand.aidlapi.map.ALatLon;
|
||||
|
||||
public class AppInfoParams extends AidlParams {
|
||||
|
||||
private ALatLon lastKnownLocation;
|
||||
private ALatLon mapLocation;
|
||||
private int time;
|
||||
private long eta;
|
||||
private int leftDistance;
|
||||
private boolean mapVisible;
|
||||
|
||||
public AppInfoParams(ALatLon lastKnownLocation, ALatLon mapLocation, int time, long eta, int leftDistance, boolean mapVisible) {
|
||||
this.lastKnownLocation = lastKnownLocation;
|
||||
this.mapLocation = mapLocation;
|
||||
this.time = time;
|
||||
this.eta = eta;
|
||||
this.leftDistance = leftDistance;
|
||||
this.mapVisible = mapVisible;
|
||||
}
|
||||
|
||||
public AppInfoParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<AppInfoParams> CREATOR = new Creator<AppInfoParams>() {
|
||||
@Override
|
||||
public AppInfoParams createFromParcel(Parcel in) {
|
||||
return new AppInfoParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppInfoParams[] newArray(int size) {
|
||||
return new AppInfoParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public ALatLon getLastKnownLocation() {
|
||||
return lastKnownLocation;
|
||||
}
|
||||
|
||||
public ALatLon getMapLocation() {
|
||||
return mapLocation;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public long getEta() {
|
||||
return eta;
|
||||
}
|
||||
|
||||
public int getLeftDistance() {
|
||||
return leftDistance;
|
||||
}
|
||||
|
||||
public boolean isMapVisible() {
|
||||
return mapVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putParcelable("location", lastKnownLocation);
|
||||
bundle.putParcelable("mapLocation", mapLocation);
|
||||
bundle.putInt("time", time);
|
||||
bundle.putLong("eta", eta);
|
||||
bundle.putInt("leftDistance", leftDistance);
|
||||
bundle.putBoolean("mapVisible", mapVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
lastKnownLocation = bundle.getParcelable("location");
|
||||
mapLocation = bundle.getParcelable("mapLocation");
|
||||
time = bundle.getInt("time");
|
||||
eta = bundle.getLong("eta");
|
||||
leftDistance = bundle.getInt("leftDistance");
|
||||
mapVisible = bundle.getBoolean("mapVisible");
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ import net.osmand.GPXUtilities;
|
|||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.aidl.gpx.AGpxFile;
|
||||
import net.osmand.aidl.gpx.AGpxFileDetails;
|
||||
|
@ -38,6 +39,8 @@ import net.osmand.aidl.navigation.ADirectionInfo;
|
|||
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
|
||||
import net.osmand.aidl.quickaction.QuickActionInfoParams;
|
||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||
import net.osmand.aidlapi.info.AppInfoParams;
|
||||
import net.osmand.aidlapi.map.ALatLon;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -76,10 +79,10 @@ import net.osmand.plus.settings.backend.ApplicationMode;
|
|||
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.backend.SettingsHelper;
|
||||
import net.osmand.plus.views.layers.AidlMapLayer;
|
||||
import net.osmand.plus.views.layers.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.layers.AidlMapLayer;
|
||||
import net.osmand.plus.views.layers.MapInfoLayer;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -202,7 +205,7 @@ public class OsmandAidlApi {
|
|||
private Map<String, AidlContextMenuButtonsWrapper> contextMenuButtonsParams = new ConcurrentHashMap<>();
|
||||
private Map<Long, VoiceRouter.VoiceMessageListener> voiceRouterMessageCallbacks = new ConcurrentHashMap<>();
|
||||
|
||||
private AMapPointUpdateListener aMapPointUpdateListener;
|
||||
private MapActivity mapActivity;
|
||||
|
||||
private boolean mapActivityActive = false;
|
||||
|
||||
|
@ -238,12 +241,12 @@ public class OsmandAidlApi {
|
|||
registerLockStateReceiver(mapActivity);
|
||||
initOsmandTelegram();
|
||||
app.getAppCustomization().addListener(mapActivity);
|
||||
aMapPointUpdateListener = mapActivity;
|
||||
this.mapActivity = mapActivity;
|
||||
}
|
||||
|
||||
public void onDestroyMapActivity(MapActivity mapActivity) {
|
||||
app.getAppCustomization().removeListener(mapActivity);
|
||||
aMapPointUpdateListener = null;
|
||||
this.mapActivity = null;
|
||||
mapActivityActive = false;
|
||||
for (BroadcastReceiver b : receivers.values()) {
|
||||
if (b == null) {
|
||||
|
@ -263,7 +266,7 @@ public class OsmandAidlApi {
|
|||
}
|
||||
|
||||
AMapPointUpdateListener getAMapPointUpdateListener() {
|
||||
return aMapPointUpdateListener;
|
||||
return mapActivity;
|
||||
}
|
||||
|
||||
private void initOsmandTelegram() {
|
||||
|
@ -1714,6 +1717,36 @@ public class OsmandAidlApi {
|
|||
return true;
|
||||
}
|
||||
|
||||
AppInfoParams getAppInfo() {
|
||||
ALatLon lastKnownLocation = null;
|
||||
Location location = app.getLocationProvider().getLastKnownLocation();
|
||||
if (location != null) {
|
||||
lastKnownLocation = new ALatLon(location.getLatitude(), location.getLongitude());
|
||||
}
|
||||
|
||||
boolean mapVisible = false;
|
||||
ALatLon mapLocation = null;
|
||||
if (mapActivity != null) {
|
||||
LatLon mapLoc = mapActivity.getMapLocation();
|
||||
if (mapLoc != null) {
|
||||
mapLocation = new ALatLon(mapLoc.getLatitude(), mapLoc.getLongitude());
|
||||
}
|
||||
mapVisible = mapActivity.isMapVisible();
|
||||
}
|
||||
|
||||
int time = 0;
|
||||
long eta = 0;
|
||||
int leftDistance = 0;
|
||||
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (routingHelper.isRouteCalculated()) {
|
||||
time = routingHelper.getLeftTime();
|
||||
eta = time + System.currentTimeMillis() / 1000;
|
||||
leftDistance = routingHelper.getLeftDistance();
|
||||
}
|
||||
return new AppInfoParams(lastKnownLocation, mapLocation, time, eta, leftDistance, mapVisible);
|
||||
}
|
||||
|
||||
boolean search(final String searchQuery, final int searchType, final double latitude, final double longitude,
|
||||
final int radiusLevel, final int totalLimit, final SearchCompleteCallback callback) {
|
||||
if (Algorithms.isEmpty(searchQuery) || latitude == 0 || longitude == 0 || callback == null) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams;
|
|||
import net.osmand.aidlapi.contextmenu.RemoveContextMenuButtonsParams;
|
||||
import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams;
|
||||
import net.osmand.aidlapi.copyfile.CopyFileParams;
|
||||
import net.osmand.aidlapi.info.AppInfoParams;
|
||||
import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
||||
import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
|
||||
import net.osmand.aidlapi.customization.OsmandSettingsParams;
|
||||
|
@ -1295,6 +1296,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppInfoParams getAppInfo() {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("getAppInfo");
|
||||
return api != null ? api.getAppInfo() : null;
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||
|
|
|
@ -147,15 +147,15 @@ import net.osmand.plus.settings.fragments.ProfileAppearanceFragment;
|
|||
import net.osmand.plus.track.TrackAppearanceFragment;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.layers.MapControlsLayer;
|
||||
import net.osmand.plus.views.layers.MapInfoLayer;
|
||||
import net.osmand.plus.views.layers.MapQuickActionLayer;
|
||||
import net.osmand.plus.views.OsmAndMapLayersView;
|
||||
import net.osmand.plus.views.OsmAndMapSurfaceView;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.OsmandMapTileView.OnDrawMapListener;
|
||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||
import net.osmand.plus.views.layers.MapControlsLayer;
|
||||
import net.osmand.plus.views.layers.MapInfoLayer;
|
||||
import net.osmand.plus.views.layers.MapQuickActionLayer;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
@ -1119,6 +1119,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return mIsDestroyed;
|
||||
}
|
||||
|
||||
public boolean isMapVisible() {
|
||||
return AndroidUtils.isActivityNotDestroyed(this) && settings.MAP_ACTIVITY_ENABLED.get();
|
||||
}
|
||||
|
||||
private void restartApp() {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||
bld.setMessage(R.string.storage_permission_restart_is_required);
|
||||
|
|
Loading…
Reference in a new issue