Skip to content
Snippets Groups Projects
Commit 372f94bd authored by Pierre Nicolas's avatar Pierre Nicolas :joy:
Browse files

cleanup: remove hardcoded strings

GitLab: #1684

Change-Id: I0153fe8e2fd86ced8df21401075c8edb0797c12c
parent a23de6f2
Branches
Tags
No related merge requests found
Showing
with 71 additions and 38 deletions
......@@ -180,8 +180,11 @@ class AccountWizardActivity : BaseActivity<AccountWizardPresenter>(), AccountWiz
}
override fun displayCreationError() {
Toast.makeText(this@AccountWizardActivity, "Error creating account", Toast.LENGTH_SHORT)
.show()
Toast.makeText(
this@AccountWizardActivity,
getString(R.string.account_creation_error),
Toast.LENGTH_SHORT
).show()
}
override fun blockOrientation() {
......
......@@ -33,6 +33,7 @@ import dagger.hilt.android.AndroidEntryPoint
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import net.jami.account.HomeAccountCreationPresenter
import net.jami.account.HomeAccountCreationView
import net.jami.utils.Log
import java.io.File
@AndroidEntryPoint
......@@ -87,7 +88,7 @@ class HomeAccountCreationFragment :
.setType("*/*"), ARCHIVE_REQUEST_CODE)
} catch (e: Exception) {
view?.let { v ->
Snackbar.make(v, "No file browser available on this device", Snackbar.LENGTH_SHORT).show() }
Snackbar.make(v, getString(R.string.browser_error), Snackbar.LENGTH_SHORT).show() }
}
}
......@@ -104,8 +105,9 @@ class HomeAccountCreationFragment :
replaceFragmentWithSlide(
JamiLinkAccountFragment(), JamiLinkAccountFragment.TAG, R.id.wizard_container)
}) { e: Throwable ->
Log.e(TAG, "Error importing archive", e)
view?.let { v ->
Snackbar.make(v, "Can't import archive: " + e.message, Snackbar.LENGTH_LONG).show() }
Snackbar.make(v, getString(R.string.import_archive_error), Snackbar.LENGTH_LONG).show() }
}
}
}
......
......@@ -193,8 +193,14 @@ class JamiAccountSummaryFragment :
.observeOn(DeviceUtils.uiScheduler)
.subscribe({}) { e: Throwable ->
val v = view
if (v != null)
Snackbar.make(v, "Can't export archive: " + e.message, Snackbar.LENGTH_LONG).show()
if (v != null) {
Log.e(TAG, "Error exporting archive", e)
Snackbar.make(
v,
getString(R.string.export_archive_error),
Snackbar.LENGTH_LONG
).show()
}
}
}
}
......@@ -464,7 +470,11 @@ class JamiAccountSummaryFragment :
tmpProfilePhotoUri = uri
startActivityForResult(intent, HomeActivity.REQUEST_CODE_PHOTO)
} catch (e: Exception) {
Toast.makeText(requireContext(), "Error starting camera: " + e.localizedMessage, Toast.LENGTH_SHORT).show()
Toast.makeText(
requireContext(),
getString(R.string.starting_camera_error),
Toast.LENGTH_SHORT
).show()
Log.e(TAG, "Can't create temp file", e)
}
}
......
......@@ -1049,7 +1049,7 @@ class ConversationAdapter(
Log.w(TAG, "Message ${it.type} ${it.body} $it")
}
MaterialAlertDialogBuilder(it.context)
.setTitle("Message history")
.setTitle(it.context.getString(R.string.menu_message_history))
.setItems(c.filterIsInstance<TextMessage>().map { it.body!! }
.toTypedArray())
{ dialog, _ -> dialog.dismiss() }
......
......@@ -18,6 +18,7 @@ package cx.ring.client
import android.Manifest
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.ColorStateList
......@@ -72,6 +73,7 @@ import net.jami.services.DeviceRuntimeService
import net.jami.services.HardwareService
import net.jami.services.NotificationService
import java.io.ByteArrayOutputStream
import java.io.IOException
import javax.inject.Inject
import javax.inject.Singleton
......@@ -299,9 +301,16 @@ class ContactDetailsActivity : AppCompatActivity(), TabLayout.OnTabSelectedListe
.putExtra("android.intent.extra.USE_FRONT_CAMERA", true)
tmpProfilePhotoUri = uri
cameraResultLauncher.launch(intent)
} catch (e: Exception) {
Toast.makeText(this, "Error starting camera: " + e.localizedMessage, Toast.LENGTH_SHORT).show()
} catch (e: IOException) {
Log.e(TAG, "Can't create temp file", e)
} catch (e: IllegalArgumentException) {
Log.e(TAG, "File is outside the paths supported by the provider", e)
} catch (e: ActivityNotFoundException) {
Log.e(TAG, "No camera app found", e)
} catch (e: Exception) {
Log.e(TAG, "Error launching camera", e)
} finally {
Toast.makeText(this, getString(R.string.camera_error), Toast.LENGTH_SHORT).show()
}
}
......
......@@ -118,7 +118,8 @@ class LogsActivity : AppCompatActivity() {
}
startActivity(Intent.createChooser(sendIntent, null))
}) { e: Throwable ->
Snackbar.make(binding.root, "Error sharing logs: " + e.localizedMessage, Snackbar.LENGTH_SHORT).show()
Log.e(TAG, "Error sharing logs", e)
Snackbar.make(binding.root, getString(R.string.sharing_log_error), Snackbar.LENGTH_SHORT).show()
})
}
fun saveFile(fileMaybe: Maybe<File>) {
......@@ -246,7 +247,7 @@ class LogsActivity : AppCompatActivity() {
}
}.show(supportFragmentManager, CrashBottomSheet.TAG)
} else if (userInitiated) {
Snackbar.make(binding.root, "No recent native crash", Snackbar.LENGTH_SHORT).show()
Snackbar.make(binding.root, getString(R.string.no_native_crash), Snackbar.LENGTH_SHORT).show()
}
}
......
......@@ -313,7 +313,11 @@ class RingtoneActivity : AppCompatActivity() {
AndroidFileUtils.getCacheFile(this, uri)
.observeOn(DeviceUtils.uiScheduler)
.subscribe({ ringtone: File -> onFileFound(ringtone) }) {
Toast.makeText(this, "Can't load ringtone !", Toast.LENGTH_SHORT).show()
Toast.makeText(
this,
getString(R.string.load_ringtone_error),
Toast.LENGTH_SHORT
).show()
}
}
}
......
......@@ -1275,8 +1275,11 @@ class CallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView,
displayLocalVideo(false)
}
} else {
Toast.makeText(requireContext(), "Can't start screen sharing", Toast.LENGTH_SHORT)
.show()
Toast.makeText(
requireContext(),
getString(R.string.screen_sharing_error),
Toast.LENGTH_SHORT
).show()
}
}
......
......@@ -508,7 +508,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
startActivityForResult(intent, REQUEST_CODE_CAPTURE_AUDIO)
} catch (ex: Exception) {
Log.e(TAG, "sendAudioMessage: error", ex)
Toast.makeText(activity, "Can't find audio recorder app", Toast.LENGTH_SHORT).show()
Toast.makeText(activity, getString(R.string.audio_recorder_error), Toast.LENGTH_SHORT).show()
}
}
}
......@@ -531,7 +531,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
startActivityForResult(intent, REQUEST_CODE_CAPTURE_VIDEO)
} catch (ex: Exception) {
Log.e(TAG, "sendVideoMessage: error", ex)
Toast.makeText(activity, "Can't find video recorder app", Toast.LENGTH_SHORT).show()
Toast.makeText(activity, getString(R.string.video_recorder_error), Toast.LENGTH_SHORT).show()
}
}
}
......@@ -554,7 +554,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
mCurrentPhoto = photoFile
startActivityForResult(takePictureIntent, REQUEST_CODE_TAKE_PICTURE)
} catch (e: Exception) {
Toast.makeText(c, "Error taking picture: " + e.localizedMessage, Toast.LENGTH_SHORT)
Toast.makeText(c, getString(R.string.taking_picture_error), Toast.LENGTH_SHORT)
.show()
}
}
......@@ -624,7 +624,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
if (sendingFile != null)
startFileSend(sendingFile.flatMapCompletable { f -> sendFile(f) })
else
Toast.makeText(activity, "Can't find picture", Toast.LENGTH_SHORT).show()
Toast.makeText(activity, getString(R.string.find_picture_error), Toast.LENGTH_SHORT).show()
} else if (requestCode == REQUEST_CODE_SAVE_FILE) {
val uri = resultData?.data
if (resultCode == Activity.RESULT_OK && uri != null) {
......
......@@ -139,7 +139,7 @@ class HomeFragment: BaseSupportFragment<HomePresenter, HomeView>(),
searchBar.setNavigationOnClickListener { // Account selection
val accounts = mAccountService.observableAccountList.blockingFirst()
MaterialAlertDialogBuilder(requireContext())
.setTitle("Select Account")
.setTitle(getString(R.string.account_selection))
.setAdapter(
AccountAdapter(
requireContext(),
......
......@@ -71,7 +71,7 @@ class LinkDeviceFragment : BaseBottomSheetFragment<LinkDevicePresenter>(), LinkD
// Android 13 and higher automatically provide visual feedback when an app copies content
// to the clipboard. Provide manual notification in Android 12L (API level 32) and lower
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2)
Toast.makeText(context, "Pin code copied", Toast.LENGTH_SHORT).show()
Toast.makeText(context, getString(R.string.pin_copied), Toast.LENGTH_SHORT).show()
}
}
......
......@@ -111,10 +111,7 @@ class PluginsListSettingsFragment : Fragment(), PluginListItemListener {
unloadPlugin(pluginDetails.rootPath)
status = getString(R.string.unload_sucess, pluginDetails.name)
}
Toast.makeText(
requireContext(), status,
Toast.LENGTH_SHORT
).show()
Toast.makeText(requireContext(), status, Toast.LENGTH_SHORT).show()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
......@@ -174,11 +171,12 @@ class PluginsListSettingsFragment : Fragment(), PluginListItemListener {
}
mAdapter!!.updatePluginsList(getInstalledPlugins(requireContext()))
showLoading(false)
Toast.makeText(requireContext(), "Plugin: $filename successfully installed", Toast.LENGTH_LONG)
Toast.makeText(requireContext(), getString(R.string.install_sucess, filename), Toast.LENGTH_LONG)
.show()
}) { e: Throwable ->
if (binding != null) {
val sb = Snackbar.make(binding!!.listLayout, "" + e.message, Snackbar.LENGTH_LONG)
Log.e(TAG, "Error importing plugin", e)
val sb = Snackbar.make(binding!!.listLayout, getString(R.string.install_error), Snackbar.LENGTH_LONG)
sb.setAction(R.string.plugin_force_install) { v: View? -> installPluginFromUri(uri, true) }
sb.show()
}
......
......@@ -124,7 +124,7 @@ class TVAccountWizard : BaseActivity<AccountWizardPresenter>(), AccountWizardVie
}
override fun displayCreationError() {
Toast.makeText(this@TVAccountWizard, "Error creating account", Toast.LENGTH_SHORT).show()
Toast.makeText(this@TVAccountWizard, getString(R.string.account_creation_error), Toast.LENGTH_SHORT).show()
}
override fun blockOrientation() {
......
......@@ -92,7 +92,7 @@ class CustomCameraActivity : Activity() {
try {
mCamera!!.takePicture(null, null, mPicture)
} catch (e: Exception) {
Toast.makeText(this, "Error taking picture", Toast.LENGTH_LONG).show()
Toast.makeText(this, getString(R.string.taking_picture_error), Toast.LENGTH_LONG).show()
finish()
}
}
......@@ -173,7 +173,7 @@ class CustomCameraActivity : Activity() {
}
}
}) { e: Throwable ->
Toast.makeText(this, "Can't open camera", Toast.LENGTH_LONG).show()
Toast.makeText(this, getString(R.string.open_camera_error), Toast.LENGTH_LONG).show()
finish()
})
}
......@@ -249,7 +249,8 @@ class CustomCameraActivity : Activity() {
recorder!!.prepare()
recorder!!.start()
} catch (e: Exception) {
Toast.makeText(this, "Error starting the recorder: " + e.localizedMessage, Toast.LENGTH_LONG).show()
Toast.makeText(this, getString(R.string.starting_recorder_error), Toast.LENGTH_LONG).show()
Log.e(TAG, "Error starting recorder", e)
finish()
}
}
......
......@@ -255,6 +255,7 @@ object AndroidFileUtils {
private val dateFormat = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US)
@Throws(IOException::class)
fun createImageFile(context: Context): File =
File.createTempFile("img_${dateFormat.format(Date())}_", ".jpg", getTempShareDir(context))
......
......@@ -50,7 +50,7 @@
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="2"
android:text="Reply" />
tools:text="Reply" />
</LinearLayout>
<LinearLayout
......
......@@ -2,15 +2,16 @@
<com.google.android.material.chip.ChipGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal">
<com.google.android.material.chip.Chip
android:text="@string/default_emoji_1"
tools:text="@string/default_emoji_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.google.android.material.chip.Chip
android:text="👍😍 3"
tools:text="👍😍 3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
......
......@@ -47,7 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="You have no document yet" />
android:text="@string/swarm_detail_no_document" />
</LinearLayout>
......
......@@ -93,14 +93,14 @@
android:layout_height="wrap_content"
android:checkable="true"
android:checked="true"
android:text="1 hour" />
tools:text="1 hour" />
<com.google.android.material.chip.Chip
android:id="@+id/location_share_time_10m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="true"
android:text="10 minutes" />
tools:text="10 minutes" />
</com.google.android.material.chip.ChipGroup>
......
......@@ -58,6 +58,6 @@
android:textAppearance="@style/TextAppearance.Material3.LabelSmall"
android:ellipsize="middle"
android:singleLine="true"
android:text="2.7GB" />
tools:text="2.7GB" />
</RelativeLayout>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment