blob: 9e86ee8e54a094c4bad8e3696ec76dfb66a8ca06 [file] [log] [blame]
Tingting Wang902e02a2015-11-05 15:17:22 -08001/*
2 * Copyright (C) 2015 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 */
16package com.android.contacts.common.activity;
17
18import com.android.contacts.common.R;
19
Wenyi Wangca4e1332016-11-17 15:22:32 -080020import android.support.v7.app.ActionBar;
21import android.support.v7.app.AppCompatActivity;
Tingting Wang902e02a2015-11-05 15:17:22 -080022import android.os.Bundle;
23import android.view.MenuItem;
24import android.webkit.WebView;
25
26/**
27 * Displays the licenses for all open source libraries.
28 */
Wenyi Wangca4e1332016-11-17 15:22:32 -080029public class LicenseActivity extends AppCompatActivity {
Tingting Wang902e02a2015-11-05 15:17:22 -080030 private static final String LICENSE_FILE = "file:///android_asset/licenses.html";
31 private WebView mWebView;
32
33 @Override
34 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState);
36 setContentView(R.layout.licenses);
37 mWebView = (WebView) findViewById(R.id.webview);
38 mWebView.loadUrl(LICENSE_FILE);
Wenyi Wangca4e1332016-11-17 15:22:32 -080039 final ActionBar actionBar = getSupportActionBar();
Wenyi Wangcc3016e2015-12-30 16:54:05 -080040 if (actionBar != null) {
41 actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
42 }
Tingting Wang902e02a2015-11-05 15:17:22 -080043 }
44
45 @Override
46 protected void onDestroy() {
47 mWebView.destroy();
48 super.onDestroy();
49 }
50
51 @Override
52 public boolean onOptionsItemSelected(MenuItem item) {
53 if (item.getItemId() == android.R.id.home) {
54 finish();
55 return true;
56 }
57 return super.onOptionsItemSelected(item);
58 }
59}