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
3d855539
Commit
3d855539
authored
Jan 16, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix type: budge -> badge; modify badge size with no text
parent
e54692a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
15 deletions
+31
-15
RoomToolbar.java
...src/main/java/chat/rocket/android/widget/RoomToolbar.java
+20
-15
badge_without_number.xml
...id-widgets/src/main/res/drawable/badge_without_number.xml
+6
-0
badge_styles.xml
...chat-android-widgets/src/main/res/values/badge_styles.xml
+5
-0
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RoomToolbar.java
View file @
3d855539
...
@@ -2,13 +2,13 @@ package chat.rocket.android.widget;
...
@@ -2,13 +2,13 @@ package chat.rocket.android.widget;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.content.res.TypedArray
;
import
android.graphics.Color
;
import
android.graphics.Typeface
;
import
android.graphics.Typeface
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.support.annotation.DrawableRes
;
import
android.support.annotation.DrawableRes
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.StringRes
;
import
android.support.annotation.StringRes
;
import
android.support.graphics.drawable.VectorDrawableCompat
;
import
android.support.graphics.drawable.VectorDrawableCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.widget.TextViewCompat
;
import
android.support.v4.widget.TextViewCompat
;
import
android.support.v7.widget.AppCompatImageView
;
import
android.support.v7.widget.AppCompatImageView
;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
...
@@ -24,7 +24,7 @@ import java.lang.reflect.Field;
...
@@ -24,7 +24,7 @@ import java.lang.reflect.Field;
public
class
RoomToolbar
extends
Toolbar
{
public
class
RoomToolbar
extends
Toolbar
{
private
TextView
titleTextView
;
private
TextView
titleTextView
;
private
ImageView
b
u
dgeImageView
;
private
ImageView
b
a
dgeImageView
;
public
RoomToolbar
(
Context
context
)
{
public
RoomToolbar
(
Context
context
)
{
super
(
context
);
super
(
context
);
...
@@ -110,30 +110,35 @@ public class RoomToolbar extends Toolbar {
...
@@ -110,30 +110,35 @@ public class RoomToolbar extends Toolbar {
return
;
return
;
}
}
if
(
budgeImageView
==
null
)
{
if
(
badgeImageView
==
null
)
{
budgeImageView
=
new
AppCompatImageView
(
getContext
());
badgeImageView
=
new
AppCompatImageView
(
getContext
());
badgeImageView
.
setScaleType
(
ImageView
.
ScaleType
.
CENTER_INSIDE
);
}
}
if
(
b
u
dgeImageView
.
getParent
()
!=
this
)
{
//ref: Toolbar#isChildOrHidden
if
(
b
a
dgeImageView
.
getParent
()
!=
this
)
{
//ref: Toolbar#isChildOrHidden
addView
(
b
u
dgeImageView
,
generateDefaultLayoutParams
());
addView
(
b
a
dgeImageView
,
generateDefaultLayoutParams
());
}
}
if
(
numUnreadChannels
>
0
)
{
if
(
numUnreadChannels
>
0
)
{
budgeImageView
.
setImageDrawable
(
getBudgeDrawable
(
numMentionsSum
));
if
(
numMentionsSum
>
0
)
{
budgeImageView
.
setVisibility
(
View
.
VISIBLE
);
badgeImageView
.
setImageDrawable
(
getBadgeDrawable
(
numMentionsSum
));
}
else
{
badgeImageView
.
setScaleType
(
ImageView
.
ScaleType
.
CENTER
);
badgeImageView
.
setImageResource
(
R
.
drawable
.
badge_without_number
);
}
badgeImageView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
{
b
u
dgeImageView
.
setVisibility
(
View
.
GONE
);
b
a
dgeImageView
.
setVisibility
(
View
.
GONE
);
}
}
}
}
private
Drawable
getBudgeDrawable
(
int
number
)
{
private
Drawable
getBadgeDrawable
(
int
number
)
{
String
icon
=
number
>
99
?
"99+"
:
String
icon
=
number
>
99
?
"99+"
:
Integer
.
toString
(
number
);
(
number
<=
0
?
""
:
Integer
.
toString
(
number
));
return
TextDrawable
.
builder
()
return
TextDrawable
.
builder
()
.
beginConfig
()
.
beginConfig
()
.
useFont
(
Typeface
.
SANS_SERIF
)
.
useFont
(
Typeface
.
SANS_SERIF
)
.
endConfig
()
.
endConfig
()
.
buildRound
(
icon
,
Co
lor
.
RED
);
.
buildRound
(
icon
,
Co
ntextCompat
.
getColor
(
getContext
(),
R
.
color
.
badge_color
)
);
}
}
...
@@ -142,7 +147,7 @@ public class RoomToolbar extends Toolbar {
...
@@ -142,7 +147,7 @@ public class RoomToolbar extends Toolbar {
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
int
bottom
)
{
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
int
bottom
)
{
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
if
(
b
udgeImageView
!=
null
&&
bu
dgeImageView
.
getVisibility
()
!=
View
.
GONE
)
{
if
(
b
adgeImageView
!=
null
&&
ba
dgeImageView
.
getVisibility
()
!=
View
.
GONE
)
{
try
{
try
{
Field
field
=
Toolbar
.
class
.
getDeclaredField
(
"mNavButtonView"
);
Field
field
=
Toolbar
.
class
.
getDeclaredField
(
"mNavButtonView"
);
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
...
@@ -156,7 +161,7 @@ public class RoomToolbar extends Toolbar {
...
@@ -156,7 +161,7 @@ public class RoomToolbar extends Toolbar {
int
budgeRight
=
iconLeft
+
(
iconRight
-
iconLeft
)
*
7
/
8
;
int
budgeRight
=
iconLeft
+
(
iconRight
-
iconLeft
)
*
7
/
8
;
int
budgeTop
=
iconTop
+
(
iconBottom
-
iconTop
)
/
8
;
int
budgeTop
=
iconTop
+
(
iconBottom
-
iconTop
)
/
8
;
int
budgeBottom
=
iconTop
+
(
iconBottom
-
iconTop
)
*
3
/
8
;
int
budgeBottom
=
iconTop
+
(
iconBottom
-
iconTop
)
*
3
/
8
;
b
u
dgeImageView
.
layout
(
budgeLeft
,
budgeTop
,
budgeRight
,
budgeBottom
);
b
a
dgeImageView
.
layout
(
budgeLeft
,
budgeTop
,
budgeRight
,
budgeBottom
);
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
return
;
return
;
}
}
...
...
rocket-chat-android-widgets/src/main/res/drawable/badge_without_number.xml
0 → 100644
View file @
3d855539
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"oval"
>
<solid
android:color=
"@color/badge_color"
/>
<size
android:width=
"@dimen/badge_size"
android:height=
"@dimen/badge_size"
/>
</shape>
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/values/badge_styles.xml
0 → 100644
View file @
3d855539
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"badge_color"
>
#FFFF0000
</color>
<dimen
name=
"badge_size"
>
8dp
</dimen>
</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