package com.dankideacentral.dic.authentication;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
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 com.dankideacentral.dic.SearchActivity;
import com.dankideacentral.dic.R;

public class OAuthWebViewFragment extends Fragment {
    private WebView webView;
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        String auth = getArguments().getString(getString(R.string.string_extra_authentication_url));

        webView.loadUrl(auth);
        webView.setWebViewClient(new WebViewClient()
        {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (url.contains("oauth_verifier=")) {
                    // Create user session
                    TwitterSession.getInstance().createSession(Uri.parse(url),
                            getActivity().getApplicationContext());

                    // TODO: add logic to check location enabled
                    Intent intent = new Intent(getActivity().getApplicationContext(),
                            SearchActivity.class);
                    startActivity(intent);
                }

                view.loadUrl(url);
                return true;
            }
        });
        WebSettings webSettings = webView.getSettings();

        webSettings.setDomStorageEnabled(true);
        webSettings.setJavaScriptEnabled(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_oauth_webview,container,false);
        webView = (WebView) view.findViewById(R.id.webViewOAuth);
        return view;
    }
}

@@ -69,24 +69,66 @@
 ent.Intent;%0A
+import android.content.pm.PackageManager;%0A
 import andro
@@ -139,16 +139,16 @@
 et.Uri;%0A
-
 import a
@@ -482,16 +482,66 @@
 l.dic.R;
+%0Aimport com.dankideacentral.dic.TweetFeedActivity;
 %0A%0Apublic
@@ -587,16 +587,121 @@
 gment %7B%0A
+%0A    private static final String FINE_LOCATION_PERMISSION = %22android.permissions.ACCESS_FINE_LOCATION%22;%0A%0A
     priv
@@ -717,24 +717,25 @@
 ew webView;%0A
+%0A
     @Overrid
@@ -1210,24 +1210,60 @@
 ifier=%22)) %7B%0A
+                    Intent intent;%0A%0A
             
@@ -1465,79 +1465,265 @@
     
-// TODO: add logic to check location enabled%0A                    Intent
+if (isLocationEnabled() == PackageManager.PERMISSION_GRANTED) %7B%0A                        intent = new Intent(getActivity().getApplicationContext(),%0A                                TweetFeedActivity.class);%0A                    %7D else %7B%0A                       
  int
@@ -1806,16 +1806,20 @@
         
+    
 SearchAc
@@ -1825,32 +1825,55 @@
 ctivity.class);%0A
+                    %7D%0A%0A
                 
@@ -2436,24 +2436,24 @@
 ViewOAuth);%0A
-
         retu
@@ -2466,11 +2466,462 @@
 w;%0A    %7D
+%0A%0A    /**%0A     * Checks the %7B@link PackageManager%7D to determine if location%0A     * services have been enabled.%0A     *%0A     * @return%0A     *          Either %7B@link PackageManager#PERMISSION_GRANTED%7D or%0A     *          %7B@link PackageManager#PERMISSION_DENIED%7D.%0A     */%0A    private int isLocationEnabled() %7B%0A        return getActivity().getPackageManager().checkPermission(%0A                FINE_LOCATION_PERMISSION, getActivity().getPackageName());%0A    %7D
 %0A%7D%0A

Add location check logic at the end of auth flow