1 /* 2 * Copyright 2018 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.example.androidx.webkit; 18 19 import android.app.Activity; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.os.Bundle; 23 24 import androidx.appcompat.app.AppCompatActivity; 25 26 import org.jspecify.annotations.Nullable; 27 28 /** 29 * An {@link Activity} to exercise Safe Browsing functionality. 30 */ 31 public class SafeBrowsingActivity extends AppCompatActivity { 32 @Override onCreate(@ullable Bundle savedInstanceState)33 protected void onCreate(@Nullable Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 setupLayout(); 36 } 37 setupLayout()38 private void setupLayout() { 39 setContentView(R.layout.activity_safe_browsing); 40 setTitle(R.string.safebrowsing_activity_title); 41 WebkitHelpers.appendWebViewVersionToTitle(this); 42 43 final Context activityContext = this; 44 MenuListView listView = findViewById(R.id.safe_browsing_list); 45 MenuListView.MenuItem[] menuItems = new MenuListView.MenuItem[] { 46 new MenuListView.MenuItem( 47 getResources().getString(R.string.small_interstitial_activity_title), 48 new Intent(activityContext, SmallInterstitialActivity.class) 49 .putExtra(SmallInterstitialActivity.CONTENT_TYPE, 50 ContentType.MALICIOUS_CONTENT)), 51 new MenuListView.MenuItem( 52 getResources().getString(R.string.medium_wide_interstitial_activity_title), 53 new Intent(activityContext, MediumInterstitialActivity.class) 54 .putExtra(MediumInterstitialActivity.LAYOUT_HORIZONTAL, false)), 55 new MenuListView.MenuItem( 56 getResources().getString(R.string.medium_tall_interstitial_activity_title), 57 new Intent(activityContext, MediumInterstitialActivity.class) 58 .putExtra(MediumInterstitialActivity.LAYOUT_HORIZONTAL, true)), 59 new MenuListView.MenuItem( 60 getResources().getString(R.string.loud_interstitial_activity_title), 61 new Intent(activityContext, FullPageInterstitialActivity.class) 62 .putExtra(FullPageInterstitialActivity.CONTENT_TYPE, 63 ContentType.MALICIOUS_CONTENT)), 64 new MenuListView.MenuItem( 65 getResources().getString(R.string.giant_interstitial_activity_title), 66 new Intent(activityContext, GiantInterstitialActivity.class)), 67 new MenuListView.MenuItem( 68 getResources().getString(R.string.per_web_view_enable_activity_title), 69 new Intent(activityContext, PerWebViewEnableActivity.class)), 70 new MenuListView.MenuItem( 71 getResources().getString(R.string.invisible_activity_title), 72 new Intent(activityContext, InvisibleActivity.class)), 73 new MenuListView.MenuItem( 74 getResources().getString(R.string.unattached_activity_title), 75 new Intent(activityContext, UnattachedActivity.class)), 76 new MenuListView.MenuItem( 77 getResources().getString(R.string.custom_interstitial_activity_title), 78 new Intent(activityContext, CustomInterstitialActivity.class)), 79 new MenuListView.MenuItem( 80 getResources().getString(R.string.allowlist_activity_title), 81 new Intent(activityContext, AllowlistActivity.class)), 82 }; 83 listView.setItems(menuItems); 84 } 85 } 86