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
0bbd1810
Commit
0bbd1810
authored
Aug 28, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RoomToolbar.java
parent
3fb7630e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
28 deletions
+30
-28
RoomToolbar.java
...src/main/java/chat/rocket/android/widget/RoomToolbar.java
+30
-28
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RoomToolbar.java
View file @
0bbd1810
...
@@ -21,12 +21,15 @@ import com.amulyakhare.textdrawable.TextDrawable;
...
@@ -21,12 +21,15 @@ import com.amulyakhare.textdrawable.TextDrawable;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
public
class
RoomToolbar
extends
Toolbar
{
public
class
RoomToolbar
extends
Toolbar
{
private
TextView
titleTextView
;
private
TextView
toolbarText
;
private
ImageView
roomIconImageView
;
private
ImageView
roomTypeImage
;
private
ImageView
userStatusImage
;
private
ImageView
badgeImageView
;
private
ImageView
badgeImageView
;
private
Drawable
privateChannelDrawable
;
private
Drawable
privateChannelDrawable
;
private
Drawable
publicChannelDrawable
;
private
Drawable
publicChannelDrawable
;
private
Drawable
userStatusDrawable
;
private
Drawable
userStatusDrawable
;
public
static
final
int
STATUS_ONLINE
=
1
;
public
static
final
int
STATUS_ONLINE
=
1
;
public
static
final
int
STATUS_BUSY
=
2
;
public
static
final
int
STATUS_BUSY
=
2
;
public
static
final
int
STATUS_AWAY
=
3
;
public
static
final
int
STATUS_AWAY
=
3
;
...
@@ -48,51 +51,43 @@ public class RoomToolbar extends Toolbar {
...
@@ -48,51 +51,43 @@ public class RoomToolbar extends Toolbar {
}
}
private
void
initialize
(
Context
context
)
{
private
void
initialize
(
Context
context
)
{
View
.
inflate
(
context
,
R
.
layout
.
room_
toolbar
,
this
);
View
.
inflate
(
context
,
R
.
layout
.
toolbar
,
this
);
setNavigationIcon
();
setNavigationIcon
();
titleTextView
=
findViewById
(
R
.
id
.
toolbar_title
);
toolbarText
=
findViewById
(
R
.
id
.
text_toolbar
);
roomIconImageView
=
findViewById
(
R
.
id
.
roomIconImageView
);
roomTypeImage
=
findViewById
(
R
.
id
.
image_room_type
);
userStatusDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_user_status_black_24dp
,
null
);
userStatusImage
=
findViewById
(
R
.
id
.
image_user_status
);
privateChannelDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_lock_black_24dp
,
null
);
publicChannelDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_hashtag_black_24dp
,
null
);
// TODO Change to lambda and method reference (AS 3+, jackOptions ?).
// List<Drawable> drawableArrayList = Arrays.asList(userStatusDrawable, privateChannelDrawable, publicChannelDrawable);
// drawableArrayList.forEach(...)
// That is beautiful, but consumes more resources, does more process?? #thinking...
wrapDrawable
(
userStatusDrawable
);
wrapDrawable
(
privateChannelDrawable
);
wrapDrawable
(
publicChannelDrawable
);
tintDrawable
(
userStatusDrawable
,
android
.
R
.
color
.
white
);
privateChannelDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_lock_white_24dp
,
null
);
tintDrawable
(
privateChannelDrawable
,
android
.
R
.
color
.
white
);
publicChannelDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_hashtag_white_24dp
,
null
);
tintDrawable
(
publicChannelDrawable
,
android
.
R
.
color
.
white
);
userStatusDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_user_status_black_24dp
,
null
);
}
}
private
void
setNavigationIcon
()
{
private
void
setNavigationIcon
()
{
Drawable
menuDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_menu_black_24dp
,
null
);
Drawable
menuDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_menu_white_24dp
,
null
);
wrapDrawable
(
menuDrawable
);
tintDrawable
(
menuDrawable
,
android
.
R
.
color
.
white
);
super
.
setNavigationIcon
(
menuDrawable
);
super
.
setNavigationIcon
(
menuDrawable
);
}
}
@Override
@Override
public
void
setTitle
(
@StringRes
int
resId
)
{
public
void
setTitle
(
@StringRes
int
resId
)
{
t
itleTextView
.
setText
(
getContext
().
getText
(
resId
));
t
oolbarText
.
setText
(
getContext
().
getText
(
resId
));
}
}
@Override
@Override
public
void
setTitle
(
CharSequence
title
)
{
public
void
setTitle
(
CharSequence
title
)
{
t
itleTextView
.
setText
(
title
);
t
oolbarText
.
setText
(
title
);
}
}
public
void
showPrivateChannelIcon
()
{
public
void
showPrivateChannelIcon
()
{
roomIconImageView
.
setImageDrawable
(
privateChannelDrawable
);
roomTypeImage
.
setImageDrawable
(
privateChannelDrawable
);
userStatusImage
.
setVisibility
(
GONE
);
roomTypeImage
.
setVisibility
(
VISIBLE
);
}
}
public
void
showPublicChannelIcon
()
{
public
void
showPublicChannelIcon
()
{
roomIconImageView
.
setImageDrawable
(
publicChannelDrawable
);
roomTypeImage
.
setImageDrawable
(
publicChannelDrawable
);
userStatusImage
.
setVisibility
(
GONE
);
roomTypeImage
.
setVisibility
(
VISIBLE
);
}
}
public
void
showUserStatusIcon
(
int
status
)
{
public
void
showUserStatusIcon
(
int
status
)
{
...
@@ -116,9 +111,16 @@ public class RoomToolbar extends Toolbar {
...
@@ -116,9 +111,16 @@ public class RoomToolbar extends Toolbar {
break
;
break
;
}
}
roomIconImageView
.
setImageDrawable
(
userStatusDrawable
);
userStatusImage
.
setImageDrawable
(
userStatusDrawable
);
roomTypeImage
.
setVisibility
(
GONE
);
userStatusImage
.
setVisibility
(
VISIBLE
);
}
}
/**
* Wraps a drawable to be used for example for tinting.
* @param drawable The drawable to wrap.
* @see #tintDrawable(Drawable, int)
*/
private
void
wrapDrawable
(
Drawable
drawable
)
{
private
void
wrapDrawable
(
Drawable
drawable
)
{
DrawableCompat
.
wrap
(
drawable
);
DrawableCompat
.
wrap
(
drawable
);
}
}
...
@@ -197,4 +199,4 @@ public class RoomToolbar extends Toolbar {
...
@@ -197,4 +199,4 @@ public class RoomToolbar extends Toolbar {
}
}
}
}
}
}
}
}
\ 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