ArViewer  Android Version
Arvos - Augmented reality viewer open source
 All Classes Namespaces Files Functions Variables
WebViewer.java
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013, Peter Graf
3 
4  This file is part of Arvos - AR Viewer Open Source for Android.
5  Arvos is free software.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20  For more information on the AR Viewer Open Source or Peter Graf,
21  please see: http://www.mission-base.com/.
22  */
23 
24 package com.mission_base.arviewer_android.viewer;
25 
26 import android.app.*;
27 import android.os.*;
28 import android.view.*;
29 import android.webkit.*;
30 import com.mission_base.arviewer_android.*;
31 
38 public class WebViewer extends Activity
39 {
40  @Override
41  protected void onCreate(Bundle savedInstanceState)
42  {
43  super.onCreate(savedInstanceState);
44 
45  String url = getIntent().getStringExtra("url");
46 
47  setContentView(R.layout.web_viewer_main);
48 
49  WebView webView = (WebView) findViewById(R.id.WebView01);
50  webView.setWebViewClient(new Callback());
51  WebSettings webSettings = webView.getSettings();
52  webSettings.setBuiltInZoomControls(true);
53 
54  // ---Part 1---
55  webView.loadUrl(url);
56 
57  // ---Part 2---
58  // final String mimeType = "text/html";
59  // final String encoding = "UTF-8";
60  // String html =
61  // "<H1>A simple HTML page</H1><body>" +
62  // "<p>The quick brown fox jumps over the lazy dog</p></body>";
63  // webView.loadDataWithBaseURL("", html, mimeType, encoding, "");
64 
65  // ---Part 3---
66  // webView.loadUrl("file:///android_asset/index.html");
67  }
68 
69  private class Callback extends WebViewClient
70  {
71  @Override
72  public boolean shouldOverrideUrlLoading(WebView view, String url)
73  {
74  return (false);
75  }
76  }
77 
78  @Override
79  protected void onResume()
80  {
81  super.onResume();
82  }
83 
84  @Override
85  protected void onPause()
86  {
87  super.onPause();
88  }
89 
90  static final private int MENU_ITEM_CLOSE = Menu.FIRST;
91 
92  @Override
93  public boolean onCreateOptionsMenu(Menu menu)
94  {
95  super.onCreateOptionsMenu(menu);
96 
97  int groupId = 0;
98  int menuItemId = MENU_ITEM_CLOSE;
99  int menuItemOrder = Menu.NONE;
100  int menuItemText = R.string.menu_close;
101 
102  // Create the Menu Item and keep a reference to it
103  MenuItem menuItem = menu.add(groupId, menuItemId, menuItemOrder, menuItemText);
104  menuItem = menu.add(groupId, menuItemId++, menuItemOrder, menuItemText);
105  // menuItem.setIcon(R.drawable.ic_action_refresh_white);
106  menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
107 
108  return true;
109  }
110 
111  public boolean onOptionsItemSelected(MenuItem item)
112  {
113  super.onOptionsItemSelected(item);
114 
115  switch (item.getItemId())
116  {
117  case (MENU_ITEM_CLOSE):
118  finish();
119  return true;
120  }
121  return false;
122  }
123 }