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
3b618e38
Commit
3b618e38
authored
Jan 12, 2017
by
Yusuke Iwaki
Committed by
GitHub
Jan 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #126 from RocketChat/feature/burger-menu
Added a burger menu
parents
20b4436a
28d63853
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
209 additions
and
42 deletions
+209
-42
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+40
-17
AbstractChatRoomFragment.java
...t/android/fragment/chatroom/AbstractChatRoomFragment.java
+30
-3
HomeFragment.java
...a/chat/rocket/android/fragment/chatroom/HomeFragment.java
+3
-3
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+5
-5
activity_main.xml
app/src/main/res/layout-w720dp/activity_main.xml
+6
-3
activity_main.xml
app/src/main/res/layout/activity_main.xml
+8
-6
fragment_sidebar_main.xml
app/src/main/res/layout/fragment_sidebar_main.xml
+7
-4
RoomToolbar.java
...src/main/java/chat/rocket/android/widget/RoomToolbar.java
+89
-0
room_toolbar.xml
...chat-android-widgets/src/main/res/layout/room_toolbar.xml
+12
-0
room_toolbar_attrs.xml
...ndroid-widgets/src/main/res/values/room_toolbar_attrs.xml
+8
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
3b618e38
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
<activity
<activity
android:name=
".activity.LoginActivity"
android:name=
".activity.LoginActivity"
android:windowSoftInputMode=
"adjustResize"
android:windowSoftInputMode=
"adjustResize"
android:configChanges=
"orientation|screenSize"
/>
android:configChanges=
"orientation|screenSize"
/>
<service
android:name=
".service.RocketChatService"
/>
<service
android:name=
".service.RocketChatService"
/>
...
...
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
3b618e38
...
@@ -4,6 +4,7 @@ import android.os.Bundle;
...
@@ -4,6 +4,7 @@ import android.os.Bundle;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.Snackbar
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.support.v7.graphics.drawable.DrawerArrowDrawable
;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.view.View
;
import
android.view.View
;
...
@@ -91,25 +92,47 @@ public class MainActivity extends AbstractAuthedActivity {
...
@@ -91,25 +92,47 @@ public class MainActivity extends AbstractAuthedActivity {
private
void
setupSidebar
()
{
private
void
setupSidebar
()
{
SlidingPaneLayout
pane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sliding_pane
);
SlidingPaneLayout
pane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sliding_pane
);
if
(
pane
!=
null
)
{
if
(
pane
==
null
)
{
final
SlidingPaneLayout
subPane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sub_sliding_pane
);
return
;
pane
.
setPanelSlideListener
(
new
SlidingPaneLayout
.
SimplePanelSlideListener
()
{
}
@Override
public
void
onPanelClosed
(
View
panel
)
{
super
.
onPanelClosed
(
panel
);
if
(
subPane
!=
null
)
{
subPane
.
closePane
();
}
}
});
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
activity_main_toolbar
);
final
SlidingPaneLayout
subPane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sub_sliding_pane
);
toolbar
.
setNavigationOnClickListener
(
view
->
{
pane
.
setPanelSlideListener
(
new
SlidingPaneLayout
.
SimplePanelSlideListener
()
{
if
(
pane
.
isSlideable
()
&&
!
pane
.
isOpen
())
{
@Override
pane
.
openPane
();
public
void
onPanelClosed
(
View
panel
)
{
super
.
onPanelClosed
(
panel
);
if
(
subPane
!=
null
)
{
subPane
.
closePane
();
}
}
});
}
}
});
final
DrawerArrowDrawable
drawerArrowDrawable
=
new
DrawerArrowDrawable
(
this
);
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
activity_main_toolbar
);
toolbar
.
setNavigationIcon
(
drawerArrowDrawable
);
toolbar
.
setNavigationOnClickListener
(
view
->
{
if
(
pane
.
isSlideable
()
&&
!
pane
.
isOpen
())
{
pane
.
openPane
();
}
});
//ref: ActionBarDrawerToggle#setProgress
pane
.
setPanelSlideListener
(
new
SlidingPaneLayout
.
PanelSlideListener
()
{
@Override
public
void
onPanelSlide
(
View
panel
,
float
slideOffset
)
{
drawerArrowDrawable
.
setProgress
(
slideOffset
);
}
@Override
public
void
onPanelOpened
(
View
panel
)
{
drawerArrowDrawable
.
setVerticalMirror
(
true
);
}
@Override
public
void
onPanelClosed
(
View
panel
)
{
drawerArrowDrawable
.
setVerticalMirror
(
false
);
}
});
}
}
private
boolean
closeSidebarIfNeeded
()
{
private
boolean
closeSidebarIfNeeded
()
{
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/AbstractChatRoomFragment.java
View file @
3b618e38
package
chat
.
rocket
.
android
.
fragment
.
chatroom
;
package
chat
.
rocket
.
android
.
fragment
.
chatroom
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.DrawableRes
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.
v7.widget.Toolbar
;
import
android.support.
annotation.StringRes
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.widget.RoomToolbar
;
abstract
class
AbstractChatRoomFragment
extends
AbstractFragment
{
abstract
class
AbstractChatRoomFragment
extends
AbstractFragment
{
protected
Toolbar
activityToolbar
;
private
RoomToolbar
roomToolbar
;
@Nullable
@Nullable
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
@Nullable
Bundle
savedInstanceState
)
{
activityToolbar
=
(
Toolbar
)
getActivity
().
findViewById
(
R
.
id
.
activity_main_toolbar
);
roomToolbar
=
(
Room
Toolbar
)
getActivity
().
findViewById
(
R
.
id
.
activity_main_toolbar
);
return
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
return
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
}
}
protected
void
setTitleText
(
@StringRes
int
stringResId
)
{
if
(
roomToolbar
==
null
)
{
return
;
}
roomToolbar
.
setTitle
(
stringResId
);
}
protected
void
setTitleText
(
CharSequence
title
)
{
if
(
roomToolbar
==
null
)
{
return
;
}
roomToolbar
.
setTitle
(
title
);
}
protected
void
setTitleDrawableLeft
(
@DrawableRes
int
drawableResId
)
{
if
(
roomToolbar
==
null
)
{
return
;
}
roomToolbar
.
setRoomIcon
(
drawableResId
);
}
}
}
app/src/main/java/chat/rocket/android/fragment/chatroom/HomeFragment.java
View file @
3b618e38
...
@@ -13,13 +13,13 @@ public class HomeFragment extends AbstractChatRoomFragment {
...
@@ -13,13 +13,13 @@ public class HomeFragment extends AbstractChatRoomFragment {
@Override
@Override
protected
void
onSetupView
()
{
protected
void
onSetupView
()
{
activityToolbar
.
setTitle
(
R
.
string
.
home_fragment_title
);
setTitleText
(
R
.
string
.
home_fragment_title
);
}
}
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
activityToolbar
.
setNavigationIcon
(
null
);
setTitleDrawableLeft
(
0
);
activityToolbar
.
setTitle
(
R
.
string
.
home_fragment_title
);
setTitleText
(
R
.
string
.
home_fragment_title
);
}
}
}
}
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
3b618e38
...
@@ -266,15 +266,15 @@ public class RoomFragment extends AbstractChatRoomFragment
...
@@ -266,15 +266,15 @@ public class RoomFragment extends AbstractChatRoomFragment
String
type
=
roomSubscription
.
getType
();
String
type
=
roomSubscription
.
getType
();
if
(
RoomSubscription
.
TYPE_CHANNEL
.
equals
(
type
))
{
if
(
RoomSubscription
.
TYPE_CHANNEL
.
equals
(
type
))
{
activityToolbar
.
setNavigationIcon
(
R
.
drawable
.
ic_hashtag_gray_24dp
);
setTitleDrawableLeft
(
R
.
drawable
.
ic_hashtag_gray_24dp
);
}
else
if
(
RoomSubscription
.
TYPE_PRIVATE
.
equals
(
type
))
{
}
else
if
(
RoomSubscription
.
TYPE_PRIVATE
.
equals
(
type
))
{
activityToolbar
.
setNavigationIcon
(
R
.
drawable
.
ic_lock_gray_24dp
);
setTitleDrawableLeft
(
R
.
drawable
.
ic_lock_gray_24dp
);
}
else
if
(
RoomSubscription
.
TYPE_DIRECT_MESSAGE
.
equals
(
type
))
{
}
else
if
(
RoomSubscription
.
TYPE_DIRECT_MESSAGE
.
equals
(
type
))
{
activityToolbar
.
setNavigationIcon
(
R
.
drawable
.
ic_at_gray_24dp
);
setTitleDrawableLeft
(
R
.
drawable
.
ic_at_gray_24dp
);
}
else
{
}
else
{
activityToolbar
.
setNavigationIcon
(
null
);
setTitleDrawableLeft
(
0
);
}
}
activityToolbar
.
setTitle
(
roomSubscription
.
getName
());
setTitleText
(
roomSubscription
.
getName
());
}
}
private
void
onUpdateLoadMessageProcedure
(
LoadMessageProcedure
procedure
)
{
private
void
onUpdateLoadMessageProcedure
(
LoadMessageProcedure
procedure
)
{
...
...
app/src/main/res/layout-w720dp/activity_main.xml
View file @
3b618e38
...
@@ -14,12 +14,15 @@
...
@@ -14,12 +14,15 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
<android.support.v7.widget.Toolbar
<chat.rocket.android.widget.RoomToolbar
android:id=
"@+id/activity_main_toolbar"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:
theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar
"
android:
background=
"@color/white
"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
app:title=
"@string/app_name"
/>
app:titleText=
"@string/app_name"
app:titleTextColor=
"@color/titleTextColor"
app:titleDrawablePadding=
"@dimen/margin_8"
/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
<FrameLayout
...
...
app/src/main/res/layout/activity_main.xml
View file @
3b618e38
...
@@ -15,19 +15,21 @@
...
@@ -15,19 +15,21 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
<
android.support.v7.widget.
Toolbar
<
chat.rocket.android.widget.Room
Toolbar
android:id=
"@+id/activity_main_toolbar"
android:id=
"@+id/activity_main_toolbar"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@color/white"
android:background=
"@color/white"
android:titleTextColor=
"@color/titleTextColor"
app:titleText=
"@string/app_name"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
app:titleTextColor=
"@color/titleTextColor"
app:title=
"@string/app_name"
/>
app:titleDrawablePadding=
"@dimen/margin_8"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
/>
<View
android:layout_width=
"match_parent"
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_height=
"1dp"
android:layout_below=
"@+id/button_menu"
android:layout_below=
"@+id/button_menu"
android:background=
"@color/borderColor"
/>
android:background=
"@color/borderColor"
/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
<FrameLayout
...
...
app/src/main/res/layout/fragment_sidebar_main.xml
View file @
3b618e38
...
@@ -8,14 +8,17 @@
...
@@ -8,14 +8,17 @@
<LinearLayout
<LinearLayout
android:id=
"@+id/user_info_container"
android:id=
"@+id/user_info_container"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_content
"
android:layout_height=
"
?attr/actionBarSize
"
android:layout_alignParentTop=
"true"
android:layout_alignParentTop=
"true"
android:background=
"?attr/colorPrimaryDark"
android:background=
"?attr/colorPrimaryDark"
android:elevation=
"2dp"
android:elevation=
"2dp"
android:foreground=
"?attr/selectableItemBackground"
android:foreground=
"?attr/selectableItemBackground"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
android:padding=
"@dimen/margin_16"
>
android:paddingBottom=
"@dimen/margin_8"
android:paddingTop=
"@dimen/margin_8"
android:paddingLeft=
"@dimen/margin_16"
android:paddingRight=
"@dimen/margin_16"
>
<ImageView
<ImageView
android:id=
"@+id/current_user_status"
android:id=
"@+id/current_user_status"
...
@@ -29,8 +32,8 @@
...
@@ -29,8 +32,8 @@
<ImageView
<ImageView
android:id=
"@+id/current_user_avatar"
android:id=
"@+id/current_user_avatar"
android:layout_width=
"4
8
dp"
android:layout_width=
"4
0
dp"
android:layout_height=
"4
8
dp"
/>
android:layout_height=
"4
0
dp"
/>
<TextView
<TextView
android:id=
"@+id/current_user_name"
android:id=
"@+id/current_user_name"
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RoomToolbar.java
0 → 100644
View file @
3b618e38
package
chat
.
rocket
.
android
.
widget
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.graphics.Color
;
import
android.graphics.drawable.Drawable
;
import
android.support.annotation.DrawableRes
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.StringRes
;
import
android.support.graphics.drawable.VectorDrawableCompat
;
import
android.support.v7.widget.Toolbar
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.widget.TextView
;
public
class
RoomToolbar
extends
Toolbar
{
private
TextView
titleTextView
;
public
RoomToolbar
(
Context
context
)
{
super
(
context
);
initialize
(
context
,
null
);
}
public
RoomToolbar
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
initialize
(
context
,
attrs
);
}
public
RoomToolbar
(
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
initialize
(
context
,
attrs
);
}
private
void
initialize
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
View
.
inflate
(
context
,
R
.
layout
.
room_toolbar
,
this
);
titleTextView
=
(
TextView
)
findViewById
(
R
.
id
.
toolbar_title
);
if
(
titleTextView
==
null
)
{
return
;
}
TypedArray
typedArray
=
context
.
getTheme
().
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
RoomToolbar
,
0
,
0
);
try
{
titleTextView
.
setText
(
typedArray
.
getText
(
R
.
styleable
.
RoomToolbar_titleText
));
titleTextView
.
setTextColor
(
typedArray
.
getColor
(
R
.
styleable
.
RoomToolbar_titleTextColor
,
Color
.
BLACK
));
titleTextView
.
setCompoundDrawablePadding
(
typedArray
.
getLayoutDimension
(
R
.
styleable
.
RoomToolbar_titleDrawablePadding
,
0
));
}
finally
{
typedArray
.
recycle
();
}
}
@Override
public
void
setTitle
(
@StringRes
int
resId
)
{
if
(
titleTextView
!=
null
)
{
titleTextView
.
setText
(
resId
);
return
;
}
super
.
setTitle
(
resId
);
}
@Override
public
void
setTitle
(
CharSequence
title
)
{
if
(
titleTextView
!=
null
)
{
titleTextView
.
setText
(
title
);
return
;
}
super
.
setTitle
(
title
);
}
public
void
setRoomIcon
(
@DrawableRes
int
drawableResId
)
{
if
(
titleTextView
==
null
)
{
return
;
}
Drawable
drawable
=
drawableResId
>
0
?
VectorDrawableCompat
.
create
(
getResources
(),
drawableResId
,
null
)
:
null
;
titleTextView
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
);
}
}
rocket-chat-android-widgets/src/main/res/layout/room_toolbar.xml
0 → 100644
View file @
3b618e38
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<TextView
android:id=
"@+id/toolbar_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
/>
</merge>
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/values/room_toolbar_attrs.xml
0 → 100644
View file @
3b618e38
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable
name=
"RoomToolbar"
>
<attr
name=
"titleText"
format=
"string"
/>
<attr
name=
"titleTextColor"
format=
"color"
/>
<attr
name=
"titleDrawablePadding"
format=
"dimension"
/>
</declare-styleable>
</resources>
\ No newline at end of file
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