Fix enabling "Write Log File" option (closes #261)
This commit is contained in:
parent
df3a06ac9b
commit
71461642f7
|
@ -7,11 +7,16 @@ import android.os.Bundle;
|
|||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandPreferencesActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_GENDER;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_HEIGHT_CM;
|
||||
|
@ -80,6 +85,26 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||
|
||||
});
|
||||
|
||||
pref = findPreference("log_to_file");
|
||||
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
if (Boolean.TRUE.equals(newVal)) {
|
||||
try {
|
||||
FileUtils.getExternalFilesDir(); // ensures that it is created
|
||||
} catch (IOException ex) {
|
||||
GB.toast(getApplicationContext(),
|
||||
getString(R.string.error_creating_directory_for_logfiles, ex.getLocalizedMessage()),
|
||||
Toast.LENGTH_LONG,
|
||||
GB.ERROR,
|
||||
ex);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Get all receivers of Media Buttons
|
||||
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||
|
||||
|
|
|
@ -233,5 +233,6 @@
|
|||
<string name="appwidget_alarms_set">An alarm was set for %1$02d:%2$02d</string>
|
||||
<string name="device_hw">HW: %1$s</string>
|
||||
<string name="device_fw">FW: %1$s</string>
|
||||
<string name="error_creating_directory_for_logfiles">Error creating directory for log files: %1$s</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue