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

100 lines
2.9 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;
2021-01-29 14:51:28 +01:00
import java.util.List;
2020-10-01 14:57:45 +02:00
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";
2021-02-01 00:19:40 +01:00
public static final String SILENT_IMPORT_KEY = "silentImport";
2020-10-01 14:57:45 +02:00
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;
2021-01-29 14:51:28 +01:00
private List<String> settingsTypeKeyList = new ArrayList<>();
2021-01-28 14:11:24 +01:00
private boolean silent;
private boolean replace;
2019-11-29 16:43:50 +01:00
2021-01-29 14:51:28 +01:00
public ProfileSettingsParams(Uri profileSettingsUri, List<AExportSettingsType> settingsTypeList, boolean replace,
2021-01-28 14:11:24 +01:00
boolean silent, 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;
2021-01-28 14:11:24 +01:00
this.silent = silent;
2019-11-29 16:43:50 +01:00
}
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;
}
2021-01-29 14:51:28 +01:00
public List<String> getSettingsTypeKeys() {
2020-10-01 14:57:45 +02:00
return settingsTypeKeyList;
}
public boolean isReplace() {
return replace;
}
2021-01-28 14:11:24 +01:00
public boolean isSilent() {
return silent;
}
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);
2021-01-29 14:51:28 +01:00
bundle.putStringArrayList(SETTINGS_TYPE_KEY, new ArrayList<>(settingsTypeKeyList));
2020-10-01 14:57:45 +02:00
bundle.putBoolean(REPLACE_KEY, replace);
2021-01-28 14:11:24 +01:00
bundle.putBoolean(SILENT_IMPORT_KEY, silent);
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);
2021-01-28 14:11:24 +01:00
silent = bundle.getBoolean(SILENT_IMPORT_KEY);
2019-11-29 16:43:50 +01:00
}
}