|
@@ -1,13 +1,25 @@
|
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
|
|
|
|
+import android.app.AlertDialog;
|
|
|
+import android.app.DownloadManager;
|
|
|
+import android.app.Fragment;
|
|
|
import android.app.FragmentManager;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.content.Intent;
|
|
|
+import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Environment;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.TextView;
|
|
|
+
|
|
|
+import de.tudarmstadt.informatik.hostage.Hostage;
|
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
|
import de.tudarmstadt.informatik.hostage.system.Device;
|
|
|
+import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
|
|
|
|
|
|
/**
|
|
|
* Creates the view to edit the preferences of the app and shows the porthack and rooted state of the device
|
|
@@ -45,7 +57,62 @@ public class SettingsFragment extends UpNavigatibleFragment {
|
|
|
porthackText.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
}
|
|
|
|
|
|
- return v;
|
|
|
+ //Allow no porthack text box clickable
|
|
|
+ if (Device.isRooted() && !Device.isPorthackInstalled())
|
|
|
+ {
|
|
|
+ porthackText.setOnClickListener(new View.OnClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View arg0) {
|
|
|
+ new AlertDialog.Builder(getActivity())
|
|
|
+ .setTitle(R.string.information)
|
|
|
+ .setMessage(R.string.no_portbinder_msg)
|
|
|
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton(R.string.help, new DialogInterface.OnClickListener() {
|
|
|
+
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ final AlertDialog alert;
|
|
|
+
|
|
|
+ new AlertDialog.Builder(getActivity())
|
|
|
+ .setTitle(R.string.portbinder)
|
|
|
+ .setMessage(R.string.helpPortbinder)
|
|
|
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNeutralButton(R.string.portbinder_tutorial, new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ Uri uri = Uri.parse("https://www.youtube.com/watch?v=gi6fSiIJASk");
|
|
|
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
|
|
+ startActivity(intent);
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton(R.string.portbinder_website, new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ Uri uri = Uri.parse("https://www.tk.informatik.tu-darmstadt.de/de/research/secure-smart-infrastructures/hostage/");
|
|
|
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
|
|
+ startActivity(intent);
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setIcon(android.R.drawable.ic_dialog_info).show();
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setIcon(android.R.drawable.ic_dialog_info).show();}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return v;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -55,6 +122,7 @@ public class SettingsFragment extends UpNavigatibleFragment {
|
|
|
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();
|
|
|
}
|