Commit 79615038 authored by Divyanshu Bhargava's avatar Divyanshu Bhargava

Added strings

parent 805f30fe
......@@ -918,7 +918,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
if(hasCameraPermission(it)) {
dispatchTakePictureIntent()
} else {
getCameraPermission(it)
getCameraPermission(this)
}
}
handler.postDelayed({
......@@ -939,10 +939,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
button_drawing.setOnClickListener {
activity?.let { fragmentActivity ->
if (!hasWriteExternalStoragePermission(fragmentActivity)) {
getWriteExternalStoragePermission(fragmentActivity)
getWriteExternalStoragePermission(this)
} else {
val intent = Intent(fragmentActivity, DrawingActivity::class.java)
startActivityForResult(intent, REQUEST_CODE_FOR_DRAW)
dispatchDrawingIntent()
}
}
......@@ -953,6 +952,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
private fun dispatchDrawingIntent() {
val intent = Intent(activity, DrawingActivity::class.java)
startActivityForResult(intent, REQUEST_CODE_FOR_DRAW)
}
private fun dispatchTakePictureIntent() {
Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent ->
// Create the File where the photo should go
......@@ -973,17 +977,38 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
Log.e("TAG_permission", requestCode.toString())
when(requestCode) {
AndroidPermissionsHelper.CAMERA_CODE -> {
if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
dispatchTakePictureIntent()
} else {
// permission denied
Snackbar.make(root_layout, R.string.msg_camera_permission_denied, Snackbar.LENGTH_SHORT).show()
Snackbar.make(
root_layout,
R.string.msg_camera_permission_denied,
Snackbar.LENGTH_SHORT
).show()
}
return
}
AndroidPermissionsHelper.WRITE_EXTERNAL_STORAGE_CODE -> {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
dispatchDrawingIntent()
} else {
// permission denied
Snackbar.make(
root_layout,
R.string.msg_storage_permission_denied,
Snackbar.LENGTH_SHORT
).show()
}
return
}
......
......@@ -7,6 +7,7 @@ import android.content.pm.PackageManager
import android.view.ContextThemeWrapper
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
object AndroidPermissionsHelper {
......@@ -28,28 +29,31 @@ object AndroidPermissionsHelper {
return AndroidPermissionsHelper.checkPermission(context, Manifest.permission.CAMERA)
}
fun getCameraPermission(context: Context) {
if (context is ContextThemeWrapper) {
val activity = if (context.baseContext is Activity) context.baseContext as Activity else context as Activity
AndroidPermissionsHelper.requestPermission(
activity,
Manifest.permission.CAMERA,
AndroidPermissionsHelper.WRITE_EXTERNAL_STORAGE_CODE
fun getCameraPermission(fragment: Fragment) {
fragment.requestPermissions(
arrayOf(Manifest.permission.CAMERA),
CAMERA_CODE
)
}
}
fun hasWriteExternalStoragePermission(context: Context): Boolean {
return checkPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)
}
fun getWriteExternalStoragePermission(context: Context) {
fun getWriteExternalStoragePermission(fragment: Fragment) {
fragment.requestPermissions(
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
WRITE_EXTERNAL_STORAGE_CODE
)
}
fun checkWritingPermission(context: Context) {
if (context is ContextThemeWrapper) {
val activity = if (context.baseContext is Activity) context.baseContext as Activity else context as Activity
AndroidPermissionsHelper.requestPermission(
activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
WRITE_EXTERNAL_STORAGE_CODE
AndroidPermissionsHelper.WRITE_EXTERNAL_STORAGE_CODE
)
}
}
......
package chat.rocket.android.helper
import android.Manifest
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
......@@ -9,7 +7,6 @@ import android.media.MediaScannerConnection
import android.os.Environment
import android.text.TextUtils
import android.util.TypedValue
import android.view.ContextThemeWrapper
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
......@@ -18,7 +15,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.net.toUri
import androidx.core.view.setPadding
import chat.rocket.android.R
import chat.rocket.android.helper.AndroidPermissionsHelper.getWriteExternalStoragePermission
import chat.rocket.android.helper.AndroidPermissionsHelper.checkWritingPermission
import chat.rocket.android.helper.AndroidPermissionsHelper.hasWriteExternalStoragePermission
import com.facebook.binaryresource.FileBinaryResource
import com.facebook.cache.common.CacheKey
......@@ -120,7 +117,7 @@ object ImageHelper {
private fun saveImage(context: Context): Boolean {
if (!hasWriteExternalStoragePermission(context)) {
getWriteExternalStoragePermission(context)
checkWritingPermission(context)
return false
}
if (ImagePipelineFactory.getInstance().mainFileCache.hasKey(cacheKey)) {
......
......@@ -183,6 +183,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Credentials saved successfully</string> <!-- TODO Translate -->
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -174,6 +174,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Login-Daten erfolgreich gespeichert</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -193,6 +193,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Credenciales guardadas con éxito</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<!-- Preferences messages -->
<string name="msg_analytics_tracking">Analytics tracking</string> <!-- TODO Add translation -->
......
......@@ -178,6 +178,7 @@
</plurals> <!-- TODO Add translation -->
<string name="msg_credentials_saved_successfully">اختیارها با موفقیت ذخیره شد</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -182,6 +182,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Certificats sauvegardés</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -168,6 +168,7 @@
<string name="msg_two_factor_authentication">दो तरीकों से प्रमाणीकरण</string>
<string name="msg__your_2fa_code">आपका 2FA कोड क्या है?</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<!-- Create channel messages -->
<string name="msg_private_channel">प्राइवेट</string>
......
......@@ -175,6 +175,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Credenziali salvate con successo</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -178,6 +178,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">資格情報を正常に保存しました</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -183,6 +183,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Credenciais salvas com sucesso</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -174,6 +174,7 @@
<item quantity="other">%1$s reagiram com %2$s</item>
</plurals>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -181,6 +181,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Учетные данные успешно сохранены</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -165,6 +165,7 @@
<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 -->
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<!-- Create channel messages -->
<string name="msg_private_channel">Özel</string>
......
......@@ -180,6 +180,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">Облікові дані було успішно збережено</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -175,6 +175,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">凭证成功保存</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -175,6 +175,7 @@
</plurals>
<string name="msg_credentials_saved_successfully">憑證保存成功</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string> <!-- TODO Add translation -->
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string> <!-- TODO Add translation -->
<string name="msg_server">Server</string> <!-- TODO Translate -->
<string name="msg_add_new_server">Add New Server</string> <!-- TODO Translate -->
......
......@@ -191,6 +191,7 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
</plurals>
<string name="msg_credentials_saved_successfully">Credentials saved successfully</string>
<string name="msg_camera_permission_denied">Camera permission is needed to open camera.</string>
<string name="msg_storage_permission_denied">Storage permission is needed to open Drawing.</string>
<string name="msg_server">Server</string>
<string name="msg_add_new_server">Add New Server</string>
......
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