| 54 | import java.util.Locale; |
| 55 | |
| 56 | public class ActivityAMP extends ActivityBase { |
| 57 | private WebView wvAmp; |
| 58 | private ContentLoadingProgressBar pbWait; |
| 59 | private Group grpReady; |
| 60 | |
| 61 | private boolean force_light = false; |
| 62 | |
| 63 | private static final List<String> ALLOWED_SCRIPT_HOSTS = Collections.unmodifiableList(Arrays.asList( |
| 64 | "cdn.ampproject.org" |
| 65 | )); |
| 66 | |
| 67 | @Override |
| 68 | protected void onCreate(Bundle savedInstanceState) { |
| 69 | super.onCreate(savedInstanceState); |
| 70 | |
| 71 | if (savedInstanceState != null) |
| 72 | force_light = savedInstanceState.getBoolean("fair:force_light"); |
| 73 | |
| 74 | View view = LayoutInflater.from(this).inflate(R.layout.activity_amp, null); |
| 75 | setContentView(view); |
| 76 | |
| 77 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
| 78 | |
| 79 | wvAmp = findViewById(R.id.wvAmp); |
| 80 | pbWait = findViewById(R.id.pbWait); |
| 81 | grpReady = findViewById(R.id.grpReady); |
| 82 | |
| 83 | wvAmp.clearCache(true); |
| 84 | |
| 85 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
| 86 | boolean overview_mode = prefs.getBoolean("overview_mode", false); |
| 87 | boolean safe_browsing = prefs.getBoolean("safe_browsing", false); |
| 88 | |
| 89 | WebSettings settings = wvAmp.getSettings(); |
| 90 | settings.setUserAgentString(WebViewEx.getUserAgent(this, wvAmp)); |
| 91 | settings.setUseWideViewPort(true); |
| 92 | settings.setLoadWithOverviewMode(overview_mode); |
| 93 | |
| 94 | settings.setBuiltInZoomControls(true); |
| 95 | settings.setDisplayZoomControls(false); |
| 96 | |
| 97 | settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING); |
| 98 | |
| 99 | settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); |
| 100 | settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); |
| 101 | |
| 102 | if (WebViewEx.isFeatureSupported(this, WebViewFeature.SAFE_BROWSING_ENABLE)) |
| 103 | WebSettingsCompat.setSafeBrowsingEnabled(settings, safe_browsing); |
| 104 | if (WebViewEx.isFeatureSupported(this, WebViewFeature.ATTRIBUTION_REGISTRATION_BEHAVIOR)) |
| 105 | WebSettingsCompat.setAttributionRegistrationBehavior(settings, WebSettingsCompat.ATTRIBUTION_BEHAVIOR_DISABLED); |
| 106 | |
| 107 | setDarkMode(); |
| 108 | |
| 109 | settings.setLoadsImagesAutomatically(true); |
| 110 | settings.setBlockNetworkLoads(false); |
| 111 | settings.setBlockNetworkImage(false); |
| 112 | settings.setAllowFileAccess(false); |
| 113 | settings.setJavaScriptEnabled(true); |
nothing calls this directly
no outgoing calls
no test coverage detected