mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-22 13:34:49 +01:00
reformat the rename conditions a bit
This commit is contained in:
parent
5c144a607b
commit
1da4050d4a
@ -242,18 +242,19 @@ public class MainActivity extends AppCompatActivity
|
||||
public void onClick(View v) {
|
||||
final String newDirName = dirNameET.getText().toString().trim();
|
||||
|
||||
if (!newDirName.isEmpty()) {
|
||||
final File newDir = new File(dir.getParent(), newDirName);
|
||||
if (newDirName.isEmpty()) {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dir.renameTo(newDir)) {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_ok);
|
||||
alertDialog.dismiss();
|
||||
actionMode.finish();
|
||||
final String[] newDirPath = new String[]{newDir.getAbsolutePath()};
|
||||
MediaScannerConnection.scanFile(getApplicationContext(), newDirPath, null, MainActivity.this);
|
||||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
||||
}
|
||||
final File newDir = new File(dir.getParent(), newDirName);
|
||||
|
||||
if (dir.renameTo(newDir)) {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_ok);
|
||||
alertDialog.dismiss();
|
||||
actionMode.finish();
|
||||
final String[] newDirPath = new String[]{newDir.getAbsolutePath()};
|
||||
MediaScannerConnection.scanFile(getApplicationContext(), newDirPath, null, MainActivity.this);
|
||||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
||||
}
|
||||
|
@ -195,19 +195,20 @@ public class ViewPagerActivity extends AppCompatActivity
|
||||
final String fileName = fileNameET.getText().toString().trim();
|
||||
final String extension = extensionET.getText().toString().trim();
|
||||
|
||||
if (!fileName.isEmpty() && !extension.isEmpty()) {
|
||||
final File newFile = new File(file.getParent(), fileName + "." + extension);
|
||||
if (fileName.isEmpty() || extension.isEmpty()) {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_file_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.renameTo(newFile)) {
|
||||
photos.set(pager.getCurrentItem(), newFile.getAbsolutePath());
|
||||
final File newFile = new File(file.getParent(), fileName + "." + extension);
|
||||
|
||||
final String[] changedFiles = {file.getAbsolutePath(), newFile.getAbsolutePath()};
|
||||
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null);
|
||||
updateActionbarTitle();
|
||||
alertDialog.dismiss();
|
||||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_file_error);
|
||||
}
|
||||
if (file.renameTo(newFile)) {
|
||||
photos.set(pager.getCurrentItem(), newFile.getAbsolutePath());
|
||||
|
||||
final String[] changedFiles = {file.getAbsolutePath(), newFile.getAbsolutePath()};
|
||||
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null);
|
||||
updateActionbarTitle();
|
||||
alertDialog.dismiss();
|
||||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_file_error);
|
||||
}
|
||||
|
@ -9,7 +9,9 @@
|
||||
<string name="rename_file">Rename file</string>
|
||||
<string name="rename_folder">Rename folder</string>
|
||||
<string name="rename_file_error">Could not rename the file</string>
|
||||
<string name="rename_file_empty">File name must not be empty</string>
|
||||
<string name="rename_folder_error">Could not rename the folder</string>
|
||||
<string name="rename_folder_empty">Folder name must not be empty</string>
|
||||
<string name="rename_folder_ok">Folder renamed successfully</string>
|
||||
<string name="file_name">File name</string>
|
||||
<string name="folder_name">Folder name</string>
|
||||
|
Loading…
Reference in New Issue
Block a user