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
23aca01f
Commit
23aca01f
authored
Jan 25, 2017
by
Tiago Cunha
Committed by
GitHub
Jan 25, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature/version-bump-6
parents
78f7b26d
2d74bbdd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
169 additions
and
20 deletions
+169
-20
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+67
-15
dependencies.gradle
dependencies.gradle
+1
-0
build.gradle
rocket-chat-android-widgets/build.gradle
+1
-0
ImageKeyboardEditText.java
.../rocket/android/widget/message/ImageKeyboardEditText.java
+70
-0
MessageFormLayout.java
...chat/rocket/android/widget/message/MessageFormLayout.java
+29
-4
message_composer.xml
...-android-widgets/src/main/res/layout/message_composer.xml
+1
-1
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
23aca01f
...
...
@@ -3,11 +3,15 @@ package chat.rocket.android.fragment.chatroom;
import
android.Manifest
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.v13.view.inputmethod.InputConnectionCompat
;
import
android.support.v13.view.inputmethod.InputContentInfoCompat
;
import
android.support.v4.app.DialogFragment
;
import
android.support.v4.os.BuildCompat
;
import
android.support.v4.view.GravityCompat
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v4.widget.SlidingPaneLayout
;
...
...
@@ -23,6 +27,7 @@ import java.lang.reflect.Field;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
import
bolts.Task
;
import
chat.rocket.android.R
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.fragment.chatroom.dialog.FileUploadProgressDialogFragment
;
...
...
@@ -131,6 +136,7 @@ public class RoomFragment extends AbstractChatRoomFragment
.
createObjectObserver
(
realm
->
realm
.
where
(
LoadMessageProcedure
.
class
).
equalTo
(
LoadMessageProcedure
.
ID
,
roomId
))
.
setOnUpdateListener
(
this
::
onUpdateLoadMessageProcedure
);
if
(
savedInstanceState
==
null
)
{
initialRequest
();
}
...
...
@@ -310,20 +316,8 @@ public class RoomFragment extends AbstractChatRoomFragment
(
MessageFormLayout
)
rootView
.
findViewById
(
R
.
id
.
message_composer
);
messageFormManager
=
new
MessageFormManager
(
messageFormLayout
,
this
::
showExtraActionSelectionDialog
);
messageFormManager
.
setSendMessageCallback
(
messageText
->
realmHelper
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
Message
.
class
,
new
JSONObject
()
.
put
(
Message
.
ID
,
UUID
.
randomUUID
().
toString
())
.
put
(
Message
.
SYNC_STATE
,
SyncState
.
NOT_SYNCED
)
.
put
(
Message
.
TIMESTAMP
,
System
.
currentTimeMillis
())
.
put
(
Message
.
ROOM_ID
,
roomId
)
.
put
(
Message
.
USER
,
new
JSONObject
()
.
put
(
User
.
ID
,
userId
))
.
put
(
Message
.
MESSAGE
,
messageText
)))
.
onSuccess
(
_task
->
{
scrollToLatestMessage
();
return
null
;
}));
messageFormManager
.
setSendMessageCallback
(
this
::
sendMessage
);
messageFormLayout
.
setEditTextContentListener
(
this
::
onCommitContent
);
}
@Override
...
...
@@ -337,8 +331,12 @@ public class RoomFragment extends AbstractChatRoomFragment
return
;
}
uploadFile
(
data
.
getData
());
}
private
void
uploadFile
(
Uri
uri
)
{
String
uplId
=
new
FileUploadHelper
(
getContext
(),
realmHelper
)
.
requestUploading
(
roomId
,
data
.
getData
()
);
.
requestUploading
(
roomId
,
uri
);
if
(!
TextUtils
.
isEmpty
(
uplId
))
{
FileUploadProgressDialogFragment
.
create
(
hostname
,
roomId
,
uplId
)
.
show
(
getFragmentManager
(),
FileUploadProgressDialogFragment
.
class
.
getSimpleName
());
...
...
@@ -485,4 +483,58 @@ public class RoomFragment extends AbstractChatRoomFragment
protected
void
onExtraActionSelected
(
MessageExtraActionBehavior
action
)
{
action
.
handleItemSelectedOnFragment
(
RoomFragment
.
this
);
}
private
boolean
onCommitContent
(
InputContentInfoCompat
inputContentInfo
,
int
flags
,
Bundle
opts
,
String
[]
supportedMimeTypes
)
{
boolean
supported
=
false
;
for
(
final
String
mimeType
:
supportedMimeTypes
)
{
if
(
inputContentInfo
.
getDescription
().
hasMimeType
(
mimeType
))
{
supported
=
true
;
break
;
}
}
if
(!
supported
)
{
return
false
;
}
if
(
BuildCompat
.
isAtLeastNMR1
()
&&
(
flags
&
InputConnectionCompat
.
INPUT_CONTENT_GRANT_READ_URI_PERMISSION
)
!=
0
)
{
try
{
inputContentInfo
.
requestPermission
();
}
catch
(
Exception
e
)
{
return
false
;
}
}
Uri
linkUri
=
inputContentInfo
.
getLinkUri
();
if
(
linkUri
==
null
)
{
return
false
;
}
sendMessage
(
linkUri
.
toString
());
try
{
inputContentInfo
.
releasePermission
();
}
catch
(
Exception
e
)
{
}
return
true
;
}
private
Task
<
Void
>
sendMessage
(
String
messageText
)
{
return
realmHelper
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
Message
.
class
,
new
JSONObject
()
.
put
(
Message
.
ID
,
UUID
.
randomUUID
().
toString
())
.
put
(
Message
.
SYNC_STATE
,
SyncState
.
NOT_SYNCED
)
.
put
(
Message
.
TIMESTAMP
,
System
.
currentTimeMillis
())
.
put
(
Message
.
ROOM_ID
,
roomId
)
.
put
(
Message
.
USER
,
new
JSONObject
()
.
put
(
User
.
ID
,
userId
))
.
put
(
Message
.
MESSAGE
,
messageText
)))
.
onSuccess
(
_task
->
{
scrollToLatestMessage
();
return
null
;
});
}
}
dependencies.gradle
View file @
23aca01f
...
...
@@ -11,6 +11,7 @@ ext {
supportAnnotations
=
"com.android.support:support-annotations:$supportVersion"
supportRecyclerView
=
"com.android.support:recyclerview-v7:$supportVersion"
supportAppCompat
=
"com.android.support:appcompat-v7:$supportVersion"
supportV13
=
"com.android.support:support-v13:$supportVersion"
supportDesign
=
"com.android.support:design:$supportVersion"
rxJava
=
'io.reactivex:rxjava:1.2.3'
...
...
rocket-chat-android-widgets/build.gradle
View file @
23aca01f
...
...
@@ -33,6 +33,7 @@ dependencies {
testCompile
'junit:junit:4.12'
compile
rootProject
.
ext
.
supportAnnotations
compile
rootProject
.
ext
.
supportAppCompat
compile
rootProject
.
ext
.
supportV13
compile
rootProject
.
ext
.
supportDesign
compile
'org.nibor.autolink:autolink:0.5.0'
compile
rootProject
.
ext
.
textDrawable
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/ImageKeyboardEditText.java
0 → 100644
View file @
23aca01f
package
chat
.
rocket
.
android
.
widget
.
message
;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.v13.view.inputmethod.EditorInfoCompat
;
import
android.support.v13.view.inputmethod.InputConnectionCompat
;
import
android.support.v13.view.inputmethod.InputContentInfoCompat
;
import
android.util.AttributeSet
;
import
android.view.inputmethod.EditorInfo
;
import
android.view.inputmethod.InputConnection
;
import
android.widget.EditText
;
public
class
ImageKeyboardEditText
extends
EditText
{
private
final
String
[]
mimeTypes
=
{
"image/gif"
};
final
InputConnectionCompat
.
OnCommitContentListener
inputConnectionListener
=
new
InputConnectionCompat
.
OnCommitContentListener
()
{
@Override
public
boolean
onCommitContent
(
InputContentInfoCompat
inputContentInfo
,
int
flags
,
Bundle
opts
)
{
if
(
listener
!=
null
)
{
return
listener
.
onCommitContent
(
inputContentInfo
,
flags
,
opts
,
mimeTypes
);
}
return
false
;
}
};
private
OnCommitContentListener
listener
;
public
ImageKeyboardEditText
(
Context
context
)
{
super
(
context
);
}
public
ImageKeyboardEditText
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
public
ImageKeyboardEditText
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
}
@TargetApi
(
Build
.
VERSION_CODES
.
LOLLIPOP
)
public
ImageKeyboardEditText
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
,
int
defStyleRes
)
{
super
(
context
,
attrs
,
defStyleAttr
,
defStyleRes
);
}
@Override
public
InputConnection
onCreateInputConnection
(
EditorInfo
editorInfo
)
{
final
InputConnection
inputConnection
=
super
.
onCreateInputConnection
(
editorInfo
);
EditorInfoCompat
.
setContentMimeTypes
(
editorInfo
,
mimeTypes
);
return
InputConnectionCompat
.
createWrapper
(
inputConnection
,
editorInfo
,
inputConnectionListener
);
}
public
void
setContentListener
(
OnCommitContentListener
listener
)
{
this
.
listener
=
listener
;
}
public
interface
OnCommitContentListener
{
boolean
onCommitContent
(
InputContentInfoCompat
inputContentInfo
,
int
flags
,
Bundle
opts
,
String
[]
supportedMimeTypes
);
}
}
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/MessageFormLayout.java
View file @
23aca01f
...
...
@@ -3,6 +3,8 @@ package chat.rocket.android.widget.message;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.v13.view.inputmethod.InputContentInfoCompat
;
import
android.text.Editable
;
import
android.text.TextUtils
;
import
android.text.TextWatcher
;
...
...
@@ -10,7 +12,6 @@ import android.util.AttributeSet;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
...
...
@@ -25,6 +26,7 @@ public class MessageFormLayout extends LinearLayout {
private
ExtraActionSelectionClickListener
extraActionSelectionClickListener
;
private
SubmitTextListener
submitTextListener
;
private
ImageKeyboardEditText
.
OnCommitContentListener
listener
;
public
MessageFormLayout
(
Context
context
)
{
super
(
context
);
...
...
@@ -76,7 +78,9 @@ public class MessageFormLayout extends LinearLayout {
btnSubmit
.
setScaleY
(
0
);
btnSubmit
.
setVisibility
(
GONE
);
((
EditText
)
composer
.
findViewById
(
R
.
id
.
editor
)).
addTextChangedListener
(
new
TextWatcher
()
{
ImageKeyboardEditText
editText
=
(
ImageKeyboardEditText
)
composer
.
findViewById
(
R
.
id
.
editor
);
editText
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
...
...
@@ -97,6 +101,17 @@ public class MessageFormLayout extends LinearLayout {
}
});
editText
.
setContentListener
(
new
ImageKeyboardEditText
.
OnCommitContentListener
()
{
@Override
public
boolean
onCommitContent
(
InputContentInfoCompat
inputContentInfo
,
int
flags
,
Bundle
opts
,
String
[]
supportedMimeTypes
)
{
if
(
listener
!=
null
)
{
return
listener
.
onCommitContent
(
inputContentInfo
,
flags
,
opts
,
supportedMimeTypes
);
}
return
false
;
}
});
addView
(
composer
);
}
...
...
@@ -123,8 +138,14 @@ public class MessageFormLayout extends LinearLayout {
return
getEditor
().
getText
().
toString
().
trim
();
}
public
final
void
setText
(
CharSequence
text
)
{
getEditor
().
setText
(
text
);
public
final
void
setText
(
final
CharSequence
text
)
{
final
TextView
editor
=
getEditor
();
editor
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
editor
.
setText
(
text
);
}
});
}
public
void
setEnabled
(
boolean
enabled
)
{
...
...
@@ -132,6 +153,10 @@ public class MessageFormLayout extends LinearLayout {
composer
.
findViewById
(
R
.
id
.
btn_submit
).
setEnabled
(
enabled
);
}
public
void
setEditTextContentListener
(
ImageKeyboardEditText
.
OnCommitContentListener
listener
)
{
this
.
listener
=
listener
;
}
private
void
animateHide
(
final
View
view
)
{
view
.
animate
().
scaleX
(
0
).
scaleY
(
0
).
setDuration
(
150
).
withEndAction
(
new
Runnable
()
{
@Override
...
...
rocket-chat-android-widgets/src/main/res/layout/message_composer.xml
View file @
23aca01f
...
...
@@ -21,7 +21,7 @@
android:layout_height=
"32dp"
android:layout_margin=
"8dp"
/>
<EditText
<
chat.rocket.android.widget.message.ImageKeyboard
EditText
android:id=
"@+id/editor"
android:layout_width=
"0px"
android:layout_height=
"wrap_content"
...
...
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