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
562c7e0e
Commit
562c7e0e
authored
Nov 10, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add RoomFragment.
parent
f4803387
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
179 additions
and
14 deletions
+179
-14
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+18
-0
HomeFragment.java
...a/chat/rocket/android/fragment/chatroom/HomeFragment.java
+8
-0
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+66
-0
RoomListManager.java
...rocket/android/layouthelper/chatroom/RoomListManager.java
+34
-5
activity_main.xml
app/src/main/res/layout/activity_main.xml
+2
-0
fragment_room.xml
app/src/main/res/layout/fragment_room.xml
+19
-0
RoomListItemView.java
...chat/rocket/android/widget/internal/RoomListItemView.java
+30
-8
room_list_item.xml
...at-android-widgets/src/main/res/layout/room_list_item.xml
+2
-1
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
562c7e0e
...
@@ -2,11 +2,13 @@ package chat.rocket.android.activity;
...
@@ -2,11 +2,13 @@ package chat.rocket.android.activity;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.widget.CompoundButton
;
import
android.widget.CompoundButton
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
import
chat.rocket.android.helper.Avatar
;
import
chat.rocket.android.helper.Avatar
;
import
chat.rocket.android.layouthelper.chatroom.RoomListManager
;
import
chat.rocket.android.layouthelper.chatroom.RoomListManager
;
import
chat.rocket.android.model.Room
;
import
chat.rocket.android.model.Room
;
...
@@ -44,11 +46,23 @@ public class MainActivity extends AbstractAuthedActivity {
...
@@ -44,11 +46,23 @@ public class MainActivity extends AbstractAuthedActivity {
roomListManager
=
new
RoomListManager
(
roomListManager
=
new
RoomListManager
(
(
LinearLayout
)
findViewById
(
R
.
id
.
channels_container
),
(
LinearLayout
)
findViewById
(
R
.
id
.
channels_container
),
(
LinearLayout
)
findViewById
(
R
.
id
.
direct_messages_container
));
(
LinearLayout
)
findViewById
(
R
.
id
.
direct_messages_container
));
roomListManager
.
setOnItemClickListener
(
view
->
{
showRoomFragment
(
view
.
getRoomId
());
closeSidebarIfNeeded
();
});
ImageView
myAvatar
=
(
ImageView
)
findViewById
(
R
.
id
.
img_my_avatar
);
ImageView
myAvatar
=
(
ImageView
)
findViewById
(
R
.
id
.
img_my_avatar
);
new
Avatar
(
"demo.rocket.chat"
,
"John Doe"
).
into
(
myAvatar
);
new
Avatar
(
"demo.rocket.chat"
,
"John Doe"
).
into
(
myAvatar
);
}
}
private
void
closeSidebarIfNeeded
()
{
// REMARK: Tablet UI doesn't have SlidingPane!
SlidingPaneLayout
pane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sliding_pane
);
if
(
pane
!=
null
)
{
pane
.
closePane
();
}
}
private
void
setupUserActionToggle
()
{
private
void
setupUserActionToggle
()
{
final
CompoundButton
toggleUserAction
=
final
CompoundButton
toggleUserAction
=
((
CompoundButton
)
findViewById
(
R
.
id
.
toggle_user_action
));
((
CompoundButton
)
findViewById
(
R
.
id
.
toggle_user_action
));
...
@@ -71,6 +85,10 @@ public class MainActivity extends AbstractAuthedActivity {
...
@@ -71,6 +85,10 @@ public class MainActivity extends AbstractAuthedActivity {
}
}
};
};
private
void
showRoomFragment
(
String
roomId
)
{
showFragment
(
RoomFragment
.
create
(
roomId
));
}
@Override
protected
void
onResume
()
{
@Override
protected
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
roomsObserver
.
sub
();
roomsObserver
.
sub
();
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/HomeFragment.java
View file @
562c7e0e
...
@@ -3,6 +3,9 @@ package chat.rocket.android.fragment.chatroom;
...
@@ -3,6 +3,9 @@ package chat.rocket.android.fragment.chatroom;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
public
class
HomeFragment
extends
AbstractChatRoomFragment
{
public
class
HomeFragment
extends
AbstractChatRoomFragment
{
public
HomeFragment
()
{
}
@Override
protected
int
getLayout
()
{
@Override
protected
int
getLayout
()
{
return
R
.
layout
.
fragment_home
;
return
R
.
layout
.
fragment_home
;
}
}
...
@@ -10,4 +13,9 @@ public class HomeFragment extends AbstractChatRoomFragment {
...
@@ -10,4 +13,9 @@ public class HomeFragment extends AbstractChatRoomFragment {
@Override
protected
void
onSetupView
()
{
@Override
protected
void
onSetupView
()
{
activityToolbar
.
setTitle
(
"Rocket.Chat - Home"
);
activityToolbar
.
setTitle
(
"Rocket.Chat - Home"
);
}
}
@Override
public
void
onResume
()
{
super
.
onResume
();
activityToolbar
.
setTitle
(
"Rocket.Chat - Home"
);
}
}
}
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
0 → 100644
View file @
562c7e0e
package
chat
.
rocket
.
android
.
fragment
.
chatroom
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
chat.rocket.android.R
;
import
chat.rocket.android.model.Room
;
import
io.realm.Realm
;
import
io.realm.RealmQuery
;
import
jp.co.crowdworks.realm_java_helpers.RealmObjectObserver
;
/**
*/
public
class
RoomFragment
extends
AbstractChatRoomFragment
{
private
String
roomId
;
public
static
RoomFragment
create
(
String
roomId
)
{
Bundle
args
=
new
Bundle
();
args
.
putString
(
"roomId"
,
roomId
);
RoomFragment
fragment
=
new
RoomFragment
();
fragment
.
setArguments
(
args
);
return
fragment
;
}
public
RoomFragment
()
{
}
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Bundle
args
=
getArguments
();
roomId
=
args
.
getString
(
"roomId"
);
}
@Override
protected
int
getLayout
()
{
return
R
.
layout
.
fragment_room
;
}
@Override
protected
void
onSetupView
()
{
}
private
RealmObjectObserver
<
Room
>
roomObserver
=
new
RealmObjectObserver
<
Room
>()
{
@Override
protected
RealmQuery
<
Room
>
query
(
Realm
realm
)
{
return
realm
.
where
(
Room
.
class
).
equalTo
(
"_id"
,
roomId
);
}
@Override
protected
void
onChange
(
Room
room
)
{
onRenderRoom
(
room
);
}
};
private
void
onRenderRoom
(
Room
room
)
{
activityToolbar
.
setTitle
(
room
.
getName
());
}
@Override
public
void
onResume
()
{
super
.
onResume
();
roomObserver
.
sub
();
}
@Override
public
void
onPause
()
{
roomObserver
.
unsub
();
super
.
onPause
();
}
}
app/src/main/java/chat/rocket/android/layouthelper/chatroom/RoomListManager.java
View file @
562c7e0e
package
chat
.
rocket
.
android
.
layouthelper
.
chatroom
;
package
chat
.
rocket
.
android
.
layouthelper
.
chatroom
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.Room
;
import
chat.rocket.android.model.Room
;
...
@@ -13,6 +14,15 @@ public class RoomListManager {
...
@@ -13,6 +14,15 @@ public class RoomListManager {
private
ViewGroup
channelsContainer
;
private
ViewGroup
channelsContainer
;
private
ViewGroup
dmContainer
;
private
ViewGroup
dmContainer
;
/**
* Callback interface for List item clicked.
*/
public
interface
OnItemClickListener
{
void
onItemClick
(
RoomListItemView
roomListItemView
);
}
private
OnItemClickListener
mListener
;
/**
/**
* constructor with two ViewGroups.
* constructor with two ViewGroups.
*/
*/
...
@@ -43,13 +53,20 @@ public class RoomListManager {
...
@@ -43,13 +53,20 @@ public class RoomListManager {
}
}
}
}
private
static
void
insertOrUpdateItem
(
ViewGroup
parent
,
Room
room
)
{
/**
* set callback on List item clicked.
*/
public
void
setOnItemClickListener
(
OnItemClickListener
listener
)
{
mListener
=
listener
;
}
private
void
insertOrUpdateItem
(
ViewGroup
parent
,
Room
room
)
{
final
String
roomName
=
room
.
getName
();
final
String
roomName
=
room
.
getName
();
int
index
;
int
index
;
for
(
index
=
0
;
index
<
parent
.
getChildCount
();
index
++)
{
for
(
index
=
0
;
index
<
parent
.
getChildCount
();
index
++)
{
RoomListItemView
roomListItemView
=
(
RoomListItemView
)
parent
.
getChildAt
(
index
);
RoomListItemView
roomListItemView
=
(
RoomListItemView
)
parent
.
getChildAt
(
index
);
final
String
targetRoomName
=
roomListItemView
.
getName
();
final
String
targetRoomName
=
roomListItemView
.
get
Room
Name
();
if
(
roomName
.
equals
(
targetRoomName
))
{
if
(
roomName
.
equals
(
targetRoomName
))
{
updateRoomItemView
(
roomListItemView
,
room
);
updateRoomItemView
(
roomListItemView
,
room
);
return
;
return
;
...
@@ -68,16 +85,28 @@ public class RoomListManager {
...
@@ -68,16 +85,28 @@ public class RoomListManager {
}
}
}
}
private
static
void
updateRoomItemView
(
RoomListItemView
roomListItemView
,
Room
room
)
{
private
void
updateRoomItemView
(
RoomListItemView
roomListItemView
,
Room
room
)
{
roomListItemView
roomListItemView
.
setRoom
(
room
.
getT
(),
room
.
getName
())
.
setRoomId
(
room
.
get_id
())
.
setRoomName
(
room
.
getName
())
.
setRoomType
(
room
.
getT
())
.
setAlertCount
(
0
);
// TODO not implemented yet.
.
setAlertCount
(
0
);
// TODO not implemented yet.
roomListItemView
.
setOnClickListener
(
this
::
onItemClick
);
}
private
void
onItemClick
(
View
view
)
{
if
(
view
instanceof
RoomListItemView
)
{
if
(
mListener
!=
null
)
{
mListener
.
onItemClick
((
RoomListItemView
)
view
);
}
}
}
}
private
static
void
removeItemIfExists
(
ViewGroup
parent
,
String
roomName
)
{
private
static
void
removeItemIfExists
(
ViewGroup
parent
,
String
roomName
)
{
for
(
int
i
=
0
;
i
<
parent
.
getChildCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
parent
.
getChildCount
();
i
++)
{
RoomListItemView
roomListItemView
=
(
RoomListItemView
)
parent
.
getChildAt
(
i
);
RoomListItemView
roomListItemView
=
(
RoomListItemView
)
parent
.
getChildAt
(
i
);
if
(
roomName
.
equals
(
roomListItemView
.
getName
()))
{
if
(
roomName
.
equals
(
roomListItemView
.
get
Room
Name
()))
{
parent
.
removeViewAt
(
i
);
parent
.
removeViewAt
(
i
);
break
;
break
;
}
}
...
...
app/src/main/res/layout/activity_main.xml
View file @
562c7e0e
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout
<android.support.v4.widget.SlidingPaneLayout
android:id=
"@+id/sliding_pane"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -33,6 +34,7 @@
...
@@ -33,6 +34,7 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
android:background=
"@color/white"
android:clickable=
"true"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
></FrameLayout>
></FrameLayout>
...
...
app/src/main/res/layout/fragment_room.xml
0 → 100644
View file @
562c7e0e
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/recyclerview"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<android.support.design.widget.FloatingActionButton
android:id=
"@+id/btn_compose"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end|bottom"
android:layout_margin=
"@dimen/margin_16"
/>
</FrameLayout>
\ No newline at end of file
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/internal/RoomListItemView.java
View file @
562c7e0e
...
@@ -2,6 +2,7 @@ package chat.rocket.android.widget.internal;
...
@@ -2,6 +2,7 @@ package chat.rocket.android.widget.internal;
import
android.annotation.TargetApi
;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.os.Build
;
import
android.os.Build
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.view.View
;
...
@@ -14,7 +15,8 @@ import java.util.HashMap;
...
@@ -14,7 +15,8 @@ import java.util.HashMap;
* Room list-item view used in sidebar.
* Room list-item view used in sidebar.
*/
*/
public
class
RoomListItemView
extends
LinearLayout
{
public
class
RoomListItemView
extends
LinearLayout
{
private
String
name
;
private
String
roomId
;
private
String
roomName
;
private
static
HashMap
<
String
,
Integer
>
ICON_TABLE
=
new
HashMap
<
String
,
Integer
>(){
private
static
HashMap
<
String
,
Integer
>
ICON_TABLE
=
new
HashMap
<
String
,
Integer
>(){
{
{
...
@@ -47,19 +49,31 @@ public class RoomListItemView extends LinearLayout {
...
@@ -47,19 +49,31 @@ public class RoomListItemView extends LinearLayout {
private
void
initialize
(
Context
context
)
{
private
void
initialize
(
Context
context
)
{
setOrientation
(
HORIZONTAL
);
setOrientation
(
HORIZONTAL
);
TypedArray
array2
=
context
.
getTheme
().
obtainStyledAttributes
(
new
int
[]{
R
.
attr
.
selectableItemBackground
});
setBackground
(
array2
.
getDrawable
(
0
));
array2
.
recycle
();
View
.
inflate
(
context
,
R
.
layout
.
room_list_item
,
this
);
View
.
inflate
(
context
,
R
.
layout
.
room_list_item
,
this
);
}
}
public
RoomListItemView
setRoom
(
String
type
,
String
name
)
{
public
String
getRoomId
()
{
return
roomId
;
}
public
RoomListItemView
setRoomId
(
String
roomId
)
{
this
.
roomId
=
roomId
;
return
this
;
}
public
RoomListItemView
setRoomType
(
String
type
)
{
if
(
ICON_TABLE
.
containsKey
(
type
))
{
if
(
ICON_TABLE
.
containsKey
(
type
))
{
TextView
icon
=
(
TextView
)
findViewById
(
R
.
id
.
icon
);
TextView
icon
=
(
TextView
)
findViewById
(
R
.
id
.
icon
);
icon
.
setText
(
ICON_TABLE
.
get
(
type
));
icon
.
setText
(
ICON_TABLE
.
get
(
type
));
}
}
TextView
text
=
(
TextView
)
findViewById
(
R
.
id
.
text
);
text
.
setText
(
name
);
this
.
name
=
name
;
return
this
;
return
this
;
}
}
...
@@ -76,7 +90,15 @@ public class RoomListItemView extends LinearLayout {
...
@@ -76,7 +90,15 @@ public class RoomListItemView extends LinearLayout {
return
this
;
return
this
;
}
}
public
String
getName
()
{
public
String
getRoomName
()
{
return
name
;
return
roomName
;
}
public
RoomListItemView
setRoomName
(
String
roomName
)
{
this
.
roomName
=
roomName
;
TextView
text
=
(
TextView
)
findViewById
(
R
.
id
.
text
);
text
.
setText
(
roomName
);
return
this
;
}
}
}
}
rocket-chat-android-widgets/src/main/res/layout/room_list_item.xml
View file @
562c7e0e
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
<FrameLayout
<FrameLayout
android:layout_width=
"32dp"
android:layout_width=
"32dp"
android:layout_height=
"?attr/listPreferredItemHeightSmall"
android:layout_height=
"?attr/listPreferredItemHeightSmall"
android:layout_marginEnd=
"16dp"
>
android:layout_marginEnd=
"16dp"
>
<chat.rocket.android.widget.FontAwesomeTextView
<chat.rocket.android.widget.FontAwesomeTextView
android:id=
"@+id/icon"
android:id=
"@+id/icon"
android:layout_width=
"wrap_content"
android:layout_width=
"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