* Add icon: ic_cloud_download_red_24 * Update strings.xml * Add "Revert local changes" button code (fixes #437) * Update model: FolderStatus - add "receiveOnly*" * item_folder_list: Add revert UI button * Update icon: ic_cloud_download_red_24 * Update item_folder_list.xml * Update icon for the override changes button * Imported de translation
|
@ -15,6 +15,7 @@ public class PostRequest extends ApiRequest {
|
|||
|
||||
public static final String URI_DB_IGNORES = "/rest/db/ignores";
|
||||
public static final String URI_DB_OVERRIDE = "/rest/db/override";
|
||||
public static final String URI_DB_REVERT = "/rest/db/revert";
|
||||
public static final String URI_SYSTEM_CONFIG = "/rest/system/config";
|
||||
public static final String URI_SYSTEM_SHUTDOWN = "/rest/system/shutdown";
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ public class FolderStatus {
|
|||
public long needFiles;
|
||||
public long needSymlinks;
|
||||
public long pullErrors;
|
||||
public long receiveOnlyChangedBytes;
|
||||
public long receiveOnlyChangedDeletes;
|
||||
public long receiveOnlyChangedDirectories;
|
||||
public long receiveOnlyChangedFiles;
|
||||
public long receiveOnlyChangedSymlinks;
|
||||
public long receiveOnlyTotalItems;
|
||||
public long sequence;
|
||||
public String state;
|
||||
public String stateChanged;
|
||||
|
|
|
@ -382,6 +382,16 @@ public class RestApi {
|
|||
ImmutableMap.of("folder", folderId), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert local folder changes. This is the same as hitting
|
||||
* the "Revert local changes" button from the web UI.
|
||||
*/
|
||||
public void revertLocalChanges(String folderId) {
|
||||
Log.d(TAG, "revertLocalChanges '" + folderId + "'");
|
||||
new PostRequest(mContext, mUrl, PostRequest.URI_DB_REVERT, mApiKey,
|
||||
ImmutableMap.of("folder", folderId), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends current config to Syncthing.
|
||||
* Will result in a "ConfigSaved" event.
|
||||
|
|
|
@ -95,6 +95,13 @@ public class SyncthingService extends Service {
|
|||
public static final String ACTION_OVERRIDE_CHANGES =
|
||||
"com.github.catfriend1.syncthingandroid.SyncthingService.OVERRIDE_CHANGES";
|
||||
|
||||
/**
|
||||
* Intent action to revert local folder changes.
|
||||
*/
|
||||
public static final String ACTION_REVERT_LOCAL_CHANGES =
|
||||
"com.github.catfriend1.syncthingandroid.SyncthingService.REVERT_LOCAL_CHANGES";
|
||||
|
||||
|
||||
/**
|
||||
* Extra used together with ACTION_IGNORE_DEVICE, ACTION_IGNORE_FOLDER.
|
||||
*/
|
||||
|
@ -349,6 +356,8 @@ public class SyncthingService extends Service {
|
|||
mNotificationHandler.cancelConsentNotification(intent.getIntExtra(EXTRA_NOTIFICATION_ID, 0));
|
||||
} else if (ACTION_OVERRIDE_CHANGES.equals(intent.getAction()) && mCurrentState == State.ACTIVE) {
|
||||
mRestApi.overrideChanges(intent.getStringExtra(EXTRA_FOLDER_ID));
|
||||
} else if (ACTION_REVERT_LOCAL_CHANGES.equals(intent.getAction()) && mCurrentState == State.ACTIVE) {
|
||||
mRestApi.revertLocalChanges(intent.getStringExtra(EXTRA_FOLDER_ID));
|
||||
}
|
||||
return START_STICKY;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
|||
binding.label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label);
|
||||
binding.directory.setText(folder.path);
|
||||
binding.override.setOnClickListener(view -> { onClickOverride(view, folder); } );
|
||||
binding.revert.setOnClickListener(view -> { onClickRevert(view, folder); } );
|
||||
binding.openFolder.setOnClickListener(view -> { FileUtils.openFolder(mContext, folder.path); } );
|
||||
|
||||
// Update folder icon.
|
||||
|
@ -79,6 +80,7 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
|||
if (folderStatus == null) {
|
||||
binding.items.setVisibility(GONE);
|
||||
binding.override.setVisibility(GONE);
|
||||
binding.revert.setVisibility(GONE);
|
||||
binding.size.setVisibility(GONE);
|
||||
binding.state.setVisibility(GONE);
|
||||
setTextOrHide(binding.invalid, folder.invalid);
|
||||
|
@ -89,6 +91,10 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
|||
boolean outOfSync = folderStatus.state.equals("idle") && neededItems > 0;
|
||||
boolean overrideButtonVisible = folder.type.equals(Constants.FOLDER_TYPE_SEND_ONLY) && outOfSync;
|
||||
binding.override.setVisibility(overrideButtonVisible ? VISIBLE : GONE);
|
||||
|
||||
boolean revertButtonVisible = folder.type.equals(Constants.FOLDER_TYPE_RECEIVE_ONLY) && (folderStatus.receiveOnlyTotalItems > 0);
|
||||
binding.revert.setVisibility(revertButtonVisible ? VISIBLE : GONE);
|
||||
|
||||
binding.state.setVisibility(VISIBLE);
|
||||
if (outOfSync) {
|
||||
binding.state.setText(mContext.getString(R.string.status_outofsync));
|
||||
|
@ -204,4 +210,19 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
|||
confirmDialog.show();
|
||||
}
|
||||
|
||||
private void onClickRevert(View view, Folder folder) {
|
||||
AlertDialog.Builder confirmDialog = new AlertDialog.Builder(mContext)
|
||||
.setTitle(R.string.revert_local_changes)
|
||||
.setMessage(R.string.revert_local_changes_question)
|
||||
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
|
||||
// Send "Revert local changes" through our service to the REST API.
|
||||
Intent intent = new Intent(mContext, SyncthingService.class)
|
||||
.putExtra(SyncthingService.EXTRA_FOLDER_ID, folder.id);
|
||||
intent.setAction(SyncthingService.ACTION_REVERT_LOCAL_CHANGES);
|
||||
mContext.startService(intent);
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, (dialogInterface, i) -> {});
|
||||
confirmDialog.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_cloud_download_red_24.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-hdpi/ic_cloud_upload_red_24.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-ldpi/ic_cloud_download_red_24.png
Normal file
After Width: | Height: | Size: 600 B |
BIN
app/src/main/res/drawable-ldpi/ic_cloud_upload_red_24.png
Normal file
After Width: | Height: | Size: 689 B |
BIN
app/src/main/res/drawable-mdpi/ic_cloud_download_red_24.png
Normal file
After Width: | Height: | Size: 673 B |
BIN
app/src/main/res/drawable-mdpi/ic_cloud_upload_red_24.png
Normal file
After Width: | Height: | Size: 882 B |
BIN
app/src/main/res/drawable-xhdpi/ic_cloud_download_red_24.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_cloud_upload_red_24.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_cloud_download_red_24.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_cloud_upload_red_24.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_cloud_download_red_24.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_cloud_upload_red_24.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
|
@ -44,26 +44,49 @@
|
|||
android:ellipsize="end"
|
||||
android:textAppearance="?textAppearanceListItemSecondary" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/override"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/directory"
|
||||
android:contentDescription="@string/override_changes"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:text="@string/override_changes"
|
||||
android:drawableLeft="@android:drawable/ic_menu_upload"
|
||||
android:drawableStart="@android:drawable/ic_menu_upload"
|
||||
android:textSize="12sp" />
|
||||
<RelativeLayout
|
||||
android:id="@+id/override_revert_container"
|
||||
android:layout_below="@id/directory"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/override"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/override_changes"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:text="@string/override_changes"
|
||||
android:drawableLeft="@drawable/ic_cloud_upload_red_24"
|
||||
android:drawableStart="@drawable/ic_cloud_upload_red_24"
|
||||
android:drawablePadding="5sp"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/revert"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/revert_local_changes"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:text="@string/revert_local_changes"
|
||||
android:drawableLeft="@drawable/ic_cloud_download_red_24"
|
||||
android:drawableStart="@drawable/ic_cloud_download_red_24"
|
||||
android:drawablePadding="5sp"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/items"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/override"
|
||||
android:layout_below="@id/override_revert_container"
|
||||
android:textAppearance="?textAppearanceListItemSecondary" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -124,6 +124,14 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
|
|||
|
||||
<string name="override_changes">Änderungen überschreiben</string>
|
||||
|
||||
<!-- Override Changes Confirmation Dialog -->
|
||||
<string name="override_changes_question">Dadurch werden alle Änderungen rückgängig gemacht, die in diesem Ordner auf anderen Geräten vorgenommen wurden. Fortfahren?</string>
|
||||
|
||||
<string name="revert_local_changes">Lokale Änderungen zurücksetzen</string>
|
||||
|
||||
<!-- Revert Local Changes Confirmation Dialog -->
|
||||
<string name="revert_local_changes_question">Dadurch werden alle in diesem Ordner auf diesem Gerät vorgenommenen Änderungen rückgängig gemacht. Fortfahren?</string>
|
||||
|
||||
<string name="open_file_manager">Dateimanager öffnen</string>
|
||||
<string name="open_file_with">Öffne Datei mit</string>
|
||||
<string name="open_file_no_compatible_app">Keine App zum Öffnen der Datei gefunden.</string>
|
||||
|
@ -865,7 +873,7 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
|
|||
</string-array>
|
||||
|
||||
<!-- Possible folder states -->
|
||||
<string name="state_idle">Untätig</string>
|
||||
<string name="state_idle">Aktuell</string>
|
||||
<string name="state_scanning">Scannen</string>
|
||||
<string name="state_scan_waiting">Warte auf Scan</string>
|
||||
<string name="state_syncing_general">Synchronisiere</string>
|
||||
|
|
|
@ -130,6 +130,11 @@ Please report any problems you encounter via Github.</string>
|
|||
<!-- Override Changes Confirmation Dialog -->
|
||||
<string name="override_changes_question">This will undo all changes made on the other devices sharing this folder. Proceed?</string>
|
||||
|
||||
<string name="revert_local_changes">Revert local changes</string>
|
||||
|
||||
<!-- Revert Local Changes Confirmation Dialog -->
|
||||
<string name="revert_local_changes_question">This will undo all changes made on this device within that folder. Proceed?</string>
|
||||
|
||||
<string name="open_file_manager">Open file manager</string>
|
||||
<string name="open_file_with">Open file with</string>
|
||||
<string name="open_file_no_compatible_app">No app found to open the file.</string>
|
||||
|
|