Commit 1ba86e52 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add licence and contact us options on settings fragment.

parent d00b8247
package chat.rocket.android.helper
import android.os.Build
import android.text.SpannableString
import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.widget.TextView
import chat.rocket.android.BuildConfig
import chat.rocket.android.util.extensions.ifEmpty
object TextHelper {
......@@ -23,7 +25,12 @@ object TextHelper {
val link = links[i]
val startIndexOfLink = textView.text.indexOf(link)
spannableString.setSpan(clickableSpan, startIndexOfLink, startIndexOfLink + link.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
spannableString.setSpan(
clickableSpan,
startIndexOfLink,
startIndexOfLink + link.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
textView.movementMethod = LinkMovementMethod.getInstance()
textView.setText(spannableString, TextView.BufferType.SPANNABLE)
......@@ -39,4 +46,13 @@ object TextHelper {
string.ifEmpty("?")
return string.substring(0, 1).toUpperCase()
}
/**
* Returns the user device information as well as the app information being used by the user.
*/
fun getDeviceAndAppInformation(): String {
return "v${BuildConfig.VERSION_NAME} - (${BuildConfig.VERSION_CODE}) \n" +
"${Build.MANUFACTURER} - ${Build.MODEL} \n" +
"Android ${Build.VERSION.RELEASE}"
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ fun Context.changeServerIntent(serverUrl: String? = null, chatRoomId: String? =
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
}
class ChangeServerActivity : AppCompatActivity(), ChangeServerView {
@Inject lateinit var presenter: ChangeServerPresenter
......
package chat.rocket.android.settings.ui
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
......@@ -13,6 +14,7 @@ import chat.rocket.android.about.ui.AboutFragment
import chat.rocket.android.about.ui.TAG_ABOUT_FRAGMENT
import chat.rocket.android.analytics.AnalyticsManager
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.helper.TextHelper.getDeviceAndAppInformation
import chat.rocket.android.main.ui.MainActivity
import chat.rocket.android.preferences.ui.PreferencesFragment
import chat.rocket.android.preferences.ui.TAG_PREFERENCES_FRAGMENT
......@@ -20,10 +22,11 @@ import chat.rocket.android.settings.password.ui.PasswordActivity
import chat.rocket.android.settings.presentation.SettingsView
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.webview.ui.webViewIntent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_settings.*
import timber.log.Timber
import javax.inject.Inject
import kotlin.reflect.KClass
internal const val TAG_SETTINGS_FRAGMENT = "SettingsFragment"
......@@ -57,7 +60,7 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
when (parent?.getItemAtPosition(position).toString()) {
resources.getString(R.string.title_preferences) -> {
resources.getStringArray(R.array.settings_actions)[0] -> {
(activity as AppCompatActivity).addFragmentBackStack(
TAG_PREFERENCES_FRAGMENT,
R.id.fragment_container
......@@ -65,9 +68,11 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
PreferencesFragment.newInstance()
}
}
resources.getString(R.string.title_change_password) ->
startNewActivity(PasswordActivity::class)
resources.getString(R.string.title_about) -> {
resources.getStringArray(R.array.settings_actions)[1] ->
activity?.startActivity(Intent(activity, PasswordActivity::class.java))
resources.getStringArray(R.array.settings_actions)[2] -> {
(activity as AppCompatActivity).addFragmentBackStack(
TAG_ABOUT_FRAGMENT,
R.id.fragment_container
......@@ -75,16 +80,17 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
AboutFragment.newInstance()
}
}
resources.getString(R.string.title_share_the_app) ->{
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.type = "text/plain"
val shareBody = getString(R.string.msg_check_this_out)
val shareSub = getString(R.string.play_store_link)
shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareBody)
shareIntent.putExtra(Intent.EXTRA_TEXT, shareSub)
startActivity(Intent.createChooser(shareIntent, getString(R.string.msg_share_using)))
}
resources.getStringArray(R.array.settings_actions)[3] -> shareApp()
resources.getStringArray(R.array.settings_actions)[4] -> activity?.startActivity(
context?.webViewIntent(
getString(R.string.license_url),
getString(R.string.title_licence)
)
)
resources.getStringArray(R.array.settings_actions)[5] -> contactSupport()
}
}
......@@ -97,9 +103,27 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
getString(R.string.title_settings)
}
private fun startNewActivity(classType: KClass<out AppCompatActivity>) {
startActivity(Intent(activity, classType.java))
activity?.overridePendingTransition(R.anim.open_enter, R.anim.open_exit)
private fun shareApp() {
with(Intent(Intent.ACTION_SEND)) {
type = "text/plain"
putExtra(Intent.EXTRA_SUBJECT, getString(R.string.msg_check_this_out))
putExtra(Intent.EXTRA_TEXT, getString(R.string.play_store_link))
startActivity(Intent.createChooser(this, getString(R.string.msg_share_using)))
}
}
private fun contactSupport() {
with(Intent(Intent.ACTION_SEND)) {
type = "message/rfc822"
putExtra(Intent.EXTRA_EMAIL, arrayOf("support@rocket.chat"))
putExtra(Intent.EXTRA_SUBJECT, getString(R.string.msg_android_app_support))
putExtra(Intent.EXTRA_TEXT, getDeviceAndAppInformation())
try {
startActivity(Intent.createChooser(this, getString(R.string.msg_send_email)))
} catch (ex: ActivityNotFoundException) {
Timber.e(ex)
}
}
}
companion object {
......
......@@ -21,7 +21,8 @@
<string name="title_update_profile">Update Profil</string>
<string name="title_about">Über</string>
<string name="title_create_channel">Erstelle Raum</string>
<string name="title_are_you_sure">Are you sure?</string><!-- TODO Add translation -->
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">Verbinde</string>
......@@ -60,6 +61,8 @@
<item name="item_password">Ändere Passwort</item>
<item name="item_password">Über</item>
<item name="item_share_app">App teilen</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -163,12 +166,11 @@
<string name="msg_message_copied">Nachricht kopiert</string>
<string name="msg_delete_message">Lösche Nachricht</string>
<string name="msg_delete_description">Sind Sie sicher, dass Sie diese Nachricht löschen wollen?</string>
<!-- TODO - Add proper translation -->
<string name="msg_view_more">view more</string>
<!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string>
<!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string>
<string name="msg_view_more">view more</string> <!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string> <!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string> <!-- TODO - Add proper translation -->
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Preferences messages -->
<string name="msg_analytics_tracking">Analytics tracking</string> <!-- TODO Add translation -->
......
......@@ -20,6 +20,7 @@
<string name="title_update_profile">Actualización del perfil</string>
<string name="title_about">Acerca de</string>
<string name="title_create_channel">Crear canal</string>
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
......@@ -59,6 +60,8 @@
<item name="item_password">Cambia la contraseña</item>
<item name="item_password">Acerca de</item>
<item name="item_share_app">Compartir aplicación</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -160,12 +163,11 @@
<string name="msg_member_already_added">Ya has seleccionado este usuario</string>
<string name="msg_member_not_found">Miembro no encontrado</string>
<string name="msg_channel_created_successfully">Canal creado con éxito</string>
<!-- TODO - Add proper translation -->
<string name="msg_view_more">view more</string>
<!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string>
<!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string>
<string name="msg_view_more">view more</string> <!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string> <!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string> <!-- TODO - Add proper translation -->
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Preferences messages -->
<string name="msg_analytics_tracking">Analytics tracking</string> <!-- TODO Add translation -->
......
......@@ -21,6 +21,7 @@
<string name="title_update_profile">Mettre à jour le profil</string>
<string name="title_about">À propos</string>
<string name="title_create_channel">Créer salon</string>
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
......@@ -60,6 +61,8 @@
<item name="item_password">Changer le mot de passe</item>
<item name="item_password">À propos</item>
<item name="item_share_app">Partager l\'application</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -152,12 +155,11 @@
<string name="msg_continue_with_wordpress">Continue with <b>WordPress</b></string> <!-- TODO Add translation -->
<string name="msg_two_factor_authentication">Two-factor Authentication</string> <!-- TODO Add translation -->
<string name="msg__your_2fa_code">What’s your 2FA code?</string> <!-- TODO Add translation -->
<!-- TODO - Add proper translation -->
<string name="msg_view_more">view more</string>
<!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string>
<!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string>
<string name="msg_view_more">view more</string> <!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string> <!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string> <!-- TODO - Add proper translation -->
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Create channel messages -->
<string name="msg_private_channel">Privé</string>
......
......@@ -21,6 +21,7 @@
<string name="title_update_profile">प्रोफ़ाइल अपडेट करें</string>
<string name="title_about">परिचय</string>
<string name="title_create_channel">चैनल बनाएं</string>
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
......@@ -60,6 +61,8 @@
<item name="item_password">पासवर्ड बदलें</item>
<item name="item_password">परिचय</item>
<item name="item_share_app">ऐप शेयर करें</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -168,8 +171,9 @@
<string name="msg_channel_created_successfully">चैनल सफलतापूर्वक बनाया गया</string>
<string name="msg_view_more">और देखें</string>
<string name="msg_view_less">कम देखें</string>
<!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string>
<string name="msg_permalink_copied">Permalink copied</string> <!-- TODO - Add proper translation -->
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Preferences messages -->
<string name="msg_analytics_tracking">एनालिटिक्स ट्रैकिंग</string>
......
......@@ -22,6 +22,7 @@
<string name="title_password">パスワードの変更</string>
<string name="title_update_profile">プロフィールの更新</string>
<string name="title_about">About</string>
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_create_channel">新しいチャネルを作成</string>
<!-- Actions -->
......@@ -61,6 +62,8 @@
<item name="item_password">パスワードの変更</item>
<item name="item_password">アプリ情報</item>
<item name="item_share_app">アプリを共有する</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -171,8 +174,9 @@
<string name="msg_message_copied">メッセージをコピー</string>
<string name="msg_delete_message">メッセージを削除</string>
<string name="msg_delete_description">このメッセージを削除してもよろしいですか?</string>
<string name="msg_permalink_copied">パーマリンクのコピー</string>
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Preferences messages -->
<string name="msg_analytics_tracking">トラッキングの分析</string>
......
......@@ -21,6 +21,7 @@
<string name="title_update_profile">Editar perfil</string>
<string name="title_about">Sobre</string>
<string name="title_create_channel">Criar chat</string>
<string name="title_licence">Licença</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Você tem certeza?</string>
<!-- Actions -->
......@@ -60,6 +61,8 @@
<item name="item_password">Alterar senha</item>
<item name="item_password">Sobre</item>
<item name="item_share_app">Compartilhe o aplicativo</item>
<item name="item_share_app_licence">Licença</item>
<item name="item_contact_us">Contate-nos</item>
</string-array>
<!-- Regular information messages -->
......@@ -155,8 +158,9 @@
<string name="msg__your_2fa_code">What’s your 2FA code?</string> <!-- TODO Add translation -->
<string name="msg_view_more">visualizar mais</string>
<string name="msg_view_less">visualizar menos</string>
<!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copiado</string>
<string name="msg_send_email">Enviar e-mail</string>
<string name="msg_android_app_support">Suporte ao aplicativo Android</string>
<!-- Create channel messages -->
<string name="msg_private_channel">Privado</string>
......
......@@ -21,6 +21,7 @@
<string name="title_update_profile">Обновить профиль</string>
<string name="title_about">О программе</string>
<string name="title_create_channel">Создать новый канал</string>
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
......@@ -60,6 +61,8 @@
<item name="item_password">Изменить пароль</item>
<item name="item_password">О программе</item>
<item name="item_share_app">добавить приложение</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -154,6 +157,8 @@
<string name="msg_view_more">больше</string>
<string name="msg_view_less">меньше</string>
<string name="msg_permalink_copied">Ссылка скопирована</string>
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Create channel messages -->
<string name="msg_private_channel">Приватный</string>
......
......@@ -21,6 +21,7 @@
<string name="title_update_profile">Profilinizi Düzenleyin</string>
<string name="title_about">Hakkında</string>
<string name="title_create_channel">Yeni Kanal Oluştur</string>
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
......@@ -60,6 +61,8 @@
<item name="item_password">Şifre Değiştir</item>
<item name="item_password">Hakkında</item>
<item name="item_share_app">uygulamayı Paylaş</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -169,8 +172,9 @@
<string name="msg_delete_description">Bu mesajı silmek istediğinizden emin misiniz</string>
<string name="msg_view_more">Daha fazla göster</string>
<string name="msg_view_less">Daha az göster</string>
<!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string>
<string name="msg_permalink_copied">Permalink copied</string> <!-- TODO - Add proper translation -->
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Preferences messages -->
<string name="msg_analytics_tracking">İstatistik takibi</string>
......
......@@ -21,6 +21,7 @@
<string name="title_update_profile">Оновити профіль</string>
<string name="title_about">"Про програму"</string>
<string name="title_create_channel">Створити новий канал</string>
<string name="title_licence">Licence</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
......@@ -60,6 +61,8 @@
<item name="item_password">Change Password</item> <!-- TODO Add translation -->
<item name="item_password">About</item> <!-- TODO Add translation -->
<item name="item_share_app">поділитися прикладом</item>
<item name="item_share_app_licence">Licence</item> <!-- TODO Add translation -->
<item name="item_contact_us">Contact us</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......@@ -150,12 +153,11 @@
<string name="msg_continue_with_wordpress">Continue with <b>WordPress</b></string> <!-- TODO Add translation -->
<string name="msg_two_factor_authentication">Two-factor Authentication</string> <!-- TODO Add translation -->
<string name="msg__your_2fa_code">What’s your 2FA code?</string> <!-- TODO Add translation -->
<!-- TODO - Add proper translation -->
<string name="msg_view_more">view more</string>
<!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string>
<!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string>
<string name="msg_view_more">view more</string> <!-- TODO - Add proper translation -->
<string name="msg_view_less">view less</string> <!-- TODO - Add proper translation -->
<string name="msg_permalink_copied">Permalink copied</string> <!-- TODO - Add proper translation -->
<string name="msg_send_email">Send email</string> <!-- TODO - Add proper translation -->
<string name="msg_android_app_support">Android app support</string> <!-- TODO - Add proper translation -->
<!-- Create channel messages -->
<string name="msg_private_channel">Приватний</string>
......
......@@ -5,4 +5,5 @@
<string name="community_server_url" translatable="false">open.rocket.chat</string>
<string name="create_server_url" translatable="false">cloud.rocket.chat/trial</string>
<string name="play_store_link" translatable="false">https://play.google.com/store/apps/details?id=chat.rocket.android</string>
<string name="license_url" translatable="false">https://github.com/RocketChat/Rocket.Chat.Android/blob/develop/LICENSE</string>
</resources>
\ No newline at end of file
......@@ -33,6 +33,7 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="title_update_profile">Update profile</string>
<string name="title_about">About</string>
<string name="title_create_channel">Create Channel</string>
<string name="title_licence">Licence</string>
<string name="title_are_you_sure">Are you sure?</string>
<!-- Actions -->
......@@ -72,6 +73,8 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<item name="item_password">Change Password</item>
<item name="item_password">About</item>
<item name="item_share_app">Share App</item>
<item name="item_share_app_licence">Licence</item>
<item name="item_contact_us">Contact us</item>
</string-array>
<!-- Regular information messages -->
......@@ -166,6 +169,8 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="msg_two_factor_authentication">Two-factor Authentication</string>
<string name="msg__your_2fa_code">What’s your 2FA code?</string>
<string name="msg_permalink_copied">Permalink copied</string>
<string name="msg_send_email">Send email</string>
<string name="msg_android_app_support">Android app support</string>
<!-- Create channel messages -->
<string name="msg_private_channel">Private</string>
......
......@@ -4,6 +4,9 @@ import java.math.BigInteger
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
/**
* Returns a SHA-256 hash for a string.
*/
@Throws(NoSuchAlgorithmException::class)
fun String.gethash(): ByteArray {
val digest = MessageDigest.getInstance("SHA-256")
......@@ -11,4 +14,7 @@ fun String.gethash(): ByteArray {
return digest.digest(this.toByteArray())
}
/**
* Return the hex of a [ByteArray].
*/
fun ByteArray.toHex(): String = String.format("%0" + this.size * 2 + "X", BigInteger(1, this))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment