Prepare setting screens for localization

This commit is contained in:
nielsandriesse 2020-05-25 16:38:36 +10:00
parent 7855c7dc4f
commit 61733d90ba
8 changed files with 72 additions and 41 deletions

View File

@ -43,7 +43,7 @@
android:id="@+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:text="@string/activity_settings_title"
android:textColor="@color/text"
android:textSize="@dimen/very_large_font_size"
android:fontFamily="sans-serif-medium" />
@ -94,7 +94,7 @@
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:visibility="invisible"
android:hint="Enter a display name" />
android:hint="@string/activity_settings_display_name_edit_text_hint" />
<TextView
android:id="@+id/displayNameTextView"
@ -142,7 +142,7 @@
android:layout_width="0dp"
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:text="Copy" />
android:text="@string/copy" />
<Button
style="@style/MediumUnimportantOutlineButton"
@ -151,7 +151,7 @@
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:layout_marginLeft="@dimen/medium_spacing"
android:text="Share" />
android:text="@string/share" />
</LinearLayout>
@ -170,7 +170,7 @@
android:textSize="@dimen/medium_font_size"
android:textStyle="bold"
android:gravity="center"
android:text="Privacy" />
android:text="@string/activity_settings_privacy_button_title" />
<View
android:layout_width="match_parent"
@ -186,7 +186,7 @@
android:textSize="@dimen/medium_font_size"
android:textStyle="bold"
android:gravity="center"
android:text="Notifications" />
android:text="@string/activity_settings_notifications_button_title" />
<View
android:layout_width="match_parent"
@ -202,7 +202,7 @@
android:textSize="@dimen/medium_font_size"
android:textStyle="bold"
android:gravity="center"
android:text="Chats" />
android:text="@string/activity_settings_chats_button_title" />
<View
android:id="@+id/linkedDevicesButtonTopSeparator"
@ -219,7 +219,7 @@
android:textSize="@dimen/medium_font_size"
android:textStyle="bold"
android:gravity="center"
android:text="Devices" />
android:text="@string/activity_settings_devices_button_title" />
<View
android:id="@+id/seedButtonTopSeparator"
@ -236,7 +236,7 @@
android:textSize="@dimen/medium_font_size"
android:textStyle="bold"
android:gravity="center"
android:text="Recovery Phrase" />
android:text="@string/activity_settings_recovery_phrase_button_title" />
<View
android:layout_width="match_parent"
@ -252,7 +252,7 @@
android:textSize="@dimen/medium_font_size"
android:textStyle="bold"
android:gravity="center"
android:text="Clear All Data" />
android:text="@string/activity_settings_clear_all_data_button_title" />
<View
android:layout_width="match_parent"

View File

@ -14,7 +14,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear All Data"
android:text="@string/dialog_clear_all_data_title"
android:textColor="@color/text"
android:textStyle="bold"
android:textSize="@dimen/medium_font_size" />
@ -24,7 +24,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/large_spacing"
android:text="This will permanently delete your Session ID, including all messages, sessions, and contacts."
android:text="@string/dialog_clear_all_data_explanation"
android:textColor="@color/text"
android:textSize="@dimen/small_font_size"
android:textAlignment="center" />
@ -41,7 +41,7 @@
android:layout_width="0dp"
android:layout_height="@dimen/small_button_height"
android:layout_weight="1"
android:text="Cancel" />
android:text="@string/cancel" />
<Button
style="@style/DestructiveDialogButton"
@ -50,7 +50,7 @@
android:layout_height="@dimen/small_button_height"
android:layout_weight="1"
android:layout_marginLeft="@dimen/medium_spacing"
android:text="Delete" />
android:text="@string/delete" />
</LinearLayout>

View File

@ -14,7 +14,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Recovery Phrase"
android:text="@string/dialog_seed_title"
android:textColor="@color/text"
android:textStyle="bold"
android:textSize="@dimen/medium_font_size" />
@ -33,7 +33,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/large_spacing"
android:text="This is your recovery phrase. With it, you can restore or migrate your Session ID to a new device."
android:text="@string/dialog_seed_explanation"
android:textColor="@color/text"
android:textSize="@dimen/small_font_size"
android:textAlignment="center"
@ -51,7 +51,7 @@
android:layout_width="0dp"
android:layout_height="@dimen/small_button_height"
android:layout_weight="1"
android:text="Cancel" />
android:text="@string/cancel" />
<Button
style="@style/UnimportantDialogButton"
@ -60,7 +60,7 @@
android:layout_height="@dimen/small_button_height"
android:layout_weight="1"
android:layout_marginLeft="@dimen/medium_spacing"
android:text="Copy" />
android:text="@string/copy" />
</LinearLayout>

View File

@ -1680,6 +1680,7 @@
<string name="next">Next</string>
<string name="share">Share</string>
<string name="invalid_session_id">Invalid Session ID</string>
<string name="cancel">Cancel</string>
<string name="activity_landing_title_2">Your Session begins here...</string>
<string name="activity_landing_register_button_title">Create Session ID</string>
@ -1761,10 +1762,16 @@
<string name="fragment_enter_public_key_edit_text_hint">Enter Session ID of recipient</string>
<string name="fragment_enter_public_key_explanation">Users can share their Session ID by going into their account settings and tapping "Share Session ID", or by sharing their QR code.</string>
<string name="activity_create_closed_group_title">New Closed Group</string>
<string name="activity_create_closed_group_edit_text_hint">Enter a group name</string>
<string name="activity_create_closed_group_explanation">Closed groups support up to 10 members and provide the same privacy protections as one-on-one sessions.</string>
<string name="activity_create_closed_group_empty_state_message">You don\'t have any contacts yet</string>
<string name="activity_create_closed_group_empty_state_button_title">Start a Session</string>
<string name="activity_create_closed_group_group_name_missing_error">Please enter a group name</string>
<string name="activity_create_closed_group_group_name_too_long_error">Please enter a shorter group name</string>
<string name="activity_create_closed_group_not_enough_group_members_error">Please pick at least 2 group members</string>
<string name="activity_create_closed_group_too_many_group_members_error">A closed group cannot have more than 10 members</string>
<string name="activity_create_closed_group_invalid_session_id_error">One of the members of your group has an invalid Session ID</string>
<string name="activity_join_public_chat_title">Join Open Group</string>
<string name="activity_join_public_chat_error">Couldn\'t join group</string>
@ -1775,14 +1782,38 @@
<string name="fragment_enter_chat_url_edit_text_hint">Enter an open group URL</string>
<string name="fragment_enter_chat_url_privacy_warning">Open groups can be joined by anyone and do not provide full privacy protection</string>
<string name="fragment_contact_selection_contacts_title">Contacts</string>
<string name="fragment_contact_selection_closed_groups_title">Closed Groups</string>
<string name="fragment_contact_selection_open_groups_title">Open Groups</string>
<string name="activity_settings_title">Settings</string>
<string name="activity_settings_display_name_edit_text_hint">Enter a display name</string>
<string name="activity_settings_display_name_missing_error">Please pick a display name</string>
<string name="activity_settings_invalid_display_name_error">Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters</string>
<string name="activity_settings_display_name_too_long_error">Please pick a shorter display name</string>
<string name="activity_settings_privacy_button_title">Privacy</string>
<string name="activity_settings_notifications_button_title">Notifications</string>
<string name="activity_settings_chats_button_title">Chats</string>
<string name="activity_settings_devices_button_title">Devices</string>
<string name="activity_settings_recovery_phrase_button_title">Recovery Phrase</string>
<string name="activity_settings_clear_all_data_button_title">Clear Data</string>
<string name="preferences_notifications_strategy_category_title">Notification Strategy</string>
<string name="preferences_notifications_use_fcm_option_title">Use FCM</string>
<string name="preferences_notifications_use_fcm_option_explanation">Using Firebase Cloud Messaging allows for more reliable push notifications, but exposes your IP to Google.</string>
<string name="dialog_seed_title">Your Recovery Phrase</string>
<string name="dialog_seed_explanation">This is your recovery phrase. With it, you can restore or migrate your Session ID to a new device.</string>
<string name="dialog_clear_all_data_title">Clear All Data</string>
<string name="dialog_clear_all_data_explanation">This will permanently delete your Session ID, including all messages, sessions, and contacts.</string>
<string name="activity_qr_code_title">QR Code</string>
<string name="activity_qr_code_view_my_qr_code_tab_title">View My QR Code</string>
<string name="activity_qr_code_view_scan_qr_code_tab_title">Scan QR Code</string>
<string name="activity_qr_code_view_scan_qr_code_explanation">Scan someone\'s QR code to start a conversation with them</string>
<string name="fragment_view_my_qr_code_explanation">This is your QR code. Other users can scan it to start a session with you.</string>
<string name="fragment_view_my_qr_code_share_title">Share QR Code</string>
<string name="fragment_contact_selection_contacts_title">Contacts</string>
<string name="fragment_contact_selection_closed_groups_title">Closed Groups</string>
<string name="fragment_contact_selection_open_groups_title">Open Groups</string>
</resources>

View File

@ -47,7 +47,7 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), MemberC
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
super.onCreate(savedInstanceState, isReady)
setContentView(R.layout.activity_create_closed_group)
supportActionBar!!.title = "New Closed Group"
supportActionBar!!.title = resources.getString(R.string.activity_create_closed_group_title)
recyclerView.adapter = createClosedGroupAdapter
recyclerView.layoutManager = LinearLayoutManager(this)
createNewPrivateChatButton.setOnClickListener { createNewPrivateChat() }
@ -103,17 +103,17 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), MemberC
private fun createClosedGroup() {
val name = nameEditText.text.trim()
if (name.isEmpty()) {
return Toast.makeText(this, "Please enter a group name", Toast.LENGTH_LONG).show()
return Toast.makeText(this, R.string.activity_create_closed_group_group_name_missing_error, Toast.LENGTH_LONG).show()
}
if (name.length >= 64) {
return Toast.makeText(this, "Please enter a shorter group name", Toast.LENGTH_LONG).show()
return Toast.makeText(this, R.string.activity_create_closed_group_group_name_too_long_error, Toast.LENGTH_LONG).show()
}
val selectedMembers = this.selectedMembers
if (selectedMembers.count() < 2) {
return Toast.makeText(this, "Please pick at least 2 group members", Toast.LENGTH_LONG).show()
return Toast.makeText(this, R.string.activity_create_closed_group_not_enough_group_members_error, Toast.LENGTH_LONG).show()
}
if (selectedMembers.count() > 10) {
return Toast.makeText(this, "A closed group cannot have more than 10 members", Toast.LENGTH_LONG).show()
return Toast.makeText(this, R.string.activity_create_closed_group_too_many_group_members_error, Toast.LENGTH_LONG).show()
}
val recipients = selectedMembers.map {
Recipient.from(this, Address.fromSerialized(it), false)
@ -155,7 +155,7 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), MemberC
}
} else {
super.onPostExecute(result)
Toast.makeText(activity.applicationContext, "One of the members of your group has an invalid Session ID.", Toast.LENGTH_LONG).show()
Toast.makeText(activity.applicationContext, R.string.activity_create_closed_group_invalid_session_id_error, Toast.LENGTH_LONG).show()
}
}
}

View File

@ -40,7 +40,7 @@ class QRCodeActivity : PassphraseRequiredActionBarActivity(), ScanQRCodeWrapperF
// Set content view
setContentView(R.layout.activity_qr_code)
// Set title
supportActionBar!!.title = "QR Code"
supportActionBar!!.title = resources.getString(R.string.activity_qr_code_title)
// Set up view pager
viewPager.adapter = adapter
tabLayout.setupWithViewPager(viewPager)
@ -53,7 +53,7 @@ class QRCodeActivity : PassphraseRequiredActionBarActivity(), ScanQRCodeWrapperF
}
fun createPrivateChatIfPossible(hexEncodedPublicKey: String) {
if (!PublicKeyValidation.isValid(hexEncodedPublicKey)) { return Toast.makeText(this, "Invalid Session ID", Toast.LENGTH_SHORT).show() }
if (!PublicKeyValidation.isValid(hexEncodedPublicKey)) { return Toast.makeText(this, R.string.invalid_session_id, Toast.LENGTH_SHORT).show() }
val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(this)
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)
val targetHexEncodedPublicKey = if (hexEncodedPublicKey == masterHexEncodedPublicKey) userHexEncodedPublicKey else hexEncodedPublicKey
@ -84,7 +84,7 @@ private class QRCodeActivityAdapter(val activity: QRCodeActivity) : FragmentPage
1 -> {
val result = ScanQRCodeWrapperFragment()
result.delegate = activity
result.message = "Scan someone\'s QR code to start a conversation with them"
result.message = activity.resources.getString(R.string.activity_qr_code_view_scan_qr_code_explanation)
result
}
else -> throw IllegalStateException()
@ -93,8 +93,8 @@ private class QRCodeActivityAdapter(val activity: QRCodeActivity) : FragmentPage
override fun getPageTitle(index: Int): CharSequence? {
return when (index) {
0 -> "View My QR Code"
1 -> "Scan QR Code"
0 -> activity.resources.getString(R.string.activity_qr_code_view_my_qr_code_tab_title)
1 -> activity.resources.getString(R.string.activity_qr_code_view_scan_qr_code_tab_title)
else -> throw IllegalStateException()
}
}
@ -122,7 +122,7 @@ class ViewMyQRCodeFragment : Fragment() {
qrCodeImageView.setImageBitmap(qrCode)
// val explanation = SpannableStringBuilder("This is your unique public QR code. Other users can scan this to start a conversation with you.")
// explanation.setSpan(StyleSpan(Typeface.BOLD), 8, 34, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
explanationTextView.text = "This is your QR code. Other users can scan it to start a session with you."
explanationTextView.text = resources.getString(R.string.fragment_view_my_qr_code_explanation)
shareButton.setOnClickListener { shareQRCode() }
}
@ -142,7 +142,7 @@ class ViewMyQRCodeFragment : Fragment() {
intent.putExtra(Intent.EXTRA_STREAM, FileProviderUtil.getUriFor(activity!!, file))
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
intent.type = "image/png"
startActivity(Intent.createChooser(intent, "Share QR Code"))
startActivity(Intent.createChooser(intent, resources.getString(R.string.fragment_view_my_qr_code_share_title)))
}
if (RxPermissions(this).isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
proceed()

View File

@ -215,13 +215,13 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
private fun saveDisplayName() {
val displayName = displayNameEditText.text.toString().trim()
if (displayName.isEmpty()) {
return Toast.makeText(this, "Please pick a display name", Toast.LENGTH_SHORT).show()
return Toast.makeText(this, R.string.activity_settings_display_name_missing_error, Toast.LENGTH_SHORT).show()
}
if (!displayName.matches(Regex("[a-zA-Z0-9_]+"))) {
return Toast.makeText(this, "Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters", Toast.LENGTH_SHORT).show()
return Toast.makeText(this, R.string.activity_settings_invalid_display_name_error, Toast.LENGTH_SHORT).show()
}
if (displayName.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
return Toast.makeText(this, "Please pick a shorter display name", Toast.LENGTH_SHORT).show()
return Toast.makeText(this, R.string.activity_settings_display_name_too_long_error, Toast.LENGTH_SHORT).show()
}
isEditingDisplayName = false
displayNameToBeUploaded = displayName
@ -245,7 +245,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("Session ID", hexEncodedPublicKey)
clipboard.primaryClip = clip
Toast.makeText(this, R.string.activity_register_public_key_copied_message, Toast.LENGTH_SHORT).show()
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
}
private fun sharePublicKey() {

View File

@ -45,7 +45,7 @@ class SeedDialog : DialogFragment() {
val clipboard = activity!!.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("Seed", seed)
clipboard.primaryClip = clip
Toast.makeText(context!!, R.string.activity_register_public_key_copied_message, Toast.LENGTH_SHORT).show()
Toast.makeText(context!!, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
dismiss()
}
}