1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.accessibility; 18 19 import android.content.Context; 20 21 import androidx.annotation.NonNull; 22 23 import java.util.List; 24 25 /** 26 * Abstract data class for storing and fetching the configurations related to the preview of the 27 * text and reading options. 28 */ 29 abstract class PreviewSizeData<T extends Number> { 30 private final Context mContext; 31 private int mInitialIndex; 32 private T mDefaultValue; 33 private List<T> mValues; 34 PreviewSizeData(@onNull Context context)35 PreviewSizeData(@NonNull Context context) { 36 mContext = context; 37 } 38 getContext()39 Context getContext() { 40 return mContext; 41 } 42 43 @NonNull getValues()44 public List<T> getValues() { 45 return mValues; 46 } 47 setValues(List<T> values)48 void setValues(List<T> values) { 49 mValues = values; 50 } 51 getDefaultValue()52 T getDefaultValue() { 53 return mDefaultValue; 54 } 55 setDefaultValue(T defaultValue)56 void setDefaultValue(T defaultValue) { 57 mDefaultValue = defaultValue; 58 } 59 getInitialIndex()60 public int getInitialIndex() { 61 return mInitialIndex; 62 } 63 setInitialIndex(int initialIndex)64 void setInitialIndex(int initialIndex) { 65 mInitialIndex = initialIndex; 66 } 67 68 /** 69 * Persists the selected size. 70 */ commit(int currentProgress)71 abstract void commit(int currentProgress); 72 } 73