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.RenderParams;
21 import com.android.ide.common.rendering.api.SessionParams.Key;
22 
23 /**
24  * This contains all known keys for the {@link RenderParams#getFlag(Key)}.
25  * <p/>
26  * The IDE has its own copy of this class which may be newer or older than this one.
27  * <p/>
28  * Constants should never be modified or removed from this class.
29  */
30 public final class RenderParamsFlags {
31 
32     public static final Key<String> FLAG_KEY_ROOT_TAG =
33             new Key<String>("rootTag", String.class);
34     public static final Key<Boolean> FLAG_KEY_DISABLE_BITMAP_CACHING =
35             new Key<Boolean>("disableBitmapCaching", Boolean.class);
36     public static final Key<Boolean> FLAG_KEY_RENDER_ALL_DRAWABLE_STATES =
37             new Key<Boolean>("renderAllDrawableStates", Boolean.class);
38 
39     /**
40      * To tell LayoutLib to not render when creating a new session. This allows controlling when the first
41      * layout rendering will happen.
42      */
43     public static final Key<Boolean> FLAG_DO_NOT_RENDER_ON_CREATE =
44             new Key<Boolean>("doNotRenderOnCreate", Boolean.class);
45     /**
46      * To tell Layoutlib which path to use for the adaptive icon mask.
47      */
48     public static final Key<String> FLAG_KEY_ADAPTIVE_ICON_MASK_PATH =
49             new Key<>("adaptiveIconMaskPath", String.class);
50 
51     /**
52      * When enabled, Layoutlib will resize the output image to whatever size
53      * is returned by {@link IImageFactory#getImage(int, int)}. The default
54      * behaviour when this is false is to crop the image to the size of the image
55      * returned by {@link IImageFactory#getImage(int, int)}.
56      */
57     public static final Key<Boolean> FLAG_KEY_RESULT_IMAGE_AUTO_SCALE =
58             new Key<Boolean>("enableResultImageAutoScale", Boolean.class);
59 
60     /**
61      * Enables layout validation calls within rendering.
62      */
63     public static final Key<Boolean> FLAG_ENABLE_LAYOUT_VALIDATOR =
64             new Key<>("enableLayoutValidator", Boolean.class);
65 
66     /**
67      * Enables image-related validation checks within layout validation.
68      * {@link #FLAG_ENABLE_LAYOUT_VALIDATOR} must be enabled before this can be effective.
69      */
70     public static final Key<Boolean> FLAG_ENABLE_LAYOUT_VALIDATOR_IMAGE_CHECK =
71             new Key<>("enableLayoutValidatorImageCheck", Boolean.class);
72 
73     /**
74      * To tell Layoutlib the path of the image resource of the wallpaper to use for dynamic theming.
75      * If null, use default system colors.
76      */
77     public static final Key<String> FLAG_KEY_WALLPAPER_PATH =
78             new Key<>("wallpaperPath", String.class);
79 
80     /**
81      * To tell Layoutlib to use the themed version of adaptive icons.
82      */
83     public static final Key<Boolean> FLAG_KEY_USE_THEMED_ICON =
84             new Key<>("useThemedIcon", Boolean.class);
85 
86     /**
87      * To tell Layoutlib to the gesture navigation, instead of a button navigation bar.
88      */
89     public static final Key<Boolean> FLAG_KEY_USE_GESTURE_NAV =
90             new Key<>("useGestureNav", Boolean.class);
91 
92     // Disallow instances.
RenderParamsFlags()93     private RenderParamsFlags() {}
94 }
95