package net.osmand.aidlapi.customization; import android.os.Bundle; import android.os.Parcel; import net.osmand.aidlapi.AidlParams; import net.osmand.aidlapi.navdrawer.NavDrawerFooterParams; import net.osmand.aidlapi.navdrawer.NavDrawerHeaderParams; import net.osmand.aidlapi.navdrawer.SetNavDrawerItemsParams; import net.osmand.aidlapi.plugins.PluginParams; import java.util.ArrayList; import java.util.List; public class CustomizationInfoParams extends AidlParams { private OsmandSettingsParams settingsParams; private NavDrawerHeaderParams navDrawerHeaderParams; private NavDrawerFooterParams navDrawerFooterParams; private SetNavDrawerItemsParams navDrawerItemsParams; private ArrayList visibilityWidgetsParams = new ArrayList<>(); private ArrayList availabilityWidgetsParams = new ArrayList<>(); private ArrayList pluginsParams = new ArrayList<>(); private ArrayList featuresEnabledIds = new ArrayList<>(); private ArrayList featuresDisabledIds = new ArrayList<>(); private ArrayList featuresEnabledPatterns = new ArrayList<>(); private ArrayList featuresDisabledPatterns = new ArrayList<>(); public CustomizationInfoParams(OsmandSettingsParams settingsParams, NavDrawerHeaderParams navDrawerHeaderParams, NavDrawerFooterParams navDrawerFooterParams, SetNavDrawerItemsParams navDrawerItemsParams, ArrayList visibilityWidgetsParams, ArrayList availabilityWidgetsParams, ArrayList pluginsParams, List featuresEnabledIds, List featuresDisabledIds, List featuresEnabledPatterns, List featuresDisabledPatterns) { this.settingsParams = settingsParams; this.navDrawerHeaderParams = navDrawerHeaderParams; this.navDrawerFooterParams = navDrawerFooterParams; this.navDrawerItemsParams = navDrawerItemsParams; if (visibilityWidgetsParams != null) { this.visibilityWidgetsParams.addAll(visibilityWidgetsParams); } if (availabilityWidgetsParams != null) { this.availabilityWidgetsParams.addAll(availabilityWidgetsParams); } if (pluginsParams != null) { this.pluginsParams.addAll(pluginsParams); } if (featuresEnabledIds != null) { this.featuresEnabledIds.addAll(featuresEnabledIds); } if (featuresDisabledIds != null) { this.featuresDisabledIds.addAll(featuresDisabledIds); } if (featuresEnabledPatterns != null) { this.featuresEnabledPatterns.addAll(featuresEnabledPatterns); } if (featuresDisabledPatterns != null) { this.featuresDisabledPatterns.addAll(featuresDisabledPatterns); } } public CustomizationInfoParams(Parcel in) { readFromParcel(in); } public static final Creator CREATOR = new Creator() { @Override public CustomizationInfoParams createFromParcel(Parcel in) { return new CustomizationInfoParams(in); } @Override public CustomizationInfoParams[] newArray(int size) { return new CustomizationInfoParams[size]; } }; public OsmandSettingsParams getSettingsParams() { return settingsParams; } public NavDrawerHeaderParams getNavDrawerHeaderParams() { return navDrawerHeaderParams; } public NavDrawerFooterParams getNavDrawerFooterParams() { return navDrawerFooterParams; } public SetNavDrawerItemsParams getNavDrawerItemsParams() { return navDrawerItemsParams; } public ArrayList getVisibilityWidgetsParams() { return visibilityWidgetsParams; } public ArrayList getAvailabilityWidgetsParams() { return availabilityWidgetsParams; } public ArrayList getPluginsParams() { return pluginsParams; } public List getFeaturesEnabledIds() { return featuresEnabledIds; } public List getFeaturesDisabledIds() { return featuresDisabledIds; } public List getFeaturesEnabledPatterns() { return featuresEnabledPatterns; } public List getFeaturesDisabledPatterns() { return featuresDisabledPatterns; } @Override public void writeToBundle(Bundle bundle) { bundle.putParcelable("settingsParams", settingsParams); bundle.putParcelable("navDrawerHeaderParams", navDrawerHeaderParams); bundle.putParcelable("navDrawerFooterParams", navDrawerFooterParams); bundle.putParcelable("navDrawerItemsParams", navDrawerItemsParams); bundle.putParcelableArrayList("visibilityWidgetsParams", visibilityWidgetsParams); bundle.putParcelableArrayList("availabilityWidgetsParams", availabilityWidgetsParams); bundle.putParcelableArrayList("pluginsParams", pluginsParams); bundle.putStringArrayList("featuresEnabledIds", featuresEnabledIds); bundle.putStringArrayList("featuresDisabledIds", featuresDisabledIds); bundle.putStringArrayList("featuresEnabledPatterns", featuresEnabledPatterns); bundle.putStringArrayList("featuresDisabledPatterns", featuresDisabledPatterns); } @Override protected void readFromBundle(Bundle bundle) { bundle.setClassLoader(OsmandSettingsParams.class.getClassLoader()); settingsParams = bundle.getParcelable("settingsParams"); bundle.setClassLoader(NavDrawerHeaderParams.class.getClassLoader()); navDrawerHeaderParams = bundle.getParcelable("navDrawerHeaderParams"); bundle.setClassLoader(NavDrawerFooterParams.class.getClassLoader()); navDrawerFooterParams = bundle.getParcelable("navDrawerFooterParams"); bundle.setClassLoader(SetNavDrawerItemsParams.class.getClassLoader()); navDrawerItemsParams = bundle.getParcelable("navDrawerItemsParams"); bundle.setClassLoader(SetWidgetsParams.class.getClassLoader()); visibilityWidgetsParams = bundle.getParcelableArrayList("visibilityWidgetsParams"); availabilityWidgetsParams = bundle.getParcelableArrayList("availabilityWidgetsParams"); bundle.setClassLoader(PluginParams.class.getClassLoader()); pluginsParams = bundle.getParcelableArrayList("pluginsParams"); featuresEnabledIds = bundle.getStringArrayList("featuresEnabledIds"); featuresDisabledIds = bundle.getStringArrayList("featuresDisabledIds"); featuresEnabledPatterns = bundle.getStringArrayList("featuresEnabledPatterns"); featuresDisabledPatterns = bundle.getStringArrayList("featuresDisabledPatterns"); } }