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 getValues()43 List<T> getValues() { 44 return mValues; 45 } 46 setValues(List<T> values)47 void setValues(List<T> values) { 48 mValues = values; 49 } 50 getDefaultValue()51 T getDefaultValue() { 52 return mDefaultValue; 53 } 54 setDefaultValue(T defaultValue)55 void setDefaultValue(T defaultValue) { 56 mDefaultValue = defaultValue; 57 } 58 getInitialIndex()59 int getInitialIndex() { 60 return mInitialIndex; 61 } 62 setInitialIndex(int initialIndex)63 void setInitialIndex(int initialIndex) { 64 mInitialIndex = initialIndex; 65 } 66 67 /** 68 * Persists the selected size. 69 */ commit(int currentProgress)70 abstract void commit(int currentProgress); 71 } 72