1 /* 2 * Copyright (C) 2023 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.devicelockcontroller.activities; 18 19 import androidx.annotation.IntDef; 20 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 import java.util.Objects; 24 25 /** 26 * A data model class which is used to hold the data needed to render the RecyclerView. 27 */ 28 public final class ProvisionInfo { 29 @Retention(RetentionPolicy.SOURCE) 30 @IntDef(value = {ProvisionInfoType.REGULAR, ProvisionInfoType.TERMS_AND_CONDITIONS, 31 ProvisionInfoType.SUPPORT}) 32 public @interface ProvisionInfoType { 33 // The general type of provision info without any link 34 int REGULAR = 0; 35 // The type of provision info with a link for terms and conditions. 36 int TERMS_AND_CONDITIONS = 1; 37 // The type of provision info with a link for custom support. 38 int SUPPORT = 2; 39 } 40 41 @ProvisionInfoType 42 private final int mType; 43 private final int mDrawableId; 44 private final int mTextId; 45 46 private String mProviderName; 47 private String mUrl; 48 ProvisionInfo(int drawableId, int textId, @ProvisionInfoType int type)49 public ProvisionInfo(int drawableId, int textId, @ProvisionInfoType int type) { 50 mDrawableId = drawableId; 51 mTextId = textId; 52 mType = type; 53 } 54 getDrawableId()55 public int getDrawableId() { 56 return mDrawableId; 57 } 58 getTextId()59 public int getTextId() { 60 return mTextId; 61 } 62 63 @ProvisionInfoType getType()64 public int getType() { 65 return mType; 66 } 67 getProviderName()68 public String getProviderName() { 69 return mProviderName; 70 } 71 setProviderName(String providerName)72 public void setProviderName(String providerName) { 73 mProviderName = providerName; 74 } 75 getUrl()76 public String getUrl() { 77 return mUrl; 78 } 79 setUrl(String url)80 public void setUrl(String url) { 81 mUrl = url; 82 } 83 84 @Override equals(Object obj)85 public boolean equals(Object obj) { 86 if (this == obj) { 87 return true; 88 } 89 if (!(obj instanceof ProvisionInfo that)) { 90 return false; 91 } 92 return this.mDrawableId == that.mDrawableId && this.mTextId == that.mTextId 93 && this.mType == that.mType; 94 } 95 96 @Override hashCode()97 public int hashCode() { 98 return Objects.hash(mDrawableId, mTextId, mType); 99 } 100 } 101