本文整理汇总了Java中com.amazon.android.webkit.AmazonWebSettings类的典型用法代码示例。如果您正苦于以下问题:Java AmazonWebSettings类的具体用法?Java AmazonWebSettings怎么用?Java AmazonWebSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AmazonWebSettings类属于com.amazon.android.webkit包,在下文中一共展示了AmazonWebSettings类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildUserAgentString
import com.amazon.android.webkit.AmazonWebSettings; //导入依赖的package包/类
@Test
public void buildUserAgentString() {
// It's actually possible to get a normal webview instance with real settings and user
// agent string, which buildUserAgentString() can successfully operate on. However we can't
// easily test that the output is expected (without simply replicating what buildUserAgentString does),
// so instead we just use mocking to supply a fixed UA string - we then know exactly what
// the output String should look like:
AmazonWebSettings testSettings = mock(AmazonWebSettings.class);
when(testSettings.getUserAgentString()).thenReturn("Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
assertEquals("Mozilla/5.0 (Linux; Android " + Build.VERSION.RELEASE + ") AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 fakeappname/null",
WebViewProvider.buildUserAgentString(RuntimeEnvironment.application, testSettings, "fakeappname"));
}
示例2: create
import com.amazon.android.webkit.AmazonWebSettings; //导入依赖的package包/类
public static View create(Context context, AttributeSet attrs, AmazonWebKitFactory factory) {
final SystemWebView webkitView = new SystemWebView(context, attrs, factory);
final AmazonWebSettings settings = webkitView.getSettings();
setupView(webkitView);
configureDefaultSettings(context, settings);
applyAppSettings(context, settings);
return webkitView;
}
示例3: buildUserAgentString
import com.amazon.android.webkit.AmazonWebSettings; //导入依赖的package包/类
@VisibleForTesting static String buildUserAgentString(final Context context, final AmazonWebSettings settings, final String appName) {
final StringBuilder uaBuilder = new StringBuilder();
uaBuilder.append("Mozilla/5.0");
// WebView by default includes "; wv" as part of the platform string, but we're a full browser
// so we shouldn't include that.
// Most webview based browsers (and chrome), include the device name AND build ID, e.g.
// "Pixel XL Build/NOF26V", that seems unnecessary (and not great from a privacy perspective),
// so we skip that too.
uaBuilder.append(" (Linux; Android ").append(Build.VERSION.RELEASE).append(") ");
final String existingWebViewUA = settings.getUserAgentString();
final String appVersion;
try {
appVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
// This should be impossible - we should always be able to get information about ourselves:
throw new IllegalStateException("Unable find package details for Focus", e);
}
final String focusToken = appName + "/" + appVersion;
uaBuilder.append(getUABrowserString(existingWebViewUA, focusToken));
return uaBuilder.toString();
}
示例4: configureDefaultSettings
import com.amazon.android.webkit.AmazonWebSettings; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled") // We explicitly want to enable JavaScript
private static void configureDefaultSettings(Context context, AmazonWebSettings settings) {
settings.setJavaScriptEnabled(true);
// Needs to be enabled to display some HTML5 sites that use local storage
settings.setDomStorageEnabled(true);
// Enabling built in zooming shows the controls by default
settings.setBuiltInZoomControls(true);
// So we hide the controls after enabling zooming
settings.setDisplayZoomControls(false);
// To respect the html viewport:
settings.setLoadWithOverviewMode(true);
// Also increase text size to fill the viewport (this mirrors the behaviour of Firefox,
// Chrome does this in the current Chrome Dev, but not Chrome release).
// TODO TEXT_AUTOSIZING does not exist in AmazonWebSettings
//settings.setLayoutAlgorithm(AmazonWebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
// Disable access to arbitrary local files by webpages - assets can still be loaded
// via file:///android_asset/res, so at least error page images won't be blocked.
settings.setAllowFileAccess(false);
settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false);
final String appName = context.getResources().getString(R.string.useragent_appname);
settings.setUserAgentString(buildUserAgentString(context, settings, appName));
// Right now I do not know why we should allow loading content from a content provider
settings.setAllowContentAccess(false);
// The default for those settings should be "false" - But we want to be explicit.
settings.setAppCacheEnabled(false);
settings.setDatabaseEnabled(false);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
// We do not implement the callbacks - So let's disable it.
settings.setGeolocationEnabled(false);
// We do not want to save any data...
settings.setSaveFormData(false);
//noinspection deprecation - This method is deprecated but let's call it in case WebView implementations still obey it.
settings.setSavePassword(false);
}
示例5: applyAppSettings
import com.amazon.android.webkit.AmazonWebSettings; //导入依赖的package包/类
public static void applyAppSettings(Context context, AmazonWebSettings settings) {
// We could consider calling setLoadsImagesAutomatically() here too (This will block images not loaded over the network too)
settings.setBlockNetworkImage(Settings.getInstance(context).shouldBlockImages());
}
示例6: enableUniversalAccess
import com.amazon.android.webkit.AmazonWebSettings; //导入依赖的package包/类
static void enableUniversalAccess(AmazonWebSettings settings) {
settings.setAllowUniversalAccessFromFileURLs(true);
}
示例7: setMediaPlaybackRequiresUserGesture
import com.amazon.android.webkit.AmazonWebSettings; //导入依赖的package包/类
static void setMediaPlaybackRequiresUserGesture(AmazonWebSettings settings, boolean value) {
settings.setMediaPlaybackRequiresUserGesture(value);
}