Skip to content

Commit

Permalink
Indicate whether the selected folder is writeable
Browse files Browse the repository at this point in the history
Issue #275
  • Loading branch information
mendhak committed Oct 11, 2014
1 parent 8c6bc4b commit 477d76f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.text.Html;
import android.view.MenuItem;
import com.mendhak.gpslogger.GpsMainActivity;
import com.mendhak.gpslogger.R;
Expand Down Expand Up @@ -107,7 +108,11 @@ protected void onPostCreate(Bundle savedInstanceState) {

Preference gpsloggerFolder = (Preference) findPreference("gpslogger_folder");
gpsloggerFolder.setOnPreferenceClickListener(this);
gpsloggerFolder.setSummary(prefs.getString("gpslogger_folder", Utilities.GetDefaultStorageFolder(getApplicationContext()).getAbsolutePath()));
String gpsLoggerFolderPath = prefs.getString("gpslogger_folder", Utilities.GetDefaultStorageFolder(getApplicationContext()).getAbsolutePath());
gpsloggerFolder.setSummary(gpsLoggerFolderPath);
if(!(new File(gpsLoggerFolderPath)).canWrite()){
gpsloggerFolder.setSummary(Html.fromHtml("<font color='red'>" + gpsLoggerFolderPath + "</font>"));
}

CheckBoxPreference chkLog_opengts = (CheckBoxPreference) findPreference("log_opengts");
chkLog_opengts.setOnPreferenceClickListener(this);
Expand Down Expand Up @@ -169,6 +174,11 @@ public synchronized void onActivityResult(final int requestCode, int resultCode,
}
tracer.debug("Folder path selected" + filePath);

if(!chosenFile.canWrite()){
Utilities.MsgBox(getString(R.string.sorry), getString(R.string.pref_logging_file_no_permissions), LoggingSettingsActivity.this);
return;
}

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = prefs.edit();
editor.putString("gpslogger_folder", filePath);
Expand All @@ -177,6 +187,8 @@ public synchronized void onActivityResult(final int requestCode, int resultCode,
Preference gpsloggerFolder = (Preference) findPreference("gpslogger_folder");
gpsloggerFolder.setSummary(filePath);



} else if (resultCode == Activity.RESULT_CANCELED) {
tracer.debug("No file selected");
}
Expand Down
1 change: 1 addition & 0 deletions gpslogger/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,5 +474,6 @@
<string name="listeners_summary">Which location providers to use when they are available; GPS for satellites, Network for cell tower/wifi, Passive is a special provider that listens for locations requested from other applications.</string>
<string name="listeners_title">Location providers</string>
<string name="autosend_frequency_hint">Number of minutes</string>
<string name="pref_logging_file_no_permissions">That folder is not writable by GPSLogger</string>

</resources>

0 comments on commit 477d76f

Please sign in to comment.