mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 06:11:19 +00:00
* FoldersAdapter: Move code into onClickOverride * Override changes: Show confirmation dialog (fixes #397) * Update strings.xml
This commit is contained in:
parent
6b9745c800
commit
35839feeb9
2 changed files with 19 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.nutomic.syncthingandroid.views;
|
package com.nutomic.syncthingandroid.views;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.databinding.DataBindingUtil;
|
import android.databinding.DataBindingUtil;
|
||||||
|
@ -53,13 +54,7 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
||||||
Folder folder = getItem(position);
|
Folder folder = getItem(position);
|
||||||
binding.label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label);
|
binding.label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label);
|
||||||
binding.directory.setText(folder.path);
|
binding.directory.setText(folder.path);
|
||||||
binding.override.setOnClickListener(v -> {
|
binding.override.setOnClickListener(view -> { onClickOverride(view, folder); } );
|
||||||
// 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.openFolder.setOnClickListener(view -> { FileUtils.openFolder(mContext, folder.path); } );
|
binding.openFolder.setOnClickListener(view -> { FileUtils.openFolder(mContext, folder.path); } );
|
||||||
|
|
||||||
// Update folder icon.
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,9 @@ Please report any problems you encounter via Github.</string>
|
||||||
|
|
||||||
<string name="override_changes">Override changes</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_manager">Open file manager</string>
|
||||||
<string name="open_file_with">Open file with</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>
|
<string name="open_file_no_compatible_app">No app found to open the file.</string>
|
||||||
|
|
Loading…
Reference in a new issue