1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 06:11:19 +00:00

Override changes: Show confirmation dialog (fixes #397) (#436)

* FoldersAdapter: Move code into onClickOverride

* Override changes: Show confirmation dialog (fixes #397)

* Update strings.xml
This commit is contained in:
Catfriend1 2019-07-11 13:09:39 +02:00 committed by GitHub
parent 6b9745c800
commit 35839feeb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View file

@ -1,5 +1,6 @@
package com.nutomic.syncthingandroid.views;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
@ -53,13 +54,7 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
Folder folder = getItem(position);
binding.label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label);
binding.directory.setText(folder.path);
binding.override.setOnClickListener(v -> {
// Send "Override 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_OVERRIDE_CHANGES);
mContext.startService(intent);
});
binding.override.setOnClickListener(view -> { onClickOverride(view, folder); } );
binding.openFolder.setOnClickListener(view -> { FileUtils.openFolder(mContext, folder.path); } );
// Update folder icon.
@ -194,5 +189,19 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
}
}
private void onClickOverride(View view, Folder folder) {
AlertDialog.Builder confirmDialog = new AlertDialog.Builder(mContext)
.setTitle(R.string.override_changes)
.setMessage(R.string.override_changes_question)
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
// Send "Override 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_OVERRIDE_CHANGES);
mContext.startService(intent);
})
.setNegativeButton(android.R.string.no, (dialogInterface, i) -> {});
confirmDialog.show();
}
}

View file

@ -127,6 +127,9 @@ Please report any problems you encounter via Github.</string>
<string name="override_changes">Override changes</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="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>