mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-04 17:55:36 +08:00
Replace "if(" with "if ("
This commit is contained in:
@@ -52,7 +52,7 @@ public class RunCommandService extends Service {
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Logger.logDebug(LOG_TAG, "onStartCommand");
|
||||
|
||||
if(intent == null) return Service.START_NOT_STICKY;
|
||||
if (intent == null) return Service.START_NOT_STICKY;
|
||||
|
||||
// Run again in case service is already started and onCreate() is not called
|
||||
runStartForeground();
|
||||
@@ -195,7 +195,7 @@ public class RunCommandService extends Service {
|
||||
TermuxConstants.TERMUX_RUN_COMMAND_NOTIFICATION_CHANNEL_ID, Notification.PRIORITY_LOW,
|
||||
TermuxConstants.TERMUX_RUN_COMMAND_NOTIFICATION_CHANNEL_NAME, null, null,
|
||||
null, NotificationUtils.NOTIFICATION_MODE_SILENT);
|
||||
if(builder == null) return null;
|
||||
if (builder == null) return null;
|
||||
|
||||
// No need to show a timestamp:
|
||||
builder.setShowWhen(false);
|
||||
|
@@ -362,7 +362,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
setTerminalToolbarHeight();
|
||||
|
||||
String savedTextInput = null;
|
||||
if(savedInstanceState != null)
|
||||
if (savedInstanceState != null)
|
||||
savedTextInput = savedInstanceState.getString(ARG_TERMINAL_TOOLBAR_TEXT_INPUT);
|
||||
|
||||
terminalToolbarViewPager.setAdapter(new TerminalToolbarViewPager.PageAdapter(this, savedTextInput));
|
||||
@@ -371,7 +371,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
private void setTerminalToolbarHeight() {
|
||||
final ViewPager terminalToolbarViewPager = findViewById(R.id.terminal_toolbar_view_pager);
|
||||
if(terminalToolbarViewPager == null) return;
|
||||
if (terminalToolbarViewPager == null) return;
|
||||
ViewGroup.LayoutParams layoutParams = terminalToolbarViewPager.getLayoutParams();
|
||||
layoutParams.height = (int) Math.round(mTerminalToolbarDefaultHeight *
|
||||
(mProperties.getExtraKeysInfo() == null ? 0 : mProperties.getExtraKeysInfo().getMatrix().length) *
|
||||
@@ -381,7 +381,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
public void toggleTerminalToolbar() {
|
||||
final ViewPager terminalToolbarViewPager = findViewById(R.id.terminal_toolbar_view_pager);
|
||||
if(terminalToolbarViewPager == null) return;
|
||||
if (terminalToolbarViewPager == null) return;
|
||||
|
||||
final boolean showNow = mPreferences.toogleShowTerminalToolbar();
|
||||
Logger.showToast(this, (showNow ? getString(R.string.msg_enabling_terminal_toolbar) : getString(R.string.msg_disabling_terminal_toolbar)), true);
|
||||
@@ -393,12 +393,12 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
}
|
||||
|
||||
private void saveTerminalToolbarTextInput(Bundle savedInstanceState) {
|
||||
if(savedInstanceState == null) return;
|
||||
if (savedInstanceState == null) return;
|
||||
|
||||
final EditText textInputView = findViewById(R.id.terminal_toolbar_text_input);
|
||||
if(textInputView != null) {
|
||||
if (textInputView != null) {
|
||||
String textInput = textInputView.getText().toString();
|
||||
if(!textInput.isEmpty()) savedInstanceState.putString(ARG_TERMINAL_TOOLBAR_TEXT_INPUT, textInput);
|
||||
if (!textInput.isEmpty()) savedInstanceState.putString(ARG_TERMINAL_TOOLBAR_TEXT_INPUT, textInput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,14 +431,14 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
private void setSoftKeyboardState() {
|
||||
// If soft keyboard is to disabled
|
||||
if(!mPreferences.getSoftKeyboardEnabled()) {
|
||||
if (!mPreferences.getSoftKeyboardEnabled()) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
} else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
}
|
||||
|
||||
// If soft keyboard is to be hidden on startup
|
||||
if(mProperties.shouldSoftKeyboardBeHiddenOnStartup()) {
|
||||
if (mProperties.shouldSoftKeyboardBeHiddenOnStartup()) {
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
/** Show a toast and dismiss the last one if still visible. */
|
||||
public void showToast(String text, boolean longDuration) {
|
||||
if(text == null || text.isEmpty()) return;
|
||||
if (text == null || text.isEmpty()) return;
|
||||
if (mLastToast != null) mLastToast.cancel();
|
||||
mLastToast = Toast.makeText(TermuxActivity.this, text, longDuration ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
|
||||
mLastToast.setGravity(Gravity.TOP, 0, 0);
|
||||
@@ -611,7 +611,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
}
|
||||
}
|
||||
private void toggleKeepScreenOn() {
|
||||
if(mTerminalView.getKeepScreenOn()) {
|
||||
if (mTerminalView.getKeepScreenOn()) {
|
||||
mTerminalView.setKeepScreenOn(false);
|
||||
mPreferences.setKeepScreenOn(false);
|
||||
} else {
|
||||
@@ -696,7 +696,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
@Nullable
|
||||
public TerminalSession getCurrentSession() {
|
||||
if(mTerminalView != null)
|
||||
if (mTerminalView != null)
|
||||
return mTerminalView.getCurrentSession();
|
||||
else
|
||||
return null;
|
||||
@@ -766,11 +766,11 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
}
|
||||
|
||||
private void reloadTermuxActivityStyling() {
|
||||
if(mTermuxTerminalSessionClient != null) {
|
||||
if (mTermuxTerminalSessionClient != null) {
|
||||
mTermuxTerminalSessionClient.checkForFontAndColors();
|
||||
}
|
||||
|
||||
if(mProperties!= null) {
|
||||
if (mProperties!= null) {
|
||||
mProperties.loadTermuxPropertiesFromDisk();
|
||||
|
||||
if (mExtraKeysView != null) {
|
||||
|
@@ -689,7 +689,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
|
||||
TermuxConstants.TERMUX_APP_NOTIFICATION_CHANNEL_ID, priority,
|
||||
getText(R.string.application_name), notificationText, null,
|
||||
pendingIntent, NotificationUtils.NOTIFICATION_MODE_SILENT);
|
||||
if(builder == null) return null;
|
||||
if (builder == null) return null;
|
||||
|
||||
// No need to show a timestamp:
|
||||
builder.setShowWhen(false);
|
||||
@@ -742,7 +742,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
|
||||
|
||||
|
||||
private void setCurrentStoredTerminalSession(TerminalSession session) {
|
||||
if(session == null) return;
|
||||
if (session == null) return;
|
||||
// Make the newly created session the current one to be displayed:
|
||||
TermuxAppSharedPreferences preferences = new TermuxAppSharedPreferences(this);
|
||||
preferences.setCurrentSession(session.mHandle);
|
||||
@@ -762,7 +762,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
|
||||
|
||||
@Nullable
|
||||
public synchronized TermuxSession getTermuxSession(int index) {
|
||||
if(index >= 0 && index < mTermuxSessions.size())
|
||||
if (index >= 0 && index < mTermuxSessions.size())
|
||||
return mTermuxSessions.get(index);
|
||||
else
|
||||
return null;
|
||||
|
@@ -32,7 +32,7 @@ public class DebuggingPreferencesFragment extends PreferenceFragmentCompat {
|
||||
}
|
||||
|
||||
protected ListPreference setLogLevelListPreferenceData(ListPreference logLevelListPreference, Context context) {
|
||||
if(logLevelListPreference == null)
|
||||
if (logLevelListPreference == null)
|
||||
logLevelListPreference = new ListPreference(context);
|
||||
|
||||
CharSequence[] logLevels = Logger.getLogLevelsArray();
|
||||
@@ -73,7 +73,7 @@ class DebuggingPreferencesDataStore extends PreferenceDataStore {
|
||||
@Override
|
||||
@Nullable
|
||||
public String getString(String key, @Nullable String defValue) {
|
||||
if(key == null) return null;
|
||||
if (key == null) return null;
|
||||
|
||||
switch (key) {
|
||||
case "log_level":
|
||||
@@ -85,7 +85,7 @@ class DebuggingPreferencesDataStore extends PreferenceDataStore {
|
||||
|
||||
@Override
|
||||
public void putString(String key, @Nullable String value) {
|
||||
if(key == null) return;
|
||||
if (key == null) return;
|
||||
|
||||
switch (key) {
|
||||
case "log_level":
|
||||
@@ -102,7 +102,7 @@ class DebuggingPreferencesDataStore extends PreferenceDataStore {
|
||||
|
||||
@Override
|
||||
public void putBoolean(String key, boolean value) {
|
||||
if(key == null) return;
|
||||
if (key == null) return;
|
||||
|
||||
switch (key) {
|
||||
case "terminal_view_key_logging_enabled":
|
||||
|
@@ -45,7 +45,7 @@ class TerminalIOPreferencesDataStore extends PreferenceDataStore {
|
||||
|
||||
@Override
|
||||
public void putBoolean(String key, boolean value) {
|
||||
if(key == null) return;
|
||||
if (key == null) return;
|
||||
|
||||
switch (key) {
|
||||
case "soft_keyboard_enabled":
|
||||
|
@@ -70,7 +70,7 @@ public class TermuxAppSharedProperties extends TermuxSharedProperties implements
|
||||
* Set the terminal sessions shortcuts.
|
||||
*/
|
||||
private void setSessionShortcuts() {
|
||||
if(mSessionShortcuts == null)
|
||||
if (mSessionShortcuts == null)
|
||||
mSessionShortcuts = new ArrayList<>();
|
||||
else
|
||||
mSessionShortcuts.clear();
|
||||
|
@@ -188,7 +188,7 @@ public final class ExtraKeysView extends GridLayout {
|
||||
int width = view.getMeasuredWidth();
|
||||
int height = view.getMeasuredHeight();
|
||||
Button button;
|
||||
if(isSpecialButton(extraButton)) {
|
||||
if (isSpecialButton(extraButton)) {
|
||||
button = createSpecialButton(extraButton.getKey(), false);
|
||||
if (button == null) return;
|
||||
} else {
|
||||
@@ -240,7 +240,7 @@ public final class ExtraKeysView extends GridLayout {
|
||||
*/
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public void reload(ExtraKeysInfo infos) {
|
||||
if(infos == null)
|
||||
if (infos == null)
|
||||
return;
|
||||
|
||||
for(SpecialButtonState state : specialButtons.values())
|
||||
@@ -258,7 +258,7 @@ public final class ExtraKeysView extends GridLayout {
|
||||
final ExtraKeyButton buttonInfo = buttons[row][col];
|
||||
|
||||
Button button;
|
||||
if(isSpecialButton(buttonInfo)) {
|
||||
if (isSpecialButton(buttonInfo)) {
|
||||
button = createSpecialButton(buttonInfo.getKey(), true);
|
||||
if (button == null) return;
|
||||
} else {
|
||||
|
@@ -88,7 +88,7 @@ static int create_subprocess(JNIEnv* env,
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(self_dir)) != NULL) {
|
||||
int fd = atoi(entry->d_name);
|
||||
if(fd > 2 && fd != self_dir_fd) close(fd);
|
||||
if (fd > 2 && fd != self_dir_fd) close(fd);
|
||||
}
|
||||
closedir(self_dir);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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 {
|
||||
|
@@ -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;
|
||||
|
@@ -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");
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user