|
@@ -133,9 +133,6 @@ public class HomeFragment extends Fragment {
|
|
|
}
|
|
|
|
|
|
public void setStateActive(boolean initial) {
|
|
|
- mHomeTextAttacks.setVisibility(View.VISIBLE);
|
|
|
- mHomeTextSecurity.setVisibility(View.VISIBLE);
|
|
|
-
|
|
|
mHomeTextName.setTextColor(mDefaultTextColor);
|
|
|
mHomeTextProfile.setTextColor(mDefaultTextColor);
|
|
|
mHomeTextProfileHeader.setTextColor(mDefaultTextColor);
|
|
@@ -157,6 +154,8 @@ public class HomeFragment extends Fragment {
|
|
|
}
|
|
|
|
|
|
public void setStateConnected() {
|
|
|
+ mHomeTextAttacks.setVisibility(View.VISIBLE);
|
|
|
+ mHomeTextSecurity.setVisibility(View.VISIBLE);
|
|
|
mHomeTextProfile.setVisibility(View.VISIBLE);
|
|
|
mHomeTextProfileHeader.setVisibility(View.VISIBLE);
|
|
|
mHomeProfileImage.setVisibility(View.VISIBLE);
|
|
@@ -197,41 +196,45 @@ public class HomeFragment extends Fragment {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (isConnected) {
|
|
|
+ if (totalAttacks == 0) {
|
|
|
+ mHomeTextAttacks.setText(R.string.zero_attacks);
|
|
|
+ mHomeTextSecurity.setText(R.string.secure);
|
|
|
+ } else {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mHomeTextAttacks.setText("");
|
|
|
+ mHomeTextSecurity.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
if (hasActiveListeners) {
|
|
|
setStateActive(true);
|
|
|
|
|
|
- if(!isConnected){
|
|
|
- ThreatIndicatorGLRenderer.setThreatLevel(ThreatIndicatorGLRenderer.ThreatLevel.NO_THREAT);
|
|
|
- mHomeTextAttacks.setText("");
|
|
|
- mHomeTextSecurity.setText("");
|
|
|
- } else {
|
|
|
- switch (mThreatLevel) {
|
|
|
- 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(mThreatLevel);
|
|
|
+ // color text according to threat level
|
|
|
+ switch (mThreatLevel) {
|
|
|
+ case NO_THREAT:
|
|
|
+ mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
+ mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
+ break;
|
|
|
+ case PAST_THREAT:
|
|
|
+ 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(mThreatLevel);
|
|
|
} else {
|
|
|
setStateNotActive();
|
|
|
}
|