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
23ea6c57
Commit
23ea6c57
authored
Jan 09, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing to custom toolbar
parent
7dfd882e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
145 additions
and
52 deletions
+145
-52
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-2
AbstractChatRoomFragment.java
...t/android/fragment/chatroom/AbstractChatRoomFragment.java
+9
-23
activity_main.xml
app/src/main/res/layout-w720dp/activity_main.xml
+5
-13
activity_main.xml
app/src/main/res/layout/activity_main.xml
+6
-14
CustomToolbar.java
...c/main/java/chat/rocket/android/widget/CustomToolbar.java
+98
-0
custom_toolbar.xml
...at-android-widgets/src/main/res/layout/custom_toolbar.xml
+13
-0
custom_toolbar_attrs.xml
...roid-widgets/src/main/res/values/custom_toolbar_attrs.xml
+12
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
23ea6c57
...
@@ -34,9 +34,9 @@
...
@@ -34,9 +34,9 @@
android:name=
".activity.AddServerActivity"
android:name=
".activity.AddServerActivity"
android:windowSoftInputMode=
"adjustResize"
/>
android:windowSoftInputMode=
"adjustResize"
/>
<activity
<activity
android:name=
".activity.
ServerConfig
Activity"
android:name=
".activity.
Login
Activity"
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/fragment/chatroom/AbstractChatRoomFragment.java
View file @
23ea6c57
package
chat
.
rocket
.
android
.
fragment
.
chatroom
;
package
chat
.
rocket
.
android
.
fragment
.
chatroom
;
import
android.graphics.Color
;
import
android.graphics.drawable.Drawable
;
import
android.os.Bundle
;
import
android.os.Bundle
;
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.v4.graphics.drawable.DrawableCompat
;
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
android.widget.TextView
;
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.CustomToolbar
;
abstract
class
AbstractChatRoomFragment
extends
AbstractFragment
{
abstract
class
AbstractChatRoomFragment
extends
AbstractFragment
{
private
static
final
String
TABLET
=
"tablet"
;
private
CustomToolbar
customToolbar
;
private
TextView
toolbarTitle
;
@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
)
{
toolbarTitle
=
(
TextView
)
getActivity
().
findViewById
(
R
.
id
.
toolbar_title
);
customToolbar
=
(
CustomToolbar
)
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
)
{
protected
void
setTitleText
(
@StringRes
int
stringResId
)
{
if
(
toolbarTitle
==
null
)
{
if
(
customToolbar
==
null
)
{
return
;
return
;
}
}
toolbarTitle
.
setText
(
stringResId
);
customToolbar
.
setTitle
(
stringResId
);
}
}
protected
void
setTitleText
(
CharSequence
title
)
{
protected
void
setTitleText
(
CharSequence
title
)
{
if
(
toolbarTitle
==
null
)
{
if
(
customToolbar
==
null
)
{
return
;
return
;
}
}
toolbarTitle
.
setText
(
title
);
customToolbar
.
setTitle
(
title
);
}
}
protected
void
setTitleDrawableLeft
(
@DrawableRes
int
drawableResId
)
{
protected
void
setTitleDrawableLeft
(
@DrawableRes
int
drawableResId
)
{
if
(
toolbarTitle
==
null
)
{
if
(
customToolbar
==
null
)
{
return
;
return
;
}
}
Drawable
drawable
=
drawableResId
>
0
customToolbar
.
setTitleDrawableLeft
(
drawableResId
);
?
VectorDrawableCompat
.
create
(
getResources
(),
drawableResId
,
null
)
:
null
;
if
(
drawable
!=
null
&&
TABLET
.
equals
(
toolbarTitle
.
getTag
()))
{
DrawableCompat
.
setTint
(
drawable
,
Color
.
WHITE
);
}
toolbarTitle
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
);
}
}
}
}
app/src/main/res/layout-w720dp/activity_main.xml
View file @
23ea6c57
...
@@ -14,23 +14,15 @@
...
@@ -14,23 +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.Custom
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:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
>
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
app:mode=
"tablet"
<TextView
app:titleText=
"@string/app_name"
android:id=
"@+id/toolbar_title"
app:titleDrawablePadding=
"@dimen/margin_8"
/>
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/app_name"
android:drawablePadding=
"@dimen/margin_8"
android:tag=
"tablet"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
<FrameLayout
...
...
app/src/main/res/layout/activity_main.xml
View file @
23ea6c57
...
@@ -15,24 +15,16 @@
...
@@ -15,24 +15,16 @@
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.Custom
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"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
>
app:mode=
"phone"
app:titleText=
"@string/app_name"
<TextView
app:titleTextColor=
"@color/titleTextColor"
android:id=
"@+id/toolbar_title"
app:titleDrawablePadding=
"@dimen/margin_8"
android:layout_width=
"wrap_content"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
/>
android:layout_height=
"wrap_content"
android:text=
"@string/app_name"
android:textColor=
"@color/titleTextColor"
android:drawablePadding=
"@dimen/margin_8"
android:tag=
"phone"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
/>
</android.support.v7.widget.Toolbar>
<View
<View
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/CustomToolbar.java
0 → 100644
View file @
23ea6c57
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.v4.graphics.drawable.DrawableCompat
;
import
android.support.v7.widget.Toolbar
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.widget.TextView
;
public
class
CustomToolbar
extends
Toolbar
{
private
static
final
String
TABLET
=
"tablet"
;
private
TextView
titleTextView
;
private
int
mode
;
public
CustomToolbar
(
Context
context
)
{
super
(
context
);
initialize
(
context
,
null
);
}
public
CustomToolbar
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
initialize
(
context
,
attrs
);
}
public
CustomToolbar
(
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
.
custom_toolbar
,
this
);
titleTextView
=
(
TextView
)
findViewById
(
R
.
id
.
toolbar_title
);
if
(
titleTextView
==
null
)
{
return
;
}
TypedArray
typedArray
=
context
.
getTheme
().
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
CustomToolbar
,
0
,
0
);
try
{
titleTextView
.
setText
(
typedArray
.
getText
(
R
.
styleable
.
CustomToolbar_titleText
));
titleTextView
.
setTextColor
(
typedArray
.
getColor
(
R
.
styleable
.
CustomToolbar_titleTextColor
,
Color
.
BLACK
));
titleTextView
.
setCompoundDrawablePadding
(
typedArray
.
getLayoutDimension
(
R
.
styleable
.
CustomToolbar_titleDrawablePadding
,
0
));
mode
=
typedArray
.
getInt
(
R
.
styleable
.
CustomToolbar_mode
,
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
setTitleDrawableLeft
(
@DrawableRes
int
drawableResId
)
{
if
(
titleTextView
==
null
)
{
return
;
}
Drawable
drawable
=
drawableResId
>
0
?
VectorDrawableCompat
.
create
(
getResources
(),
drawableResId
,
null
)
:
null
;
if
(
drawable
!=
null
&&
mode
==
1
)
{
DrawableCompat
.
setTint
(
drawable
,
Color
.
WHITE
);
}
titleTextView
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
);
}
}
rocket-chat-android-widgets/src/main/res/layout/custom_toolbar.xml
0 → 100644
View file @
23ea6c57
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
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/custom_toolbar_attrs.xml
0 → 100644
View file @
23ea6c57
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable
name=
"CustomToolbar"
>
<attr
name=
"mode"
format=
"enum"
>
<enum
name=
"phone"
value=
"0"
/>
<enum
name=
"tablet"
value=
"1"
/>
</attr>
<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