diff --git a/snippets/src/main/AndroidManifest.xml b/snippets/src/main/AndroidManifest.xml index 6e63b1d6..45e0f12b 100644 --- a/snippets/src/main/AndroidManifest.xml +++ b/snippets/src/main/AndroidManifest.xml @@ -27,7 +27,7 @@ + android:value="26.36" /> + .setPositiveButton(ctx.getString(R.string.snippet_action_save)) { _, _ -> val prefix = prefixInput.text?.toString()?.trim() ?: "" val desc = descInput.text?.toString()?.trim() ?: "" val lang = langSpinner.selectedItem?.toString() ?: "" @@ -154,7 +158,7 @@ class SnippetManagerFragment : Fragment() { val body = bodyInput.text?.toString()?.split("\n") ?: emptyList() if (prefix.isEmpty() || desc.isEmpty() || lang.isEmpty() || scope.isEmpty()) { - Toast.makeText(ctx, "All fields are required", Toast.LENGTH_SHORT).show() + PluginWindows.showToast(ctx, ctx.getString(R.string.snippet_msg_all_fields_required)) return@setPositiveButton } @@ -175,8 +179,9 @@ class SnippetManagerFragment : Fragment() { save() renderList() } - .setNegativeButton("Cancel", null) - .show() + .setNegativeButton(ctx.getString(R.string.snippet_action_cancel), null) + .create() + PluginWindows.showDialog(editDialog) applyDialogButtonColors(editDialog) } @@ -185,15 +190,16 @@ class SnippetManagerFragment : Fragment() { val entry = snippets.getOrNull(index) ?: return val deleteDialog = MaterialAlertDialogBuilder(ctx) - .setTitle("Delete Snippet") - .setMessage("Delete \"${entry.prefix}\"?") - .setPositiveButton("Delete") { _, _ -> + .setTitle(ctx.getString(R.string.snippet_delete_title)) + .setMessage(ctx.getString(R.string.snippet_delete_confirm, entry.prefix)) + .setPositiveButton(ctx.getString(R.string.snippet_action_delete)) { _, _ -> snippets.removeAt(index) save() renderList() } - .setNegativeButton("Cancel", null) - .show() + .setNegativeButton(ctx.getString(R.string.snippet_action_cancel), null) + .create() + PluginWindows.showDialog(deleteDialog) applyDialogButtonColors(deleteDialog) } @@ -211,10 +217,10 @@ class SnippetManagerFragment : Fragment() { SnippetsConfigParser.write(file, SnippetsConfig(snippets.toList())) SnippetsPlugin.instance?.invalidateCache() SnippetsPlugin.instance?.refreshRegistry() - Toast.makeText(requireContext(), "Snippets saved", Toast.LENGTH_SHORT).show() + PluginWindows.showToast(requireContext(), getString(R.string.snippet_msg_saved)) } catch (e: Exception) { Log.e("SnippetManager", "Failed to save snippets", e) - Toast.makeText(requireContext(), "Failed to save", Toast.LENGTH_SHORT).show() + PluginWindows.showToast(requireContext(), getString(R.string.snippet_msg_save_failed)) } } diff --git a/snippets/src/main/res/values/strings.xml b/snippets/src/main/res/values/strings.xml new file mode 100644 index 00000000..25a84fce --- /dev/null +++ b/snippets/src/main/res/values/strings.xml @@ -0,0 +1,13 @@ + + + New Snippet + Edit Snippet + Save + Cancel + Delete + Delete Snippet + Delete \"%1$s\"? + All fields are required + Snippets saved + Failed to save +