2 * Copyright 2008 ZXing authors
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.google.zxing.client.android;
19 import android.app.Activity;
20 import android.os.Bundle;
21 import android.view.View;
22 import android.view.KeyEvent;
23 import android.webkit.WebView;
24 import android.webkit.WebViewClient;
25 import android.widget.Button;
28 * @author dswitkin@google.com (Daniel Switkin)
30 public final class HelpActivity extends Activity {
32 private static final String DEFAULT_URL = "file:///android_asset/html/index.html";
34 private WebView mWebView;
35 private Button mBackButton;
38 protected void onCreate(Bundle icicle) {
39 super.onCreate(icicle);
40 setContentView(R.layout.help);
42 mWebView = (WebView)findViewById(R.id.help_contents);
43 mWebView.setWebViewClient(new HelpClient());
45 mWebView.restoreState(icicle);
47 mWebView.loadUrl(DEFAULT_URL);
50 mBackButton = (Button)findViewById(R.id.back_button);
51 mBackButton.setOnClickListener(mBackListener);
53 Button exitButton = (Button)findViewById(R.id.exit_button);
54 exitButton.setOnClickListener(mExitListener);
58 public void onResume() {
63 protected void onSaveInstanceState(Bundle state) {
64 mWebView.saveState(state);
68 public boolean onKeyDown(int keyCode, KeyEvent event) {
69 if (keyCode == KeyEvent.KEYCODE_BACK) {
70 if (mWebView.canGoBack()) {
75 return super.onKeyDown(keyCode, event);
78 private final Button.OnClickListener mBackListener = new Button.OnClickListener() {
79 public void onClick(View view) {
84 private final Button.OnClickListener mExitListener = new Button.OnClickListener() {
85 public void onClick(View view) {
90 private final class HelpClient extends WebViewClient {
93 public void onPageFinished(WebView view, String url) {
94 setTitle(view.getTitle());
95 mBackButton.setEnabled(view.canGoBack());