Upstream version 8.36.161.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core / src / org / xwalk / core / XWalkPreferences.java
1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.xwalk.core;
6
7 import org.xwalk.core.internal.XWalkPreferencesInternal;
8
9 /**
10  * This class represents the preferences and could be set by callers.
11  * It is not thread-safe and must be called on the UI thread.
12  * Afterwards, the preference could be read from all threads and can impact
13  * all XWalkView instances.
14  */
15 public final class XWalkPreferences extends XWalkPreferencesInternal {
16     /**
17      * The key string to enable/disable remote debugging.
18      * @since 1.0
19      */
20     public static final String REMOTE_DEBUGGING = "remote-debugging";
21
22     /**
23      * The key string to enable/disable animatable XWalkView. Default value is
24      * false.
25      *
26      * If this key is set to True, the XWalkView created by Crosswalk can be
27      * transformed and animated. Internally, Crosswalk is alternatively using
28      * TextureView as the backend of XWalkView.
29      *
30      * <a href="http://developer.android.com/reference/android/view/TextureView.html">
31      * TextureView</a> is a kind of
32      * <a href="http://developer.android.com/reference/android/view/View.html">
33      * android.view.View</a> that is different from
34      * <a href="http://developer.android.com/reference/android/view/SurfaceView.html">
35      * SurfaceView</a>. Unlike SurfaceView, it can be resized, transformed and
36      * animated. Once this key is set to True, all XWalkView will use TextureView
37      * as the rendering target instead of SurfaceView. The downside of TextureView
38      * is, it would consume more graphics memory than SurfaceView and may have
39      * 1~3 extra frames of latency to display updates.
40      *
41      * Note this key MUST be set before creating the first XWalkView, otherwise
42      * a RuntimeException will be thrown.
43      * @since 2.0
44      */
45     public static final String ANIMATABLE_XWALK_VIEW = "animatable-xwalk-view";
46
47     /**
48      * Set a preference value into Crosswalk. An exception will be thrown if
49      * the key for the preference is not valid.
50      * @param key the string name of the key.
51      * @param enabled true if setting it as enabled.
52      * @since 1.0
53      */
54     public static synchronized void setValue(String key, boolean enabled) throws RuntimeException {
55         XWalkPreferencesInternal.setValue(key, enabled);
56     }
57
58     /**
59      * Get a preference value from Crosswalk. An exception will be thrown if
60      * the key for the preference is not valid.
61      * @param key the string name of the key.
62      * @return true if it's enabled.
63      * @since 1.0
64      */
65     public static synchronized boolean getValue(String key) throws RuntimeException {
66         return XWalkPreferencesInternal.getValue(key);
67     }
68 }