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
c6bbc28c
Commit
c6bbc28c
authored
Aug 26, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RoomToolbar.java
parent
3dda009f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
7 deletions
+35
-7
RoomToolbar.java
...src/main/java/chat/rocket/android/widget/RoomToolbar.java
+35
-7
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RoomToolbar.java
View file @
c6bbc28c
...
...
@@ -14,6 +14,7 @@ import android.support.v4.widget.TextViewCompat;
import
android.support.v7.widget.AppCompatImageView
;
import
android.support.v7.widget.Toolbar
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
...
...
@@ -21,32 +22,57 @@ import android.widget.TextView;
import
com.amulyakhare.textdrawable.TextDrawable
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.function.Consumer
;
public
class
RoomToolbar
extends
Toolbar
{
public
RoomToolbar
(
Context
context
)
{
super
(
context
);
initialize
(
context
,
null
);
initialize
(
context
);
}
public
RoomToolbar
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
initialize
(
context
,
attrs
);
initialize
(
context
);
}
public
RoomToolbar
(
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
initialize
(
context
,
attrs
);
initialize
(
context
);
}
private
void
initialize
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
private
void
initialize
(
Context
context
)
{
View
.
inflate
(
context
,
R
.
layout
.
room_toolbar
,
this
);
setNavigationIcon
();
titleTextView
=
findViewById
(
R
.
id
.
toolbar_title
);
roomIconImageView
=
findViewById
(
R
.
id
.
roomIconImageView
);
userStatusDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_user_status_black_24dp
,
null
);
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
);
tintDrawable
(
privateChannelDrawable
,
android
.
R
.
color
.
white
);
tintDrawable
(
publicChannelDrawable
,
android
.
R
.
color
.
white
);
}
private
void
setNavigationIcon
()
{
Drawable
menuDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_menu_black_24dp
,
null
);
wrapDrawable
(
menuDrawable
);
tintDrawable
(
menuDrawable
,
android
.
R
.
color
.
white
);
super
.
setNavigationIcon
(
menuDrawable
);
}
@Override
...
...
@@ -138,7 +164,7 @@ public class RoomToolbar extends Toolbar {
.
beginConfig
()
.
useFont
(
Typeface
.
SANS_SERIF
)
.
endConfig
()
.
buildRound
(
icon
,
ContextCompat
.
getColor
(
getContext
(),
R
.
color
.
badge_color
));
.
buildRound
(
icon
,
ContextCompat
.
getColor
(
getContext
(),
android
.
R
.
color
.
white
));
}
@Override
...
...
@@ -162,8 +188,10 @@ public class RoomToolbar extends Toolbar {
int
badgeTop
=
iconTop
+
(
iconBottom
-
iconTop
)
/
8
;
int
badgeBottom
=
iconTop
+
(
iconBottom
-
iconTop
)
*
3
/
8
;
badgeImageView
.
layout
(
badgeLeft
,
badgeTop
,
badgeRight
,
badgeBottom
);
}
catch
(
Exception
exception
)
{
return
;
}
catch
(
NoSuchFieldException
noSuchFieldException
)
{
Log
.
v
(
"RoomToolbar exception: "
,
noSuchFieldException
.
getMessage
());
}
catch
(
IllegalAccessException
illegalAccessException
)
{
Log
.
v
(
"RoomToolbar exception: "
,
illegalAccessException
.
getMessage
());
}
}
}
...
...
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