Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-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
xabber-android
Commits
9bda59c9
Commit
9bda59c9
authored
Mar 12, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ContactViewerNew: new variant of expandable toolbar with transparent toolbar and fake panel.
parent
ad8c887b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
17 deletions
+83
-17
ContactViewerNew.java
...src/main/java/com/xabber/android/ui/ContactViewerNew.java
+60
-11
activity_contact_viewer.xml
app/src/main/res/layout/activity_contact_viewer.xml
+7
-1
contact_title.xml
app/src/main/res/layout/contact_title.xml
+12
-4
dimens.xml
app/src/main/res/values/dimens.xml
+4
-1
No files found.
app/src/main/java/com/xabber/android/ui/ContactViewerNew.java
View file @
9bda59c9
...
...
@@ -3,46 +3,79 @@ package com.xabber.android.ui;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.res.TypedArray
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.v7.widget.Toolbar
;
import
android.util.TypedValue
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.RelativeLayout
;
import
com.github.ksoichiro.android.observablescrollview.ObservableScrollView
;
import
com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks
;
import
com.github.ksoichiro.android.observablescrollview.ScrollState
;
import
com.github.ksoichiro.android.observablescrollview.ScrollUtils
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.intent.AccountIntentBuilder
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.helper.ContactTitle
ActionBar
Inflater
;
import
com.xabber.android.ui.helper.ContactTitleInflater
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
import
static
java
.
lang
.
Math
.
pow
;
import
static
java
.
lang
.
Math
.
round
;
import
static
java
.
lang
.
Math
.
sqrt
;
public
class
ContactViewerNew
extends
ManagedActivity
implements
ObservableScrollViewCallbacks
{
private
Toolbar
toolbar
;
private
int
toolbarHeight
;
private
View
actionBarView
;
private
int
paddingLeft
;
private
int
paddingRight
;
private
int
actionBarSize
;
private
int
radius
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_contact_viewer
);
setSupportActionBar
((
Toolbar
)
findViewById
(
R
.
id
.
contact_viewer_toolbar
));
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
getSupportActionBar
().
setDisplayShowTitleEnabled
(
false
);
setContentView
(
R
.
layout
.
activity_contact_viewer
);
int
[]
accountActionBarColors
;
int
[]
accountStatusBarColors
;
setSupportActionBar
((
Toolbar
)
findViewById
(
R
.
id
.
contact_viewer_toolbar
));
accountActionBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
accountStatusBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_status_bar
);
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
actionBarView
=
findViewById
(
R
.
id
.
title
);
paddingLeft
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_left
);
paddingRight
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_right
);
ContactTitleActionBarInflater
contactTitleActionBarInflater
=
new
ContactTitleActionBarInflater
(
this
);
contactTitleActionBarInflater
.
setUpActionBarView
();
contactTitleActionBarInflater
.
update
(
RosterManager
.
getInstance
().
getBestContact
(
getAccount
(
getIntent
()),
getUser
(
getIntent
())));
TypedArray
a
=
getTheme
().
obtainStyledAttributes
(
R
.
style
.
Theme
,
new
int
[]
{
R
.
attr
.
colorPrimary
});
AbstractContact
bestContact
=
RosterManager
.
getInstance
().
getBestContact
(
getAccount
(
getIntent
()),
getUser
(
getIntent
()));
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
contact_viewer_toolbar
);
ContactTitleInflater
.
updateTitle
(
actionBarView
,
this
,
bestContact
);
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
bestContact
.
getAccount
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
);
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
}
actionBarView
.
setBackgroundDrawable
(
new
ColorDrawable
(
accountActionBarColors
[
colorLevel
]));
toolbarHeight
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
toolbar_height
);
...
...
@@ -57,6 +90,14 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
});
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
actionBarSize
=
getActionBarSize
();
radius
=
toolbarHeight
-
actionBarSize
;
}
protected
int
getActionBarSize
()
{
TypedValue
typedValue
=
new
TypedValue
();
int
[]
textSizeAttr
=
new
int
[]{
R
.
attr
.
actionBarSize
};
...
...
@@ -81,14 +122,22 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
}
private
void
updateFlexibleSpaceText
(
final
int
scrollY
)
{
int
actionBarSize
=
getActionBarSize
();
if
(
scrollY
<=
radius
)
{
int
newPadding
=
(
int
)
round
(
sqrt
(
pow
(
radius
,
2
)
-
pow
(
scrollY
-
radius
,
2
)));
if
(
newPadding
>
radius
)
{
newPadding
=
radius
;
}
actionBarView
.
setPadding
(
paddingLeft
+
newPadding
,
0
,
paddingRight
,
0
);
}
int
newHeight
=
toolbarHeight
-
scrollY
;
if
(
newHeight
<
actionBarSize
)
{
newHeight
=
actionBarSize
;
}
toolbar
.
setLayoutParams
(
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
MATCH_PARENT
,
newHeight
));
actionBarView
.
setLayoutParams
(
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
MATCH_PARENT
,
newHeight
));
}
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
...
...
app/src/main/res/layout/activity_contact_viewer.xml
View file @
9bda59c9
...
...
@@ -30,10 +30,16 @@
</com.github.ksoichiro.android.observablescrollview.ObservableScrollView>
<include
layout=
"@layout/contact_title"
android:layout_height=
"@dimen/toolbar_height"
android:layout_width=
"match_parent"
android:id=
"@+id/title"
/>
<android.support.v7.widget.Toolbar
android:id=
"@+id/contact_viewer_toolbar"
android:layout_width=
"match_parent"
android:layout_height=
"
@dimen/toolbar_height
"
android:layout_height=
"
?attr/actionBarSize
"
app:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
/>
...
...
app/src/main/res/layout/contact_title.xml
View file @
9bda59c9
<?xml version="1.0" encoding="utf-8"?>
<
Linear
Layout
<
Frame
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/title"
android:layout_width=
"match_parent"
android:layout_height=
"?android:attr/actionBarSize"
android:orientation=
"horizontal"
android:background=
"@color/green_500"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"?android:attr/actionBarSize"
android:orientation=
"horizontal"
android:layout_gravity=
"bottom"
>
<ImageView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/avatar"
android:layout_width=
"48dip"
android:layout_height=
"48dip"
android:src=
"@drawable/ic_avatar_1"
android:layout_gravity=
"
bottom
"
android:layout_gravity=
"
center_vertical
"
/>
<LinearLayout
...
...
@@ -22,7 +29,7 @@
android:layout_width=
"0dp"
android:layout_height=
"48dip"
android:orientation=
"vertical"
android:layout_gravity=
"
bottom
"
android:layout_gravity=
"
center_vertical
"
android:layout_weight=
"1"
>
<TextView
...
...
@@ -76,3 +83,4 @@
/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
app/src/main/res/values/dimens.xml
View file @
9bda59c9
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen
name=
"toolbar_height"
>
96dp
</dimen>
<dimen
name=
"toolbar_height"
>
108dp
</dimen>
<dimen
name=
"contact_title_padding_left"
>
10dp
</dimen>
<dimen
name=
"contact_title_padding_right"
>
10dp
</dimen>
<dimen
name=
"contact_title_padding_bottom"
>
10dp
</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