SettingsFragment.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package de.tudarmstadt.informatik.hostage.ui2.fragment;
  2. import android.app.FragmentManager;
  3. import android.os.Bundle;
  4. import android.view.LayoutInflater;
  5. import android.view.View;
  6. import android.view.ViewGroup;
  7. import android.widget.TextView;
  8. import de.tudarmstadt.informatik.hostage.R;
  9. import de.tudarmstadt.informatik.hostage.system.Device;
  10. /**
  11. * Creates the view to edit the preferences of the app and shows the porthack and rooted state of the device
  12. *
  13. * @author Alexander Brakowski
  14. * @created 24.02.14 23:37
  15. */
  16. public class SettingsFragment extends UpNavigatibleFragment {
  17. /**
  18. * {@inheritDoc}
  19. */
  20. @Override
  21. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  22. super.onCreateView(inflater, container, savedInstanceState);
  23. getActivity().setTitle(getResources().getString(R.string.drawer_settings));
  24. View v = inflater.inflate(R.layout.fragment_settings, container, false);
  25. TextView rootedText = (TextView) v.findViewById(R.id.settings_device_rooted);
  26. TextView porthackText = (TextView) v.findViewById(R.id.settings_porthack_installed);
  27. if (Device.isRooted()) {
  28. rootedText.setText(R.string.yes);
  29. rootedText.setTextColor(getResources().getColor(R.color.holo_dark_green));
  30. } else {
  31. rootedText.setText(R.string.no);
  32. rootedText.setTextColor(getResources().getColor(R.color.holo_red));
  33. }
  34. if (Device.isPorthackInstalled()) {
  35. porthackText.setText(R.string.yes);
  36. porthackText.setTextColor(getResources().getColor(R.color.holo_dark_green));
  37. } else {
  38. porthackText.setText(R.string.no);
  39. porthackText.setTextColor(getResources().getColor(R.color.holo_red));
  40. }
  41. return v;
  42. }
  43. /**
  44. * {@inheritDoc}
  45. */
  46. @Override
  47. public void onViewCreated(View view, Bundle savedInstanceState) {
  48. super.onViewCreated(view, savedInstanceState);
  49. FragmentManager manager = this.getFragmentManager();
  50. manager.beginTransaction().replace(R.id.settings_fragment_container, new PreferenceHostageFrament()).commit();
  51. }
  52. }