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
039cbe39
Commit
039cbe39
authored
Dec 04, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement "sending..." and resend feature.
parent
0f02b39b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
6 deletions
+73
-6
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+35
-3
MessageViewHolder.java
...cket/android/layouthelper/chatroom/MessageViewHolder.java
+10
-0
PairedMessage.java
...t/rocket/android/layouthelper/chatroom/PairedMessage.java
+1
-1
MessageRenderer.java
...in/java/chat/rocket/android/renderer/MessageRenderer.java
+19
-2
ic_error_outline_black_24dp.xml
app/src/main/res/drawable/ic_error_outline_black_24dp.xml
+5
-0
strings.xml
app/src/main/res/values/strings.xml
+3
-0
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
039cbe39
...
...
@@ -6,6 +6,7 @@ import android.support.design.widget.FloatingActionButton;
import
android.support.v4.view.GravityCompat
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.support.v7.app.AlertDialog
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.View
;
...
...
@@ -16,12 +17,14 @@ import chat.rocket.android.helper.LogcatIfError;
import
chat.rocket.android.helper.OnBackPressListener
;
import
chat.rocket.android.layouthelper.chatroom.MessageComposerManager
;
import
chat.rocket.android.layouthelper.chatroom.MessageListAdapter
;
import
chat.rocket.android.layouthelper.chatroom.PairedMessage
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.model.SyncState
;
import
chat.rocket.android.model.ddp.Message
;
import
chat.rocket.android.model.ddp.RoomSubscription
;
import
chat.rocket.android.model.internal.LoadMessageProcedure
;
import
chat.rocket.android.realm_helper.RealmHelper
;
import
chat.rocket.android.realm_helper.RealmModelListAdapter
;
import
chat.rocket.android.realm_helper.RealmObjectObserver
;
import
chat.rocket.android.realm_helper.RealmStore
;
import
chat.rocket.android.service.RocketChatService
;
...
...
@@ -36,7 +39,8 @@ import timber.log.Timber;
/**
* Chat room screen.
*/
public
class
RoomFragment
extends
AbstractChatRoomFragment
implements
OnBackPressListener
{
public
class
RoomFragment
extends
AbstractChatRoomFragment
implements
OnBackPressListener
,
RealmModelListAdapter
.
OnItemClickListener
<
PairedMessage
>
{
private
String
serverConfigId
;
private
RealmHelper
realmHelper
;
...
...
@@ -93,12 +97,14 @@ public class RoomFragment extends AbstractChatRoomFragment implements OnBackPres
@Override
protected
void
onSetupView
()
{
RecyclerView
listView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
recyclerview
);
listView
.
setAdapter
(
realmHelper
.
createListAdapter
(
getContext
(),
MessageListAdapter
adapter
=
(
MessageListAdapter
)
realmHelper
.
createListAdapter
(
getContext
(),
realm
->
realm
.
where
(
Message
.
class
)
.
equalTo
(
"rid"
,
roomId
)
.
findAllSorted
(
"ts"
,
Sort
.
DESCENDING
),
context
->
new
MessageListAdapter
(
context
,
hostname
)
));
);
listView
.
setAdapter
(
adapter
);
adapter
.
setOnItemClickListener
(
this
);
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
true
);
...
...
@@ -115,6 +121,32 @@ public class RoomFragment extends AbstractChatRoomFragment implements OnBackPres
setupMessageComposer
();
}
@Override
public
void
onItemClick
(
PairedMessage
pairedMessage
)
{
if
(
pairedMessage
.
target
!=
null
)
{
final
int
syncstate
=
pairedMessage
.
target
.
getSyncstate
();
if
(
syncstate
==
SyncState
.
FAILED
)
{
final
String
messageId
=
pairedMessage
.
target
.
get_id
();
new
AlertDialog
.
Builder
(
getContext
())
.
setPositiveButton
(
R
.
string
.
resend
,
(
dialog
,
which
)
->
{
realmHelper
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
Message
.
class
,
new
JSONObject
()
.
put
(
"_id"
,
messageId
)
.
put
(
"syncstate"
,
SyncState
.
NOT_SYNCED
))
).
continueWith
(
new
LogcatIfError
());
})
.
setNegativeButton
(
android
.
R
.
string
.
cancel
,
null
)
.
setNeutralButton
(
R
.
string
.
discard
,
(
dialog
,
which
)
->
{
realmHelper
.
executeTransaction
(
realm
->
realm
.
where
(
Message
.
class
)
.
equalTo
(
"_id"
,
messageId
).
findAll
().
deleteAllFromRealm
()
).
continueWith
(
new
LogcatIfError
());;
})
.
show
();
}
}
}
private
void
setupSideMenu
()
{
View
sidemenu
=
rootView
.
findViewById
(
R
.
id
.
room_side_menu
);
sidemenu
.
findViewById
(
R
.
id
.
btn_users
).
setOnClickListener
(
view
->
{
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageViewHolder.java
View file @
039cbe39
...
...
@@ -7,6 +7,7 @@ import android.widget.TextView;
import
chat.rocket.android.R
;
import
chat.rocket.android.helper.DateTime
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.SyncState
;
import
chat.rocket.android.realm_helper.RealmModelViewHolder
;
import
chat.rocket.android.renderer.MessageRenderer
;
import
chat.rocket.android.widget.message.RocketChatMessageLayout
;
...
...
@@ -49,6 +50,15 @@ public class MessageViewHolder extends RealmModelViewHolder<PairedMessage> {
.
timestampInto
(
timestamp
)
.
bodyInto
(
body
);
if
(
pairedMessage
.
target
!=
null
)
{
int
syncstate
=
pairedMessage
.
target
.
getSyncstate
();
if
(
syncstate
==
SyncState
.
NOT_SYNCED
||
syncstate
==
SyncState
.
SYNCING
)
{
itemView
.
setAlpha
(
0.6f
);
}
else
{
itemView
.
setAlpha
(
1.0f
);
}
}
renderNewDayAndSequential
(
pairedMessage
);
}
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/PairedMessage.java
View file @
039cbe39
...
...
@@ -7,7 +7,7 @@ import chat.rocket.android.model.ddp.Message;
* View Model for messages in chatroom.
*/
public
class
PairedMessage
{
final
Message
target
;
public
final
Message
target
;
final
Message
nextSibling
;
public
PairedMessage
(
Message
target
,
Message
nextSibling
)
{
...
...
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.java
View file @
039cbe39
...
...
@@ -3,7 +3,9 @@ package chat.rocket.android.renderer;
import
android.content.Context
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
chat.rocket.android.R
;
import
chat.rocket.android.helper.DateTime
;
import
chat.rocket.android.model.SyncState
;
import
chat.rocket.android.model.ddp.Message
;
import
chat.rocket.android.widget.message.RocketChatMessageLayout
;
...
...
@@ -23,7 +25,14 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show Avatar image.
*/
public
MessageRenderer
avatarInto
(
ImageView
imageView
,
String
hostname
)
{
userRenderer
.
avatarInto
(
imageView
,
hostname
);
switch
(
object
.
getSyncstate
())
{
case
SyncState
.
FAILED
:
imageView
.
setImageResource
(
R
.
drawable
.
ic_error_outline_black_24dp
);
break
;
default
:
userRenderer
.
avatarInto
(
imageView
,
hostname
);
break
;
}
return
this
;
}
...
...
@@ -43,7 +52,15 @@ public class MessageRenderer extends AbstractRenderer<Message> {
return
this
;
}
textView
.
setText
(
DateTime
.
fromEpocMs
(
object
.
getTs
(),
DateTime
.
Format
.
TIME
));
switch
(
object
.
getSyncstate
())
{
case
SyncState
.
NOT_SYNCED
:
case
SyncState
.
SYNCING
:
textView
.
setText
(
R
.
string
.
sending
);
break
;
default
:
textView
.
setText
(
DateTime
.
fromEpocMs
(
object
.
getTs
(),
DateTime
.
Format
.
TIME
));
break
;
}
return
this
;
}
...
...
app/src/main/res/drawable/ic_error_outline_black_24dp.xml
0 → 100644
View file @
039cbe39
<vector
android:alpha=
"0.78"
android:height=
"24dp"
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"#FF000000"
android:pathData=
"M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"
/>
</vector>
app/src/main/res/values/strings.xml
View file @
039cbe39
...
...
@@ -11,4 +11,7 @@
<string
name=
"start_of_conversation"
>
Start of conversation
</string>
<string
name=
"users_of_room_title"
>
Members List
</string>
<string
name=
"fmt_room_user_count"
>
Total: %,d users
</string>
<string
name=
"sending"
>
Sending...
</string>
<string
name=
"resend"
>
Resend
</string>
<string
name=
"discard"
>
Discard
</string>
</resources>
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