commit
5b377cbf21
8 changed files with 244 additions and 1 deletions
|
@ -78,6 +78,8 @@ import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
||||||
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
||||||
import net.osmand.aidlapi.customization.MapMarginsParams;
|
import net.osmand.aidlapi.customization.MapMarginsParams;
|
||||||
import net.osmand.aidlapi.customization.CustomPluginParams;
|
import net.osmand.aidlapi.customization.CustomPluginParams;
|
||||||
|
import net.osmand.aidlapi.customization.SelectProfileParams;
|
||||||
|
import net.osmand.aidlapi.customization.AProfile;
|
||||||
|
|
||||||
import net.osmand.aidlapi.gpx.AGpxFile;
|
import net.osmand.aidlapi.gpx.AGpxFile;
|
||||||
import net.osmand.aidlapi.gpx.AGpxFileDetails;
|
import net.osmand.aidlapi.gpx.AGpxFileDetails;
|
||||||
|
@ -886,4 +888,8 @@ interface IOsmAndAidlInterface {
|
||||||
boolean isMenuOpen();
|
boolean isMenuOpen();
|
||||||
|
|
||||||
int getPluginVersion(in CustomPluginParams params);
|
int getPluginVersion(in CustomPluginParams params);
|
||||||
|
|
||||||
|
boolean selectProfile(in SelectProfileParams params);
|
||||||
|
|
||||||
|
boolean getProfiles(out List<AProfile> profiles);
|
||||||
}
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidlapi.customization;
|
||||||
|
|
||||||
|
parcelable AProfile;
|
129
OsmAnd-api/src/net/osmand/aidlapi/customization/AProfile.java
Normal file
129
OsmAnd-api/src/net/osmand/aidlapi/customization/AProfile.java
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
package net.osmand.aidlapi.customization;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcel;
|
||||||
|
|
||||||
|
import net.osmand.aidlapi.AidlParams;
|
||||||
|
|
||||||
|
public class AProfile extends AidlParams {
|
||||||
|
|
||||||
|
public static final String PROFILE_ID_KEY = "profile_id";
|
||||||
|
public static final String USER_PROFILE_NAME_KEY = "user_profile_name";
|
||||||
|
public static final String PARENT_KEY = "parent";
|
||||||
|
public static final String ICON_NAME_KEY = "icon_name";
|
||||||
|
public static final String ICON_COLOR_KEY = "icon_color";
|
||||||
|
public static final String ROUTING_PROFILE_KEY = "routing_profile";
|
||||||
|
public static final String ROUTE_SERVICE_KEY = "route_service";
|
||||||
|
public static final String LOC_ICON_KEY = "loc_icon";
|
||||||
|
public static final String NAV_ICON_KEY = "nav_icon";
|
||||||
|
public static final String ORDER_KEY = "order";
|
||||||
|
|
||||||
|
private String appModeKey;
|
||||||
|
private String userProfileName;
|
||||||
|
private String parent;
|
||||||
|
private String iconName;
|
||||||
|
private String iconColor;
|
||||||
|
private String routingProfile;
|
||||||
|
private String routeService;
|
||||||
|
private String locIcon;
|
||||||
|
private String navIcon;
|
||||||
|
private int order = -1;
|
||||||
|
|
||||||
|
public AProfile(String appModeKey, String userProfileName, String parent, String iconName, String iconColor,
|
||||||
|
String routingProfile, String routeService, String locIcon, String navIcon, int order) {
|
||||||
|
this.appModeKey = appModeKey;
|
||||||
|
this.userProfileName = userProfileName;
|
||||||
|
this.parent = parent;
|
||||||
|
this.iconName = iconName;
|
||||||
|
this.iconColor = iconColor;
|
||||||
|
this.routingProfile = routingProfile;
|
||||||
|
this.routeService = routeService;
|
||||||
|
this.locIcon = locIcon;
|
||||||
|
this.navIcon = navIcon;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AProfile(Parcel in) {
|
||||||
|
readFromParcel(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<AProfile> CREATOR = new Creator<AProfile>() {
|
||||||
|
@Override
|
||||||
|
public AProfile createFromParcel(Parcel in) {
|
||||||
|
return new AProfile(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AProfile[] newArray(int size) {
|
||||||
|
return new AProfile[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public String getStringKey() {
|
||||||
|
return appModeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserProfileName() {
|
||||||
|
return userProfileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIconName() {
|
||||||
|
return iconName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIconColor() {
|
||||||
|
return iconColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoutingProfile() {
|
||||||
|
return routingProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRouteService() {
|
||||||
|
return routeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocIcon() {
|
||||||
|
return locIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNavIcon() {
|
||||||
|
return navIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrder() {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToBundle(Bundle bundle) {
|
||||||
|
bundle.putString(PROFILE_ID_KEY, appModeKey);
|
||||||
|
bundle.putString(USER_PROFILE_NAME_KEY, userProfileName);
|
||||||
|
bundle.putString(PARENT_KEY, parent);
|
||||||
|
bundle.putString(ICON_NAME_KEY, iconName);
|
||||||
|
bundle.putString(ICON_COLOR_KEY, iconColor);
|
||||||
|
bundle.putString(ROUTING_PROFILE_KEY, routingProfile);
|
||||||
|
bundle.putString(ROUTE_SERVICE_KEY, routeService);
|
||||||
|
bundle.putString(LOC_ICON_KEY, locIcon);
|
||||||
|
bundle.putString(NAV_ICON_KEY, navIcon);
|
||||||
|
bundle.putInt(ORDER_KEY, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFromBundle(Bundle bundle) {
|
||||||
|
appModeKey = bundle.getString(PROFILE_ID_KEY);
|
||||||
|
userProfileName = bundle.getString(USER_PROFILE_NAME_KEY);
|
||||||
|
parent = bundle.getString(PARENT_KEY);
|
||||||
|
iconName = bundle.getString(ICON_NAME_KEY);
|
||||||
|
iconColor = bundle.getString(ICON_COLOR_KEY);
|
||||||
|
routingProfile = bundle.getString(ROUTING_PROFILE_KEY);
|
||||||
|
routeService = bundle.getString(ROUTE_SERVICE_KEY);
|
||||||
|
locIcon = bundle.getString(LOC_ICON_KEY);
|
||||||
|
navIcon = bundle.getString(NAV_ICON_KEY);
|
||||||
|
order = bundle.getInt(ORDER_KEY);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidlapi.customization;
|
||||||
|
|
||||||
|
parcelable SelectProfileParams;
|
|
@ -0,0 +1,47 @@
|
||||||
|
package net.osmand.aidlapi.customization;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcel;
|
||||||
|
|
||||||
|
import net.osmand.aidlapi.AidlParams;
|
||||||
|
|
||||||
|
public class SelectProfileParams extends AidlParams {
|
||||||
|
|
||||||
|
public static final String PROFILE_ID_KEY = "profile_id";
|
||||||
|
|
||||||
|
private String appModeKey;
|
||||||
|
|
||||||
|
public SelectProfileParams(String appModeKey) {
|
||||||
|
this.appModeKey = appModeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectProfileParams(Parcel in) {
|
||||||
|
readFromParcel(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<SelectProfileParams> CREATOR = new Creator<SelectProfileParams>() {
|
||||||
|
@Override
|
||||||
|
public SelectProfileParams createFromParcel(Parcel in) {
|
||||||
|
return new SelectProfileParams(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SelectProfileParams[] newArray(int size) {
|
||||||
|
return new SelectProfileParams[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public String getAppModeKey() {
|
||||||
|
return appModeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToBundle(Bundle bundle) {
|
||||||
|
bundle.putString(PROFILE_ID_KEY, appModeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFromBundle(Bundle bundle) {
|
||||||
|
appModeKey = bundle.getString(PROFILE_ID_KEY);
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,6 +40,7 @@ import net.osmand.aidl.navigation.ADirectionInfo;
|
||||||
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
|
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
|
||||||
import net.osmand.aidl.quickaction.QuickActionInfoParams;
|
import net.osmand.aidl.quickaction.QuickActionInfoParams;
|
||||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||||
|
import net.osmand.aidlapi.customization.AProfile;
|
||||||
import net.osmand.aidlapi.info.AppInfoParams;
|
import net.osmand.aidlapi.info.AppInfoParams;
|
||||||
import net.osmand.aidlapi.map.ALatLon;
|
import net.osmand.aidlapi.map.ALatLon;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
@ -79,6 +80,7 @@ import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.VoiceRouter;
|
import net.osmand.plus.routing.VoiceRouter;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
@ -2337,6 +2339,35 @@ public class OsmandAidlApi {
|
||||||
return CANNOT_ACCESS_API_ERROR;
|
return CANNOT_ACCESS_API_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean selectProfile(String appModeKey) {
|
||||||
|
final ApplicationMode appMode = ApplicationMode.valueOfStringKey(appModeKey, null);
|
||||||
|
if (appMode != null) {
|
||||||
|
app.runInUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!ApplicationMode.values(app).contains(appMode)) {
|
||||||
|
ApplicationMode.changeProfileAvailability(appMode, true, app);
|
||||||
|
}
|
||||||
|
app.getSettings().APPLICATION_MODE.set(appMode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getProfiles(List<AProfile> profiles) {
|
||||||
|
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||||
|
ApplicationModeBean bean = mode.toModeBean();
|
||||||
|
AProfile aProfile = new AProfile(bean.stringKey, bean.userProfileName, bean.parent, bean.iconName,
|
||||||
|
bean.iconColor.name(), bean.routingProfile, bean.routeService.name(), bean.locIcon.name(),
|
||||||
|
bean.navIcon.name(), bean.order);
|
||||||
|
|
||||||
|
profiles.add(aProfile);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static class FileCopyInfo {
|
private static class FileCopyInfo {
|
||||||
long startTime;
|
long startTime;
|
||||||
long lastAccessTime;
|
long lastAccessTime;
|
||||||
|
|
|
@ -22,12 +22,14 @@ import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams;
|
||||||
import net.osmand.aidlapi.contextmenu.RemoveContextMenuButtonsParams;
|
import net.osmand.aidlapi.contextmenu.RemoveContextMenuButtonsParams;
|
||||||
import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams;
|
import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams;
|
||||||
import net.osmand.aidlapi.copyfile.CopyFileParams;
|
import net.osmand.aidlapi.copyfile.CopyFileParams;
|
||||||
|
import net.osmand.aidlapi.customization.AProfile;
|
||||||
import net.osmand.aidlapi.customization.CustomPluginParams;
|
import net.osmand.aidlapi.customization.CustomPluginParams;
|
||||||
import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
||||||
import net.osmand.aidlapi.customization.MapMarginsParams;
|
import net.osmand.aidlapi.customization.MapMarginsParams;
|
||||||
import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
|
import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
|
||||||
import net.osmand.aidlapi.customization.OsmandSettingsParams;
|
import net.osmand.aidlapi.customization.OsmandSettingsParams;
|
||||||
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
||||||
|
import net.osmand.aidlapi.customization.SelectProfileParams;
|
||||||
import net.osmand.aidlapi.customization.SetWidgetsParams;
|
import net.osmand.aidlapi.customization.SetWidgetsParams;
|
||||||
import net.osmand.aidlapi.events.AKeyEventsParams;
|
import net.osmand.aidlapi.events.AKeyEventsParams;
|
||||||
import net.osmand.aidlapi.favorite.AFavorite;
|
import net.osmand.aidlapi.favorite.AFavorite;
|
||||||
|
@ -1372,6 +1374,28 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
||||||
}
|
}
|
||||||
return CANNOT_ACCESS_API_ERROR;
|
return CANNOT_ACCESS_API_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean selectProfile(SelectProfileParams params) {
|
||||||
|
try {
|
||||||
|
OsmandAidlApi api = getApi("selectProfile");
|
||||||
|
return api != null && api.selectProfile(params.getAppModeKey());
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getProfiles(List<AProfile> profiles) {
|
||||||
|
try {
|
||||||
|
OsmandAidlApi api = getApi("getProfiles");
|
||||||
|
return api != null && api.getProfiles(profiles);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||||
|
|
|
@ -786,6 +786,6 @@ public class ApplicationMode {
|
||||||
@Expose
|
@Expose
|
||||||
public NavigationIcon navIcon = null;
|
public NavigationIcon navIcon = null;
|
||||||
@Expose
|
@Expose
|
||||||
int order = -1;
|
public int order = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue