diff --git a/app/src/main/java/com/termux/app/activities/ReportActivity.java b/app/src/main/java/com/termux/app/activities/ReportActivity.java index 57a4ae3c..3bf5bdce 100644 --- a/app/src/main/java/com/termux/app/activities/ReportActivity.java +++ b/app/src/main/java/com/termux/app/activities/ReportActivity.java @@ -46,9 +46,9 @@ public class ReportActivity extends AppCompatActivity { Bundle bundle = null; Intent intent = getIntent(); - if(intent != null) + if (intent != null) bundle = intent.getExtras(); - else if(savedInstanceState != null) + else if (savedInstanceState != null) bundle = savedInstanceState; updateUI(bundle); @@ -60,7 +60,7 @@ public class ReportActivity extends AppCompatActivity { super.onNewIntent(intent); setIntent(intent); - if(intent != null) + if (intent != null) updateUI(intent.getExtras()); } @@ -148,12 +148,12 @@ public class ReportActivity extends AppCompatActivity { mReportMarkdownString = ReportInfo.getReportInfoMarkdownString(mReportInfo); mReportActivityMarkdownString = ""; - if(mReportInfo.reportStringPrefix != null) + if (mReportInfo.reportStringPrefix != null) mReportActivityMarkdownString += mReportInfo.reportStringPrefix; mReportActivityMarkdownString += mReportMarkdownString; - if(mReportInfo.reportStringSuffix != null) + if (mReportInfo.reportStringSuffix != null) mReportActivityMarkdownString += mReportInfo.reportStringSuffix; } diff --git a/app/src/main/java/com/termux/app/crash/CrashHandler.java b/app/src/main/java/com/termux/app/crash/CrashHandler.java index 7de2f1aa..a1f18f07 100644 --- a/app/src/main/java/com/termux/app/crash/CrashHandler.java +++ b/app/src/main/java/com/termux/app/crash/CrashHandler.java @@ -26,7 +26,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler { * Set default uncaught crash handler of current thread to {@link CrashHandler}. */ public static void setCrashHandler(final Context context) { - if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CrashHandler)) { + if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CrashHandler)) { Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(context)); } } diff --git a/app/src/main/java/com/termux/app/crash/CrashUtils.java b/app/src/main/java/com/termux/app/crash/CrashUtils.java index c4d900d8..e1af3dd0 100644 --- a/app/src/main/java/com/termux/app/crash/CrashUtils.java +++ b/app/src/main/java/com/termux/app/crash/CrashUtils.java @@ -57,7 +57,7 @@ public class CrashUtils { // Write report string to crash log file String errmsg = FileUtils.writeStringToFile(context, "crash log", TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH, Charset.defaultCharset(), reportString.toString(), false); - if(errmsg != null) { + if (errmsg != null) { Logger.logError(LOG_TAG, errmsg); } } @@ -77,7 +77,7 @@ public class CrashUtils { * @param logTagParam The log tag to use for logging. */ public static void notifyCrash(final Context context, final String logTagParam) { - if(context == null) return; + if (context == null) return; TermuxAppSharedPreferences preferences = new TermuxAppSharedPreferences(context); @@ -90,7 +90,7 @@ public class CrashUtils { public void run() { String logTag = DataUtils.getDefaultIfNull(logTagParam, LOG_TAG); - if(!FileUtils.regularFileExists(TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH, false)) + if (!FileUtils.regularFileExists(TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH, false)) return; String errmsg; @@ -98,20 +98,20 @@ public class CrashUtils { // Read report string from crash log file errmsg = FileUtils.readStringFromFile(context, "crash log", TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH, Charset.defaultCharset(), reportStringBuilder, false); - if(errmsg != null) { + if (errmsg != null) { Logger.logError(logTag, errmsg); return; } // Move crash log file to backup location if it exists FileUtils.moveRegularFile(context, "crash log", TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH, TermuxConstants.TERMUX_CRASH_LOG_BACKUP_FILE_PATH, true); - if(errmsg != null) { + if (errmsg != null) { Logger.logError(logTag, errmsg); } String reportString = reportStringBuilder.toString(); - if(reportString == null || reportString.isEmpty()) + if (reportString == null || reportString.isEmpty()) return; // Send a notification to show the crash log which when clicked will open the {@link ReportActivity} @@ -128,12 +128,12 @@ public class CrashUtils { // Build the notification Notification.Builder builder = getCrashReportsNotificationBuilder(context, title, null, null, pendingIntent, NotificationUtils.NOTIFICATION_MODE_VIBRATE); - if(builder == null) return; + if (builder == null) return; // Send the notification int nextNotificationId = NotificationUtils.getNextNotificationId(context); NotificationManager notificationManager = NotificationUtils.getNotificationManager(context); - if(notificationManager != null) + if (notificationManager != null) notificationManager.notify(nextNotificationId, builder.build()); } }.start(); @@ -158,7 +158,7 @@ public class CrashUtils { NOTIFICATION_CHANNEL_ID_CRASH_REPORT_ERRORS, Notification.PRIORITY_HIGH, title, notifiationText, notificationBigText, pendingIntent, notificationMode); - if(builder == null) return null; + if (builder == null) return null; // Enable timestamp builder.setShowWhen(true); diff --git a/app/src/main/java/com/termux/app/file/FileUtils.java b/app/src/main/java/com/termux/app/file/FileUtils.java index 4e5abadd..b91cd2e4 100644 --- a/app/src/main/java/com/termux/app/file/FileUtils.java +++ b/app/src/main/java/com/termux/app/file/FileUtils.java @@ -41,7 +41,7 @@ public class FileUtils { * @return Returns the {@code expand path}. */ public static String getExpandedTermuxPath(String path) { - if(path != null && !path.isEmpty()) { + if (path != null && !path.isEmpty()) { path = path.replaceAll("^\\$PREFIX$", TermuxConstants.TERMUX_PREFIX_DIR_PATH); path = path.replaceAll("^\\$PREFIX/", TermuxConstants.TERMUX_PREFIX_DIR_PATH + "/"); path = path.replaceAll("^~/$", TermuxConstants.TERMUX_HOME_DIR_PATH); @@ -58,7 +58,7 @@ public class FileUtils { * @return Returns the {@code unexpand path}. */ public static String getUnExpandedTermuxPath(String path) { - if(path != null && !path.isEmpty()) { + if (path != null && !path.isEmpty()) { path = path.replaceAll("^" + Pattern.quote(TermuxConstants.TERMUX_PREFIX_DIR_PATH) + "/", "\\$PREFIX/"); path = path.replaceAll("^" + Pattern.quote(TermuxConstants.TERMUX_HOME_DIR_PATH) + "/", "~/"); } @@ -88,7 +88,7 @@ public class FileUtils { public static String getCanonicalPath(String path, final String prefixForNonAbsolutePath, final boolean expandPath) { if (path == null) path = ""; - if(expandPath) + if (expandPath) path = getExpandedTermuxPath(path); String absolutePath; @@ -153,7 +153,7 @@ public class FileUtils { String normalizedDirPath = normalizePath(dirPath); - if(ensureUnder) + if (ensureUnder) return !path.equals(normalizedDirPath) && path.startsWith(normalizedDirPath + "/"); else return path.startsWith(normalizedDirPath + "/"); @@ -276,7 +276,7 @@ public class FileUtils { if (setPermissions && permissionsToCheck != null && fileType == FileType.REGULAR) { // If there is not parentDirPath restriction or path is under parentDirPath if (parentDirPath == null || (isPathUnderParentDirPath && getFileType(parentDirPath, false) == FileType.DIRECTORY)) { - if(setMissingPermissionsOnly) + if (setMissingPermissionsOnly) setMissingFilePermissions(label + "file", filePath, permissionsToCheck); else setFilePermissions(label + "file", filePath, permissionsToCheck); @@ -369,7 +369,7 @@ public class FileUtils { // If setPermissions is enabled and path is a directory if (setPermissions && permissionsToCheck != null && fileType == FileType.DIRECTORY) { - if(setMissingPermissionsOnly) + if (setMissingPermissionsOnly) setMissingFilePermissions(label + "directory", filePath, permissionsToCheck); else setFilePermissions(label + "directory", filePath, permissionsToCheck); @@ -471,13 +471,13 @@ public class FileUtils { // Create the file parent directory errmsg = createParentDirectoryFile(context, label + "regular file parent", filePath); - if(errmsg != null) + if (errmsg != null) return errmsg; try { Logger.logVerbose(LOG_TAG, "Creating " + label + "regular file at path \"" + filePath + "\""); - if(!file.createNewFile()) + if (!file.createNewFile()) return context.getString(R.string.error_creating_file_failed, label + "regular file", filePath); } catch (Exception e) { return context.getString(R.string.error_creating_file_failed_with_exception, label + "regular file", filePath, e.getMessage()); @@ -509,7 +509,7 @@ public class FileUtils { File file = new File(filePath); String fileParentPath = file.getParent(); - if(fileParentPath != null) + if (fileParentPath != null) return createDirectoryFile(context, label, fileParentPath, null, false, false); else @@ -648,7 +648,7 @@ public class FileUtils { // If target path is relative instead of absolute if (!targetFilePath.startsWith("/")) { String destFileParentPath = destFile.getParent(); - if(destFileParentPath != null) + if (destFileParentPath != null) targetFileAbsolutePath = destFileParentPath + "/" + targetFilePath; } @@ -658,29 +658,29 @@ public class FileUtils { // If target file does not exist if (targetFileType == FileType.NO_EXIST) { // If dangling symlink should not be allowed, then return with error - if(!allowDangling) + if (!allowDangling) return context.getString(R.string.error_file_not_found_at_path, label + "symlink target file", targetFileAbsolutePath); } // If destination exists - if(destFileType != FileType.NO_EXIST) { + if (destFileType != FileType.NO_EXIST) { // If destination must not be overwritten - if(!overwrite) { + if (!overwrite) { return null; } // If overwriteOnlyIfDestIsASymlink is enabled but destination file is not a symlink - if(overwriteOnlyIfDestIsASymlink && destFileType != FileType.SYMLINK) + if (overwriteOnlyIfDestIsASymlink && destFileType != FileType.SYMLINK) return context.getString(R.string.error_cannot_overwrite_a_non_symlink_file_type, label + " file", destFilePath, targetFilePath, destFileType.getName()); // Delete the destination file errmsg = deleteFile(context, label + "symlink destination", destFilePath, true); - if(errmsg != null) + if (errmsg != null) return errmsg; } else { // Create the destination file parent directory errmsg = createParentDirectoryFile(context, label + "symlink destination file parent", destFilePath); - if(errmsg != null) + if (errmsg != null) return errmsg; } @@ -942,7 +942,7 @@ public class FileUtils { // If source file does not exist if (srcFileType == FileType.NO_EXIST) { // If copy or move is to be ignored if source file is not found - if(ignoreNonExistentSrcFile) + if (ignoreNonExistentSrcFile) return null; // Else return with error else @@ -950,7 +950,7 @@ public class FileUtils { } // If the file type of the source file does not exist in the allowedFileTypeFlags, then return with error - if((allowedFileTypeFlags & srcFileType.getValue()) <= 0) + if ((allowedFileTypeFlags & srcFileType.getValue()) <= 0) return context.getString(R.string.error_file_not_an_allowed_file_type, label + "source file meant to be " + modePast, srcFilePath, FileTypes.convertFileTypeFlagsToNamesString(allowedFileTypeFlags)); // If source and destination file path are the same @@ -958,19 +958,19 @@ public class FileUtils { return context.getString(R.string.error_copying_or_moving_file_to_same_path, mode + " " + label + "source file", srcFilePath, destFilePath); // If destination exists - if(destFileType != FileType.NO_EXIST) { + if (destFileType != FileType.NO_EXIST) { // If destination must not be overwritten - if(!overwrite) { + if (!overwrite) { return null; } // If overwriteOnlyIfDestSameFileTypeAsSrc is enabled but destination file does not match source file type - if(overwriteOnlyIfDestSameFileTypeAsSrc && destFileType != srcFileType) + if (overwriteOnlyIfDestSameFileTypeAsSrc && destFileType != srcFileType) return context.getString(R.string.error_cannot_overwrite_a_different_file_type, label + "source file", mode.toLowerCase(), srcFilePath, destFilePath, destFileType.getName(), srcFileType.getName()); // Delete the destination file errmsg = deleteFile(context, label + "destination file", destFilePath, true); - if(errmsg != null) + if (errmsg != null) return errmsg; } @@ -979,14 +979,14 @@ public class FileUtils { boolean copyFile = !moveFile; // If moveFile is true - if(moveFile) { + if (moveFile) { // We first try to rename source file to destination file to save a copy operation in case both source and destination are on the same filesystem Logger.logVerbose(LOG_TAG, "Attempting to rename source to destination."); // https://cs.android.com/android/platform/superproject/+/android-11.0.0_r3:libcore/ojluni/src/main/java/java/io/UnixFileSystem.java;l=358 // https://cs.android.com/android/platform/superproject/+/android-11.0.0_r3:libcore/luni/src/main/java/android/system/Os.java;l=512 // Uses File.getPath() to get the path of source and destination and not the canonical path - if(!srcFile.renameTo(destFile)) { + if (!srcFile.renameTo(destFile)) { // If destination directory is a subdirectory of the source directory // Copying is still allowed by copyDirectory() by excluding destination directory files if (srcFileType == FileType.DIRECTORY && destFileCanonicalPath.startsWith(srcFileCanonicalPath + File.separator)) @@ -999,12 +999,12 @@ public class FileUtils { } // If moveFile is false or renameTo failed while moving - if(copyFile) { + if (copyFile) { Logger.logVerbose(LOG_TAG, "Attempting to copy source to destination."); // Create the dest file parent directory errmsg = createParentDirectoryFile(context, label + "dest file parent", destFilePath); - if(errmsg != null) + if (errmsg != null) return errmsg; if (srcFileType == FileType.DIRECTORY) { @@ -1031,10 +1031,10 @@ public class FileUtils { } // If source file had to be moved - if(moveFile) { + if (moveFile) { // Delete the source file since copying would have succeeded errmsg = deleteFile(context, label + "source file", srcFilePath, true); - if(errmsg != null) + if (errmsg != null) return errmsg; } @@ -1149,7 +1149,7 @@ public class FileUtils { // If file does not exist if (fileType == FileType.NO_EXIST) { // If delete is to be ignored if file does not exist - if(ignoreNonExistentFile) + if (ignoreNonExistentFile) return null; // Else return with error else @@ -1157,7 +1157,7 @@ public class FileUtils { } // If the file type of the file does not exist in the allowedFileTypeFlags, then return with error - if((allowedFileTypeFlags & fileType.getValue()) <= 0) + if ((allowedFileTypeFlags & fileType.getValue()) <= 0) return context.getString(R.string.error_file_not_an_allowed_file_type, label + "file meant to be deleted", filePath, FileTypes.convertFileTypeFlagsToNamesString(allowedFileTypeFlags)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -1185,7 +1185,7 @@ public class FileUtils { // If file still exists after deleting it fileType = getFileType(filePath, false); - if(fileType != FileType.NO_EXIST) + if (fileType != FileType.NO_EXIST) return context.getString(R.string.error_file_still_exists_after_deleting, label + "file meant to be deleted", filePath); } catch (Exception e) { @@ -1254,7 +1254,7 @@ public class FileUtils { // Else create it else { errmsg = createDirectoryFile(context, label, filePath); - if(errmsg != null) + if (errmsg != null) return errmsg; } } catch (Exception e) { @@ -1297,18 +1297,18 @@ public class FileUtils { // If file does not exist if (fileType == FileType.NO_EXIST) { // If reading is to be ignored if file does not exist - if(ignoreNonExistentFile) + if (ignoreNonExistentFile) return null; // Else return with error else return context.getString(R.string.error_file_not_found_at_path, label + "file meant to be read", filePath); } - if(charset == null) charset = Charset.defaultCharset(); + if (charset == null) charset = Charset.defaultCharset(); // Check if charset is supported errmsg = isCharsetSupported(context, charset); - if(errmsg != null) + if (errmsg != null) return errmsg; FileInputStream fileInputStream = null; @@ -1322,7 +1322,7 @@ public class FileUtils { boolean firstLine = true; while ((receiveString = bufferedReader.readLine()) != null ) { - if(!firstLine) dataStringBuilder.append("\n"); else firstLine = false; + if (!firstLine) dataStringBuilder.append("\n"); else firstLine = false; dataStringBuilder.append(receiveString); } @@ -1365,14 +1365,14 @@ public class FileUtils { // Create the file parent directory errmsg = createParentDirectoryFile(context, label + "file parent", filePath); - if(errmsg != null) + if (errmsg != null) return errmsg; - if(charset == null) charset = Charset.defaultCharset(); + if (charset == null) charset = Charset.defaultCharset(); // Check if charset is supported errmsg = isCharsetSupported(context, charset); - if(errmsg != null) + if (errmsg != null) return errmsg; FileOutputStream fileOutputStream = null; @@ -1407,7 +1407,7 @@ public class FileUtils { if (charset == null) return context.getString(R.string.error_null_or_empty_parameter, "charset", "isCharsetSupported"); try { - if(!Charset.isSupported(charset.name())) { + if (!Charset.isSupported(charset.name())) { return context.getString(R.string.error_unsupported_charset, charset.name()); } } catch (Exception e) { diff --git a/app/src/main/java/com/termux/app/file/filesystem/FileTypes.java b/app/src/main/java/com/termux/app/file/filesystem/FileTypes.java index 6f750715..447f11f5 100644 --- a/app/src/main/java/com/termux/app/file/filesystem/FileTypes.java +++ b/app/src/main/java/com/termux/app/file/filesystem/FileTypes.java @@ -90,7 +90,7 @@ public class FileTypes { return getFileType(fileAttributes); } catch (Exception e) { // If not a ENOENT (No such file or directory) exception - if(!e.getMessage().contains("ENOENT")) + if (!e.getMessage().contains("ENOENT")) Logger.logError("Failed to get file type for file at path \"" + filePath + "\": " + e.getMessage()); return FileType.NO_EXIST; } diff --git a/app/src/main/java/com/termux/app/file/filesystem/NativeDispatcher.java b/app/src/main/java/com/termux/app/file/filesystem/NativeDispatcher.java index d4495373..2eb6bfad 100644 --- a/app/src/main/java/com/termux/app/file/filesystem/NativeDispatcher.java +++ b/app/src/main/java/com/termux/app/file/filesystem/NativeDispatcher.java @@ -44,14 +44,14 @@ public class NativeDispatcher { File file = new File(filePath); - //if(!file.exists()) + //if (!file.exists()) // throw new IOException("No such file or directory: \"" + filePath + "\""); } public static void validateFileDescriptor(FileDescriptor fileDescriptor) throws IOException { if (fileDescriptor == null) throw new IOException("The file descriptor is null"); - if(!fileDescriptor.valid()) + if (!fileDescriptor.valid()) throw new IOException("No such file descriptor: \"" + fileDescriptor.toString() + "\""); } diff --git a/app/src/main/java/com/termux/app/models/ExecutionCommand.java b/app/src/main/java/com/termux/app/models/ExecutionCommand.java index aa83d747..ec43b7e6 100644 --- a/app/src/main/java/com/termux/app/models/ExecutionCommand.java +++ b/app/src/main/java/com/termux/app/models/ExecutionCommand.java @@ -146,7 +146,7 @@ public class ExecutionCommand { @NonNull @Override public String toString() { - if(!hasExecuted()) + if (!hasExecuted()) return getExecutionInputLogString(this, true); else { return getExecutionOutputLogString(this, true); @@ -167,7 +167,7 @@ public class ExecutionCommand { logString.append(executionCommand.getCommandIdAndLabelLogString()).append(":"); - if(executionCommand.previousState != ExecutionState.PRE_EXECUTION) + if (executionCommand.previousState != ExecutionState.PRE_EXECUTION) logString.append("\n").append(executionCommand.getPreviousStateLogString()); logString.append("\n").append(executionCommand.getCurrentStateLogString()); @@ -178,11 +178,11 @@ public class ExecutionCommand { logString.append("\n").append(executionCommand.getIsFailsafeLogString()); - if(!ignoreNull || executionCommand.sessionAction != null) + if (!ignoreNull || executionCommand.sessionAction != null) logString.append("\n").append(executionCommand.getSessionActionLogString()); logString.append("\n").append(executionCommand.getIsPluginExecutionCommandLogString()); - if(!ignoreNull || executionCommand.isPluginExecutionCommand) { + if (!ignoreNull || executionCommand.isPluginExecutionCommand) { if (!ignoreNull || executionCommand.pluginPendingIntent != null) logString.append("\n").append(executionCommand.getPendingIntentCreatorLogString()); } @@ -226,7 +226,7 @@ public class ExecutionCommand { public static String getExecutionErrLogString(final ExecutionCommand executionCommand, boolean ignoreNull) { StringBuilder logString = new StringBuilder(); - if(!ignoreNull || (executionCommand.isStateFailed())) { + if (!ignoreNull || (executionCommand.isStateFailed())) { logString.append("\n").append(executionCommand.getErrCodeLogString()); logString.append("\n").append(executionCommand.getErrmsgLogString()); logString.append("\n").append(executionCommand.geStackTracesLogString()); @@ -299,7 +299,7 @@ public class ExecutionCommand { markdownString.append("\n").append("**Errmsg:**\n").append(DataUtils.getDefaultIfNull(executionCommand.errmsg, "-")); markdownString.append("\n\n").append(executionCommand.geStackTracesMarkdownString()); - if(executionCommand.commandDescription != null || executionCommand.commandHelp != null) { + if (executionCommand.commandDescription != null || executionCommand.commandHelp != null) { if (executionCommand.commandDescription != null) markdownString.append("\n\n### Command Description\n\n").append(executionCommand.commandDescription).append("\n"); if (executionCommand.commandHelp != null) @@ -307,7 +307,7 @@ public class ExecutionCommand { markdownString.append("\n##\n"); } - if(executionCommand.pluginAPIHelp != null) { + if (executionCommand.pluginAPIHelp != null) { markdownString.append("\n\n### Plugin API Help\n\n").append(executionCommand.pluginAPIHelp); markdownString.append("\n##\n"); } @@ -318,7 +318,7 @@ public class ExecutionCommand { public String getIdLogString() { - if(id != null) + if (id != null) return "(" + id + ") "; else return ""; @@ -490,7 +490,7 @@ public class ExecutionCommand { public synchronized boolean setState(ExecutionState newState) { // The state transition cannot go back or change if already at {@link ExecutionState#SUCCESS} - if(newState.getValue() < currentState.getValue() || currentState == ExecutionState.SUCCESS) { + if (newState.getValue() < currentState.getValue() || currentState == ExecutionState.SUCCESS) { Logger.logError("Invalid "+ getCommandIdAndLabelLogString() + " state transition from \"" + currentState.getName() + "\" to " + "\"" + newState.getName() + "\""); return false; } @@ -498,7 +498,7 @@ public class ExecutionCommand { // The {@link ExecutionState#FAILED} can be set again, like to add more errors, but we don't update // {@link #previousState} with the {@link #currentState} value if its at {@link ExecutionState#FAILED} to // preserve the last valid state - if(currentState != ExecutionState.FAILED) + if (currentState != ExecutionState.FAILED) previousState = currentState; currentState = newState; @@ -515,23 +515,23 @@ public class ExecutionCommand { this.errmsg = errmsg; - if(!setState(ExecutionState.FAILED)) + if (!setState(ExecutionState.FAILED)) return false; - if(this.throwableList == null) + if (this.throwableList == null) this.throwableList = new ArrayList<>(); - if(throwable != null) + if (throwable != null) this.throwableList.add(throwable); return true; } public synchronized boolean isStateFailed() { - if(currentState != ExecutionState.FAILED) + if (currentState != ExecutionState.FAILED) return false; - if(errCode <= RESULT_CODE_OK) { + if (errCode <= RESULT_CODE_OK) { Logger.logWarn("The " + getCommandIdAndLabelLogString() + " has an invalid errCode value \"" + errCode + "\" while having ExecutionState.FAILED state."); return false; } else { diff --git a/app/src/main/java/com/termux/app/models/ReportInfo.java b/app/src/main/java/com/termux/app/models/ReportInfo.java index cd12e5ed..a4d62f15 100644 --- a/app/src/main/java/com/termux/app/models/ReportInfo.java +++ b/app/src/main/java/com/termux/app/models/ReportInfo.java @@ -48,7 +48,7 @@ public class ReportInfo implements Serializable { StringBuilder markdownString = new StringBuilder(); - if(reportInfo.addReportInfoToMarkdown) { + if (reportInfo.addReportInfoToMarkdown) { markdownString.append("## Report Info\n\n"); markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("User Action", reportInfo.userAction, "-")); markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Sender", reportInfo.sender, "-")); diff --git a/app/src/main/java/com/termux/app/settings/properties/SharedProperties.java b/app/src/main/java/com/termux/app/settings/properties/SharedProperties.java index d2dfc417..c1797d6e 100644 --- a/app/src/main/java/com/termux/app/settings/properties/SharedProperties.java +++ b/app/src/main/java/com/termux/app/settings/properties/SharedProperties.java @@ -31,7 +31,7 @@ import javax.annotation.Nullable; * * The {@link SharedProperties} also provides static functions that can be used to read properties * from files or individual key values or even their internal values. An automatic mapping to a - * boolean as internal value can also be done. An in-memory cache is not maintained, nor a locks used. + * boolean as internal value can also be done. An in-memory cache is not maintained, nor are locks used. * * This currently only has read support, write support can/will be added later if needed. Check android's * SharedPreferencesImpl class for reference implementation. @@ -119,7 +119,7 @@ public class SharedProperties { Properties newProperties = new Properties(); Set propertiesList = mPropertiesList; - if(propertiesList == null) + if (propertiesList == null) propertiesList = properties.stringPropertyNames(); String value; @@ -240,7 +240,7 @@ public class SharedProperties { properties.load(new InputStreamReader(in, StandardCharsets.UTF_8)); } } catch (Exception e) { - if(context != null) + if (context != null) Toast.makeText(context, "Could not open properties file \"" + propertiesFile.getAbsolutePath() + "\": " + e.getMessage(), Toast.LENGTH_LONG).show(); Logger.logStackTraceWithMessage(LOG_TAG, "Error loading properties file \"" + propertiesFile.getAbsolutePath() + "\"", e); return null; @@ -394,7 +394,7 @@ public class SharedProperties { } public static Properties getPropertiesCopy(Properties inputProperties) { - if(inputProperties == null) return null; + if (inputProperties == null) return null; Properties outputProperties = new Properties(); for (String key : inputProperties.stringPropertyNames()) { @@ -405,7 +405,7 @@ public class SharedProperties { } public static Map getMapCopy(Map map) { - if(map == null) return null; + if (map == null) return null; return new HashMap(map); } diff --git a/app/src/main/java/com/termux/app/settings/properties/TermuxSharedProperties.java b/app/src/main/java/com/termux/app/settings/properties/TermuxSharedProperties.java index f3d2d549..79c6ffae 100644 --- a/app/src/main/java/com/termux/app/settings/properties/TermuxSharedProperties.java +++ b/app/src/main/java/com/termux/app/settings/properties/TermuxSharedProperties.java @@ -228,7 +228,7 @@ public class TermuxSharedProperties implements SharedPropertiesParser { * @return Returns the internal termux {@link Object} object. */ public static Object getInternalTermuxPropertyValueFromValue(Context context, String key, String value) { - if(key == null) return null; + if (key == null) return null; /* For keys where a MAP_* is checked by respective functions. Note that value to this function would actually be the key for the MAP_*: @@ -269,10 +269,10 @@ public class TermuxSharedProperties implements SharedPropertiesParser { return (String) getExtraKeysStyleInternalPropertyValueFromValue(value); default: // default boolean behaviour - if(TermuxPropertyConstants.TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key)) + if (TermuxPropertyConstants.TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key)) return (boolean) SharedProperties.getBooleanValueForStringValue(value, false); // default inverted boolean behaviour - else if(TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key)) + else if (TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key)) return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(value, true); // just use String object as is (may be null) else diff --git a/app/src/main/java/com/termux/app/terminal/TermuxSessionClient.java b/app/src/main/java/com/termux/app/terminal/TermuxSessionClient.java index 110b5564..96fc3849 100644 --- a/app/src/main/java/com/termux/app/terminal/TermuxSessionClient.java +++ b/app/src/main/java/com/termux/app/terminal/TermuxSessionClient.java @@ -137,7 +137,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase { /** Try switching to session. */ public void setCurrentSession(TerminalSession session) { - if(session == null) return; + if (session == null) return; if (mActivity.getTerminalView().attachSession(session)) { // notify about switched session if not already displaying the session @@ -170,13 +170,13 @@ public class TermuxSessionClient extends TermuxSessionClientBase { } TermuxSession termuxSession = service.getTermuxSession(index); - if(termuxSession != null) + if (termuxSession != null) setCurrentSession(termuxSession.getTerminalSession()); } public void switchToSession(int index) { TermuxSession termuxSession = mActivity.getTermuxService().getTermuxSession(index); - if(termuxSession != null) + if (termuxSession != null) setCurrentSession(termuxSession.getTerminalSession()); } @@ -232,7 +232,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase { } else { // Else return the last session currently running TermuxSession termuxSession = mActivity.getTermuxService().getLastTermuxSession(); - if(termuxSession != null) + if (termuxSession != null) return termuxSession.getTerminalSession(); else return null; @@ -243,7 +243,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase { String sessionHandle = mActivity.getPreferences().getCurrentSession(); // If no session is stored in shared preferences - if(sessionHandle == null) + if (sessionHandle == null) return null; // Check if the session handle found matches one of the currently running sessions @@ -264,7 +264,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase { index = size - 1; } TermuxSession termuxSession = service.getTermuxSession(index); - if(termuxSession != null) + if (termuxSession != null) setCurrentSession(termuxSession.getTerminalSession()); } } @@ -278,7 +278,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase { final int indexOfSession = mActivity.getTermuxService().getIndexOfSession(session); if (indexOfSession < 0) return; final ListView termuxSessionsListView = mActivity.findViewById(R.id.terminal_sessions_list); - if(termuxSessionsListView == null) return; + if (termuxSessionsListView == null) return; termuxSessionsListView.setItemChecked(indexOfSession, true); // Delay is necessary otherwise sometimes scroll to newly added session does not happen diff --git a/app/src/main/java/com/termux/app/terminal/TermuxSessionsListViewController.java b/app/src/main/java/com/termux/app/terminal/TermuxSessionsListViewController.java index 94ea9de5..5dcec5e0 100644 --- a/app/src/main/java/com/termux/app/terminal/TermuxSessionsListViewController.java +++ b/app/src/main/java/com/termux/app/terminal/TermuxSessionsListViewController.java @@ -94,7 +94,6 @@ public class TermuxSessionsListViewController extends ArrayAdapter