// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java
// public class Constants {
//     public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB
//     public static final int TWEETS_PER_PAGE = 50;
// 
//     public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message";
//     public static final String FIREBASE_CONFIG_WEB_URL = "web_url";
//     public static final String FIREBASE_CONFIG_API_URL = "api_url";
//     public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html";
// 
//     public static final String TWITTER_CONSUMER_KEY = "XXXXXX";
//     public static final String TWITTER_CONSUMER_SECRET = "XXXXXX";
// }


import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.referendum.uoctubre.R;
import com.referendum.uoctubre.main.Constants;
import im.delight.android.webview.AdvancedWebView;
package com.referendum.uoctubre.fragments;




public class WebFragment extends BaseFragment implements AdvancedWebView.Listener {

    public static final String TAG = "web_fragment";

    public static WebFragment newInstance() {
        Bundle args = new Bundle();
        WebFragment fragment = new WebFragment();
        fragment.setArguments(args);
        return fragment;
    }

    private AdvancedWebView mWebView;
    private View loadingLayout;
    private View errorLayout;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_web, container, false);

        mWebView = view.findViewById(R.id.webview);
        loadingLayout = view.findViewById(R.id.loading_layout);
        errorLayout = view.findViewById(R.id.error_layout);

        errorLayout.findViewById(R.id.error_retry_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                errorLayout.setVisibility(View.GONE);
                loadingLayout.setVisibility(View.VISIBLE);
                mWebView.setVisibility(View.VISIBLE);
                mWebView.loadUrl("about:blank");

                //Allow to change URL via Firebase
                FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
                firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java
// public class Constants {
//     public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB
//     public static final int TWEETS_PER_PAGE = 50;
// 
//     public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message";
//     public static final String FIREBASE_CONFIG_WEB_URL = "web_url";
//     public static final String FIREBASE_CONFIG_API_URL = "api_url";
//     public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html";
// 
//     public static final String TWITTER_CONSUMER_KEY = "XXXXXX";
//     public static final String TWITTER_CONSUMER_SECRET = "XXXXXX";
// }


// Path: app/src/main/java/com/referendum/uoctubre/fragments/WebFragment.java
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.referendum.uoctubre.R;
import com.referendum.uoctubre.main.Constants;
import im.delight.android.webview.AdvancedWebView;

package com.referendum.uoctubre.fragments;




public class WebFragment extends BaseFragment implements AdvancedWebView.Listener {

    public static final String TAG = "web_fragment";

    public static WebFragment newInstance() {
        Bundle args = new Bundle();
        WebFragment fragment = new WebFragment();
        fragment.setArguments(args);
        return fragment;
    }

    private AdvancedWebView mWebView;
    private View loadingLayout;
    private View errorLayout;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_web, container, false);

        mWebView = view.findViewById(R.id.webview);
        loadingLayout = view.findViewById(R.id.loading_layout);
        errorLayout = view.findViewById(R.id.error_layout);

        errorLayout.findViewById(R.id.error_retry_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                errorLayout.setVisibility(View.GONE);
                loadingLayout.setVisibility(View.VISIBLE);
                mWebView.setVisibility(View.VISIBLE);
                mWebView.loadUrl("about:blank");

                //Allow to change URL via Firebase
                FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
                firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
                String webUrl = firebaseRemoteConfig.getString(Constants.FIREBASE_CONFIG_WEB_URL);