Home | History | Annotate | Download | only in impl
      1 /*
      2  * Copyright 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 androidx.slice.builders.impl;
     18 
     19 import static android.app.slice.Slice.SUBTYPE_MESSAGE;
     20 
     21 import android.graphics.drawable.Icon;
     22 
     23 import androidx.annotation.RequiresApi;
     24 import androidx.annotation.RestrictTo;
     25 import androidx.core.graphics.drawable.IconCompat;
     26 import androidx.slice.Slice;
     27 import androidx.slice.SliceSpec;
     28 
     29 /**
     30  * @hide
     31  */
     32 @RestrictTo(RestrictTo.Scope.LIBRARY)
     33 public class MessagingV1Impl extends TemplateBuilderImpl implements MessagingBuilder {
     34 
     35     /**
     36      */
     37     public MessagingV1Impl(Slice.Builder b, SliceSpec spec) {
     38         super(b, spec);
     39     }
     40 
     41     /**
     42      */
     43     @Override
     44     public void add(TemplateBuilderImpl builder) {
     45         getBuilder().addSubSlice(builder.build(), SUBTYPE_MESSAGE);
     46     }
     47 
     48     /**
     49      */
     50     @Override
     51     public void apply(Slice.Builder builder) {
     52 
     53     }
     54 
     55     /**
     56      */
     57     @Override
     58     public TemplateBuilderImpl createMessageBuilder() {
     59         return new MessageBuilder(this);
     60     }
     61 
     62     /**
     63      */
     64     public static final class MessageBuilder extends TemplateBuilderImpl
     65             implements MessagingBuilder.MessageBuilder {
     66         /**
     67          */
     68         public MessageBuilder(MessagingV1Impl parent) {
     69             super(parent.createChildBuilder(), null);
     70         }
     71 
     72         /**
     73          */
     74         @Override
     75         @RequiresApi(23)
     76         public void addSource(Icon source) {
     77             getBuilder().addIcon(IconCompat.createFromIcon(source),
     78                     android.app.slice.Slice.SUBTYPE_SOURCE);
     79         }
     80 
     81         /**
     82          */
     83         @Override
     84         public void addText(CharSequence text) {
     85             getBuilder().addText(text, null);
     86         }
     87 
     88         /**
     89          */
     90         @Override
     91         public void addTimestamp(long timestamp) {
     92             getBuilder().addTimestamp(timestamp, null);
     93         }
     94 
     95         /**
     96          */
     97         @Override
     98         public void apply(Slice.Builder builder) {
     99         }
    100     }
    101 }
    102