1 /* 2 * Copyright (C) 2018 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.homepage.contextualcards.legacysuggestion; 18 19 import android.app.PendingIntent; 20 import android.service.settings.suggestions.Suggestion; 21 22 import com.android.settings.homepage.contextualcards.ContextualCard; 23 24 public class LegacySuggestionContextualCard extends ContextualCard { 25 26 private final PendingIntent mPendingIntent; 27 private final Suggestion mSuggestion; 28 LegacySuggestionContextualCard(Builder builder)29 public LegacySuggestionContextualCard(Builder builder) { 30 super(builder); 31 mPendingIntent = builder.mPendingIntent; 32 mSuggestion = builder.mSuggestion; 33 } 34 35 @Override getCardType()36 public int getCardType() { 37 return CardType.LEGACY_SUGGESTION; 38 } 39 getPendingIntent()40 public PendingIntent getPendingIntent() { 41 return mPendingIntent; 42 } 43 getSuggestion()44 public Suggestion getSuggestion() { 45 return mSuggestion; 46 } 47 48 public static class Builder extends ContextualCard.Builder { 49 50 private PendingIntent mPendingIntent; 51 private Suggestion mSuggestion; 52 setPendingIntent(PendingIntent pendingIntent)53 public Builder setPendingIntent(PendingIntent pendingIntent) { 54 mPendingIntent = pendingIntent; 55 return this; 56 } 57 setSuggestion(Suggestion suggestion)58 public Builder setSuggestion(Suggestion suggestion) { 59 mSuggestion = suggestion; 60 return this; 61 } 62 63 @Override setCardType(int cardType)64 public Builder setCardType(int cardType) { 65 throw new IllegalArgumentException( 66 "Cannot change card type for " + getClass().getName()); 67 } 68 build()69 public LegacySuggestionContextualCard build() { 70 return new LegacySuggestionContextualCard(this); 71 } 72 } 73 74 } 75