1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 04:41:16 +00:00

Added advanced folder picker (fixes #170).

This commit is contained in:
Felix Ableitner 2014-10-28 13:57:40 +02:00
parent 8b563da25d
commit 87fd57bf83
3 changed files with 22 additions and 2 deletions

View file

@ -6,9 +6,11 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.IBinder; import android.os.IBinder;
import android.preference.PreferenceManager;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -19,6 +21,7 @@ import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.syncthing.SyncthingService; import com.nutomic.syncthingandroid.syncthing.SyncthingService;
@ -72,6 +75,11 @@ public class FolderPickerActivity extends SyncthingActivity
mRootDirectories.addAll(Arrays.asList(getExternalFilesDirs(null))); mRootDirectories.addAll(Arrays.asList(getExternalFilesDirs(null)));
} }
mRootDirectories.add(Environment.getExternalStorageDirectory()); mRootDirectories.add(Environment.getExternalStorageDirectory());
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
if (sp.getBoolean("advanced_folder_picker", false)) {
mRootDirectories.add(new File("/"));
}
for (File f : mRootDirectories) { for (File f : mRootDirectories) {
mRootsAdapter.add(f); mRootsAdapter.add(f);
} }
@ -145,8 +153,11 @@ public class FolderPickerActivity extends SyncthingActivity
*/ */
private void createFolder(String name) { private void createFolder(String name) {
File newFolder = new File(mLocation, name); File newFolder = new File(mLocation, name);
newFolder.mkdir(); if (newFolder.mkdir()) {
displayFolder(newFolder); displayFolder(newFolder);
} else {
Toast.makeText(this, R.string.create_folder_failed, Toast.LENGTH_SHORT).show();
}
} }
/** /**

View file

@ -214,6 +214,8 @@ Please report any problems you encounter via Github.</string>
<string name="sync_only_wifi">Sync only on wifi</string> <string name="sync_only_wifi">Sync only on wifi</string>
<string name="advanced_folder_picker">Use advanced Folder Picker</string>
<string name="syncthing_options">Syncthing Options</string> <string name="syncthing_options">Syncthing Options</string>
<string name="listen_address">Sync Protocol Listen Addresses</string> <string name="listen_address">Sync Protocol Listen Addresses</string>
@ -279,6 +281,8 @@ Please report any problems you encounter via Github.</string>
<!-- Menu item to select the current folder --> <!-- Menu item to select the current folder -->
<string name="select_folder">Select Folder</string> <string name="select_folder">Select Folder</string>
<string name="create_folder_failed">Failed to create folder</string>
<!-- SyncthingService --> <!-- SyncthingService -->

View file

@ -16,6 +16,11 @@
android:title="@string/sync_only_wifi" android:title="@string/sync_only_wifi"
android:defaultValue="false" /> android:defaultValue="false" />
<CheckBoxPreference
android:key="advanced_folder_picker"
android:title="@string/advanced_folder_picker"
android:defaultValue="false" />
<PreferenceScreen <PreferenceScreen
android:key="syncthing_options" android:key="syncthing_options"
android:title="@string/syncthing_options" android:title="@string/syncthing_options"