Skip to content
Snippets Groups Projects
Commit 0677b9d7 authored by Florian Taurer's avatar Florian Taurer
Browse files

settings get updated also visual now on reset of the settings

parent c14fae90
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ public final class ConfigConstants { ...@@ -35,7 +35,7 @@ public final class ConfigConstants {
public static final String SETTING_PAUSE_DURATION = "etprefPauseDuration"; public static final String SETTING_PAUSE_DURATION = "etprefPauseDuration";
public static final String SETTING_PAUSE_DURATION_DEFAULT = "0"; public static final String SETTING_PAUSE_DURATION_DEFAULT = "0";
public static final String SETTING_BANDWIDTH = "etprefBandwidth"; public static final String SETTING_BANDWIDTH = "etprefBandwidth";
public static final String SETTING_BANDWIDTH_DEFAULT = "1"; public static final String SETTING_BANDWIDTH_DEFAULT = "10";
public static final String SETTING_BLOCKING_DURATION = "etprefSpoofDuration"; public static final String SETTING_BLOCKING_DURATION = "etprefSpoofDuration";
public static final String SETTING_BLOCKING_DURATION_DEFAULT = "1"; public static final String SETTING_BLOCKING_DURATION_DEFAULT = "1";
public static final String SETTING_GPS = "cbprefGpsUse"; public static final String SETTING_GPS = "cbprefGpsUse";
......
...@@ -36,6 +36,20 @@ public class SettingsFragment extends PreferenceFragment { ...@@ -36,6 +36,20 @@ public class SettingsFragment extends PreferenceFragment {
AlertDialog alertDelete = null; AlertDialog alertDelete = null;
AlertDialog alertReset = null; AlertDialog alertReset = null;
private CheckBoxPreference cbContinuousSpoofing;
private CheckBoxPreference cbGPSUse;
private CheckBoxPreference cbNetworkUse;
private CheckBoxPreference cbMicrophone;
private CheckBoxPreference cbSaveJson;
private CheckBoxPreference cbPreventiveSpoofing;
private CheckBoxPreference cbAlertLocationDontAsk;
private EditTextPreference etLocationRadius;
private EditTextPreference etPulseDuration;
private EditTextPreference etPauseDuration;
private EditTextPreference etBandwidth;
private EditTextPreference etBlockingDuration;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -47,6 +61,19 @@ public class SettingsFragment extends PreferenceFragment { ...@@ -47,6 +61,19 @@ public class SettingsFragment extends PreferenceFragment {
nextMain = main.getMainIsMain(); nextMain = main.getMainIsMain();
jsonMan = new JSONManager(nextMain); jsonMan = new JSONManager(nextMain);
cbContinuousSpoofing = (CheckBoxPreference) findPreference(ConfigConstants.SETTING_CONTINOUS_SPOOFING);
cbGPSUse = (CheckBoxPreference) findPreference(ConfigConstants.SETTING_GPS);
cbNetworkUse = (CheckBoxPreference) findPreference(ConfigConstants.SETTING_NETWORK_USE);
cbMicrophone = (CheckBoxPreference) findPreference(ConfigConstants.SETTING_MICROPHONE_FOR_BLOCKING);
cbSaveJson = (CheckBoxPreference) findPreference(ConfigConstants.SETTING_SAVE_DATA_TO_JSON_FILE);
cbPreventiveSpoofing = (CheckBoxPreference) findPreference(ConfigConstants.SETTING_PREVENTIVE_SPOOFING);
cbAlertLocationDontAsk = (CheckBoxPreference) findPreference(ConfigConstants.SETTINGS_ALERT_LOCATION_IS_OFF_DONT_ASK_AGAIN);
etLocationRadius = (EditTextPreference) findPreference(ConfigConstants.SETTING_LOCATION_RADIUS);
etPulseDuration = (EditTextPreference) findPreference(ConfigConstants.SETTING_PULSE_DURATION);
etPauseDuration = (EditTextPreference) findPreference(ConfigConstants.SETTING_PAUSE_DURATION);
etBandwidth = (EditTextPreference) findPreference(ConfigConstants.SETTING_BANDWIDTH);
etBlockingDuration = (EditTextPreference) findPreference(ConfigConstants.SETTING_BLOCKING_DURATION);
Preference pref = findPreference(ConfigConstants.PREFERENCE_DELETE_JSON); Preference pref = findPreference(ConfigConstants.PREFERENCE_DELETE_JSON);
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
...@@ -98,6 +125,21 @@ public class SettingsFragment extends PreferenceFragment { ...@@ -98,6 +125,21 @@ public class SettingsFragment extends PreferenceFragment {
editor.putBoolean(ConfigConstants.SETTINGS_ALERT_LOCATION_IS_OFF_DONT_ASK_AGAIN,ConfigConstants.SETTINGS_ALERT_LOCATION_IS_OFF_DONT_ASK_AGAIN_DEFAULT); editor.putBoolean(ConfigConstants.SETTINGS_ALERT_LOCATION_IS_OFF_DONT_ASK_AGAIN,ConfigConstants.SETTINGS_ALERT_LOCATION_IS_OFF_DONT_ASK_AGAIN_DEFAULT);
editor.apply(); editor.apply();
editor.commit(); editor.commit();
cbContinuousSpoofing.setChecked(ConfigConstants.SETTING_CONTINOUS_SPOOFING_DEFAULT);
cbGPSUse.setChecked(ConfigConstants.SETTING_GPS_DEFAULT);
cbNetworkUse.setChecked(ConfigConstants.SETTING_NETWORK_USE_DEFAULT);
cbMicrophone.setChecked(ConfigConstants.SETTING_MICROPHONE_FOR_BLOCKING_DEFAULT);
cbSaveJson.setChecked(ConfigConstants.SETTING_SAVE_DATA_TO_JSON_FILE_DEFAULT);
cbPreventiveSpoofing.setChecked(ConfigConstants.SETTING_PREVENTIVE_SPOOFING_DEFAULT);
cbAlertLocationDontAsk.setChecked(ConfigConstants.SETTINGS_ALERT_LOCATION_IS_OFF_DONT_ASK_AGAIN_DEFAULT);
etLocationRadius.setText(ConfigConstants.SETTING_LOCATION_RADIUS_DEFAULT);
etPulseDuration.setText(ConfigConstants.SETTING_PULSE_DURATION_DEFAULT);
etPauseDuration.setText(ConfigConstants.SETTING_PAUSE_DURATION_DEFAULT);
etBandwidth.setText(ConfigConstants.SETTING_BANDWIDTH_DEFAULT);
etBlockingDuration.setText(ConfigConstants.SETTING_BLOCKING_DURATION_DEFAULT);
resetEditTextPreferenceTexts();
} }
}) })
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
...@@ -169,67 +211,69 @@ public class SettingsFragment extends PreferenceFragment { ...@@ -169,67 +211,69 @@ public class SettingsFragment extends PreferenceFragment {
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
resetEditTextPreferenceTexts();
}
@Override
public void onResume() {
super.onResume();
// Maybe to add again when we support orientation change
/*
Preference prefLocRad = findPreference(ConfigConstants.SETTING_LOCATION_RADIUS); Preference prefLocRad = findPreference(ConfigConstants.SETTING_LOCATION_RADIUS);
int locationRadius = Integer.valueOf(prefLocRad.getSharedPreferences().getString(prefLocRad.getKey(), ConfigConstants.SETTING_LOCATION_RADIUS_DEFAULT)); int locationRadius = Integer.valueOf(prefLocRad.getSharedPreferences().getString(prefLocRad.getKey(), ConfigConstants.SETTING_LOCATION_RADIUS_DEFAULT));
String prefLocRadStr = String.format("Location radius (%d metres)", locationRadius); prefLocRad.setTitle("Location Radius (" + locationRadius + " metres)");
prefLocRad.setTitle(prefLocRadStr);
Preference prefPulseDur = findPreference(ConfigConstants.SETTING_PULSE_DURATION); Preference prefPulseDur = findPreference(ConfigConstants.SETTING_PULSE_DURATION);
int pulsingDuration = Integer.valueOf(prefPulseDur.getSharedPreferences().getString(prefPulseDur.getKey(), ConfigConstants.SETTING_PULSE_DURATION_DEFAULT)); int pulsingDuration = Integer.valueOf(prefPulseDur.getSharedPreferences().getString(prefPulseDur.getKey(), ConfigConstants.SETTING_PULSE_DURATION_DEFAULT));
String prefPulseDurStr = String.format("Pulse duration (%d ms)", pulsingDuration); prefPulseDur.setTitle("Pulse Duration (" + pulsingDuration + " ms)");
prefPulseDur.setTitle(prefPulseDurStr);
Preference prefPauseDur = findPreference(ConfigConstants.SETTING_PAUSE_DURATION); Preference prefPauseDur = findPreference(ConfigConstants.SETTING_PAUSE_DURATION);
int pauseDuration = Integer.valueOf(prefPauseDur.getSharedPreferences().getString(prefPauseDur.getKey(), ConfigConstants.SETTING_PAUSE_DURATION_DEFAULT)); int pauseDuration = Integer.valueOf(prefPauseDur.getSharedPreferences().getString(prefPauseDur.getKey(), ConfigConstants.SETTING_PAUSE_DURATION_DEFAULT));
String prefPauseDurStr = String.format("Pause duration (%d ms)", pauseDuration); prefPauseDur.setTitle("Pause Duration (" + pauseDuration + " ms)");
prefPauseDur.setTitle(prefPauseDurStr);
Preference prefBandwidth = findPreference(ConfigConstants.SETTING_BANDWIDTH); Preference prefBandwidth = findPreference(ConfigConstants.SETTING_BANDWIDTH);
int bandwidth = Integer.valueOf(prefBandwidth.getSharedPreferences().getString(prefBandwidth.getKey(), ConfigConstants.SETTING_BANDWIDTH_DEFAULT)); int bandwidth = Integer.valueOf(prefBandwidth.getSharedPreferences().getString(prefBandwidth.getKey(), ConfigConstants.SETTING_BANDWIDTH_DEFAULT));
String prefBandwidthStr = String.format("Bandwidth (%d Hz)", bandwidth); prefBandwidth.setTitle("Bandwidth (" + bandwidth + " Hz)");
prefBandwidth.setTitle(prefBandwidthStr);
Preference prefBlockingDuration = findPreference(ConfigConstants.SETTING_BLOCKING_DURATION); Preference prefBlockingDuration = findPreference(ConfigConstants.SETTING_BLOCKING_DURATION);
int blockingDuration = Integer.valueOf(prefBlockingDuration.getSharedPreferences().getString(prefBlockingDuration.getKey(), ConfigConstants.SETTING_BLOCKING_DURATION_DEFAULT)); int blockingDuration = Integer.valueOf(prefBlockingDuration.getSharedPreferences().getString(prefBlockingDuration.getKey(), ConfigConstants.SETTING_BLOCKING_DURATION_DEFAULT));
if(blockingDuration==1) { if(blockingDuration==1) {
String prefBlockingDurationStr = String.format("Blocking duration (%d minute)", blockingDuration); prefBlockingDuration.setTitle("Blocking Duration (" + blockingDuration + " Minute)");
prefBlockingDuration.setTitle(prefBlockingDurationStr);
}else{ }else{
String prefBlockingDurationStr = String.format("Blocking duration (%d minutes)", blockingDuration); prefBlockingDuration.setTitle("Blocking Duration (" + blockingDuration + " Minutes)");
prefBlockingDuration.setTitle(prefBlockingDurationStr);
} }
*/
} }
@Override private void resetEditTextPreferenceTexts(){
public void onResume() {
super.onResume();
// Maybe to add again when we support orientation change
/*
Preference prefLocRad = findPreference(ConfigConstants.SETTING_LOCATION_RADIUS); Preference prefLocRad = findPreference(ConfigConstants.SETTING_LOCATION_RADIUS);
int locationRadius = Integer.valueOf(prefLocRad.getSharedPreferences().getString(prefLocRad.getKey(), ConfigConstants.SETTING_LOCATION_RADIUS_DEFAULT)); int locationRadius = Integer.valueOf(prefLocRad.getSharedPreferences().getString(prefLocRad.getKey(), ConfigConstants.SETTING_LOCATION_RADIUS_DEFAULT));
prefLocRad.setTitle("Location Radius (" + locationRadius + " metres)"); String prefLocRadStr = String.format("Location radius (%d metres)", locationRadius);
prefLocRad.setTitle(prefLocRadStr);
Preference prefPulseDur = findPreference(ConfigConstants.SETTING_PULSE_DURATION); Preference prefPulseDur = findPreference(ConfigConstants.SETTING_PULSE_DURATION);
int pulsingDuration = Integer.valueOf(prefPulseDur.getSharedPreferences().getString(prefPulseDur.getKey(), ConfigConstants.SETTING_PULSE_DURATION_DEFAULT)); int pulsingDuration = Integer.valueOf(prefPulseDur.getSharedPreferences().getString(prefPulseDur.getKey(), ConfigConstants.SETTING_PULSE_DURATION_DEFAULT));
prefPulseDur.setTitle("Pulse Duration (" + pulsingDuration + " ms)"); String prefPulseDurStr = String.format("Pulse duration (%d ms)", pulsingDuration);
prefPulseDur.setTitle(prefPulseDurStr);
Preference prefPauseDur = findPreference(ConfigConstants.SETTING_PAUSE_DURATION); Preference prefPauseDur = findPreference(ConfigConstants.SETTING_PAUSE_DURATION);
int pauseDuration = Integer.valueOf(prefPauseDur.getSharedPreferences().getString(prefPauseDur.getKey(), ConfigConstants.SETTING_PAUSE_DURATION_DEFAULT)); int pauseDuration = Integer.valueOf(prefPauseDur.getSharedPreferences().getString(prefPauseDur.getKey(), ConfigConstants.SETTING_PAUSE_DURATION_DEFAULT));
prefPauseDur.setTitle("Pause Duration (" + pauseDuration + " ms)"); String prefPauseDurStr = String.format("Pause duration (%d ms)", pauseDuration);
prefPauseDur.setTitle(prefPauseDurStr);
Preference prefBandwidth = findPreference(ConfigConstants.SETTING_BANDWIDTH); Preference prefBandwidth = findPreference(ConfigConstants.SETTING_BANDWIDTH);
int bandwidth = Integer.valueOf(prefBandwidth.getSharedPreferences().getString(prefBandwidth.getKey(), ConfigConstants.SETTING_BANDWIDTH_DEFAULT)); int bandwidth = Integer.valueOf(prefBandwidth.getSharedPreferences().getString(prefBandwidth.getKey(), ConfigConstants.SETTING_BANDWIDTH_DEFAULT));
prefBandwidth.setTitle("Bandwidth (" + bandwidth + " Hz)"); String prefBandwidthStr = String.format("Bandwidth (%d Hz)", bandwidth);
prefBandwidth.setTitle(prefBandwidthStr);
Preference prefBlockingDuration = findPreference(ConfigConstants.SETTING_BLOCKING_DURATION); Preference prefBlockingDuration = findPreference(ConfigConstants.SETTING_BLOCKING_DURATION);
int blockingDuration = Integer.valueOf(prefBlockingDuration.getSharedPreferences().getString(prefBlockingDuration.getKey(), ConfigConstants.SETTING_BLOCKING_DURATION_DEFAULT)); int blockingDuration = Integer.valueOf(prefBlockingDuration.getSharedPreferences().getString(prefBlockingDuration.getKey(), ConfigConstants.SETTING_BLOCKING_DURATION_DEFAULT));
if(blockingDuration==1) { if(blockingDuration==1) {
prefBlockingDuration.setTitle("Blocking Duration (" + blockingDuration + " Minute)"); String prefBlockingDurationStr = String.format("Blocking duration (%d minute)", blockingDuration);
prefBlockingDuration.setTitle(prefBlockingDurationStr);
}else{ }else{
prefBlockingDuration.setTitle("Blocking Duration (" + blockingDuration + " Minutes)"); String prefBlockingDurationStr = String.format("Blocking duration (%d minutes)", blockingDuration);
prefBlockingDuration.setTitle(prefBlockingDurationStr);
} }
*/
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment