Aidl margins initial commit

This commit is contained in:
Vitaliy 2020-09-02 15:13:24 +03:00
parent ec69531993
commit 1a94d5d98a
5 changed files with 98 additions and 0 deletions

View file

@ -74,6 +74,7 @@ import net.osmand.aidlapi.customization.OsmandSettingsParams;
import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
import net.osmand.aidlapi.customization.CustomizationInfoParams;
import net.osmand.aidlapi.customization.ProfileSettingsParams;
import net.osmand.aidlapi.customization.MapMarginsParams;
import net.osmand.aidlapi.gpx.AGpxFile;
import net.osmand.aidlapi.gpx.AGpxFileDetails;
@ -864,4 +865,6 @@ interface IOsmAndAidlInterface {
long registerForKeyEvents(in AKeyEventsParams params, IOsmAndAidlCallback callback);
AppInfoParams getAppInfo();
boolean setMapMargins(in MapMarginsParams params);
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidlapi.customization;
parcelable MapMarginsParams;

View file

@ -0,0 +1,75 @@
package net.osmand.aidlapi.customization;
import android.os.Bundle;
import android.os.Parcel;
import net.osmand.aidlapi.AidlParams;
public class MapMarginsParams extends AidlParams {
private String appModeKey;
private int leftMargin;
private int topMargin;
private int rightMargin;
private int bottomMargin;
public MapMarginsParams(String appModeKey, int leftMargin, int topMargin, int rightMargin, int bottomMargin) {
this.appModeKey = appModeKey;
this.leftMargin = leftMargin;
this.topMargin = topMargin;
this.rightMargin = rightMargin;
this.bottomMargin = bottomMargin;
}
public MapMarginsParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<MapMarginsParams> CREATOR = new Creator<MapMarginsParams>() {
@Override
public MapMarginsParams createFromParcel(Parcel in) {
return new MapMarginsParams(in);
}
@Override
public MapMarginsParams[] newArray(int size) {
return new MapMarginsParams[size];
}
};
public String getAppModeKey() {
return appModeKey;
}
public int getLeftMargin() {
return leftMargin;
}
public int getTopMargin() {
return topMargin;
}
public int getRightMargin() {
return rightMargin;
}
public int getBottomMargin() {
return bottomMargin;
}
@Override
public void writeToBundle(Bundle bundle) {
bundle.putInt("leftMargin", leftMargin);
bundle.putInt("topMargin", topMargin);
bundle.putInt("rightMargin", rightMargin);
bundle.putInt("bottomMargin", bottomMargin);
}
@Override
protected void readFromBundle(Bundle bundle) {
leftMargin = bundle.getInt("leftMargin");
topMargin = bundle.getInt("topMargin");
rightMargin = bundle.getInt("rightMargin");
bottomMargin = bundle.getInt("bottomMargin");
}
}

View file

@ -2273,6 +2273,10 @@ public class OsmandAidlApi {
return true;
}
public boolean setMapMargins(String appModeKey, int leftMargin, int topMargin, int bottomMargin, int rightMargin) {
return false;
}
private class FileCopyInfo {
long startTime;
long lastAccessTime;

View file

@ -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.customization.MapMarginsParams;
import net.osmand.aidlapi.info.AppInfoParams;
import net.osmand.aidlapi.customization.CustomizationInfoParams;
import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
@ -1307,6 +1308,18 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
return null;
}
}
@Override
public boolean setMapMargins(MapMarginsParams params) {
try {
OsmandAidlApi api = getApi("setMapMargins");
return api != null && api.setMapMargins(params.getAppModeKey(), params.getLeftMargin(), params.getTopMargin(),
params.getBottomMargin(), params.getRightMargin());
} catch (Exception e) {
handleException(e);
return false;
}
}
};
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {