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.
5 package org.xwalk.core;
7 import org.xwalk.core.internal.XWalkPreferencesInternal;
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.
15 public final class XWalkPreferences extends XWalkPreferencesInternal {
17 * The key string to enable/disable remote debugging.
20 public static final String REMOTE_DEBUGGING = "remote-debugging";
23 * The key string to enable/disable animatable XWalkView. Default value is
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.
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.
41 * Note this key MUST be set before creating the first XWalkView, otherwise
42 * a RuntimeException will be thrown.
45 public static final String ANIMATABLE_XWALK_VIEW = "animatable-xwalk-view";
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.
54 public static synchronized void setValue(String key, boolean enabled) throws RuntimeException {
55 XWalkPreferencesInternal.setValue(key, enabled);
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.
65 public static synchronized boolean getValue(String key) throws RuntimeException {
66 return XWalkPreferencesInternal.getValue(key);