Make new strings translatable

This commit is contained in:
Arjan Schrijver
2025-12-25 14:45:08 +01:00
committed by Arjan Schrijver
parent 441c21c9f3
commit 87754b654f
9 changed files with 74 additions and 33 deletions
+1 -1
View File
@@ -212,7 +212,7 @@
android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".activities.InternetHelperPreferencesActivity"
android:label="@string/prefs_title_internet_helper"
android:label="@string/prefs_internet_helper_title"
android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".activities.AboutUserPreferencesActivity"
@@ -16,6 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.activities
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
@@ -63,7 +64,7 @@ class InternetHelperPreferencesActivity : AbstractGBActivity() {
val recyclerView = findViewById<RecyclerView>(R.id.internet_helper_url_list)
recyclerView.isNestedScrollingEnabled = false
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = UrlListAdapter(urlItems) { entry, action ->
recyclerView.adapter = UrlListAdapter(this, urlItems) { entry, action ->
when (action) {
UrlListAdapter.UrlAction.ALLOW -> {
entry.urlFilterEntry.allowed = true
@@ -81,17 +82,17 @@ class InternetHelperPreferencesActivity : AbstractGBActivity() {
setText(entry.urlFilterEntry.url)
}
inputLayout.addView(editText)
inputLayout.hint = "Please enter (a part of) a URL to match against."
inputLayout.hint = getString(R.string.internet_helper_url_filter_hint)
MaterialAlertDialogBuilder(this)
.setTitle("URL filter")
.setTitle(getString(R.string.internet_helper_url_filter_title))
.setView(inputLayout)
.setPositiveButton(R.string.ok) { dialog, _ ->
.setPositiveButton(R.string.save) { dialog, _ ->
entry.urlFilterEntry.url = editText.text.toString()
DBHelper.store(entry.urlFilterEntry)
recyclerView.adapter?.notifyDataSetChanged()
}
.setNegativeButton("Cancel", null)
.setNegativeButton(getString(R.string.Cancel), null)
.show()
}
UrlListAdapter.UrlAction.DELETE -> {
@@ -102,7 +103,7 @@ class InternetHelperPreferencesActivity : AbstractGBActivity() {
recyclerView.adapter?.notifyDataSetChanged()
}
.setNegativeButton(R.string.no, null)
.setMessage("Are you sure you want to delete this URL?")
.setMessage(getString(R.string.internet_helper_url_filter_delete))
.show()
}
}
@@ -130,6 +131,7 @@ class InternetHelperPreferencesActivity : AbstractGBActivity() {
}
class UrlListAdapter(
private val context: Context,
private val urls: List<UrlEntry>,
private val onAction: (UrlEntry, UrlAction) -> Unit
) : RecyclerView.Adapter<UrlListAdapter.UrlViewHolder>() {
@@ -157,7 +159,10 @@ class InternetHelperPreferencesActivity : AbstractGBActivity() {
val entry = urls[position]
holder.title.text = entry.urlFilterEntry.url
holder.status.text = if (entry.urlFilterEntry.allowed) "Allowed" else "Denied"
holder.status.text = if (entry.urlFilterEntry.allowed)
context.getString(R.string.internet_helper_url_allowed)
else
context.getString(R.string.internet_helper_url_denied)
holder.menuButton.setOnClickListener {
showPopupMenu(holder.menuButton, entry)
@@ -167,12 +172,16 @@ class InternetHelperPreferencesActivity : AbstractGBActivity() {
private fun showPopupMenu(anchor: View, entry: UrlEntry) {
val popupMenu = PopupMenu(anchor.context, anchor)
if (entry.urlFilterEntry.allowed) {
popupMenu.menu.add(Menu.NONE, 1, Menu.NONE, "Deny")
popupMenu.menu.add(Menu.NONE, 1, Menu.NONE,
context.getString(R.string.internet_helper_url_action_deny))
} else {
popupMenu.menu.add(Menu.NONE, 2, Menu.NONE, "Allow")
popupMenu.menu.add(Menu.NONE, 2, Menu.NONE,
context.getString(R.string.internet_helper_url_action_allow))
}
popupMenu.menu.add(Menu.NONE, 3, Menu.NONE, "Edit")
popupMenu.menu.add(Menu.NONE, 4, Menu.NONE, "Delete")
popupMenu.menu.add(Menu.NONE, 3, Menu.NONE,
context.getString(R.string.internet_helper_url_action_edit))
popupMenu.menu.add(Menu.NONE, 4, Menu.NONE,
context.getString(R.string.internet_helper_url_action_delete))
popupMenu.setOnMenuItemClickListener { item ->
when (item.itemId) {
@@ -131,7 +131,10 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
override fun onResponse(response: HttpResponse) {
val contentType = response.headers["content-type"]?.split(";")?.get(0)
if (!contentType.equals("application/octet-stream") && !contentType.equals("application/zip")) {
GB.toast("Download failed, wrong content-type: $contentType", Toast.LENGTH_LONG, GB.ERROR)
GB.toast(
getString(R.string.rebble_appstore_download_failed_wrong_content_type, contentType),
Toast.LENGTH_LONG, GB.ERROR
)
return
}
val inputStream = ParcelFileDescriptor.AutoCloseInputStream(response.body)
@@ -158,7 +161,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
startActivity(startIntent)
}
override fun onException(message: String?) {
GB.toast("Download failed: $message", Toast.LENGTH_LONG, GB.ERROR)
GB.toast(getString(R.string.rebble_appstore_download_failed, message), Toast.LENGTH_LONG, GB.ERROR)
}
})
}
@@ -171,7 +174,10 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
override fun onResponse(response: HttpResponse) {
val contentType = response.headers["content-type"]?.split(";")?.get(0)
if (!contentType.equals("application/json")) {
GB.toast("Fetching app info failed, wrong content-type: $contentType", Toast.LENGTH_LONG, GB.ERROR)
GB.toast(
getString(R.string.rebble_appstore_fetch_app_info_failed_content_type, contentType),
Toast.LENGTH_LONG, GB.ERROR
)
return
}
val inputStream = ParcelFileDescriptor.AutoCloseInputStream(response.body)
@@ -184,7 +190,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
downloadInstallWatchapp(pbwFile.toUri())
}
override fun onException(message: String?) {
GB.toast("Fetching download file failed: $message", Toast.LENGTH_LONG, GB.ERROR)
GB.toast(getString(R.string.rebble_appstore_fetching_download_file_failed, message), Toast.LENGTH_LONG, GB.ERROR)
}
})
}
@@ -147,8 +147,8 @@ public class PermissionsUtils {
if (AndroidUtils.isPackageInstalled(PACKAGE_INTERNET_HELPER)) {
permissionsList.add(new PermissionDetails(
CUSTOM_PERM_INTERNET_HELPER,
"Internet helper",
"Permit access to the Gadgetbridge-internethelper add-on app"
activity.getString(R.string.internet_helper_permission_title),
activity.getString(R.string.internet_helper_permission_summary)
));
}
// permissionsList.add(new PermissionDetails( // NOTE: can't request this, it's only allowed for system apps
@@ -24,7 +24,7 @@
android:id="@+id/url_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Allowed"
android:text="@string/internet_helper_url_allowed"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
app:layout_constraintStart_toStartOf="@id/url_title"
@@ -36,7 +36,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu"
android:contentDescription="Options"
android:contentDescription="@string/internet_helper_url_options"
android:background="?attr/selectableItemBackgroundBorderless"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
+2 -2
View File
@@ -4651,8 +4651,8 @@
</string-array>
<string-array name="internethelper_new_url_action">
<item>Allow</item>
<item>Deny</item>
<item>@string/internet_helper_url_action_allow</item>
<item>@string/internet_helper_url_action_deny</item>
</string-array>
<string-array name="internethelper_new_url_action_values">
<item>allow</item>
+27 -1
View File
@@ -1383,6 +1383,7 @@
<string name="Delete">Delete</string>
<string name="delete_device_and_retain_files">Keep Files</string>
<string name="ok">OK</string>
<string name="save">Save</string>
<string name="dismiss">Dismiss</string>
<string name="notifications_dismiss_all">Dismiss All</string>
<string name="start">Start</string>
@@ -4449,5 +4450,30 @@
<string name="pref_notifications_pictures_enable">Send notification pictures</string>
<string name="pref_notifications_pictures_enable_summary">Send notification pictures for current device</string>
<string name="activity_title_rebble_app_store">Rebble app store</string>
<string name="prefs_title_internet_helper">Internet helper</string>
<string name="prefs_internet_helper_title">Internet helper</string>
<string name="prefs_internet_helper_summary">Configure the URLs that are allowed to be requested through the internet helper add-on app</string>
<string name="internet_helper_url_filter_hint">Please enter (a part of) a URL to match against.</string>
<string name="internet_helper_url_filter_title">URL filter</string>
<string name="internet_helper_url_filter_delete">Are you sure you want to delete this URL?</string>
<string name="internet_helper_url_allowed">Allowed</string>
<string name="internet_helper_url_denied">Denied</string>
<string name="internet_helper_url_action_deny">Deny</string>
<string name="internet_helper_url_action_allow">Allow</string>
<string name="internet_helper_url_action_edit">Edit</string>
<string name="internet_helper_url_action_delete">Delete</string>
<string name="internet_helper_url_options">Options</string>
<string name="internet_helper_pref_app_req_title">Add-on app required</string>
<string name="internet_helper_pref_app_req_summary">This feature requires the installation of an add-on app. Tap here to go to the download page.</string>
<string name="internet_helper_pref_new_url_action_title">New URL action</string>
<string name="internet_helper_pref_new_url_action_summary">Set the default action to take when a URL is requested that isn\'t already in the list below.</string>
<string name="internet_helper_pref_intercept_supported_title">Intercept supported requests</string>
<string name="internet_helper_pref_intercept_supported_summary">Some internet requests can be intercepted and responded to locally without sending anything to the internet.</string>
<string name="internet_helper_pref_known_urls_title">Known URLs</string>
<string name="internet_helper_url_list_instruction_summary">Use the list below to configure which (parts of) URLs are allowed or denied to be forwarded to the internethelper add-on app. The validation is using a simple text comparison, so a part of a URL can be entered too.</string>
<string name="rebble_appstore_download_failed_wrong_content_type">Download failed, wrong content-type: %1$s</string>
<string name="rebble_appstore_download_failed">Download failed: %1$s</string>
<string name="rebble_appstore_fetch_app_info_failed_content_type">Fetching app info failed, wrong content-type: %1$s</string>
<string name="rebble_appstore_fetching_download_file_failed">Fetching download file failed: %1$s</string>
<string name="internet_helper_permission_title">Internet helper add-on</string>
<string name="internet_helper_permission_summary">Permit access to the Gadgetbridge-internethelper add-on app</string>
</resources>
@@ -5,8 +5,8 @@
<Preference
android:icon="@drawable/ic_warning"
android:key="pref_key_internethelper_not_installed"
android:title="Add-on app required"
android:summary="This feature requires the installation of an add-on app. Tap here to go to the download page." />
android:title="@string/internet_helper_pref_app_req_title"
android:summary="@string/internet_helper_pref_app_req_summary" />
<PreferenceCategory
android:title="@string/pref_header_general"
app:iconSpaceReserved="false">
@@ -15,24 +15,24 @@
android:entries="@array/internethelper_new_url_action"
android:entryValues="@array/internethelper_new_url_action_values"
android:key="pref_key_internethelper_new_url_action"
android:summary="Set the default action to take when a URL is requested that isn't already in the list below."
android:title="New URL action"
android:title="@string/internet_helper_pref_new_url_action_title"
android:summary="@string/internet_helper_pref_new_url_action_summary"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_key_internethelper_force_local"
android:layout="@layout/preference_checkbox"
android:title="Intercept supported requests"
android:summary="Some internet requests can be intercepted and responded to locally without sending anything to the internet."
android:title="@string/internet_helper_pref_intercept_supported_title"
android:summary="@string/internet_helper_pref_intercept_supported_summary"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_internethelper_url_list"
android:title="Known URLs"
android:title="@string/internet_helper_pref_known_urls_title"
app:iconSpaceReserved="false">
<Preference
android:key="pref_key_internethelper_info"
android:summary="Use the list below to configure which (parts of) URLs are allowed or denied to be forwarded to the internethelper add-on app. The validation is using a simple text comparison, so a part of a URL can be entered too."
android:summary="@string/internet_helper_url_list_instruction_summary"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
+2 -2
View File
@@ -341,8 +341,8 @@
<PreferenceScreen
android:icon="@drawable/ic_language"
android:key="pref_category_internethelper"
android:title="Internet helper"
android:summary="Configure the URLs that are allowed to be requested through the internet helper add-on app" />
android:title="@string/prefs_internet_helper_title"
android:summary="@string/prefs_internet_helper_summary" />
</PreferenceScreen>
<Preference