Skip to content

Commit eeb8554

Browse files
Fix string resources naming convention
1 parent 4eced52 commit eeb8554

15 files changed

+152
-117
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
<permission
1717
android:name="${TERMUX_PACKAGE_NAME}.permission.RUN_COMMAND"
18-
android:description="@string/run_command_permission_description"
18+
android:description="@string/permission_run_command_description"
1919
android:icon="@mipmap/ic_launcher"
20-
android:label="@string/run_command_permission_label"
20+
android:label="@string/permission_run_command_label"
2121
android:protectionLevel="dangerous" />
2222

2323
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

app/src/main/java/com/termux/app/RunCommandService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ public int onStartCommand(Intent intent, int flags, int startId) {
186186
runStartForeground();
187187

188188
ExecutionCommand executionCommand = new ExecutionCommand();
189-
executionCommand.pluginAPIHelp = this.getString(R.string.run_command_service_api_help);
189+
executionCommand.pluginAPIHelp = this.getString(R.string.error_run_command_service_api_help);
190190

191191
String errmsg;
192192

193193
// If invalid action passed, then just return
194194
if (!RUN_COMMAND_SERVICE.ACTION_RUN_COMMAND.equals(intent.getAction())) {
195-
errmsg = this.getString(R.string.run_command_service_invalid_action, intent.getAction());
195+
errmsg = this.getString(R.string.error_run_command_service_invalid_intent_action, intent.getAction());
196196
executionCommand.setStateFailed(1, errmsg, null);
197197
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand);
198198
return Service.START_NOT_STICKY;
@@ -227,7 +227,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
227227
null, PluginUtils.PLUGIN_EXECUTABLE_FILE_PERMISSIONS,
228228
false, false);
229229
if (errmsg != null) {
230-
errmsg += "\n" + this.getString(R.string.executable_absolute_path, executionCommand.executable);
230+
errmsg += "\n" + this.getString(R.string.msg_executable_absolute_path, executionCommand.executable);
231231
executionCommand.setStateFailed(1, errmsg, null);
232232
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand);
233233
return Service.START_NOT_STICKY;
@@ -248,7 +248,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
248248
true, true, false,
249249
true);
250250
if (errmsg != null) {
251-
errmsg += "\n" + this.getString(R.string.working_directory_absolute_path, executionCommand.workingDirectory);
251+
errmsg += "\n" + this.getString(R.string.msg_working_directory_absolute_path, executionCommand.workingDirectory);
252252
executionCommand.setStateFailed(1, errmsg, null);
253253
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand);
254254
return Service.START_NOT_STICKY;

app/src/main/java/com/termux/app/TermuxActivity.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ private void setNewSessionButtonView() {
395395
View newSessionButton = findViewById(R.id.new_session_button);
396396
newSessionButton.setOnClickListener(v -> mTermuxSessionClient.addNewSession(false, null));
397397
newSessionButton.setOnLongClickListener(v -> {
398-
DialogUtils.textInput(TermuxActivity.this, R.string.session_new_named_title, null, R.string.session_new_named_positive_button,
399-
text -> mTermuxSessionClient.addNewSession(false, text), R.string.new_session_failsafe, text -> mTermuxSessionClient.addNewSession(true, text)
398+
DialogUtils.textInput(TermuxActivity.this, R.string.title_create_named_session, null, R.string.action_create_named_session_confirm,
399+
text -> mTermuxSessionClient.addNewSession(false, text), R.string.action_new_session_failsafe, text -> mTermuxSessionClient.addNewSession(true, text)
400400
, -1, null, null);
401401
return true;
402402
});
@@ -489,15 +489,15 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuIn
489489
}
490490
}
491491

492-
menu.add(Menu.NONE, CONTEXT_MENU_SELECT_URL_ID, Menu.NONE, R.string.select_url);
493-
menu.add(Menu.NONE, CONTEXT_MENU_SHARE_TRANSCRIPT_ID, Menu.NONE, R.string.select_all_and_share);
494-
if (addAutoFillMenu) menu.add(Menu.NONE, CONTEXT_MENU_AUTOFILL_ID, Menu.NONE, R.string.autofill_password);
495-
menu.add(Menu.NONE, CONTEXT_MENU_RESET_TERMINAL_ID, Menu.NONE, R.string.reset_terminal);
496-
menu.add(Menu.NONE, CONTEXT_MENU_KILL_PROCESS_ID, Menu.NONE, getResources().getString(R.string.kill_process, getCurrentSession().getPid())).setEnabled(currentSession.isRunning());
497-
menu.add(Menu.NONE, CONTEXT_MENU_STYLING_ID, Menu.NONE, R.string.style_terminal);
498-
menu.add(Menu.NONE, CONTEXT_MENU_TOGGLE_KEEP_SCREEN_ON, Menu.NONE, R.string.toggle_keep_screen_on).setCheckable(true).setChecked(mPreferences.getKeepScreenOn());
499-
menu.add(Menu.NONE, CONTEXT_MENU_HELP_ID, Menu.NONE, R.string.help);
500-
menu.add(Menu.NONE, CONTEXT_MENU_SETTINGS_ID, Menu.NONE, R.string.settings);
492+
menu.add(Menu.NONE, CONTEXT_MENU_SELECT_URL_ID, Menu.NONE, R.string.action_select_url);
493+
menu.add(Menu.NONE, CONTEXT_MENU_SHARE_TRANSCRIPT_ID, Menu.NONE, R.string.action_share_transcript);
494+
if (addAutoFillMenu) menu.add(Menu.NONE, CONTEXT_MENU_AUTOFILL_ID, Menu.NONE, R.string.action_autofill_password);
495+
menu.add(Menu.NONE, CONTEXT_MENU_RESET_TERMINAL_ID, Menu.NONE, R.string.action_reset_terminal);
496+
menu.add(Menu.NONE, CONTEXT_MENU_KILL_PROCESS_ID, Menu.NONE, getResources().getString(R.string.action_kill_process, getCurrentSession().getPid())).setEnabled(currentSession.isRunning());
497+
menu.add(Menu.NONE, CONTEXT_MENU_STYLING_ID, Menu.NONE, R.string.action_style_terminal);
498+
menu.add(Menu.NONE, CONTEXT_MENU_TOGGLE_KEEP_SCREEN_ON, Menu.NONE, R.string.action_toggle_keep_screen_on).setCheckable(true).setChecked(mPreferences.getKeepScreenOn());
499+
menu.add(Menu.NONE, CONTEXT_MENU_HELP_ID, Menu.NONE, R.string.action_open_help);
500+
menu.add(Menu.NONE, CONTEXT_MENU_SETTINGS_ID, Menu.NONE, R.string.action_open_settings);
501501
}
502502

503503
/** Hook system menu to show context menu instead. */
@@ -552,7 +552,7 @@ private void showKillSessionDialog(TerminalSession session) {
552552

553553
final AlertDialog.Builder b = new AlertDialog.Builder(this);
554554
b.setIcon(android.R.drawable.ic_dialog_alert);
555-
b.setMessage(R.string.confirm_kill_process);
555+
b.setMessage(R.string.title_confirm_kill_process);
556556
b.setPositiveButton(android.R.string.yes, (dialog, id) -> {
557557
dialog.dismiss();
558558
session.finishIfRunning();
@@ -564,7 +564,7 @@ private void showKillSessionDialog(TerminalSession session) {
564564
private void resetSession(TerminalSession session) {
565565
if (session != null) {
566566
session.reset();
567-
showToast(getResources().getString(R.string.reset_toast_notification), true);
567+
showToast(getResources().getString(R.string.msg_terminal_reset), true);
568568
}
569569
}
570570

@@ -576,8 +576,8 @@ private void showStylingDialog() {
576576
} catch (ActivityNotFoundException | IllegalArgumentException e) {
577577
// The startActivity() call is not documented to throw IllegalArgumentException.
578578
// However, crash reporting shows that it sometimes does, so catch it here.
579-
new AlertDialog.Builder(this).setMessage(getString(R.string.styling_not_installed))
580-
.setPositiveButton(R.string.styling_install, (dialog, which) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://f-droid.org/en/packages/" + TermuxConstants.TERMUX_STYLING_PACKAGE_NAME + " /")))).setNegativeButton(android.R.string.cancel, null).show();
579+
new AlertDialog.Builder(this).setMessage(getString(R.string.error_styling_not_installed))
580+
.setPositiveButton(R.string.action_styling_install, (dialog, which) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://f-droid.org/en/packages/" + TermuxConstants.TERMUX_STYLING_PACKAGE_NAME + " /")))).setNegativeButton(android.R.string.cancel, null).show();
581581
}
582582
}
583583
private void toggleKeepScreenOn() {

app/src/main/java/com/termux/app/activities/ReportActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public boolean onOptionsItemSelected(final MenuItem item) {
129129
int id = item.getItemId();
130130
if (id == R.id.menu_item_share_report) {
131131
if (mReportInfo != null)
132-
ShareUtils.shareText(this, getString(R.string.report_text), mReportInfo.reportString);
132+
ShareUtils.shareText(this, getString(R.string.title_report_text), mReportInfo.reportString);
133133
} else if (id == R.id.menu_item_copy_report) {
134134
if (mReportInfo != null)
135135
ShareUtils.copyTextToClipboard(this, mReportInfo.reportString, null);

app/src/main/java/com/termux/app/terminal/TermuxSessionClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ public void switchToSession(boolean forward) {
176176
public void renameSession(final TerminalSession sessionToRename) {
177177
if (sessionToRename == null) return;
178178

179-
DialogUtils.textInput(mActivity, R.string.session_rename_title, sessionToRename.mSessionName, R.string.session_rename_positive_button, text -> {
179+
DialogUtils.textInput(mActivity, R.string.title_rename_session, sessionToRename.mSessionName, R.string.action_rename_session_confirm, text -> {
180180
sessionToRename.mSessionName = text;
181181
terminalSessionListNotifyUpdated();
182182
}, -1, null, -1, null, null);
183183
}
184184

185185
public void addNewSession(boolean isFailSafe, String sessionName) {
186186
if (mActivity.getTermuxService().getSessions().size() >= MAX_SESSIONS) {
187-
new AlertDialog.Builder(mActivity).setTitle(R.string.max_terminals_reached_title).setMessage(R.string.max_terminals_reached_message)
187+
new AlertDialog.Builder(mActivity).setTitle(R.string.title_max_terminals_reached).setMessage(R.string.msg_max_terminals_reached)
188188
.setPositiveButton(android.R.string.ok, null).show();
189189
} else {
190190
TerminalSession currentSession = mActivity.getCurrentSession();

app/src/main/java/com/termux/app/terminal/TermuxViewClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ public void shareSessionTranscript() {
346346
intent.setType("text/plain");
347347
transcriptText = TextDataUtils.getTruncatedCommandOutput(transcriptText, 100_000);
348348
intent.putExtra(Intent.EXTRA_TEXT, transcriptText);
349-
intent.putExtra(Intent.EXTRA_SUBJECT, mActivity.getString(R.string.share_transcript_title));
350-
mActivity.startActivity(Intent.createChooser(intent, mActivity.getString(R.string.share_transcript_chooser_title)));
349+
intent.putExtra(Intent.EXTRA_SUBJECT, mActivity.getString(R.string.title_share_transcript));
350+
mActivity.startActivity(Intent.createChooser(intent, mActivity.getString(R.string.title_share_transcript_with)));
351351
} catch (Exception e) {
352352
Logger.logStackTraceWithMessage("Failed to get share session transcript of length " + transcriptText.length(), e);
353353
}
@@ -361,7 +361,7 @@ public void showUrlSelection() {
361361

362362
LinkedHashSet<CharSequence> urlSet = TextDataUtils.extractUrls(text);
363363
if (urlSet.isEmpty()) {
364-
new AlertDialog.Builder(mActivity).setMessage(R.string.select_url_no_found).show();
364+
new AlertDialog.Builder(mActivity).setMessage(R.string.title_select_url_none_found).show();
365365
return;
366366
}
367367

@@ -373,8 +373,8 @@ public void showUrlSelection() {
373373
String url = (String) urls[which];
374374
ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService(Context.CLIPBOARD_SERVICE);
375375
clipboard.setPrimaryClip(new ClipData(null, new String[]{"text/plain"}, new ClipData.Item(url)));
376-
Toast.makeText(mActivity, R.string.select_url_copied_to_clipboard, Toast.LENGTH_LONG).show();
377-
}).setTitle(R.string.select_url_dialog_title).create();
376+
Toast.makeText(mActivity, R.string.msg_select_url_copied_to_clipboard, Toast.LENGTH_LONG).show();
377+
}).setTitle(R.string.title_select_url_dialog).create();
378378

379379
// Long press to open URL:
380380
dialog.setOnShowListener(di -> {

app/src/main/java/com/termux/app/utils/FileUtils.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ public static boolean isPathInDirPath(String path, String dirPath, boolean ensur
156156
* failed, otherwise {@code null}.
157157
*/
158158
public static String validateRegularFileExistenceAndPermissions(final Context context, final String path, final String parentDirPath, String permissionsToCheck, final boolean setMissingPermissions, final boolean ignoreErrorsIfPathIsUnderParentDirPath) {
159-
if (path == null || path.isEmpty()) return context.getString(R.string.null_or_empty_file);
159+
if (path == null || path.isEmpty()) return context.getString(R.string.error_null_or_empty_file);
160160

161161
try {
162162
File file = new File(path);
163163

164164
// If file exits but not a regular file
165165
if (file.exists() && !file.isFile()) {
166-
return context.getString(R.string.non_regular_file_found);
166+
return context.getString(R.string.error_non_regular_file_found);
167167
}
168168

169169
boolean isPathUnderParentDirPath = false;
@@ -183,7 +183,7 @@ public static String validateRegularFileExistenceAndPermissions(final Context co
183183
// If path is not a regular file
184184
// Regular files cannot be automatically created so we do not ignore if missing
185185
if (!file.isFile()) {
186-
return context.getString(R.string.no_regular_file_found);
186+
return context.getString(R.string.error_no_regular_file_found);
187187
}
188188

189189
// If there is not parentDirPath restriction or path is not under parentDirPath or
@@ -197,7 +197,7 @@ public static String validateRegularFileExistenceAndPermissions(final Context co
197197
}
198198
// Some function calls may throw SecurityException, etc
199199
catch (Exception e) {
200-
return context.getString(R.string.validate_file_existence_and_permissions_failed_with_exception, path, e.getMessage());
200+
return context.getString(R.string.error_validate_file_existence_and_permissions_failed_with_exception, path, e.getMessage());
201201
}
202202

203203
return null;
@@ -230,14 +230,14 @@ public static String validateRegularFileExistenceAndPermissions(final Context co
230230
* failed, otherwise {@code null}.
231231
*/
232232
public static String validateDirectoryExistenceAndPermissions(final Context context, final String path, final String parentDirPath, String permissionsToCheck, final boolean createDirectoryIfMissing, final boolean setMissingPermissions, final boolean ignoreErrorsIfPathIsInParentDirPath, final boolean ignoreIfNotExecutable) {
233-
if (path == null || path.isEmpty()) return context.getString(R.string.null_or_empty_directory);
233+
if (path == null || path.isEmpty()) return context.getString(R.string.error_null_or_empty_directory);
234234

235235
try {
236236
File file = new File(path);
237237

238238
// If file exits but not a directory file
239239
if (file.exists() && !file.isDirectory()) {
240-
return context.getString(R.string.non_directory_file_found);
240+
return context.getString(R.string.error_non_directory_file_found);
241241
}
242242

243243
boolean isPathInParentDirPath = false;
@@ -254,7 +254,7 @@ public static String validateDirectoryExistenceAndPermissions(final Context cont
254254
Logger.logVerbose(LOG_TAG, "Creating missing directory at path: \"" + path + "\"");
255255
// If failed to create directory
256256
if (!file.mkdirs()) {
257-
return context.getString(R.string.creating_missing_directory_failed, path);
257+
return context.getString(R.string.error_creating_missing_directory_failed, path);
258258
}
259259
}
260260

@@ -271,7 +271,7 @@ public static String validateDirectoryExistenceAndPermissions(final Context cont
271271
// If path is not a directory
272272
// Directories can be automatically created so we can ignore if missing with above check
273273
if (!file.isDirectory()) {
274-
return context.getString(R.string.no_directory_found);
274+
return context.getString(R.string.error_no_directory_found);
275275
}
276276

277277
if (permissionsToCheck != null) {
@@ -282,7 +282,7 @@ public static String validateDirectoryExistenceAndPermissions(final Context cont
282282
}
283283
// Some function calls may throw SecurityException, etc
284284
catch (Exception e) {
285-
return context.getString(R.string.validate_directory_existence_and_permissions_failed_with_exception, path, e.getMessage());
285+
return context.getString(R.string.error_validate_directory_existence_and_permissions_failed_with_exception, path, e.getMessage());
286286
}
287287

288288
return null;
@@ -332,11 +332,11 @@ public static void setMissingFilePermissions(String path, String permissionsToSe
332332
* @return Returns the {@code errmsg} if validating permissions failed, otherwise {@code null}.
333333
*/
334334
public static String checkMissingFilePermissions(Context context, String path, String permissionsToCheck, String fileType, boolean ignoreIfNotExecutable) {
335-
if (path == null || path.isEmpty()) return context.getString(R.string.null_or_empty_path);
335+
if (path == null || path.isEmpty()) return context.getString(R.string.error_null_or_empty_path);
336336

337337
if (!isValidPermissingString(permissionsToCheck)) {
338338
Logger.logError(LOG_TAG, "Invalid permissionsToCheck passed to checkMissingFilePermissions: \"" + permissionsToCheck + "\"");
339-
return context.getString(R.string.invalid_file_permissions_string_to_check);
339+
return context.getString(R.string.error_invalid_file_permissions_string_to_check);
340340
}
341341

342342
if (fileType == null || fileType.isEmpty()) fileType = "File";
@@ -345,17 +345,17 @@ public static String checkMissingFilePermissions(Context context, String path, S
345345

346346
// If file is not readable
347347
if (permissionsToCheck.contains("r") && !file.canRead()) {
348-
return context.getString(R.string.file_not_readable, fileType);
348+
return context.getString(R.string.error_file_not_readable, fileType);
349349
}
350350

351351
// If file is not writable
352352
if (permissionsToCheck.contains("w") && !file.canWrite()) {
353-
return context.getString(R.string.file_not_writable, fileType);
353+
return context.getString(R.string.error_file_not_writable, fileType);
354354
}
355355
// If file is not executable
356356
// This canExecute() will give "avc: granted { execute }" warnings for target sdk 29
357357
else if (permissionsToCheck.contains("x") && !file.canExecute() && !ignoreIfNotExecutable) {
358-
return context.getString(R.string.file_not_executable, fileType);
358+
return context.getString(R.string.error_file_not_executable, fileType);
359359
}
360360

361361
return null;

app/src/main/java/com/termux/app/utils/PluginUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static void sendExecuteResultToResultsService(final Context context, fina
9696
public static String checkIfRunCommandServiceAllowExternalAppsPolicyIsViolated(final Context context) {
9797
String errmsg = null;
9898
if (!SharedProperties.isPropertyValueTrue(context, TermuxPropertyConstants.getTermuxPropertiesFile(), TermuxConstants.PROP_ALLOW_EXTERNAL_APPS)) {
99-
errmsg = context.getString(R.string.run_command_service_allow_external_apps_ungranted_warning);
99+
errmsg = context.getString(R.string.error_run_command_service_allow_external_apps_ungranted);
100100
}
101101

102102
return errmsg;

app/src/main/java/com/termux/app/utils/ShareUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void shareText(final Context context, final String subject, final
4343
shareTextIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
4444
shareTextIntent.putExtra(Intent.EXTRA_TEXT, text);
4545

46-
openSystemAppChooser(context, shareTextIntent, context.getString(R.string.share_with));
46+
openSystemAppChooser(context, shareTextIntent, context.getString(R.string.title_share_with));
4747
}
4848

4949
/**

0 commit comments

Comments
 (0)