From 3899abf454c4e3288d4d443ad30fdc0738d759aa Mon Sep 17 00:00:00 2001 From: Unrud Date: Mon, 13 Jun 2016 01:13:32 +0200 Subject: [PATCH] Use folderLabel from FolderRejected events Show folder label in notification and preset value for new folder. --- .../nutomic/syncthingandroid/fragments/FolderFragment.java | 4 ++++ .../nutomic/syncthingandroid/syncthing/EventProcessor.java | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java index 29933ec5..f38f9a7e 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java @@ -55,6 +55,9 @@ public class FolderFragment extends Fragment public static final String EXTRA_FOLDER_ID = "com.nutomic.syncthingandroid.fragments.FolderFragment.FOLDER_ID"; + public static final String EXTRA_FOLDER_LABEL = + "com.nutomic.syncthingandroid.fragments.FolderFragment.FOLDER_LABEL"; + public static final String EXTRA_DEVICE_ID = "com.nutomic.syncthingandroid.fragments.FolderFragment.DEVICE_ID"; @@ -362,6 +365,7 @@ public class FolderFragment extends Fragment private void initFolder() { mFolder = new RestApi.Folder(); mFolder.id = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_ID); + mFolder.label = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_LABEL);; mFolder.path = ""; mFolder.rescanIntervalS = 259200; // Scan every 3 days (in case inotify dropped some changes) mFolder.deviceIds = new ArrayList<>(); diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java index 14b3e016..df551cea 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java @@ -109,13 +109,15 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene case "FolderRejected": deviceId = data.getString("device"); String folderId = data.getString("folder"); + String folderLabel = data.getString("folderLabel"); Log.d(TAG, "Device " + deviceId + " wants to share folder " + folderId); intent = new Intent(mContext, SettingsActivity.class) .setAction(SettingsActivity.ACTION_FOLDER_SETTINGS) .putExtra(SettingsActivity.EXTRA_IS_CREATE, true) .putExtra(FolderFragment.EXTRA_DEVICE_ID, deviceId) - .putExtra(FolderFragment.EXTRA_FOLDER_ID, folderId); + .putExtra(FolderFragment.EXTRA_FOLDER_ID, folderId) + .putExtra(FolderFragment.EXTRA_FOLDER_LABEL, folderLabel); pi = PendingIntent.getActivity(mContext, 0, intent, 0); String deviceName = null; @@ -123,7 +125,8 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene if (d.deviceID.equals(deviceId)) deviceName = RestApi.getDeviceDisplayName(d); } - title = mContext.getString(R.string.folder_rejected, deviceName, folderId); + title = mContext.getString(R.string.folder_rejected, deviceName, + folderLabel.isEmpty() ? folderId : folderLabel + " (" + folderId + ")"); notify(title, pi); break;