package com.zoblak.farm;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;

/**
 * A placeholder fragment containing a simple view.
 */
public class MainScreenFragment extends Fragment {

    public MainScreenFragment() {

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_main_screen, container, false);

        WebView webView = (WebView)view.findViewById(R.id.main_web_view);
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getContext());
        String controllers = prefs.getString("controllers", "");
        webView.loadUrl("http://agrar.zoblak.com/alarm?controller_id=" + controllers);

        return view;
    }
}
