Add list-select as an inline result

Move the majority of the Setting set & get logic into
InlinePayload, but add formatting of input to each
concrete payload class.

Bug: 62022517
Test: make RunSettingsRoboTests
Change-Id: I08932871554beb4a04625f05f8555a5b3a887fe2
This commit is contained in:
Matthew Fritze
2017-06-23 10:05:07 -07:00
parent 63e36128e6
commit 694088075e
10 changed files with 387 additions and 165 deletions

View File

@@ -0,0 +1,62 @@
package com.android.settings.search;
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Payload for settings which are selected from multiple values. For example, Location can be
* set to multiple degrees of accuracy.
*/
public class InlineListPayload extends InlinePayload {
/**
* Number of selections in the list.
*/
private int mNumOptions;
public InlineListPayload(String key, @PayloadType int payloadType, Intent intent,
boolean isDeviceSupported, int numOptions) {
super(key, payloadType, intent, isDeviceSupported);
mNumOptions = numOptions;
}
private InlineListPayload(Parcel in) {
super(in);
mNumOptions = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(mNumOptions);
}
@Override
protected int standardizeInput(int input) throws IllegalArgumentException {
if (input < 0 || input >= mNumOptions) {
throw new IllegalArgumentException(
"Invalid argument for ListSelect. Expected between 0 and "
+ mNumOptions + " but found: " + input);
}
return input;
}
@Override
@PayloadType public int getType() {
return PayloadType.INLINE_LIST;
}
public static final Parcelable.Creator<InlineListPayload> CREATOR =
new Parcelable.Creator<InlineListPayload>() {
@Override
public InlineListPayload createFromParcel(Parcel in) {
return new InlineListPayload(in);
}
@Override
public InlineListPayload[] newArray(int size) {
return new InlineListPayload[size];
}
};
}