OsmAnd/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java

90 lines
2.6 KiB
Java
Raw Normal View History

2019-11-29 16:43:50 +01:00
package net.osmand.aidlapi.customization;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import net.osmand.aidlapi.AidlParams;
2020-10-06 13:04:48 +02:00
import net.osmand.aidlapi.profile.AExportSettingsType;
2020-10-01 14:57:45 +02:00
import java.util.ArrayList;
import static net.osmand.aidlapi.profile.ExportProfileParams.SETTINGS_TYPE_KEY;
2019-11-29 16:43:50 +01:00
public class ProfileSettingsParams extends AidlParams {
2020-10-01 14:57:45 +02:00
public static final String VERSION_KEY = "version";
public static final String REPLACE_KEY = "replace";
public static final String LATEST_CHANGES_KEY = "latestChanges";
public static final String PROFILE_SETTINGS_URI_KEY = "profileSettingsUri";
2019-11-29 16:43:50 +01:00
private Uri profileSettingsUri;
private String latestChanges;
private int version;
2020-10-06 13:04:48 +02:00
private ArrayList<String> settingsTypeKeyList = new ArrayList<>();
2020-10-01 14:57:45 +02:00
boolean replace;
2019-11-29 16:43:50 +01:00
2020-10-06 13:04:48 +02:00
public ProfileSettingsParams(Uri profileSettingsUri, ArrayList<AExportSettingsType> settingsTypeList, boolean replace,
2020-10-01 14:57:45 +02:00
String latestChanges, int version) {
2019-11-29 16:43:50 +01:00
this.profileSettingsUri = profileSettingsUri;
2020-10-06 13:04:48 +02:00
for (AExportSettingsType settingsType : settingsTypeList) {
2020-10-01 14:57:45 +02:00
settingsTypeKeyList.add(settingsType.name());
}
this.replace = replace;
2019-11-29 16:43:50 +01:00
this.latestChanges = latestChanges;
this.version = version;
}
public ProfileSettingsParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<ProfileSettingsParams> CREATOR = new Creator<ProfileSettingsParams>() {
@Override
public ProfileSettingsParams createFromParcel(Parcel in) {
return new ProfileSettingsParams(in);
}
@Override
public ProfileSettingsParams[] newArray(int size) {
return new ProfileSettingsParams[size];
}
};
public int getVersion() {
return version;
}
public String getLatestChanges() {
return latestChanges;
}
public Uri getProfileSettingsUri() {
return profileSettingsUri;
}
2020-10-01 14:57:45 +02:00
public ArrayList<String> getSettingsTypeKeys() {
return settingsTypeKeyList;
}
public boolean isReplace() {
return replace;
}
2019-11-29 16:43:50 +01:00
@Override
public void writeToBundle(Bundle bundle) {
2020-10-01 14:57:45 +02:00
bundle.putInt(VERSION_KEY, version);
bundle.putString(LATEST_CHANGES_KEY, latestChanges);
bundle.putParcelable(PROFILE_SETTINGS_URI_KEY, profileSettingsUri);
bundle.putStringArrayList(SETTINGS_TYPE_KEY, settingsTypeKeyList);
bundle.putBoolean(REPLACE_KEY, replace);
2019-11-29 16:43:50 +01:00
}
@Override
protected void readFromBundle(Bundle bundle) {
2020-10-01 14:57:45 +02:00
version = bundle.getInt(VERSION_KEY);
latestChanges = bundle.getString(LATEST_CHANGES_KEY);
profileSettingsUri = bundle.getParcelable(PROFILE_SETTINGS_URI_KEY);
settingsTypeKeyList = bundle.getStringArrayList(SETTINGS_TYPE_KEY);
replace = bundle.getBoolean(REPLACE_KEY);
2019-11-29 16:43:50 +01:00
}
}