Tingting Wang | 902e02a | 2015-11-05 15:17:22 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package com.android.contacts.common.activity; |
| 17 | |
| 18 | import com.android.contacts.common.R; |
| 19 | |
Wenyi Wang | ca4e133 | 2016-11-17 15:22:32 -0800 | [diff] [blame] | 20 | import android.support.v7.app.ActionBar; |
| 21 | import android.support.v7.app.AppCompatActivity; |
Tingting Wang | 902e02a | 2015-11-05 15:17:22 -0800 | [diff] [blame] | 22 | import android.os.Bundle; |
| 23 | import android.view.MenuItem; |
| 24 | import android.webkit.WebView; |
| 25 | |
| 26 | /** |
| 27 | * Displays the licenses for all open source libraries. |
| 28 | */ |
Wenyi Wang | ca4e133 | 2016-11-17 15:22:32 -0800 | [diff] [blame] | 29 | public class LicenseActivity extends AppCompatActivity { |
Tingting Wang | 902e02a | 2015-11-05 15:17:22 -0800 | [diff] [blame] | 30 | 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 Wang | ca4e133 | 2016-11-17 15:22:32 -0800 | [diff] [blame] | 39 | final ActionBar actionBar = getSupportActionBar(); |
Wenyi Wang | cc3016e | 2015-12-30 16:54:05 -0800 | [diff] [blame] | 40 | if (actionBar != null) { |
| 41 | actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); |
| 42 | } |
Tingting Wang | 902e02a | 2015-11-05 15:17:22 -0800 | [diff] [blame] | 43 | } |
| 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 | } |