package fr.free.nrw.commons.auth;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import fr.free.nrw.commons.R;

public class SignupActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d("SignupActivity", "Signup Activity started");

        WebView webView = new WebView(this);
        setContentView(webView);

        webView.setWebViewClient(new MyWebViewClient());
        //myWebView.loadUrl("https://commons.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page");
        //Mobile page, looks better than the above
        webView.loadUrl("https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes");

        //After Create Account button is pressed within WebView, it brings user to https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes. So can we just override that URL?
        //Do we NEED to enable JS? Validation seems to work fine here
    }

    private class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (Uri.parse(url).getHost().equals("www.example.com")) {
                // This is my web site, so do not override; let my WebView load the page
                return false;
            }
            // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }
    }
}

@@ -1415,23 +1415,79 @@
 ls(%22
-www.example.com
+https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes
 %22)) 
@@ -1597,281 +1597,337 @@
     
-return false;%0A            %7D%0A            // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs%0A            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));%0A            startActivity(intent);%0A            return true;
+Log.d(%22SignupActivity%22, %22Overriding URL%22);%0A                Intent intent = new Intent(getApplicationContext(), LoginActivity.class);%0A                startActivity(intent);%0A                return true;%0A            %7D else %7B%0A                Log.d(%22SignupActivity%22, %22Not overriding URL%22);%0A                return false;%0A            %7D%0A
 %0A   

Add intent to go to LoginActivity