package de.tudarmstadt.informatik.hostage.ui2.fragment;

import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import de.tudarmstadt.informatik.hostage.R;
import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;

/**
 * @author Alexander Brakowski
 * @created 24.02.14 23:37
 */
public class SettingsFragment extends Fragment {
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
		super.onCreateView(inflater, container, savedInstanceState);
		getActivity().setTitle(getResources().getString(R.string.drawer_settings));
		View v = inflater.inflate(R.layout.fragment_settings, container, false);

		TextView rootedText = (TextView) v.findViewById(R.id.settings_device_rooted);
		TextView porthackText = (TextView) v.findViewById(R.id.settings_porthack_installed);

		if(MainActivity.isRooted){
			rootedText.setText(R.string.yes);
			rootedText.setTextColor(getResources().getColor(R.color.holo_dark_green));
		} else {
			rootedText.setText(R.string.no);
			rootedText.setTextColor(getResources().getColor(R.color.holo_red));
		}

		if(MainActivity.porthackInstalled){
			porthackText.setText(R.string.yes);
			porthackText.setTextColor(getResources().getColor(R.color.holo_dark_green));
		} else {
			porthackText.setText(R.string.no);
			porthackText.setTextColor(getResources().getColor(R.color.holo_red));
		}

		return v;
	}

	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);

		FragmentManager manager = this.getFragmentManager();
		manager.beginTransaction().replace(R.id.settings_fragment_container, new PreferenceHostageFrament()).commit();
	}
}
