1 /*
2  * Copyright (C) 2014 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.layoutlib.bridge.android;
18 
19 import com.android.ide.common.rendering.api.IImageFactory;
20 import com.android.ide.common.rendering.api.LayoutlibCallback;
21 import com.android.ide.common.rendering.api.RenderParams;
22 import com.android.ide.common.rendering.api.SessionParams.Key;
23 
24 /**
25  * This contains all known keys for the {@link RenderParams#getFlag(Key)}.
26  * <p/>
27  * The IDE has its own copy of this class which may be newer or older than this one.
28  * <p/>
29  * Constants should never be modified or removed from this class.
30  */
31 public final class RenderParamsFlags {
32 
33     public static final Key<String> FLAG_KEY_ROOT_TAG =
34             new Key<String>("rootTag", String.class);
35     public static final Key<Boolean> FLAG_KEY_DISABLE_BITMAP_CACHING =
36             new Key<Boolean>("disableBitmapCaching", Boolean.class);
37     public static final Key<Boolean> FLAG_KEY_RENDER_ALL_DRAWABLE_STATES =
38             new Key<Boolean>("renderAllDrawableStates", Boolean.class);
39     /**
40      * To tell LayoutLib that the IDE supports RecyclerView.
41      * <p/>
42      * Default is false.
43      */
44     public static final Key<Boolean> FLAG_KEY_RECYCLER_VIEW_SUPPORT =
45             new Key<Boolean>("recyclerViewSupport", Boolean.class);
46     /**
47      * The application package name. Used via {@link LayoutlibCallback#getFlag(Key)}
48      */
49     public static final Key<String> FLAG_KEY_APPLICATION_PACKAGE =
50             new Key<String>("applicationPackage", String.class);
51     /**
52      * To tell LayoutLib that IDE supports providing XML Parser for a file (useful for getting in
53      * memory contents of the file). Used via {@link LayoutlibCallback#getFlag(Key)}
54      */
55     public static final Key<Boolean> FLAG_KEY_XML_FILE_PARSER_SUPPORT =
56             new Key<Boolean>("xmlFileParser", Boolean.class);
57     /**
58      * To tell LayoutLib to not render when creating a new session. This allows controlling when the first
59      * layout rendering will happen.
60      */
61     public static final Key<Boolean> FLAG_DO_NOT_RENDER_ON_CREATE =
62             new Key<Boolean>("doNotRenderOnCreate", Boolean.class);
63     /**
64      * The adaptive icon mask path. Used via {@link LayoutlibCallback#getFlag(Key)}
65      */
66     public static final Key<String> FLAG_KEY_ADAPTIVE_ICON_MASK_PATH =
67             new Key<>("adaptiveIconMaskPath", String.class);
68 
69     /**
70      * When enabled, Layoutlib will resize the output image to whatever size
71      * is returned by {@link IImageFactory#getImage(int, int)}. The default
72      * behaviour when this is false is to crop the image to the size of the image
73      * returned by {@link IImageFactory#getImage(int, int)}.
74      */
75     public static final Key<Boolean> FLAG_KEY_RESULT_IMAGE_AUTO_SCALE =
76             new Key<Boolean>("enableResultImageAutoScale", Boolean.class);
77 
78     /**
79      * Enables Ray Traced shadows in layoutlib.
80      */
81     public static final Key<Boolean> FLAG_RENDER_HIGH_QUALITY_SHADOW =
82             new Key<>("renderHighQualityShadow", Boolean.class);
83 
84     /**
85      * Flags to enable shadows in layoutlib.
86      */
87     public static final Key<Boolean> FLAG_ENABLE_SHADOW =
88             new Key<>("enableShadow", Boolean.class);
89 
90     // Disallow instances.
RenderParamsFlags()91     private RenderParamsFlags() {}
92 }
93