3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package de.dhbwloe.campusapp.fragments;
17 import android.content.Intent;
18 import android.net.Uri;
19 import android.os.Bundle;
20 import android.support.v4.app.Fragment;
21 import android.view.LayoutInflater;
22 import android.view.View;
23 import android.view.ViewGroup;
24 import android.webkit.WebView;
26 import de.dhbwloe.campusapp.CampusAppFragment;
27 import de.dhbwloe.campusapp.R;
29 public class WebBrowser extends CampusAppFragment {
30 private boolean bRedirectedToBrowser = false;
31 private boolean bBrowserRunning = false;
34 public View onCreateView(LayoutInflater inflater, ViewGroup container,
35 Bundle savedInstanceState) {
36 View view = inflater.inflate(R.layout.fragment_web_browser, container, false);
37 WebView webview = (WebView) view.findViewById(R.id.browserWebView);
39 Bundle args = getArguments();
41 AppContext.getNavigationManager().navigatePage("Dashboard", null, false);
46 if((str = args.getString("html")) != null) {
47 showWebViewHtml(webview, str);
49 else if((str = args.getString("url")) != null) {
50 Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(str));
51 startActivity(browserIntent);
53 bRedirectedToBrowser = true;
60 private void showWebViewHtml(WebView webview, String html) {
61 webview.loadData(html, "text/html", null);
65 public void onPause() {
68 if(bRedirectedToBrowser)
69 bBrowserRunning = true;
73 public void onResume() {
76 if(bRedirectedToBrowser && bBrowserRunning) {
77 AppContext.getMainActivity().onBackPressed();