package com.brogrammers.shopkinmanager;

/**
 * Many thanks to Jamie Avins for the Open Source Android App, FastBook
 * Repository Link: https://github.com/extjs/fastbook
 * <p>
 * This is a custom implementation of the same application, and functions
 * very similarly. Few things had to be changed, but due to API differences,
 * several refactors and port changes were required on our own part
 * <p>
 * --Jose Stovall / oitsjustjose [GitHub]
 */

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.GeolocationPermissions;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity
{
    class NimbleKitClient extends WebViewClient
    {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {
            if (url.startsWith("http:") || url.startsWith("https:"))
                view.loadUrl(url);
            return true;
        }
    }


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView webView = (WebView) findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setPluginState(WebSettings.PluginState.ON);
        webView.getSettings().setMixedContentMode(0);
        webView.setWebViewClient(new NimbleKitClient());

        webView.setWebChromeClient(new WebChromeClient()
        {
            public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback)
            {
                callback.invoke(origin, true, false);
            }
        });
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setDatabaseEnabled(true);
        webView.loadUrl("http://oitsjustjose.github.io/Brogrammers/");
        webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        webView.requestFocus(View.FOCUS_DOWN);
    }
}
@@ -499,16 +499,46 @@
 Bundle;%0A
+import android.view.KeyEvent;%0A
 import a
@@ -551,24 +551,24 @@
 .view.View;%0A
-
 import andro
@@ -789,16 +789,46 @@
 ivity%0A%7B%0A
+    private WebView webView;%0A%0A
     clas
@@ -1297,24 +1297,21 @@
         
-WebView 
+this.
 webView 
@@ -2124,16 +2124,16 @@
 ERLAY);%0A
-
         
@@ -2176,10 +2176,499 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public boolean onKeyDown(int keyCode, KeyEvent event)%0A    %7B%0A        if (event.getAction() == KeyEvent.ACTION_DOWN)%0A        %7B%0A            switch (keyCode)%0A            %7B%0A                case KeyEvent.KEYCODE_BACK:%0A                    if (webView.canGoBack())%0A                        webView.goBack();%0A                    else%0A                        finish();%0A                    return true;%0A            %7D%0A%0A        %7D%0A        return super.onKeyDown(keyCode, event);%0A    %7D
 %0A%7D

Fix App to support Back nav