export hardcoded strings (#547)

This commit is contained in:
Andre K
2022-12-28 17:37:25 -03:00
committed by GitHub
parent 96ea0bf5a9
commit 99a42b1aa1
43 changed files with 186 additions and 468 deletions

View File

@@ -18,21 +18,21 @@ class AppIntroduction : AppIntro() {
// You can use AppIntroFragment to use a pre-built fragment
addSlide(
AppIntroFragment.createInstance(
title = resources.getString(R.string.intro_welcome_title),
description = resources.getString(R.string.intro_meshtastic_desc),
title = resources.getString(R.string.intro_welcome),
description = resources.getString(R.string.intro_welcome_text),
imageDrawable = R.mipmap.ic_launcher2_round,
backgroundColorRes = R.color.colourGrey,
descriptionColorRes = R.color.colorOnPrimary
))
addSlide(AppIntroFragment.createInstance(
title = resources.getString(R.string.intro_get_started),
title = resources.getString(R.string.intro_started),
description = resources.getString(R.string.intro_started_text),
imageDrawable = R.drawable.icon_meanings,
backgroundColorRes = R.color.colourGrey,
descriptionColorRes = R.color.colorOnPrimary
))
addSlide(AppIntroFragment.createInstance(
title = resources.getString(R.string.intro_encryption_title),
title = resources.getString(R.string.intro_encryption),
description = resources.getString(R.string.intro_encryption_text),
imageDrawable = R.drawable.channel_name_image,
backgroundColorRes = R.color.colourGrey,

View File

@@ -829,7 +829,7 @@ class MainActivity : AppCompatActivity(), Logging {
/// Prepare dialog and its items
val builder = MaterialAlertDialogBuilder(this)
builder.setTitle(getString(R.string.choose_theme_title))
builder.setTitle(getString(R.string.choose_theme))
val styles = arrayOf(
getString(R.string.theme_light),

View File

@@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.widget.Toast
import com.geeksville.mesh.R
import java.util.*
/**
@@ -26,7 +27,7 @@ class ExpireChecker(val context: Activity) : Logging {
Toast.makeText(
context,
"This application is out of date and must be updated",
R.string.app_too_old,
Toast.LENGTH_LONG
).show()
val i = Intent(Intent.ACTION_VIEW)

View File

@@ -149,7 +149,7 @@ class MeshService : Service(), Logging {
private fun getSenderName(packet: DataPacket?): String {
val name = nodeDBbyID[packet?.from]?.user?.longName
return name ?: "Unknown username"
return name ?: getString(R.string.unknown_username)
}
private val notificationSummary

View File

@@ -242,7 +242,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
// User just locked it, we should warn and then apply changes to radio
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.reset_to_defaults)
.setMessage(R.string.are_you_shure_change_default)
.setMessage(R.string.are_you_sure_change_default)
.setNeutralButton(R.string.cancel) { _, _ ->
setGUIfromModel() // throw away any edits
}

View File

@@ -13,7 +13,7 @@ import com.google.android.material.composethemeadapter.MdcTheme
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class DeviceSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
class DeviceSettingsFragment : ScreenFragment("Device Settings"), Logging {
private var _binding: ComposeViewBinding? = null
private val binding get() = _binding!!

View File

@@ -8,7 +8,6 @@ import android.graphics.Color
import android.graphics.Paint
import android.graphics.Rect
import android.os.Bundle
import android.util.Log
import android.view.*
import android.widget.*
import androidx.core.content.ContextCompat
@@ -31,7 +30,6 @@ import org.osmdroid.config.Configuration
import org.osmdroid.events.MapListener
import org.osmdroid.events.ScrollEvent
import org.osmdroid.events.ZoomEvent
import org.osmdroid.tileprovider.MapTileProviderBasic
import org.osmdroid.tileprovider.cachemanager.CacheManager
import org.osmdroid.tileprovider.cachemanager.CacheManager.CacheManagerCallback
import org.osmdroid.tileprovider.modules.SqliteArchiveTileWriter
@@ -45,11 +43,10 @@ import org.osmdroid.views.MapView
import org.osmdroid.views.overlay.*
import org.osmdroid.views.overlay.gridlines.LatLonGridlineOverlay2
import java.io.File
import kotlin.math.pow
@AndroidEntryPoint
class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
class MapFragment : ScreenFragment("Map Fragment"), Logging, View.OnClickListener {
// UI Elements
private lateinit var binding: MapViewBinding
@@ -150,13 +147,13 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
activity
)
// set title
alertDialogBuilder.setTitle("Offline Manager")
alertDialogBuilder.setTitle(R.string.map_offline_manager)
// set dialog message
alertDialogBuilder.setItems(
arrayOf<CharSequence>(
"Current Cache size",
"Download Region",
"Clear Downloaded Tiles",
resources.getString(R.string.map_cache_size),
resources.getString(R.string.map_download_region),
resources.getString(R.string.map_clear_tiles),
resources.getString(R.string.cancel)
)
) { dialog, which ->
@@ -181,7 +178,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
private fun purgeTileSource() {
cache = SqlTileWriterExt()
val builder = AlertDialog.Builder(context)
builder.setTitle("Tile Source")
builder.setTitle(R.string.map_tile_source)
val sources = cache!!.sources
val sourceList = mutableListOf<String>()
for (i in sources.indices) {
@@ -200,43 +197,43 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
}
}
builder.setPositiveButton("Clear") { _, _ ->
builder.setPositiveButton(R.string.clear) { _, _ ->
for (x in selectedList) {
val item = sources[x]
val b = cache!!.purgeCache(item.source)
if (b) Toast.makeText(
context,
"SQL Cache purged for ${item.source}",
getString(R.string.map_purge_success).format(item.source),
Toast.LENGTH_SHORT
)
.show() else Toast.makeText(
context,
"SQL Cache purge failed, see logcat for details",
R.string.map_purge_fail,
Toast.LENGTH_LONG
).show()
}
}
builder.setNegativeButton(
"Cancel"
R.string.cancel
) { dialog, _ -> dialog.cancel() }
builder.show()
}
private fun showCurrentCacheInfo() {
Toast.makeText(activity, "Calculating...", Toast.LENGTH_SHORT).show()
Toast.makeText(activity, R.string.calculating, Toast.LENGTH_SHORT).show()
cacheManager = CacheManager(map) // Make sure CacheManager has latest from map
Thread {
val alertDialogBuilder = AlertDialog.Builder(
activity
)
// set title
alertDialogBuilder.setTitle("Cache Manager")
alertDialogBuilder.setTitle(R.string.map_cache_manager)
.setMessage(
"""
Cache Capacity (mb): ${cacheManager.cacheCapacity() * 2.0.pow(-20.0)}
Cache Usage (mb): ${cacheManager.currentCacheUsage() * 2.0.pow(-20.0)}
""".trimIndent()
getString(R.string.map_cache_info).format(
cacheManager.cacheCapacity() / (1024.0 * 1024.0),
cacheManager.currentCacheUsage() / (1024.0 * 1024.0)
)
)
// set dialog message
alertDialogBuilder.setItems(
@@ -301,13 +298,13 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
map.overlayManager.add(polygon)
mapController.setZoom(zoomLevel - 1.0)
cacheManager = CacheManager(map)
val tilecount: Int =
val tileCount: Int =
cacheManager.possibleTilesInArea(
downloadRegionBoundingBox,
zoomLevelMax.toInt(),
zoomLevelMin.toInt()
)
cacheEstimate.text = ("$tilecount tiles")
cacheEstimate.text = getString(R.string.map_cache_tiles).format(tileCount)
}
@@ -330,7 +327,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
cacheManager =
CacheManager(map, writer) // Make sure cacheManager has latest from map
} catch (ex: TileSourcePolicyException) {
Log.d("MapFragment", "Tilesource does not allow archiving: ${ex.message}")
debug("Tile source does not allow archiving: ${ex.message}")
return
}
//this triggers the download
@@ -353,7 +350,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
zoommax,
object : CacheManagerCallback {
override fun onTaskComplete() {
Toast.makeText(activity, "Download complete!", Toast.LENGTH_LONG)
Toast.makeText(activity, R.string.map_download_complete, Toast.LENGTH_LONG)
.show()
writer.onDetach()
defaultMapSettings()
@@ -362,7 +359,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
override fun onTaskFailed(errors: Int) {
Toast.makeText(
activity,
"Download complete with $errors errors",
getString(R.string.map_download_errors).format(errors),
Toast.LENGTH_LONG
).show()
writer.onDetach()
@@ -390,9 +387,16 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
private fun chooseMapStyle() {
/// Prepare dialog and its items
val mapStyles by lazy { resources.getStringArray(R.array.map_styles) }
val builder = MaterialAlertDialogBuilder(context!!)
val mapStyles = arrayOf<CharSequence>(
"OpenStreetMap",
"USGS TOPO",
"Open TOPO",
"ESRI World TOPO",
"USGS Satellite",
"ESRI World Overview",
)
/// Load preferences and its value
val mapStyleInt = mPrefs.getInt(mapStyleId, 1)
builder.setSingleChoiceItems(mapStyles, mapStyleInt) { dialog, which ->
@@ -461,7 +465,10 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
marker.snippet = model.gpsString(p)
model.nodeDB.ourNodeInfo.value?.let { our ->
our.distanceStr(node)?.let { dist ->
marker.subDescription = "bearing: ${our.bearing(node)}° distance: $dist"
marker.subDescription = getString(R.string.map_subDescription).format(
our.bearing(node),
dist
)
}
}
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM)
@@ -617,7 +624,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
map.onResume()
}
override fun onDestroy() {
override fun onDestroyView() {
super.onDestroyView()
map.onDetach()
}

View File

@@ -23,7 +23,7 @@ import dagger.hilt.android.AndroidEntryPoint
import java.util.*
@AndroidEntryPoint
class QuickChatSettingsFragment : ScreenFragment("Quick Chat settings"), Logging {
class QuickChatSettingsFragment : ScreenFragment("Quick Chat Settings"), Logging {
private var _binding: QuickChatSettingsFragmentBinding? = null
private val binding get() = _binding!!
@@ -44,9 +44,9 @@ class QuickChatSettingsFragment : ScreenFragment("Quick Chat settings"), Logging
super.onViewCreated(view, savedInstanceState)
binding.quickChatSettingsCreateButton.setOnClickListener {
val builder = createEditDialog(requireContext(), "New quick chat")
val builder = createEditDialog(requireContext(), getString(R.string.quick_chat_new))
builder.builder.setPositiveButton("Add") { view, x ->
builder.builder.setPositiveButton(R.string.add) { _, _ ->
val name = builder.nameInput.text.toString().trim()
val message = builder.messageInput.text.toString()
@@ -63,7 +63,7 @@ class QuickChatSettingsFragment : ScreenFragment("Quick Chat settings"), Logging
val quickChatActionAdapter =
QuickChatActionAdapter(requireContext(), { action: QuickChatAction ->
val builder = createEditDialog(requireContext(), "Edit quick chat")
val builder = createEditDialog(requireContext(), getString(R.string.quick_chat_edit))
builder.nameInput.setText(action.name)
builder.messageInput.setText(action.message)
val isInstant = action.mode == QuickChatAction.Mode.Instant
@@ -73,7 +73,7 @@ class QuickChatSettingsFragment : ScreenFragment("Quick Chat settings"), Logging
builder.builder.setNegativeButton(R.string.delete) { _, _ ->
model.deleteQuickChatAction(action)
}
builder.builder.setPositiveButton(R.string.save_btn) { _, _ ->
builder.builder.setPositiveButton(R.string.save) { _, _ ->
if (builder.isNotEmpty()) {
model.updateQuickChatAction(
action,
@@ -148,10 +148,10 @@ class QuickChatSettingsFragment : ScreenFragment("Quick Chat settings"), Logging
modeSwitch.setOnCheckedChangeListener { _, _ ->
if (modeSwitch.isChecked) {
modeSwitch.setText(R.string.mode_instant)
modeSwitch.setText(R.string.quick_chat_instant)
instantImage.visibility = View.VISIBLE
} else {
modeSwitch.setText(R.string.mode_append)
modeSwitch.setText(R.string.quick_chat_append)
instantImage.visibility = View.INVISIBLE
}
}

View File

@@ -91,7 +91,7 @@ fun BitwisePreference(
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Red)
) {
Text(
text = stringResource(id = R.string.clear_last_messages),
text = stringResource(id = R.string.clear),
style = MaterialTheme.typography.body1,
color = Color.Unspecified,
)

View File

@@ -48,7 +48,7 @@ fun PreferenceFooter(
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Green)
) {
Text(
text = stringResource(id = R.string.save_btn),
text = stringResource(id = R.string.save),
style = MaterialTheme.typography.body1,
color = if (!enabled) MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled) else Color.DarkGray,
)