1 /*
2  * Copyright 2019 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 import android.widget.ListView;
24 
25 import androidx.appcompat.app.AppCompatActivity;
26 
27 import org.jspecify.annotations.Nullable;
28 
29 /**
30  * An {@link Activity} for exercising various WebView functionality. This Activity is a {@link
31  * ListView} which starts other Activities, each of which may similarly be a ListView, or may
32  * actually exercise specific {@link android.webkit.WebView} features.
33  */
34 public class AssetLoaderListActivity extends AppCompatActivity {
35 
36     @Override
onCreate(@ullable Bundle savedInstanceState)37     protected void onCreate(@Nullable Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39 
40         setContentView(R.layout.activity_asset_loader_list);
41         setTitle(R.string.asset_loader_list_activity_title);
42         WebkitHelpers.appendWebViewVersionToTitle(this);
43 
44         final Context activityContext = this;
45         MenuListView listView = findViewById(R.id.asset_loader_list);
46         MenuListView.MenuItem[] menuItems = new MenuListView.MenuItem[] {
47                 new MenuListView.MenuItem(
48                         getResources().getString(R.string.asset_loader_simple_activity_title),
49                         new Intent(activityContext, AssetLoaderSimpleActivity.class)),
50                 new MenuListView.MenuItem(
51                     getResources().getString(R.string.asset_loader_ajax_activity_title),
52                     new Intent(activityContext, AssetLoaderAjaxActivity.class)),
53                 new MenuListView.MenuItem(
54                     getResources().getString(R.string.asset_loader_internal_storage_activity_title),
55                     new Intent(activityContext, AssetLoaderInternalStorageActivity.class)),
56         };
57         listView.setItems(menuItems);
58     }
59 }
60