Home | History | Annotate | Download | only in activities
      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.activities;
     17 
     18 import android.os.Bundle;
     19 import android.support.v7.app.ActionBar;
     20 import android.support.v7.app.AppCompatActivity;
     21 import android.view.MenuItem;
     22 import android.webkit.WebView;
     23 
     24 import com.android.contacts.R;
     25 
     26 /**
     27  * Displays the licenses for all open source libraries.
     28  */
     29 public class LicenseActivity extends AppCompatActivity {
     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);
     39         final ActionBar actionBar = getSupportActionBar();
     40         if (actionBar != null) {
     41             actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
     42         }
     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 }
     60