mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Remove pre-kitkat code paths in SFTP plugin
We no longer support KitKat. This simplifies the SFTP plugin quite a bit since it contained a diferent code path for pre-kitkat devices
This commit is contained in:
@@ -266,23 +266,13 @@
|
|||||||
<string name="filter_apps_info">Notifications will be synchronized for the selected apps.</string>
|
<string name="filter_apps_info">Notifications will be synchronized for the selected apps.</string>
|
||||||
<string name="show_notification_if_screen_off">Send notifications only if the screen is off</string>
|
<string name="show_notification_if_screen_off">Send notifications only if the screen is off</string>
|
||||||
<string name="screen_off_notification_state" translatable="false">pref_notification_screen_off</string>
|
<string name="screen_off_notification_state" translatable="false">pref_notification_screen_off</string>
|
||||||
<string name="sftp_sdcard_num">SD card %d</string>
|
|
||||||
<string name="sftp_sdcard">SD card</string>
|
|
||||||
<string name="sftp_readonly">(read only)</string>
|
|
||||||
<string name="sftp_camera">Camera pictures</string>
|
|
||||||
<string name="add_device_dialog_title">Add device</string>
|
<string name="add_device_dialog_title">Add device</string>
|
||||||
<string name="add_device_hint">Hostname or IP address</string>
|
<string name="add_device_hint">Hostname or IP address</string>
|
||||||
<string name="sftp_preference_detected_sdcards">Detected SD cards</string>
|
|
||||||
<string name="sftp_preference_edit_sdcard_title">Edit SD card</string>
|
|
||||||
<string name="sftp_preference_configured_storage_locations">Configured storage locations</string>
|
<string name="sftp_preference_configured_storage_locations">Configured storage locations</string>
|
||||||
<string name="sftp_preference_add_storage_location_title">Add storage location</string>
|
<string name="sftp_preference_add_storage_location_title">Add storage location</string>
|
||||||
<string name="sftp_preference_edit_storage_location">Edit storage location</string>
|
<string name="sftp_preference_edit_storage_location">Edit storage location</string>
|
||||||
<string name="sftp_preference_add_camera_shortcut">Add camera folder shortcut</string>
|
|
||||||
<string name="sftp_preference_add_camera_shortcut_summary_on">Add a shortcut to the camera folder</string>
|
|
||||||
<string name="sftp_preference_add_camera_shortcut_summary_off">Do not add a shortcut to the camera folder</string>
|
|
||||||
<string name="sftp_preference_key_preference_category" translatable="false">key_sftp_preference_category</string>
|
<string name="sftp_preference_key_preference_category" translatable="false">key_sftp_preference_category</string>
|
||||||
<string name="sftp_preference_key_add_storage" translatable="false">key_sftp_add_storage</string>
|
<string name="sftp_preference_key_add_storage" translatable="false">key_sftp_add_storage</string>
|
||||||
<string name="sftp_preference_key_add_camera_shortcut" translatable="false">key_sftp_add_camera_shotcut</string>
|
|
||||||
<string name="sftp_preference_key_storage_info" translatable="false">key_sftp_storage_info%d"</string>
|
<string name="sftp_preference_key_storage_info" translatable="false">key_sftp_storage_info%d"</string>
|
||||||
<string name="sftp_preference_key_storage_info_list" translatable="false">key_sftp_storage_info_list</string>
|
<string name="sftp_preference_key_storage_info_list" translatable="false">key_sftp_storage_info_list</string>
|
||||||
<string name="sftp_storage_preference_storage_location">Storage location</string>
|
<string name="sftp_storage_preference_storage_location">Storage location</string>
|
||||||
@@ -292,7 +282,6 @@
|
|||||||
<string name="sftp_storage_preference_display_name_already_used">This display name is already used</string>
|
<string name="sftp_storage_preference_display_name_already_used">This display name is already used</string>
|
||||||
<string name="sftp_storage_preference_display_name_cannot_be_empty">Display name cannot be empty</string>
|
<string name="sftp_storage_preference_display_name_cannot_be_empty">Display name cannot be empty</string>
|
||||||
<string name="sftp_action_mode_menu_delete">Delete</string>
|
<string name="sftp_action_mode_menu_delete">Delete</string>
|
||||||
<string name="sftp_no_sdcard_detected">No SD card detected</string>
|
|
||||||
<string name="sftp_no_storage_locations_configured">No storage locations configured</string>
|
<string name="sftp_no_storage_locations_configured">No storage locations configured</string>
|
||||||
<string name="sftp_saf_permission_explanation">To access files remotely you have to configure storage locations</string>
|
<string name="sftp_saf_permission_explanation">To access files remotely you have to configure storage locations</string>
|
||||||
<string name="no_players_connected">No players found</string>
|
<string name="no_players_connected">No players found</string>
|
||||||
|
@@ -4,9 +4,8 @@
|
|||||||
tools:keep="@xml/sftpplugin_preferences">
|
tools:keep="@xml/sftpplugin_preferences">
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="@string/sftp_preference_key_preference_category"
|
android:key="@string/sftp_preference_key_preference_category"
|
||||||
android:title="@string/sftp_preference_detected_sdcards"
|
android:title="@string/sftp_preference_configured_storage_locations"
|
||||||
android:persistent="false">
|
android:persistent="false">
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<org.kde.kdeconnect.Plugins.SftpPlugin.StoragePreference
|
<org.kde.kdeconnect.Plugins.SftpPlugin.StoragePreference
|
||||||
@@ -14,11 +13,4 @@
|
|||||||
android:icon="@drawable/ic_add"
|
android:icon="@drawable/ic_add"
|
||||||
android:title="@string/sftp_preference_add_storage_location_title"
|
android:title="@string/sftp_preference_add_storage_location_title"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<androidx.preference.SwitchPreferenceCompat
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:key="@string/sftp_preference_key_add_camera_shortcut"
|
|
||||||
android:summaryOff="@string/sftp_preference_add_camera_shortcut_summary_off"
|
|
||||||
android:summaryOn="@string/sftp_preference_add_camera_shortcut_summary_on"
|
|
||||||
android:title="@string/sftp_preference_add_camera_shortcut"/>
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -40,17 +40,6 @@ class AndroidFileSystemFactory implements FileSystemFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileSystemView createFileSystemView(final Session username) {
|
public FileSystemView createFileSystemView(final Session username) {
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
|
||||||
if (roots.size() == 0) {
|
|
||||||
throw new RuntimeException("roots cannot be empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] rootsAsString = new String[roots.size()];
|
|
||||||
roots.keySet().toArray(rootsAsString);
|
|
||||||
|
|
||||||
return new AndroidFileSystemView(roots, rootsAsString[0], username.getUsername(), context);
|
|
||||||
} else {
|
|
||||||
return new AndroidSafFileSystemView(roots, username.getUsername(), context);
|
return new AndroidSafFileSystemView(roots, username.getUsername(), context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@@ -39,7 +39,6 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
private final static String PACKET_TYPE_SFTP_REQUEST = "kdeconnect.sftp.request";
|
private final static String PACKET_TYPE_SFTP_REQUEST = "kdeconnect.sftp.request";
|
||||||
|
|
||||||
static int PREFERENCE_KEY_STORAGE_INFO_LIST = R.string.sftp_preference_key_storage_info_list;
|
static int PREFERENCE_KEY_STORAGE_INFO_LIST = R.string.sftp_preference_key_storage_info_list;
|
||||||
private static int PREFERENCE_KEY_ADD_CAMERA_SHORTCUT = R.string.sftp_preference_key_add_camera_shortcut;
|
|
||||||
|
|
||||||
private static final SimpleSftpServer server = new SimpleSftpServer();
|
private static final SimpleSftpServer server = new SimpleSftpServer();
|
||||||
|
|
||||||
@@ -57,11 +56,6 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
try {
|
try {
|
||||||
server.init(context, device);
|
server.init(context, device);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
|
||||||
return SftpSettingsFragment.getStorageInfoList(context, this).size() != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("SFTP", "Exception in server.init()", e);
|
Log.e("SFTP", "Exception in server.init()", e);
|
||||||
@@ -71,13 +65,9 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkOptionalPermissions() {
|
public boolean checkOptionalPermissions() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
return SftpSettingsFragment.getStorageInfoList(context, this).size() != 0;
|
return SftpSettingsFragment.getStorageInfoList(context, this).size() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertDialogFragment getOptionalPermissionExplanationDialog() {
|
public AlertDialogFragment getOptionalPermissionExplanationDialog() {
|
||||||
return new DeviceSettingsAlertDialogFragment.Builder()
|
return new DeviceSettingsAlertDialogFragment.Builder()
|
||||||
@@ -111,15 +101,8 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
getPathsAndNamesForStorageInfoList(paths, pathNames, storageInfoList);
|
getPathsAndNamesForStorageInfoList(paths, pathNames, storageInfoList);
|
||||||
} else {
|
} else {
|
||||||
NetworkPacket np2 = new NetworkPacket(PACKET_TYPE_SFTP);
|
NetworkPacket np2 = new NetworkPacket(PACKET_TYPE_SFTP);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
np2.set("errorMessage", context.getString(R.string.sftp_no_storage_locations_configured));
|
np2.set("errorMessage", context.getString(R.string.sftp_no_storage_locations_configured));
|
||||||
} else {
|
|
||||||
np2.set("errorMessage", context.getString(R.string.sftp_no_sdcard_detected));
|
|
||||||
}
|
|
||||||
|
|
||||||
device.sendPacket(np2);
|
device.sendPacket(np2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,14 +141,6 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
StorageInfo prevInfo = null;
|
StorageInfo prevInfo = null;
|
||||||
StringBuilder pathBuilder = new StringBuilder();
|
StringBuilder pathBuilder = new StringBuilder();
|
||||||
|
|
||||||
boolean addCameraShortcuts = false;
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
|
||||||
if (preferences != null) {
|
|
||||||
addCameraShortcuts = preferences.getBoolean(context.getString(PREFERENCE_KEY_ADD_CAMERA_SHORTCUT), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (StorageInfo curInfo : storageInfoList) {
|
for (StorageInfo curInfo : storageInfoList) {
|
||||||
pathBuilder.setLength(0);
|
pathBuilder.setLength(0);
|
||||||
pathBuilder.append("/");
|
pathBuilder.append("/");
|
||||||
@@ -188,17 +163,6 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
|
|
||||||
paths.add(pathBuilder.toString());
|
paths.add(pathBuilder.toString());
|
||||||
pathNames.add(curInfo.displayName);
|
pathNames.add(curInfo.displayName);
|
||||||
|
|
||||||
if (addCameraShortcuts) {
|
|
||||||
if (new File(curInfo.uri.getPath(), "/DCIM/Camera").exists()) {
|
|
||||||
paths.add(pathBuilder.toString() + "/DCIM/Camera");
|
|
||||||
if (storageInfoList.size() > 1) {
|
|
||||||
pathNames.add(context.getString(R.string.sftp_camera) + "(" + curInfo.displayName + ")");
|
|
||||||
} else {
|
|
||||||
pathNames.add(context.getString(R.string.sftp_camera));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,14 +204,11 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
@Override
|
@Override
|
||||||
public void copyGlobalToDeviceSpecificSettings(SharedPreferences globalSharedPreferences) {
|
public void copyGlobalToDeviceSpecificSettings(SharedPreferences globalSharedPreferences) {
|
||||||
String KeyStorageInfoList = context.getString(PREFERENCE_KEY_STORAGE_INFO_LIST);
|
String KeyStorageInfoList = context.getString(PREFERENCE_KEY_STORAGE_INFO_LIST);
|
||||||
String KeyAddCameraShortcut = context.getString(PREFERENCE_KEY_ADD_CAMERA_SHORTCUT);
|
|
||||||
|
|
||||||
if (this.preferences != null &&
|
if (this.preferences != null && !this.preferences.contains(KeyStorageInfoList)) {
|
||||||
(!this.preferences.contains(KeyStorageInfoList) || !this.preferences.contains(KeyAddCameraShortcut))) {
|
|
||||||
this.preferences
|
this.preferences
|
||||||
.edit()
|
.edit()
|
||||||
.putString(KeyStorageInfoList, globalSharedPreferences.getString(KeyStorageInfoList, "[]"))
|
.putString(KeyStorageInfoList, globalSharedPreferences.getString(KeyStorageInfoList, "[]"))
|
||||||
.putBoolean(KeyAddCameraShortcut, globalSharedPreferences.getBoolean(KeyAddCameraShortcut, true))
|
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,7 +218,6 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
sharedPreferences
|
sharedPreferences
|
||||||
.edit()
|
.edit()
|
||||||
.remove(context.getString(PREFERENCE_KEY_STORAGE_INFO_LIST))
|
.remove(context.getString(PREFERENCE_KEY_STORAGE_INFO_LIST))
|
||||||
.remove(context.getString(PREFERENCE_KEY_ADD_CAMERA_SHORTCUT))
|
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,8 +228,7 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if (key.equals(context.getString(PREFERENCE_KEY_STORAGE_INFO_LIST)) ||
|
if (key.equals(context.getString(PREFERENCE_KEY_STORAGE_INFO_LIST))) {
|
||||||
key.equals(context.getString(PREFERENCE_KEY_ADD_CAMERA_SHORTCUT))) {
|
|
||||||
//TODO: There used to be a way to request an un-mount (see desktop SftpPlugin's Mounter::onPackageReceived) but that is not handled anymore by the SftpPlugin on KDE.
|
//TODO: There used to be a way to request an un-mount (see desktop SftpPlugin's Mounter::onPackageReceived) but that is not handled anymore by the SftpPlugin on KDE.
|
||||||
if (server.isStarted()) {
|
if (server.isStarted()) {
|
||||||
server.stop();
|
server.stop();
|
||||||
|
@@ -47,8 +47,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
//TODO: Is it possible on API 19 to select a directory and then have write permission for everything beneath it
|
|
||||||
//TODO: Is it necessary to check if uri permissions are still in place? If it is make the user aware of the fact (red text or something)
|
|
||||||
public class SftpSettingsFragment
|
public class SftpSettingsFragment
|
||||||
extends PluginSettingsFragment
|
extends PluginSettingsFragment
|
||||||
implements StoragePreferenceDialogFragment.Callback,
|
implements StoragePreferenceDialogFragment.Callback,
|
||||||
@@ -100,34 +98,16 @@ public class SftpSettingsFragment
|
|||||||
int colorAccent = ta.getColor(0, 0);
|
int colorAccent = ta.getColor(0, 0);
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
|
|
||||||
int sdkInt = Build.VERSION.SDK_INT;
|
|
||||||
|
|
||||||
storageInfoList = getStorageInfoList(requireContext(), plugin);
|
storageInfoList = getStorageInfoList(requireContext(), plugin);
|
||||||
|
|
||||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
preferenceCategory = preferenceScreen
|
preferenceCategory = preferenceScreen
|
||||||
.findPreference(getString(R.string.sftp_preference_key_preference_category));
|
.findPreference(getString(R.string.sftp_preference_key_preference_category));
|
||||||
|
|
||||||
if (sdkInt <= 19) {
|
|
||||||
preferenceCategory.setTitle(R.string.sftp_preference_detected_sdcards);
|
|
||||||
} else {
|
|
||||||
preferenceCategory.setTitle(R.string.sftp_preference_configured_storage_locations);
|
|
||||||
}
|
|
||||||
|
|
||||||
addStoragePreferences(preferenceCategory);
|
addStoragePreferences(preferenceCategory);
|
||||||
|
|
||||||
Preference addStoragePreference = preferenceScreen.findPreference(getString(R.string.sftp_preference_key_add_storage));
|
Preference addStoragePreference = preferenceScreen.findPreference(getString(R.string.sftp_preference_key_add_storage));
|
||||||
addStoragePreference.getIcon().setColorFilter(colorAccent, PorterDuff.Mode.SRC_IN);
|
addStoragePreference.getIcon().setColorFilter(colorAccent, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (sdkInt <= 19) {
|
|
||||||
addStoragePreference.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Preference addCameraShortcutPreference = preferenceScreen.findPreference(getString(R.string.sftp_preference_key_add_camera_shortcut));
|
|
||||||
|
|
||||||
if (sdkInt > 19) {
|
|
||||||
addCameraShortcutPreference.setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addStoragePreferences(PreferenceCategory preferenceCategory) {
|
private void addStoragePreferences(PreferenceCategory preferenceCategory) {
|
||||||
@@ -143,17 +123,11 @@ public class SftpSettingsFragment
|
|||||||
SftpPlugin.StorageInfo storageInfo = storageInfoList.get(i);
|
SftpPlugin.StorageInfo storageInfo = storageInfoList.get(i);
|
||||||
StoragePreference preference = new StoragePreference(context);
|
StoragePreference preference = new StoragePreference(context);
|
||||||
preference.setOnPreferenceChangeListener(this);
|
preference.setOnPreferenceChangeListener(this);
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
preference.setOnLongClickListener(this);
|
preference.setOnLongClickListener(this);
|
||||||
}
|
|
||||||
preference.setKey(getString(R.string.sftp_preference_key_storage_info, i));
|
preference.setKey(getString(R.string.sftp_preference_key_storage_info, i));
|
||||||
preference.setIcon(android.R.color.transparent);
|
preference.setIcon(android.R.color.transparent);
|
||||||
preference.setDefaultValue(storageInfo);
|
preference.setDefaultValue(storageInfo);
|
||||||
if (storageInfo.isFileUri()) {
|
|
||||||
preference.setDialogTitle(R.string.sftp_preference_edit_sdcard_title);
|
|
||||||
} else {
|
|
||||||
preference.setDialogTitle(R.string.sftp_preference_edit_storage_location);
|
preference.setDialogTitle(R.string.sftp_preference_edit_storage_location);
|
||||||
}
|
|
||||||
|
|
||||||
preferenceCategory.addPreference(preference);
|
preferenceCategory.addPreference(preference);
|
||||||
}
|
}
|
||||||
@@ -266,53 +240,9 @@ public class SftpSettingsFragment
|
|||||||
Log.e("SFTPSettings", "Couldn't load storage info", e);
|
Log.e("SFTPSettings", "Couldn't load storage info", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT <= 19) {
|
|
||||||
addDetectedSDCardsToStorageInfoList(context, storageInfoList);
|
|
||||||
}
|
|
||||||
|
|
||||||
return storageInfoList;
|
return storageInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addDetectedSDCardsToStorageInfoList(@NonNull Context context, List<SftpPlugin.StorageInfo> storageInfoList) {
|
|
||||||
List<StorageHelper.StorageInfo> storageHelperInfoList = StorageHelper.getStorageList();
|
|
||||||
|
|
||||||
for (StorageHelper.StorageInfo info : storageHelperInfoList) {
|
|
||||||
// on at least API 17 emulator Environment.isExternalStorageRemovable returns false
|
|
||||||
if (info.removable || info.path.startsWith(Environment.getExternalStorageDirectory().getPath())) {
|
|
||||||
StringBuilder displayNameBuilder = new StringBuilder();
|
|
||||||
StringBuilder displayNameReadOnlyBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
Uri sdCardUri = Uri.fromFile(new File(info.path));
|
|
||||||
|
|
||||||
if (isAlreadyConfigured(storageInfoList, sdCardUri)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = 1;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (i == 1) {
|
|
||||||
displayNameBuilder.append(context.getString(R.string.sftp_sdcard));
|
|
||||||
} else {
|
|
||||||
displayNameBuilder.setLength(0);
|
|
||||||
displayNameBuilder.append(context.getString(R.string.sftp_sdcard_num, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
displayNameReadOnlyBuilder
|
|
||||||
.append(displayNameBuilder)
|
|
||||||
.append(" ")
|
|
||||||
.append(context.getString(R.string.sftp_readonly));
|
|
||||||
|
|
||||||
i++;
|
|
||||||
} while (!isDisplayNameUnique(storageInfoList, displayNameBuilder.toString(), displayNameReadOnlyBuilder.toString()));
|
|
||||||
|
|
||||||
String displayName = info.readonly ?
|
|
||||||
displayNameReadOnlyBuilder.toString() : displayNameBuilder.toString();
|
|
||||||
|
|
||||||
storageInfoList.add(new SftpPlugin.StorageInfo(displayName, Uri.fromFile(new File(info.path))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isDisplayNameUnique(List<SftpPlugin.StorageInfo> storageInfoList, String displayName, String displayNameReadOnly) {
|
private static boolean isDisplayNameUnique(List<SftpPlugin.StorageInfo> storageInfoList, String displayName, String displayNameReadOnly) {
|
||||||
for (SftpPlugin.StorageInfo info : storageInfoList) {
|
for (SftpPlugin.StorageInfo info : storageInfoList) {
|
||||||
@@ -470,7 +400,6 @@ public class SftpSettingsFragment
|
|||||||
if (preference.checkbox.isChecked()) {
|
if (preference.checkbox.isChecked()) {
|
||||||
SftpPlugin.StorageInfo info = storageInfoList.remove(i);
|
SftpPlugin.StorageInfo info = storageInfoList.remove(i);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
try {
|
try {
|
||||||
// This throws when trying to release a URI we don't have access to
|
// This throws when trying to release a URI we don't have access to
|
||||||
requireContext().getContentResolver().releasePersistableUriPermission(info.uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
requireContext().getContentResolver().releasePersistableUriPermission(info.uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
@@ -480,7 +409,6 @@ public class SftpSettingsFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
handleChangedStorageInfoList();
|
handleChangedStorageInfoList();
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user