Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
04c03587
Unverified
Commit
04c03587
authored
Apr 09, 2018
by
Rafael Kellermann Streit
Committed by
GitHub
Apr 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1060 from RocketChat/bug-fixes-beta-5
[FIX] Small pack of fixes on Uri.kt and permissions
parents
aa4e1bc8
3f4bd1f1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
21 deletions
+55
-21
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+31
-6
ConnectionManager.kt
...ocket/android/server/infraestructure/ConnectionManager.kt
+2
-1
Uri.kt
app/src/main/java/chat/rocket/android/util/extensions/Uri.kt
+21
-14
No files found.
app/src/main/AndroidManifest.xml
View file @
04c03587
...
...
@@ -5,6 +5,7 @@
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.VIBRATE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"com.google.android.c2dm.permission.RECEIVE"
/>
<permission
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
04c03587
package
chat.rocket.android.chatroom.ui
import
android.Manifest
import
android.app.Activity
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.net.Uri
import
android.os.Bundle
import
android.os.Handler
import
android.support.annotation.DrawableRes
import
android.support.v4.app.ActivityCompat
import
android.support.v4.app.Fragment
import
android.support.v4.content.ContextCompat
import
android.support.v7.widget.DefaultItemAnimator
import
android.support.v7.widget.LinearLayoutManager
import
android.support.v7.widget.RecyclerView
...
...
@@ -224,10 +228,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private
val
layoutChangeListener
=
View
.
OnLayoutChangeListener
{
_
,
_
,
_
,
_
,
bottom
,
_
,
_
,
_
,
oldBottom
->
val
y
=
oldBottom
-
bottom
if
(
y
.
absoluteValue
>
0
&&
isAdded
)
{
if
(
Math
.
abs
(
y
)
>
0
&&
isAdded
)
{
// if y is positive the keyboard is up else it's down
recycler_view
.
post
{
if
(
y
>
0
||
verticalScrollOffset
.
get
().
absoluteValue
>=
y
.
absoluteValue
)
{
if
(
y
>
0
||
Math
.
abs
(
verticalScrollOffset
.
get
())
>=
Math
.
abs
(
y
)
)
{
recycler_view
.
scrollBy
(
0
,
y
)
}
else
{
recycler_view
.
scrollBy
(
0
,
verticalScrollOffset
.
get
())
...
...
@@ -435,11 +439,32 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
override
fun
showFileSelection
(
filter
:
Array
<
String
>)
{
activity
?.
let
{
if
(
ContextCompat
.
checkSelfPermission
(
it
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
ActivityCompat
.
requestPermissions
(
it
,
arrayOf
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
),
1
)
}
else
{
val
intent
=
Intent
(
Intent
.
ACTION_GET_CONTENT
)
intent
.
type
=
"*/*"
intent
.
putExtra
(
Intent
.
EXTRA_MIME_TYPES
,
filter
)
startActivityForResult
(
intent
,
REQUEST_CODE_FOR_PERFORM_SAF
)
}
}
}
override
fun
onRequestPermissionsResult
(
requestCode
:
Int
,
permissions
:
Array
<
out
String
>,
grantResults
:
IntArray
)
{
when
(
requestCode
)
{
1
->
{
if
(!(
grantResults
.
isNotEmpty
()
&&
grantResults
.
first
()
==
PackageManager
.
PERMISSION_GRANTED
))
{
handler
.
postDelayed
({
hideAttachmentOptions
()
},
400
)
}
}
}
}
override
fun
showInvalidFileSize
(
fileSize
:
Int
,
maxFileSize
:
Int
)
{
showMessage
(
getString
(
R
.
string
.
max_file_size_exceeded
,
fileSize
,
maxFileSize
))
...
...
app/src/main/java/chat/rocket/android/server/infraestructure/ConnectionManager.kt
View file @
04c03587
...
...
@@ -9,10 +9,11 @@ import kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.channels.Channel
import
kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
java.util.concurrent.CopyOnWriteArrayList
class
ConnectionManager
(
internal
val
client
:
RocketChatClient
)
{
private
val
statusChannelList
=
ArrayList
<
Channel
<
State
>>()
private
val
statusChannelList
=
CopyOnWrite
ArrayList
<
Channel
<
State
>>()
private
val
statusChannel
=
Channel
<
State
>()
private
var
connectJob
:
Job
?
=
null
...
...
app/src/main/java/chat/rocket/android/util/extensions/Uri.kt
View file @
04c03587
...
...
@@ -9,10 +9,7 @@ import android.provider.DocumentsContract
import
android.provider.MediaStore
import
android.provider.OpenableColumns
import
android.webkit.MimeTypeMap
import
java.io.FileInputStream
import
java.io.FileNotFoundException
import
java.io.IOException
import
java.io.InputStream
import
java.io.*
fun
Uri
.
getFileName
(
context
:
Context
):
String
?
{
val
cursor
=
context
.
contentResolver
.
query
(
this
,
null
,
null
,
null
,
null
,
null
)
...
...
@@ -27,16 +24,22 @@ fun Uri.getFileName(context: Context): String? {
}
fun
Uri
.
getFileSize
(
context
:
Context
):
Int
{
va
l
cursor
=
context
.
contentResolver
.
query
(
this
,
null
,
null
,
null
,
null
,
null
)
val
fileSize
=
cursor
?.
use
{
val
sizeIndex
=
cursor
.
getColumnIndex
(
OpenableColumns
.
SIZE
)
if
(
cursor
.
moveToFirst
())
{
if
(!
cursor
.
isNull
(
sizeIndex
)
)
{
return
@use
cursor
.
getString
(
sizeIndex
)
va
r
fileSize
:
String
?
=
null
if
(
scheme
==
ContentResolver
.
SCHEME_CONTENT
)
{
try
{
val
fileInputStream
=
context
.
contentResolver
.
openInputStream
(
this
)
fileSize
=
fileInputStream
.
available
().
toString
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
(
)
}
}
else
if
(
scheme
==
ContentResolver
.
SCHEME_FILE
)
{
val
path
=
this
.
path
try
{
val
f
=
File
(
path
)
fileSize
=
f
.
length
().
toString
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
@use
null
}
return
fileSize
?.
toIntOrNull
()
?:
-
1
}
...
...
@@ -46,7 +49,11 @@ fun Uri.getMimeType(context: Context): String {
context
.
contentResolver
.
getType
(
this
)
}
else
{
val
fileExtension
=
MimeTypeMap
.
getFileExtensionFromUrl
(
toString
())
if
(
fileExtension
!=
null
)
{
MimeTypeMap
.
getSingleton
().
getMimeTypeFromExtension
(
fileExtension
.
toLowerCase
())
}
else
{
"application/octet-stream"
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment