package ca.etsmtl.applets.etsmobile.ui.fragment;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import ca.etsmtl.applets.etsmobile.util.AnalyticsHelper;
import ca.etsmtl.applets.etsmobile.util.Utility;
import ca.etsmtl.applets.etsmobile.views.LoadingView;
import ca.etsmtl.applets.etsmobile2.R;

/**
 * Created by Phil on 17/11/13. Modified by Laurence on 05/02/14.
 */
public class BiblioFragment extends WebFragment {

	private WebView webView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		
		ViewGroup v = (ViewGroup) inflater.inflate(R.layout.fragment_web_view, container, false);
		super.onCreateView(inflater, v, savedInstanceState);

		webView = (WebView) v.findViewById(R.id.webView);

		final WebSettings webSettings = webView.getSettings();
		webSettings.setJavaScriptEnabled(true);

        loadingView.showLoadingView();


		webView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
				view.loadUrl(url);
				return false;
			}

			@Override
			public void onPageFinished(WebView view, String url) {
				// super.onPageFinished(view, url);
				LoadingView.hideLoadingView(loadingView);
			}

            @Override
			public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
				view.loadUrl("file:///android_asset/webview_error_page.html");
			}
		});

		webView.loadUrl(getActivity().getString(R.string.url_biblio));
		AnalyticsHelper.getInstance(getActivity()).sendScreenEvent(getClass().getSimpleName());
		return v;
	}
}

@@ -47,63 +47,8 @@
 t;%0A%0A
-import android.content.Intent;%0Aimport android.net.Uri;%0A
 impo
@@ -269,37 +269,69 @@
 nt;%0A
+%0A
 import 
-android.widget.Toast;%0A
+ca.etsmtl.applets.etsmobile.ui.activity.MainActivity;
 %0Aimp
@@ -388,57 +388,8 @@
 er;%0A
-import ca.etsmtl.applets.etsmobile.util.Utility;%0A
 impo
@@ -482,82 +482,8 @@
 R;%0A%0A
-/**%0A * Created by Phil on 17/11/13. Modified by Laurence on 05/02/14.%0A */%0A
 publ
@@ -529,17 +529,20 @@
 ment %7B%0A%0A
-%09
+    
 private 
@@ -559,17 +559,20 @@
 bView;%0A%0A
-%09
+    
 @Overrid
@@ -569,25 +569,28 @@
   @Override%0A
-%09
+    
 public void 
@@ -627,18 +627,24 @@
 tate) %7B%0A
-%09%09
+        
 super.on
@@ -671,21 +671,27 @@
 State);%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Overrid
@@ -692,17 +692,20 @@
 verride%0A
-%09
+    
 public V
@@ -800,13 +800,17 @@
 ) %7B%0A
-%09%09%0A%09%09
+%0A        
 View
@@ -895,18 +895,94 @@
 false);%0A
-%09%09
+        ((MainActivity) getActivity()).setTitle(getFragmentTitle());%0A%0A        
 super.on
@@ -1023,26 +1023,32 @@
 nceState);%0A%0A
-%09%09
+        
 webView = (W
@@ -1086,18 +1086,24 @@
 View);%0A%0A
-%09%09
+        
 final We
@@ -1149,18 +1149,24 @@
 ings();%0A
-%09%09
+        
 webSetti
@@ -1239,18 +1239,24 @@
 ew();%0A%0A%0A
-%09%09
+        
 webView.
@@ -1294,32 +1294,50 @@
 ent() %7B%0A
-%09%09%09@Override%0A%09%09%09
+            @Override%0A            
 public b
@@ -1404,28 +1404,40 @@
 ring url) %7B%0A
-%09%09%09%09
+                
 view.loadUrl
@@ -1447,48 +1447,87 @@
 l);%0A
-%09%09%09%09return false;%0A%09%09%09%7D%0A%0A%09%09%09@Override%0A%09%09%09
+                return false;%0A            %7D%0A%0A            @Override%0A            
 publ
@@ -1577,20 +1577,32 @@
  url) %7B%0A
-%09%09%09%09
+                
 // super
@@ -1629,20 +1629,32 @@
 , url);%0A
-%09%09%09%09
+                
 LoadingV
@@ -1687,19 +1687,28 @@
 gView);%0A
-%09%09%09
+            
 %7D%0A%0A     
@@ -1724,19 +1724,28 @@
 verride%0A
-%09%09%09
+            
 public v
@@ -1838,12 +1838,24 @@
 ) %7B%0A
-%09%09%09%09
+                
 view
@@ -1917,22 +1917,43 @@
 %22);%0A
-%09%09%09%7D%0A%09%09%7D);%0A%0A%09%09
+            %7D%0A        %7D);%0A%0A        
 webV
@@ -2011,18 +2011,24 @@
 blio));%0A
-%09%09
+        
 Analytic
@@ -2111,10 +2111,16 @@
 ));%0A
-%09%09
+        
 retu
@@ -2129,9 +2129,130 @@
  v;%0A
-%09
+    %7D%0A%0A    @Override%0A    public String getFragmentTitle() %7B%0A        return getString(R.string.menu_section_2_biblio);%0A    
 %7D%0A%7D%0A

Fix display of library actionbar title