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 20 import android.app.ActionBar; 21 import android.app.Activity; 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 */ 29 public class LicenseActivity extends Activity { 30 private static final String LICENSE_FILE = "file:///android_asset/licenses.html"; 31 private WebView mWebView; 32 33 @Override onCreate(Bundle savedInstanceState)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); 39 final ActionBar actionBar = getActionBar(); 40 if (actionBar != null) { 41 actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); 42 } 43 } 44 45 @Override onDestroy()46 protected void onDestroy() { 47 mWebView.destroy(); 48 super.onDestroy(); 49 } 50 51 @Override onOptionsItemSelected(MenuItem item)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 } 60