/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.focus.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import org.mozilla.focus.R;
import org.mozilla.focus.web.IWebView;

public class InfoFragment extends WebFragment {
    private ProgressBar progressView;

    private static final String ARGUMENT_URL = "url";

    public static InfoFragment create(String url) {
        Bundle arguments = new Bundle();
        arguments.putString(ARGUMENT_URL, url);

        InfoFragment fragment = new InfoFragment();
        fragment.setArguments(arguments);

        return fragment;
    }

    @NonNull
    @Override
    public View inflateLayout(LayoutInflater inflater, @Nullable ViewGroup container,
                              @Nullable Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_info, container, false);
        progressView = (ProgressBar) view.findViewById(R.id.progress);

        return view;
    }

    @Override
    public IWebView.Callback createCallback() {
        return new IWebView.Callback() {
            @Override
            public void onPageStarted(final String url) {
                progressView.announceForAccessibility(getString(R.string.accessibility_announcement_loading));

                progressView.setVisibility(View.VISIBLE);
            }

            @Override
            public void onPageFinished(boolean isSecure) {
                progressView.announceForAccessibility(getString(R.string.accessibility_announcement_loading_finished));

                progressView.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onProgress(int progress) {
                progressView.setProgress(progress);
            }

            @Override
            public boolean handleExternalUrl(final String url) {
                return false;
            }

            @Override
            public void onLinkLongPress(final String url) {
            };
        };
    }

    @Nullable
    @Override
    public String getInitialUrl() {
        return getArguments().getString(ARGUMENT_URL);
    }
}

@@ -709,16 +709,42 @@
 essView;
+%0A    private View webView;
 %0A%0A    pr
@@ -1399,16 +1399,638 @@
 ogress);
+%0A        webView = view.findViewById(R.id.webview);%0A%0A        final String url = getInitialUrl();%0A        if (!(url.startsWith(%22http://%22) %7C%7C url.startsWith(%22https://%22))) %7B%0A            // Hide webview until content has loaded, if we're loading built in about/rights/etc%0A            // pages: this avoid a white flash (on slower devices) between the screen appearing,%0A            // and the about/right/etc content appearing. We don't do this for SUMO and other%0A            // external pages, because they are both light-coloured, and significantly slower loading.%0A            webView.setVisibility(View.INVISIBLE);%0A        %7D
 %0A%0A      
@@ -2617,24 +2617,24 @@
 inished));%0A%0A
-
             
@@ -2672,32 +2672,171 @@
 View.INVISIBLE);
+%0A%0A                if (webView.getVisibility() != View.VISIBLE) %7B%0A                    webView.setVisibility(View.VISIBLE);%0A                %7D
 %0A            %7D%0A%0A

Reimplement InfoActivity webView hiding, only for builtin pages (#199)