Replace "if(" with "if ("

This commit is contained in:
agnostic-apollo
2021-04-06 17:17:12 +05:00
parent 81d97c3584
commit 9cee71004f
15 changed files with 101 additions and 102 deletions

View File

@@ -46,9 +46,9 @@ public class ReportActivity extends AppCompatActivity {
Bundle bundle = null; Bundle bundle = null;
Intent intent = getIntent(); Intent intent = getIntent();
if(intent != null) if (intent != null)
bundle = intent.getExtras(); bundle = intent.getExtras();
else if(savedInstanceState != null) else if (savedInstanceState != null)
bundle = savedInstanceState; bundle = savedInstanceState;
updateUI(bundle); updateUI(bundle);
@@ -60,7 +60,7 @@ public class ReportActivity extends AppCompatActivity {
super.onNewIntent(intent); super.onNewIntent(intent);
setIntent(intent); setIntent(intent);
if(intent != null) if (intent != null)
updateUI(intent.getExtras()); updateUI(intent.getExtras());
} }
@@ -148,12 +148,12 @@ public class ReportActivity extends AppCompatActivity {
mReportMarkdownString = ReportInfo.getReportInfoMarkdownString(mReportInfo); mReportMarkdownString = ReportInfo.getReportInfoMarkdownString(mReportInfo);
mReportActivityMarkdownString = ""; mReportActivityMarkdownString = "";
if(mReportInfo.reportStringPrefix != null) if (mReportInfo.reportStringPrefix != null)
mReportActivityMarkdownString += mReportInfo.reportStringPrefix; mReportActivityMarkdownString += mReportInfo.reportStringPrefix;
mReportActivityMarkdownString += mReportMarkdownString; mReportActivityMarkdownString += mReportMarkdownString;
if(mReportInfo.reportStringSuffix != null) if (mReportInfo.reportStringSuffix != null)
mReportActivityMarkdownString += mReportInfo.reportStringSuffix; mReportActivityMarkdownString += mReportInfo.reportStringSuffix;
} }

View File

@@ -26,7 +26,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
* Set default uncaught crash handler of current thread to {@link CrashHandler}. * Set default uncaught crash handler of current thread to {@link CrashHandler}.
*/ */
public static void setCrashHandler(final Context context) { public static void setCrashHandler(final Context context) {
if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CrashHandler)) { if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CrashHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(context)); Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(context));
} }
} }

View File

@@ -57,7 +57,7 @@ public class CrashUtils {
// Write report string to crash log file // 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); 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); Logger.logError(LOG_TAG, errmsg);
} }
} }
@@ -77,7 +77,7 @@ public class CrashUtils {
* @param logTagParam The log tag to use for logging. * @param logTagParam The log tag to use for logging.
*/ */
public static void notifyCrash(final Context context, final String logTagParam) { public static void notifyCrash(final Context context, final String logTagParam) {
if(context == null) return; if (context == null) return;
TermuxAppSharedPreferences preferences = new TermuxAppSharedPreferences(context); TermuxAppSharedPreferences preferences = new TermuxAppSharedPreferences(context);
@@ -90,7 +90,7 @@ public class CrashUtils {
public void run() { public void run() {
String logTag = DataUtils.getDefaultIfNull(logTagParam, LOG_TAG); 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; return;
String errmsg; String errmsg;
@@ -98,20 +98,20 @@ public class CrashUtils {
// Read report string from crash log file // Read report string from crash log file
errmsg = FileUtils.readStringFromFile(context, "crash log", TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH, Charset.defaultCharset(), reportStringBuilder, false); 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); Logger.logError(logTag, errmsg);
return; return;
} }
// Move crash log file to backup location if it exists // 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); 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); Logger.logError(logTag, errmsg);
} }
String reportString = reportStringBuilder.toString(); String reportString = reportStringBuilder.toString();
if(reportString == null || reportString.isEmpty()) if (reportString == null || reportString.isEmpty())
return; return;
// Send a notification to show the crash log which when clicked will open the {@link ReportActivity} // 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 // Build the notification
Notification.Builder builder = getCrashReportsNotificationBuilder(context, title, null, null, pendingIntent, NotificationUtils.NOTIFICATION_MODE_VIBRATE); Notification.Builder builder = getCrashReportsNotificationBuilder(context, title, null, null, pendingIntent, NotificationUtils.NOTIFICATION_MODE_VIBRATE);
if(builder == null) return; if (builder == null) return;
// Send the notification // Send the notification
int nextNotificationId = NotificationUtils.getNextNotificationId(context); int nextNotificationId = NotificationUtils.getNextNotificationId(context);
NotificationManager notificationManager = NotificationUtils.getNotificationManager(context); NotificationManager notificationManager = NotificationUtils.getNotificationManager(context);
if(notificationManager != null) if (notificationManager != null)
notificationManager.notify(nextNotificationId, builder.build()); notificationManager.notify(nextNotificationId, builder.build());
} }
}.start(); }.start();
@@ -158,7 +158,7 @@ public class CrashUtils {
NOTIFICATION_CHANNEL_ID_CRASH_REPORT_ERRORS, Notification.PRIORITY_HIGH, NOTIFICATION_CHANNEL_ID_CRASH_REPORT_ERRORS, Notification.PRIORITY_HIGH,
title, notifiationText, notificationBigText, pendingIntent, notificationMode); title, notifiationText, notificationBigText, pendingIntent, notificationMode);
if(builder == null) return null; if (builder == null) return null;
// Enable timestamp // Enable timestamp
builder.setShowWhen(true); builder.setShowWhen(true);

View File

@@ -41,7 +41,7 @@ public class FileUtils {
* @return Returns the {@code expand path}. * @return Returns the {@code expand path}.
*/ */
public static String getExpandedTermuxPath(String 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("^\\$PREFIX/", TermuxConstants.TERMUX_PREFIX_DIR_PATH + "/"); path = path.replaceAll("^\\$PREFIX/", TermuxConstants.TERMUX_PREFIX_DIR_PATH + "/");
path = path.replaceAll("^~/$", TermuxConstants.TERMUX_HOME_DIR_PATH); path = path.replaceAll("^~/$", TermuxConstants.TERMUX_HOME_DIR_PATH);
@@ -58,7 +58,7 @@ public class FileUtils {
* @return Returns the {@code unexpand path}. * @return Returns the {@code unexpand path}.
*/ */
public static String getUnExpandedTermuxPath(String 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_PREFIX_DIR_PATH) + "/", "\\$PREFIX/");
path = path.replaceAll("^" + Pattern.quote(TermuxConstants.TERMUX_HOME_DIR_PATH) + "/", "~/"); 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) { public static String getCanonicalPath(String path, final String prefixForNonAbsolutePath, final boolean expandPath) {
if (path == null) path = ""; if (path == null) path = "";
if(expandPath) if (expandPath)
path = getExpandedTermuxPath(path); path = getExpandedTermuxPath(path);
String absolutePath; String absolutePath;
@@ -153,7 +153,7 @@ public class FileUtils {
String normalizedDirPath = normalizePath(dirPath); String normalizedDirPath = normalizePath(dirPath);
if(ensureUnder) if (ensureUnder)
return !path.equals(normalizedDirPath) && path.startsWith(normalizedDirPath + "/"); return !path.equals(normalizedDirPath) && path.startsWith(normalizedDirPath + "/");
else else
return path.startsWith(normalizedDirPath + "/"); return path.startsWith(normalizedDirPath + "/");
@@ -276,7 +276,7 @@ public class FileUtils {
if (setPermissions && permissionsToCheck != null && fileType == FileType.REGULAR) { if (setPermissions && permissionsToCheck != null && fileType == FileType.REGULAR) {
// If there is not parentDirPath restriction or path is under parentDirPath // If there is not parentDirPath restriction or path is under parentDirPath
if (parentDirPath == null || (isPathUnderParentDirPath && getFileType(parentDirPath, false) == FileType.DIRECTORY)) { if (parentDirPath == null || (isPathUnderParentDirPath && getFileType(parentDirPath, false) == FileType.DIRECTORY)) {
if(setMissingPermissionsOnly) if (setMissingPermissionsOnly)
setMissingFilePermissions(label + "file", filePath, permissionsToCheck); setMissingFilePermissions(label + "file", filePath, permissionsToCheck);
else else
setFilePermissions(label + "file", filePath, permissionsToCheck); setFilePermissions(label + "file", filePath, permissionsToCheck);
@@ -369,7 +369,7 @@ public class FileUtils {
// If setPermissions is enabled and path is a directory // If setPermissions is enabled and path is a directory
if (setPermissions && permissionsToCheck != null && fileType == FileType.DIRECTORY) { if (setPermissions && permissionsToCheck != null && fileType == FileType.DIRECTORY) {
if(setMissingPermissionsOnly) if (setMissingPermissionsOnly)
setMissingFilePermissions(label + "directory", filePath, permissionsToCheck); setMissingFilePermissions(label + "directory", filePath, permissionsToCheck);
else else
setFilePermissions(label + "directory", filePath, permissionsToCheck); setFilePermissions(label + "directory", filePath, permissionsToCheck);
@@ -471,13 +471,13 @@ public class FileUtils {
// Create the file parent directory // Create the file parent directory
errmsg = createParentDirectoryFile(context, label + "regular file parent", filePath); errmsg = createParentDirectoryFile(context, label + "regular file parent", filePath);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
try { try {
Logger.logVerbose(LOG_TAG, "Creating " + label + "regular file at path \"" + filePath + "\""); 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); return context.getString(R.string.error_creating_file_failed, label + "regular file", filePath);
} catch (Exception e) { } catch (Exception e) {
return context.getString(R.string.error_creating_file_failed_with_exception, label + "regular file", filePath, e.getMessage()); 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); File file = new File(filePath);
String fileParentPath = file.getParent(); String fileParentPath = file.getParent();
if(fileParentPath != null) if (fileParentPath != null)
return createDirectoryFile(context, label, fileParentPath, return createDirectoryFile(context, label, fileParentPath,
null, false, false); null, false, false);
else else
@@ -648,7 +648,7 @@ public class FileUtils {
// If target path is relative instead of absolute // If target path is relative instead of absolute
if (!targetFilePath.startsWith("/")) { if (!targetFilePath.startsWith("/")) {
String destFileParentPath = destFile.getParent(); String destFileParentPath = destFile.getParent();
if(destFileParentPath != null) if (destFileParentPath != null)
targetFileAbsolutePath = destFileParentPath + "/" + targetFilePath; targetFileAbsolutePath = destFileParentPath + "/" + targetFilePath;
} }
@@ -658,29 +658,29 @@ public class FileUtils {
// If target file does not exist // If target file does not exist
if (targetFileType == FileType.NO_EXIST) { if (targetFileType == FileType.NO_EXIST) {
// If dangling symlink should not be allowed, then return with error // 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); return context.getString(R.string.error_file_not_found_at_path, label + "symlink target file", targetFileAbsolutePath);
} }
// If destination exists // If destination exists
if(destFileType != FileType.NO_EXIST) { if (destFileType != FileType.NO_EXIST) {
// If destination must not be overwritten // If destination must not be overwritten
if(!overwrite) { if (!overwrite) {
return null; return null;
} }
// If overwriteOnlyIfDestIsASymlink is enabled but destination file is not a symlink // 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()); return context.getString(R.string.error_cannot_overwrite_a_non_symlink_file_type, label + " file", destFilePath, targetFilePath, destFileType.getName());
// Delete the destination file // Delete the destination file
errmsg = deleteFile(context, label + "symlink destination", destFilePath, true); errmsg = deleteFile(context, label + "symlink destination", destFilePath, true);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
} else { } else {
// Create the destination file parent directory // Create the destination file parent directory
errmsg = createParentDirectoryFile(context, label + "symlink destination file parent", destFilePath); errmsg = createParentDirectoryFile(context, label + "symlink destination file parent", destFilePath);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
} }
@@ -942,7 +942,7 @@ public class FileUtils {
// If source file does not exist // If source file does not exist
if (srcFileType == FileType.NO_EXIST) { if (srcFileType == FileType.NO_EXIST) {
// If copy or move is to be ignored if source file is not found // If copy or move is to be ignored if source file is not found
if(ignoreNonExistentSrcFile) if (ignoreNonExistentSrcFile)
return null; return null;
// Else return with error // Else return with error
else 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 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)); 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 // 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); return context.getString(R.string.error_copying_or_moving_file_to_same_path, mode + " " + label + "source file", srcFilePath, destFilePath);
// If destination exists // If destination exists
if(destFileType != FileType.NO_EXIST) { if (destFileType != FileType.NO_EXIST) {
// If destination must not be overwritten // If destination must not be overwritten
if(!overwrite) { if (!overwrite) {
return null; return null;
} }
// If overwriteOnlyIfDestSameFileTypeAsSrc is enabled but destination file does not match source file type // 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()); 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 // Delete the destination file
errmsg = deleteFile(context, label + "destination file", destFilePath, true); errmsg = deleteFile(context, label + "destination file", destFilePath, true);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
} }
@@ -979,14 +979,14 @@ public class FileUtils {
boolean copyFile = !moveFile; boolean copyFile = !moveFile;
// If moveFile is true // 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 // 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."); 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/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 // 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 // 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 // If destination directory is a subdirectory of the source directory
// Copying is still allowed by copyDirectory() by excluding destination directory files // Copying is still allowed by copyDirectory() by excluding destination directory files
if (srcFileType == FileType.DIRECTORY && destFileCanonicalPath.startsWith(srcFileCanonicalPath + File.separator)) 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 moveFile is false or renameTo failed while moving
if(copyFile) { if (copyFile) {
Logger.logVerbose(LOG_TAG, "Attempting to copy source to destination."); Logger.logVerbose(LOG_TAG, "Attempting to copy source to destination.");
// Create the dest file parent directory // Create the dest file parent directory
errmsg = createParentDirectoryFile(context, label + "dest file parent", destFilePath); errmsg = createParentDirectoryFile(context, label + "dest file parent", destFilePath);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
if (srcFileType == FileType.DIRECTORY) { if (srcFileType == FileType.DIRECTORY) {
@@ -1031,10 +1031,10 @@ public class FileUtils {
} }
// If source file had to be moved // If source file had to be moved
if(moveFile) { if (moveFile) {
// Delete the source file since copying would have succeeded // Delete the source file since copying would have succeeded
errmsg = deleteFile(context, label + "source file", srcFilePath, true); errmsg = deleteFile(context, label + "source file", srcFilePath, true);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
} }
@@ -1149,7 +1149,7 @@ public class FileUtils {
// If file does not exist // If file does not exist
if (fileType == FileType.NO_EXIST) { if (fileType == FileType.NO_EXIST) {
// If delete is to be ignored if file does not exist // If delete is to be ignored if file does not exist
if(ignoreNonExistentFile) if (ignoreNonExistentFile)
return null; return null;
// Else return with error // Else return with error
else 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 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)); 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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -1185,7 +1185,7 @@ public class FileUtils {
// If file still exists after deleting it // If file still exists after deleting it
fileType = getFileType(filePath, false); 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); return context.getString(R.string.error_file_still_exists_after_deleting, label + "file meant to be deleted", filePath);
} }
catch (Exception e) { catch (Exception e) {
@@ -1254,7 +1254,7 @@ public class FileUtils {
// Else create it // Else create it
else { else {
errmsg = createDirectoryFile(context, label, filePath); errmsg = createDirectoryFile(context, label, filePath);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
} }
} catch (Exception e) { } catch (Exception e) {
@@ -1297,18 +1297,18 @@ public class FileUtils {
// If file does not exist // If file does not exist
if (fileType == FileType.NO_EXIST) { if (fileType == FileType.NO_EXIST) {
// If reading is to be ignored if file does not exist // If reading is to be ignored if file does not exist
if(ignoreNonExistentFile) if (ignoreNonExistentFile)
return null; return null;
// Else return with error // Else return with error
else else
return context.getString(R.string.error_file_not_found_at_path, label + "file meant to be read", filePath); 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 // Check if charset is supported
errmsg = isCharsetSupported(context, charset); errmsg = isCharsetSupported(context, charset);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
FileInputStream fileInputStream = null; FileInputStream fileInputStream = null;
@@ -1322,7 +1322,7 @@ public class FileUtils {
boolean firstLine = true; boolean firstLine = true;
while ((receiveString = bufferedReader.readLine()) != null ) { while ((receiveString = bufferedReader.readLine()) != null ) {
if(!firstLine) dataStringBuilder.append("\n"); else firstLine = false; if (!firstLine) dataStringBuilder.append("\n"); else firstLine = false;
dataStringBuilder.append(receiveString); dataStringBuilder.append(receiveString);
} }
@@ -1365,14 +1365,14 @@ public class FileUtils {
// Create the file parent directory // Create the file parent directory
errmsg = createParentDirectoryFile(context, label + "file parent", filePath); errmsg = createParentDirectoryFile(context, label + "file parent", filePath);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
if(charset == null) charset = Charset.defaultCharset(); if (charset == null) charset = Charset.defaultCharset();
// Check if charset is supported // Check if charset is supported
errmsg = isCharsetSupported(context, charset); errmsg = isCharsetSupported(context, charset);
if(errmsg != null) if (errmsg != null)
return errmsg; return errmsg;
FileOutputStream fileOutputStream = null; 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"); if (charset == null) return context.getString(R.string.error_null_or_empty_parameter, "charset", "isCharsetSupported");
try { try {
if(!Charset.isSupported(charset.name())) { if (!Charset.isSupported(charset.name())) {
return context.getString(R.string.error_unsupported_charset, charset.name()); return context.getString(R.string.error_unsupported_charset, charset.name());
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -90,7 +90,7 @@ public class FileTypes {
return getFileType(fileAttributes); return getFileType(fileAttributes);
} catch (Exception e) { } catch (Exception e) {
// If not a ENOENT (No such file or directory) exception // 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()); Logger.logError("Failed to get file type for file at path \"" + filePath + "\": " + e.getMessage());
return FileType.NO_EXIST; return FileType.NO_EXIST;
} }

View File

@@ -44,14 +44,14 @@ public class NativeDispatcher {
File file = new File(filePath); File file = new File(filePath);
//if(!file.exists()) //if (!file.exists())
// throw new IOException("No such file or directory: \"" + filePath + "\""); // throw new IOException("No such file or directory: \"" + filePath + "\"");
} }
public static void validateFileDescriptor(FileDescriptor fileDescriptor) throws IOException { public static void validateFileDescriptor(FileDescriptor fileDescriptor) throws IOException {
if (fileDescriptor == null) throw new IOException("The file descriptor is null"); 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() + "\""); throw new IOException("No such file descriptor: \"" + fileDescriptor.toString() + "\"");
} }

View File

@@ -146,7 +146,7 @@ public class ExecutionCommand {
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {
if(!hasExecuted()) if (!hasExecuted())
return getExecutionInputLogString(this, true); return getExecutionInputLogString(this, true);
else { else {
return getExecutionOutputLogString(this, true); return getExecutionOutputLogString(this, true);
@@ -167,7 +167,7 @@ public class ExecutionCommand {
logString.append(executionCommand.getCommandIdAndLabelLogString()).append(":"); 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.getPreviousStateLogString());
logString.append("\n").append(executionCommand.getCurrentStateLogString()); logString.append("\n").append(executionCommand.getCurrentStateLogString());
@@ -178,11 +178,11 @@ public class ExecutionCommand {
logString.append("\n").append(executionCommand.getIsFailsafeLogString()); 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.getSessionActionLogString());
logString.append("\n").append(executionCommand.getIsPluginExecutionCommandLogString()); logString.append("\n").append(executionCommand.getIsPluginExecutionCommandLogString());
if(!ignoreNull || executionCommand.isPluginExecutionCommand) { if (!ignoreNull || executionCommand.isPluginExecutionCommand) {
if (!ignoreNull || executionCommand.pluginPendingIntent != null) if (!ignoreNull || executionCommand.pluginPendingIntent != null)
logString.append("\n").append(executionCommand.getPendingIntentCreatorLogString()); logString.append("\n").append(executionCommand.getPendingIntentCreatorLogString());
} }
@@ -226,7 +226,7 @@ public class ExecutionCommand {
public static String getExecutionErrLogString(final ExecutionCommand executionCommand, boolean ignoreNull) { public static String getExecutionErrLogString(final ExecutionCommand executionCommand, boolean ignoreNull) {
StringBuilder logString = new StringBuilder(); StringBuilder logString = new StringBuilder();
if(!ignoreNull || (executionCommand.isStateFailed())) { if (!ignoreNull || (executionCommand.isStateFailed())) {
logString.append("\n").append(executionCommand.getErrCodeLogString()); logString.append("\n").append(executionCommand.getErrCodeLogString());
logString.append("\n").append(executionCommand.getErrmsgLogString()); logString.append("\n").append(executionCommand.getErrmsgLogString());
logString.append("\n").append(executionCommand.geStackTracesLogString()); 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").append("**Errmsg:**\n").append(DataUtils.getDefaultIfNull(executionCommand.errmsg, "-"));
markdownString.append("\n\n").append(executionCommand.geStackTracesMarkdownString()); 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) if (executionCommand.commandDescription != null)
markdownString.append("\n\n### Command Description\n\n").append(executionCommand.commandDescription).append("\n"); markdownString.append("\n\n### Command Description\n\n").append(executionCommand.commandDescription).append("\n");
if (executionCommand.commandHelp != null) if (executionCommand.commandHelp != null)
@@ -307,7 +307,7 @@ public class ExecutionCommand {
markdownString.append("\n##\n"); 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### Plugin API Help\n\n").append(executionCommand.pluginAPIHelp);
markdownString.append("\n##\n"); markdownString.append("\n##\n");
} }
@@ -318,7 +318,7 @@ public class ExecutionCommand {
public String getIdLogString() { public String getIdLogString() {
if(id != null) if (id != null)
return "(" + id + ") "; return "(" + id + ") ";
else else
return ""; return "";
@@ -490,7 +490,7 @@ public class ExecutionCommand {
public synchronized boolean setState(ExecutionState newState) { public synchronized boolean setState(ExecutionState newState) {
// The state transition cannot go back or change if already at {@link ExecutionState#SUCCESS} // 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() + "\""); Logger.logError("Invalid "+ getCommandIdAndLabelLogString() + " state transition from \"" + currentState.getName() + "\" to " + "\"" + newState.getName() + "\"");
return false; 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 // 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 // {@link #previousState} with the {@link #currentState} value if its at {@link ExecutionState#FAILED} to
// preserve the last valid state // preserve the last valid state
if(currentState != ExecutionState.FAILED) if (currentState != ExecutionState.FAILED)
previousState = currentState; previousState = currentState;
currentState = newState; currentState = newState;
@@ -515,23 +515,23 @@ public class ExecutionCommand {
this.errmsg = errmsg; this.errmsg = errmsg;
if(!setState(ExecutionState.FAILED)) if (!setState(ExecutionState.FAILED))
return false; return false;
if(this.throwableList == null) if (this.throwableList == null)
this.throwableList = new ArrayList<>(); this.throwableList = new ArrayList<>();
if(throwable != null) if (throwable != null)
this.throwableList.add(throwable); this.throwableList.add(throwable);
return true; return true;
} }
public synchronized boolean isStateFailed() { public synchronized boolean isStateFailed() {
if(currentState != ExecutionState.FAILED) if (currentState != ExecutionState.FAILED)
return false; 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."); Logger.logWarn("The " + getCommandIdAndLabelLogString() + " has an invalid errCode value \"" + errCode + "\" while having ExecutionState.FAILED state.");
return false; return false;
} else { } else {

View File

@@ -48,7 +48,7 @@ public class ReportInfo implements Serializable {
StringBuilder markdownString = new StringBuilder(); StringBuilder markdownString = new StringBuilder();
if(reportInfo.addReportInfoToMarkdown) { if (reportInfo.addReportInfoToMarkdown) {
markdownString.append("## Report Info\n\n"); markdownString.append("## Report Info\n\n");
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("User Action", reportInfo.userAction, "-")); markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("User Action", reportInfo.userAction, "-"));
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Sender", reportInfo.sender, "-")); markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Sender", reportInfo.sender, "-"));

View File

@@ -31,7 +31,7 @@ import javax.annotation.Nullable;
* *
* The {@link SharedProperties} also provides static functions that can be used to read properties * 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 * 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 * This currently only has read support, write support can/will be added later if needed. Check android's
* SharedPreferencesImpl class for reference implementation. * SharedPreferencesImpl class for reference implementation.
@@ -119,7 +119,7 @@ public class SharedProperties {
Properties newProperties = new Properties(); Properties newProperties = new Properties();
Set<String> propertiesList = mPropertiesList; Set<String> propertiesList = mPropertiesList;
if(propertiesList == null) if (propertiesList == null)
propertiesList = properties.stringPropertyNames(); propertiesList = properties.stringPropertyNames();
String value; String value;
@@ -240,7 +240,7 @@ public class SharedProperties {
properties.load(new InputStreamReader(in, StandardCharsets.UTF_8)); properties.load(new InputStreamReader(in, StandardCharsets.UTF_8));
} }
} catch (Exception e) { } 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(); 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); Logger.logStackTraceWithMessage(LOG_TAG, "Error loading properties file \"" + propertiesFile.getAbsolutePath() + "\"", e);
return null; return null;
@@ -394,7 +394,7 @@ public class SharedProperties {
} }
public static Properties getPropertiesCopy(Properties inputProperties) { public static Properties getPropertiesCopy(Properties inputProperties) {
if(inputProperties == null) return null; if (inputProperties == null) return null;
Properties outputProperties = new Properties(); Properties outputProperties = new Properties();
for (String key : inputProperties.stringPropertyNames()) { for (String key : inputProperties.stringPropertyNames()) {
@@ -405,7 +405,7 @@ public class SharedProperties {
} }
public static Map<String, Object> getMapCopy(Map<String, Object> map) { public static Map<String, Object> getMapCopy(Map<String, Object> map) {
if(map == null) return null; if (map == null) return null;
return new HashMap<String, Object>(map); return new HashMap<String, Object>(map);
} }

View File

@@ -228,7 +228,7 @@ public class TermuxSharedProperties implements SharedPropertiesParser {
* @return Returns the internal termux {@link Object} object. * @return Returns the internal termux {@link Object} object.
*/ */
public static Object getInternalTermuxPropertyValueFromValue(Context context, String key, String value) { 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 For keys where a MAP_* is checked by respective functions. Note that value to this function
would actually be the key for the MAP_*: would actually be the key for the MAP_*:
@@ -269,10 +269,10 @@ public class TermuxSharedProperties implements SharedPropertiesParser {
return (String) getExtraKeysStyleInternalPropertyValueFromValue(value); return (String) getExtraKeysStyleInternalPropertyValueFromValue(value);
default: default:
// default boolean behaviour // 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); return (boolean) SharedProperties.getBooleanValueForStringValue(value, false);
// default inverted boolean behaviour // 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); return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(value, true);
// just use String object as is (may be null) // just use String object as is (may be null)
else else

View File

@@ -137,7 +137,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase {
/** Try switching to session. */ /** Try switching to session. */
public void setCurrentSession(TerminalSession session) { public void setCurrentSession(TerminalSession session) {
if(session == null) return; if (session == null) return;
if (mActivity.getTerminalView().attachSession(session)) { if (mActivity.getTerminalView().attachSession(session)) {
// notify about switched session if not already displaying the 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); TermuxSession termuxSession = service.getTermuxSession(index);
if(termuxSession != null) if (termuxSession != null)
setCurrentSession(termuxSession.getTerminalSession()); setCurrentSession(termuxSession.getTerminalSession());
} }
public void switchToSession(int index) { public void switchToSession(int index) {
TermuxSession termuxSession = mActivity.getTermuxService().getTermuxSession(index); TermuxSession termuxSession = mActivity.getTermuxService().getTermuxSession(index);
if(termuxSession != null) if (termuxSession != null)
setCurrentSession(termuxSession.getTerminalSession()); setCurrentSession(termuxSession.getTerminalSession());
} }
@@ -232,7 +232,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase {
} else { } else {
// Else return the last session currently running // Else return the last session currently running
TermuxSession termuxSession = mActivity.getTermuxService().getLastTermuxSession(); TermuxSession termuxSession = mActivity.getTermuxService().getLastTermuxSession();
if(termuxSession != null) if (termuxSession != null)
return termuxSession.getTerminalSession(); return termuxSession.getTerminalSession();
else else
return null; return null;
@@ -243,7 +243,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase {
String sessionHandle = mActivity.getPreferences().getCurrentSession(); String sessionHandle = mActivity.getPreferences().getCurrentSession();
// If no session is stored in shared preferences // If no session is stored in shared preferences
if(sessionHandle == null) if (sessionHandle == null)
return null; return null;
// Check if the session handle found matches one of the currently running sessions // 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; index = size - 1;
} }
TermuxSession termuxSession = service.getTermuxSession(index); TermuxSession termuxSession = service.getTermuxSession(index);
if(termuxSession != null) if (termuxSession != null)
setCurrentSession(termuxSession.getTerminalSession()); setCurrentSession(termuxSession.getTerminalSession());
} }
} }
@@ -278,7 +278,7 @@ public class TermuxSessionClient extends TermuxSessionClientBase {
final int indexOfSession = mActivity.getTermuxService().getIndexOfSession(session); final int indexOfSession = mActivity.getTermuxService().getIndexOfSession(session);
if (indexOfSession < 0) return; if (indexOfSession < 0) return;
final ListView termuxSessionsListView = mActivity.findViewById(R.id.terminal_sessions_list); final ListView termuxSessionsListView = mActivity.findViewById(R.id.terminal_sessions_list);
if(termuxSessionsListView == null) return; if (termuxSessionsListView == null) return;
termuxSessionsListView.setItemChecked(indexOfSession, true); termuxSessionsListView.setItemChecked(indexOfSession, true);
// Delay is necessary otherwise sometimes scroll to newly added session does not happen // Delay is necessary otherwise sometimes scroll to newly added session does not happen

View File

@@ -94,7 +94,6 @@ public class TermuxSessionsListViewController extends ArrayAdapter<TermuxSession
TermuxSession clickedSession = getItem(position); TermuxSession clickedSession = getItem(position);
mActivity.getTermuxSessionClient().setCurrentSession(clickedSession.getTerminalSession()); mActivity.getTermuxSessionClient().setCurrentSession(clickedSession.getTerminalSession());
mActivity.getDrawer().closeDrawers(); mActivity.getDrawer().closeDrawers();
} }
@Override @Override

View File

@@ -56,7 +56,7 @@ public class TerminalToolbarViewPager {
layout = inflater.inflate(R.layout.view_terminal_toolbar_text_input, collection, false); layout = inflater.inflate(R.layout.view_terminal_toolbar_text_input, collection, false);
final EditText editText = layout.findViewById(R.id.terminal_toolbar_text_input); final EditText editText = layout.findViewById(R.id.terminal_toolbar_text_input);
if(mSavedTextInput != null) { if (mSavedTextInput != null) {
editText.setText(mSavedTextInput); editText.setText(mSavedTextInput);
mSavedTextInput = null; mSavedTextInput = null;
} }

View File

@@ -11,21 +11,21 @@ public class DataUtils {
public static final int TRANSACTION_SIZE_LIMIT_IN_BYTES = 100 * 1024; // 100KB public static final int TRANSACTION_SIZE_LIMIT_IN_BYTES = 100 * 1024; // 100KB
public static String getTruncatedCommandOutput(String text, int maxLength, boolean fromEnd, boolean onNewline, boolean addPrefix) { public static String getTruncatedCommandOutput(String text, int maxLength, boolean fromEnd, boolean onNewline, boolean addPrefix) {
if(text == null) return null; if (text == null) return null;
String prefix = "(truncated) "; String prefix = "(truncated) ";
if(addPrefix) if (addPrefix)
maxLength = maxLength - prefix.length(); maxLength = maxLength - prefix.length();
if(maxLength < 0 || text.length() < maxLength) return text; if (maxLength < 0 || text.length() < maxLength) return text;
if (fromEnd) { if (fromEnd) {
text = text.substring(0, Math.min(text.length(), maxLength)); text = text.substring(0, Math.min(text.length(), maxLength));
} else { } else {
int cutOffIndex = text.length() - maxLength; int cutOffIndex = text.length() - maxLength;
if(onNewline) { if (onNewline) {
int nextNewlineIndex = text.indexOf('\n', cutOffIndex); int nextNewlineIndex = text.indexOf('\n', cutOffIndex);
if (nextNewlineIndex != -1 && nextNewlineIndex != text.length() - 1) { if (nextNewlineIndex != -1 && nextNewlineIndex != text.length() - 1) {
cutOffIndex = nextNewlineIndex + 1; cutOffIndex = nextNewlineIndex + 1;
@@ -34,7 +34,7 @@ public class DataUtils {
text = text.substring(cutOffIndex); text = text.substring(cutOffIndex);
} }
if(addPrefix) if (addPrefix)
text = prefix + text; text = prefix + text;
return text; return text;
@@ -49,7 +49,7 @@ public class DataUtils {
* returns default if failed to read a valid value, like in case of an exception. * returns default if failed to read a valid value, like in case of an exception.
*/ */
public static float getFloatFromString(String value, float def) { public static float getFloatFromString(String value, float def) {
if(value == null) return def; if (value == null) return def;
try { try {
return Float.parseFloat(value); return Float.parseFloat(value);
@@ -68,7 +68,7 @@ public class DataUtils {
* returns default if failed to read a valid value, like in case of an exception. * returns default if failed to read a valid value, like in case of an exception.
*/ */
public static int getIntFromString(String value, int def) { public static int getIntFromString(String value, int def) {
if(value == null) return def; if (value == null) return def;
try { try {
return Integer.parseInt(value); return Integer.parseInt(value);
@@ -89,7 +89,7 @@ public class DataUtils {
* like in case of an exception. * like in case of an exception.
*/ */
public static int getIntStoredAsStringFromBundle(Bundle bundle, String key, int def) { public static int getIntStoredAsStringFromBundle(Bundle bundle, String key, int def) {
if(bundle == null) return def; if (bundle == null) return def;
return getIntFromString(bundle.getString(key, Integer.toString(def)), def); return getIntFromString(bundle.getString(key, Integer.toString(def)), def);
} }

View File

@@ -123,14 +123,14 @@ public class TextSelectionHandleView extends View {
coords[0] += mPointX; coords[0] += mPointX;
coords[1] += mPointY; coords[1] += mPointY;
if(mHandle != null) if (mHandle != null)
mHandle.showAtLocation(terminalView, 0, coords[0], coords[1]); mHandle.showAtLocation(terminalView, 0, coords[0], coords[1]);
} }
public void hide() { public void hide() {
mIsDragging = false; mIsDragging = false;
if(mHandle != null) { if (mHandle != null) {
mHandle.dismiss(); mHandle.dismiss();
// We remove handle from its parent, otherwise it may still be shown in some cases even after the dismiss call // We remove handle from its parent, otherwise it may still be shown in some cases even after the dismiss call
@@ -141,7 +141,7 @@ public class TextSelectionHandleView extends View {
} }
public void removeFromParent() { public void removeFromParent() {
if(!isParentNull()) { if (!isParentNull()) {
((ViewGroup)this.getParent()).removeView(this); ((ViewGroup)this.getParent()).removeView(this);
} }
} }