Add getProfiles method to aidl

This commit is contained in:
Vitaliy 2020-12-11 10:28:00 +02:00
parent 946a60a668
commit f170bda509
6 changed files with 165 additions and 2 deletions

View file

@ -79,6 +79,7 @@ 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.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;
@ -889,4 +890,6 @@ interface IOsmAndAidlInterface {
int getPluginVersion(in CustomPluginParams params); int getPluginVersion(in CustomPluginParams params);
boolean selectProfile(in SelectProfileParams params); boolean selectProfile(in SelectProfileParams params);
boolean getProfiles(out List<AProfile> profiles);
} }

View file

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

View 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);
}
}

View file

@ -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;
@ -2340,13 +2342,27 @@ public class OsmandAidlApi {
public boolean selectProfile(String appModeKey) { public boolean selectProfile(String appModeKey) {
ApplicationMode appMode = ApplicationMode.valueOfStringKey(appModeKey, null); ApplicationMode appMode = ApplicationMode.valueOfStringKey(appModeKey, null);
if (appMode != null) { if (appMode != null) {
// ApplicationMode.changeProfileAvailability(appMode, true, app); if (!ApplicationMode.values(app).contains(appMode)) {
ApplicationMode.changeProfileAvailability(appMode, true, app);
}
app.getSettings().APPLICATION_MODE.set(appMode); app.getSettings().APPLICATION_MODE.set(appMode);
return true; return true;
} }
return false; 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;

View file

@ -22,6 +22,7 @@ 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;
@ -1384,6 +1385,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
return false; 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) {

View file

@ -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;
} }
} }