Replace "if(" with "if ("

This commit is contained in:
agnostic-apollo
2021-04-12 20:19:04 +05:00
parent 6293f5f170
commit 3d46849673
17 changed files with 69 additions and 69 deletions

View File

@@ -21,7 +21,7 @@ public class ShareUtils {
* @param title The title for choose menu.
*/
private static void openSystemAppChooser(final Context context, final Intent intent, final String title) {
if(context == null) return;
if (context == null) return;
final Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, intent);
@@ -38,7 +38,7 @@ public class ShareUtils {
* @param text The text to share.
*/
public static void shareText(final Context context, final String subject, final String text) {
if(context == null) return;
if (context == null) return;
final Intent shareTextIntent = new Intent(Intent.ACTION_SEND);
shareTextIntent.setType("text/plain");
@@ -57,7 +57,7 @@ public class ShareUtils {
* clipboard is successful.
*/
public static void copyTextToClipboard(final Context context, final String text, final String toastString) {
if(context == null) return;
if (context == null) return;
final ClipboardManager clipboardManager = ContextCompat.getSystemService(context, ClipboardManager.class);

View File

@@ -151,27 +151,27 @@ public class Logger {
public static String getMessageAndStackTraceString(String message, Throwable throwable) {
if (message == null && throwable == null)
return null;
else if(message != null && throwable != null)
else if (message != null && throwable != null)
return message + ":\n" + getStackTraceString(throwable);
else if(throwable == null)
else if (throwable == null)
return message;
else
return getStackTraceString(throwable);
}
public static String getMessageAndStackTracesString(String message, List<Throwable> throwableList) {
if(message == null && (throwableList == null || throwableList.size() == 0))
if (message == null && (throwableList == null || throwableList.size() == 0))
return null;
else if(message != null && (throwableList != null && throwableList.size() != 0))
else if (message != null && (throwableList != null && throwableList.size() != 0))
return message + ":\n" + getStackTracesString(null, getStackTraceStringArray(throwableList));
else if(throwableList == null || throwableList.size() == 0)
else if (throwableList == null || throwableList.size() == 0)
return message;
else
return getStackTracesString(null, getStackTraceStringArray(throwableList));
}
public static String getStackTraceString(Throwable throwable) {
if(throwable == null) return null;
if (throwable == null) return null;
String stackTraceString = null;
@@ -204,14 +204,14 @@ public class Logger {
}
public static String getStackTracesString(String label, String[] stackTraceStringArray) {
if(label == null) label = "StackTraces:";
if (label == null) label = "StackTraces:";
StringBuilder stackTracesString = new StringBuilder(label);
if (stackTraceStringArray == null || stackTraceStringArray.length == 0) {
stackTracesString.append(" -");
} else {
for (int i = 0; i != stackTraceStringArray.length; i++) {
if(stackTraceStringArray.length > 1)
if (stackTraceStringArray.length > 1)
stackTracesString.append("\n\nStacktrace ").append(i + 1);
stackTracesString.append("\n```\n").append(stackTraceStringArray[i]).append("\n```\n");
@@ -222,14 +222,14 @@ public class Logger {
}
public static String getStackTracesMarkdownString(String label, String[] stackTraceStringArray) {
if(label == null) label = "StackTraces";
if (label == null) label = "StackTraces";
StringBuilder stackTracesString = new StringBuilder("### " + label);
if (stackTraceStringArray == null || stackTraceStringArray.length == 0) {
stackTracesString.append("\n\n`-`");
} else {
for (int i = 0; i != stackTraceStringArray.length; i++) {
if(stackTraceStringArray.length > 1)
if (stackTraceStringArray.length > 1)
stackTracesString.append("\n\n\n#### Stacktrace ").append(i + 1);
stackTracesString.append("\n\n```\n").append(stackTraceStringArray[i]).append("\n```");
@@ -309,19 +309,19 @@ public class Logger {
}
public static int setLogLevel(Context context, int logLevel) {
if(logLevel >= LOG_LEVEL_OFF && logLevel <= LOG_LEVEL_VERBOSE)
if (logLevel >= LOG_LEVEL_OFF && logLevel <= LOG_LEVEL_VERBOSE)
CURRENT_LOG_LEVEL = logLevel;
else
CURRENT_LOG_LEVEL = DEFAULT_LOG_LEVEL;
if(context != null)
if (context != null)
showToast(context, context.getString(R.string.log_level_value, getLogLevelLabel(context, CURRENT_LOG_LEVEL, false)),true);
return CURRENT_LOG_LEVEL;
}
public static String getFullTag(String tag) {
if(DEFAULT_LOG_TAG.equals(tag))
if (DEFAULT_LOG_TAG.equals(tag))
return tag;
else
return DEFAULT_LOG_TAG + ":" + tag;

View File

@@ -50,15 +50,15 @@ public class MarkdownUtils {
* @return Returns the markdown code {@link String}.
*/
public static String getMarkdownCodeForString(String string, boolean codeBlock) {
if(string == null) return null;
if(string.isEmpty()) return "";
if (string == null) return null;
if (string.isEmpty()) return "";
int maxConsecutiveBackTicksCount = getMaxConsecutiveBackTicksCount(string);
// markdown requires surrounding backticks count to be at least one more than the count
// of consecutive ticks in the string itself
int backticksCountToUse;
if(codeBlock)
if (codeBlock)
backticksCountToUse = maxConsecutiveBackTicksCount + 3;
else
backticksCountToUse = maxConsecutiveBackTicksCount + 1;
@@ -66,13 +66,13 @@ public class MarkdownUtils {
// create a string with n backticks where n==backticksCountToUse
String backticksToUse = Strings.repeat(backtick, backticksCountToUse);
if(codeBlock)
if (codeBlock)
return backticksToUse + "\n" + string + "\n" + backticksToUse;
else {
// add a space to any prefixed or suffixed backtick characters
if(string.startsWith(backtick))
if (string.startsWith(backtick))
string = " " + string;
if(string.endsWith(backtick))
if (string.endsWith(backtick))
string = string + " ";
return backticksToUse + string + backticksToUse;
@@ -86,7 +86,7 @@ public class MarkdownUtils {
* @return Returns the max consecutive backticks count.
*/
public static int getMaxConsecutiveBackTicksCount(String string) {
if(string == null || string.isEmpty()) return 0;
if (string == null || string.isEmpty()) return 0;
int maxCount = 0;
int matchCount;
@@ -94,7 +94,7 @@ public class MarkdownUtils {
Matcher matcher = backticksPattern.matcher(string);
while(matcher.find()) {
matchCount = matcher.group(1).length();
if(matchCount > maxCount)
if (matchCount > maxCount)
maxCount = matchCount;
}

View File

@@ -45,7 +45,7 @@ public class NotificationUtils {
*/
@Nullable
public static NotificationManager getNotificationManager(final Context context) {
if(context == null) return null;
if (context == null) return null;
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
@@ -59,7 +59,7 @@ public class NotificationUtils {
* @return Returns the notification id that should be safe to use.
*/
public synchronized static int getNextNotificationId(final Context context) {
if(context == null) return TermuxPreferenceConstants.TERMUX_APP.DEFAULT_VALUE_KEY_LAST_NOTIFICATION_ID;
if (context == null) return TermuxPreferenceConstants.TERMUX_APP.DEFAULT_VALUE_KEY_LAST_NOTIFICATION_ID;
TermuxAppSharedPreferences preferences = new TermuxAppSharedPreferences(context);
int lastNotificationId = preferences.getLastNotificationId();
@@ -69,7 +69,7 @@ public class NotificationUtils {
nextNotificationId++;
}
if(nextNotificationId == Integer.MAX_VALUE || nextNotificationId < 0)
if (nextNotificationId == Integer.MAX_VALUE || nextNotificationId < 0)
nextNotificationId = TermuxPreferenceConstants.TERMUX_APP.DEFAULT_VALUE_KEY_LAST_NOTIFICATION_ID;
preferences.setLastNotificationId(nextNotificationId);
@@ -91,7 +91,7 @@ public class NotificationUtils {
*/
@Nullable
public static Notification.Builder geNotificationBuilder(final Context context, final String channelId, final int priority, final CharSequence title, final CharSequence notifiationText, final CharSequence notificationBigText, final PendingIntent pendingIntent, final int notificationMode) {
if(context == null) return null;
if (context == null) return null;
Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle(title);
builder.setContentText(notifiationText);
@@ -124,7 +124,7 @@ public class NotificationUtils {
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
NotificationManager notificationManager = getNotificationManager(context);
if(notificationManager != null)
if (notificationManager != null)
notificationManager.createNotificationChannel(channel);
}

View File

@@ -36,7 +36,7 @@ public class PermissionUtils {
}
public static void askPermissions(Activity context, String[] permissions) {
if(context == null || permissions == null) return;
if (context == null || permissions == null) return;
int result;
Logger.showToast(context, context.getString(R.string.message_sudo_please_grant_permissions), true);
@@ -74,9 +74,9 @@ public class PermissionUtils {
public static boolean validateDisplayOverOtherAppsPermissionForPostAndroid10(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return true;
if(!PermissionUtils.checkDisplayOverOtherAppsPermission(context)) {
if (!PermissionUtils.checkDisplayOverOtherAppsPermission(context)) {
TermuxAppSharedPreferences preferences = new TermuxAppSharedPreferences(context);
if(preferences.getPluginErrorNotificationsEnabled())
if (preferences.getPluginErrorNotificationsEnabled())
Logger.showToast(context, context.getString(R.string.error_display_over_other_apps_permission_not_granted), true);
return false;
} else {

View File

@@ -32,9 +32,9 @@ public class ShellUtils {
// This function may be called by a different package like a plugin, so we get version for Termux package via its context
Context termuxPackageContext = TermuxUtils.getTermuxPackageContext(currentPackageContext);
if(termuxPackageContext != null) {
if (termuxPackageContext != null) {
String termuxVersionName = PackageUtils.getVersionNameForPackage(termuxPackageContext);
if(termuxVersionName != null)
if (termuxVersionName != null)
environment.add("TERMUX_VERSION=" + termuxVersionName);
}
@@ -145,7 +145,7 @@ public class ShellUtils {
}
public static String getExecutableBasename(String executable) {
if(executable == null) return null;
if (executable == null) return null;
int lastSlash = executable.lastIndexOf('/');
return (lastSlash == -1) ? executable : executable.substring(lastSlash + 1);
}
@@ -169,14 +169,14 @@ public class ShellUtils {
String transcriptText;
if(linesJoined)
if (linesJoined)
transcriptText = terminalBuffer.getTranscriptTextWithFullLinesJoined();
else
transcriptText = terminalBuffer.getTranscriptTextWithoutJoinedLines();
if (transcriptText == null) return null;
if(trim)
if (trim)
transcriptText = transcriptText.trim();
return transcriptText;

View File

@@ -178,7 +178,7 @@ public class StreamGobbler extends Thread {
String line;
while ((line = reader.readLine()) != null) {
if(currentLogLevel >= logLevelVerbose)
if (currentLogLevel >= logLevelVerbose)
Logger.logVerbose(LOG_TAG, String.format(Locale.ENGLISH, "[%s] %s", shell, line)); // This will get truncated by LOGGER_ENTRY_MAX_LEN, likely 4KB
if (stringWriter != null) stringWriter.append(line).append("\n");

View File

@@ -170,7 +170,7 @@ public class TermuxSession {
*/
public void killIfExecuting(@NonNull final Context context, boolean processResult) {
// If execution command has already finished executing, then no need to process results or send SIGKILL
if(mExecutionCommand.hasExecuted()) {
if (mExecutionCommand.hasExecuted()) {
Logger.logDebug(LOG_TAG, "Ignoring sending SIGKILL to \"" + mExecutionCommand.getCommandIdAndLabelLogString() + "\" TermuxSession since it has already finished executing");
return;
}

View File

@@ -149,7 +149,7 @@ public final class TermuxTask {
STDIN.close();
//STDIN.write("exit\n".getBytes(StandardCharsets.UTF_8));
//STDIN.flush();
} catch(IOException e){
} catch(IOException e) {
if (e.getMessage().contains("EPIPE") || e.getMessage().contains("Stream closed")) {
// Method most horrid to catch broken pipe, in which case we
// do nothing. The command is not a shell, the shell closed
@@ -218,7 +218,7 @@ public final class TermuxTask {
*/
public void killIfExecuting(@NonNull final Context context, boolean processResult) {
// If execution command has already finished executing, then no need to process results or send SIGKILL
if(mExecutionCommand.hasExecuted()) {
if (mExecutionCommand.hasExecuted()) {
Logger.logDebug(LOG_TAG, "Ignoring sending SIGKILL to \"" + mExecutionCommand.getCommandIdAndLabelLogString() + "\" TermuxTask since it has already finished executing");
return;
}