|
@@ -42,28 +42,41 @@ import de.tudarmstadt.informatik.hostage.ui2.fragment.opengl.ThreatIndicatorGLRe
|
|
|
*/
|
|
|
|
|
|
public class HomeFragment extends Fragment {
|
|
|
+
|
|
|
private Switch mHomeSwitchConnection;
|
|
|
+
|
|
|
private TextView mHomeTextName;
|
|
|
+
|
|
|
private TextView mHomeTextSecurity;
|
|
|
+
|
|
|
private TextView mHomeTextAttacks;
|
|
|
+
|
|
|
private TextView mHomeTextProfile;
|
|
|
+
|
|
|
private TextView mHomeTextProfileHeader;
|
|
|
+
|
|
|
private ImageView mHomeProfileImage;
|
|
|
+
|
|
|
private ImageView mHomeConnectionInfoButton;
|
|
|
|
|
|
private View mRootView;
|
|
|
+
|
|
|
private BroadcastReceiver mReceiver;
|
|
|
|
|
|
private CompoundButton.OnCheckedChangeListener mSwitchChangeListener = null;
|
|
|
|
|
|
private int mDefaultTextColor;
|
|
|
+
|
|
|
private ProfileManager mProfileManager;
|
|
|
|
|
|
private SharedPreferences mConnectionInfo;
|
|
|
+
|
|
|
private UglyDbHelper mDbHelper;
|
|
|
|
|
|
private boolean mReceiverRegistered;
|
|
|
|
|
|
+ private boolean mRestoredFromSaved = false;
|
|
|
+
|
|
|
private void assignViews() {
|
|
|
mHomeSwitchConnection = (Switch) mRootView.findViewById(R.id.home_switch_connection);
|
|
|
mHomeTextName = (TextView) mRootView.findViewById(R.id.home_text_name);
|
|
@@ -181,28 +194,28 @@ public class HomeFragment extends Fragment {
|
|
|
setStateActive(true);
|
|
|
|
|
|
switch (threatLevel) {
|
|
|
- case NO_THREAT:
|
|
|
- mHomeTextAttacks.setText(R.string.zero_attacks);
|
|
|
- mHomeTextSecurity.setText(R.string.secure);
|
|
|
- mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
- mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
- break;
|
|
|
- case PAST_THREAT:
|
|
|
- mHomeTextAttacks.setText(totalAttacks
|
|
|
- + (totalAttacks == 1 ? getResources().getString(R.string.attack) : getResources().getString(R.string.attacks))
|
|
|
- + getResources().getString(R.string.recorded));
|
|
|
- mHomeTextSecurity.setText(R.string.insecure);
|
|
|
- mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_yellow));
|
|
|
- mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_yellow));
|
|
|
- break;
|
|
|
- case LIVE_THREAT:
|
|
|
- mHomeTextAttacks.setText(totalAttacks
|
|
|
- + (totalAttacks == 1 ? getResources().getString(R.string.attack) : getResources().getString(R.string.attacks))
|
|
|
- + getResources().getString(R.string.recorded));
|
|
|
- mHomeTextSecurity.setText(R.string.insecure);
|
|
|
- mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
- mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
- break;
|
|
|
+ case NO_THREAT:
|
|
|
+ mHomeTextAttacks.setText(R.string.zero_attacks);
|
|
|
+ mHomeTextSecurity.setText(R.string.secure);
|
|
|
+ mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
+ mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
+ break;
|
|
|
+ case PAST_THREAT:
|
|
|
+ mHomeTextAttacks.setText(totalAttacks
|
|
|
+ + (totalAttacks == 1 ? getResources().getString(R.string.attack) : getResources().getString(R.string.attacks))
|
|
|
+ + getResources().getString(R.string.recorded));
|
|
|
+ mHomeTextSecurity.setText(R.string.insecure);
|
|
|
+ mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_yellow));
|
|
|
+ mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_yellow));
|
|
|
+ break;
|
|
|
+ case LIVE_THREAT:
|
|
|
+ mHomeTextAttacks.setText(totalAttacks
|
|
|
+ + (totalAttacks == 1 ? getResources().getString(R.string.attack) : getResources().getString(R.string.attacks))
|
|
|
+ + getResources().getString(R.string.recorded));
|
|
|
+ mHomeTextSecurity.setText(R.string.insecure);
|
|
|
+ mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
+ mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
ThreatIndicatorGLRenderer.setThreatLevel(threatLevel);
|
|
@@ -218,6 +231,7 @@ public class HomeFragment extends Fragment {
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
|
+
|
|
|
setHasOptionsMenu(true);
|
|
|
|
|
|
final Activity activity = getActivity();
|
|
@@ -263,6 +277,7 @@ public class HomeFragment extends Fragment {
|
|
|
updateUI();
|
|
|
|
|
|
mHomeSwitchConnection = (Switch) mRootView.findViewById(R.id.home_switch_connection);
|
|
|
+ mHomeSwitchConnection.setSaveEnabled(false);
|
|
|
|
|
|
if (mSwitchChangeListener == null) {
|
|
|
mSwitchChangeListener = new CompoundButton.OnCheckedChangeListener() {
|
|
@@ -381,7 +396,7 @@ public class HomeFragment extends Fragment {
|
|
|
|
|
|
@Override
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
- switch(item.getItemId()){
|
|
|
+ switch (item.getItemId()) {
|
|
|
case R.id.home_action_synchronize:
|
|
|
getActivity().startActivity(new Intent(this.getActivity(), BluetoothSync.class));
|
|
|
return true;
|
|
@@ -392,8 +407,8 @@ public class HomeFragment extends Fragment {
|
|
|
|
|
|
@Override
|
|
|
public void onStop() {
|
|
|
- unregisterBroadcastReceiver();
|
|
|
super.onStop();
|
|
|
+ unregisterBroadcastReceiver();
|
|
|
}
|
|
|
|
|
|
@Override
|