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
03668ace
Commit
03668ace
authored
Mar 13, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ContactViewerNew: avatar resizing, movement trajectory improved, paddings corrected.
parent
2b05d0b6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
23 deletions
+157
-23
ContactViewerNew.java
...src/main/java/com/xabber/android/ui/ContactViewerNew.java
+74
-16
activity_contact_viewer.xml
app/src/main/res/layout/activity_contact_viewer.xml
+74
-4
contact_title.xml
app/src/main/res/layout/contact_title.xml
+2
-1
dimens.xml
app/src/main/res/values/dimens.xml
+7
-2
No files found.
app/src/main/java/com/xabber/android/ui/ContactViewerNew.java
View file @
03668ace
...
@@ -34,11 +34,18 @@ import static java.lang.Math.sqrt;
...
@@ -34,11 +34,18 @@ import static java.lang.Math.sqrt;
public
class
ContactViewerNew
extends
ManagedActivity
implements
ObservableScrollViewCallbacks
{
public
class
ContactViewerNew
extends
ManagedActivity
implements
ObservableScrollViewCallbacks
{
private
int
toolbarHeight
;
private
int
toolbarHeight
;
private
View
actionBarView
;
private
View
avatarView
;
private
int
paddingLeft
;
private
View
titleView
;
private
int
paddingLeftMin
;
private
int
paddingRight
;
private
int
paddingRight
;
private
int
actionBarSize
;
private
int
actionBarSize
;
private
int
radius
;
private
int
toolbarHeightDelta
;
private
int
avatarLargeSize
;
private
int
avatarNormalSize
;
private
int
avatarRadius
;
private
View
contactNamePanel
;
private
int
contactTitlePaddingBottomBig
;
private
int
contactTitlePaddingBottomSmall
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -56,16 +63,24 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
...
@@ -56,16 +63,24 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
accountActionBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
accountActionBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
accountStatusBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_status_bar
);
accountStatusBarColors
=
getResources
().
getIntArray
(
R
.
array
.
account_status_bar
);
actionBarView
=
findViewById
(
R
.
id
.
title
);
titleView
=
findViewById
(
R
.
id
.
title
);
avatarView
=
findViewById
(
R
.
id
.
avatar
);
contactNamePanel
=
findViewById
(
R
.
id
.
contact_name_panel
);
paddingLeft
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_left
);
paddingLeft
Min
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_left
);
paddingRight
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_right
);
paddingRight
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_right
);
avatarLargeSize
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
avatar_large_size
);
avatarNormalSize
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
avatar_normal_size
);
avatarRadius
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
avatar_radius
);
TypedArray
a
=
getTheme
().
obtainStyledAttributes
(
R
.
style
.
Theme
,
new
int
[]
{
R
.
attr
.
colorPrimary
});
contactTitlePaddingBottomBig
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_bottom_big
);
contactTitlePaddingBottomSmall
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
contact_title_padding_bottom_small
);
TypedArray
a
=
getTheme
().
obtainStyledAttributes
(
R
.
style
.
Theme
,
new
int
[]{
R
.
attr
.
colorPrimary
});
AbstractContact
bestContact
=
RosterManager
.
getInstance
().
getBestContact
(
getAccount
(
getIntent
()),
getUser
(
getIntent
()));
AbstractContact
bestContact
=
RosterManager
.
getInstance
().
getBestContact
(
getAccount
(
getIntent
()),
getUser
(
getIntent
()));
ContactTitleInflater
.
updateTitle
(
actionBar
View
,
this
,
bestContact
);
ContactTitleInflater
.
updateTitle
(
title
View
,
this
,
bestContact
);
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
bestContact
.
getAccount
());
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
bestContact
.
getAccount
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
...
@@ -75,7 +90,7 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
...
@@ -75,7 +90,7 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
}
}
actionBar
View
.
setBackgroundDrawable
(
new
ColorDrawable
(
accountActionBarColors
[
colorLevel
]));
title
View
.
setBackgroundDrawable
(
new
ColorDrawable
(
accountActionBarColors
[
colorLevel
]));
toolbarHeight
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
toolbar_height
);
toolbarHeight
=
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
toolbar_height
);
...
@@ -95,7 +110,7 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
...
@@ -95,7 +110,7 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
super
.
onResume
();
super
.
onResume
();
actionBarSize
=
getActionBarSize
();
actionBarSize
=
getActionBarSize
();
radius
=
toolbarHeight
-
actionBarSize
;
toolbarHeightDelta
=
toolbarHeight
-
actionBarSize
;
}
}
protected
int
getActionBarSize
()
{
protected
int
getActionBarSize
()
{
...
@@ -122,22 +137,65 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
...
@@ -122,22 +137,65 @@ public class ContactViewerNew extends ManagedActivity implements ObservableScrol
}
}
private
void
updateFlexibleSpaceText
(
final
int
scrollY
)
{
private
void
updateFlexibleSpaceText
(
final
int
scrollY
)
{
if
(
scrollY
<=
radius
)
{
setLeftPadding
(
scrollY
);
int
newPadding
=
(
int
)
round
(
sqrt
(
pow
(
radius
,
2
)
-
pow
(
scrollY
-
radius
,
2
)));
setTopPadding
(
scrollY
);
setAvatarSize
(
scrollY
);
setHeight
(
scrollY
);
}
private
void
setTopPadding
(
int
scrollY
)
{
int
paddingDelta
=
contactTitlePaddingBottomBig
-
contactTitlePaddingBottomSmall
;
int
paddingBottom
=
contactTitlePaddingBottomBig
-
scrollY
*
paddingDelta
/
toolbarHeightDelta
;
if
(
scrollY
<=
0
)
{
paddingBottom
=
contactTitlePaddingBottomBig
;
}
if
(
scrollY
>=
toolbarHeightDelta
)
{
paddingBottom
=
contactTitlePaddingBottomSmall
;
}
contactNamePanel
.
setPadding
(
0
,
0
,
0
,
paddingBottom
);
}
private
void
setAvatarSize
(
int
scrollY
)
{
int
newAvatarSize
=
avatarLargeSize
-
(
scrollY
/
2
);
if
(
newPadding
>
radius
)
{
if
(
newAvatarSize
<
avatarNormalSize
)
{
newPadding
=
radius
;
newAvatarSize
=
avatarNormalSize
;
}
}
actionBarView
.
setPadding
(
paddingLeft
+
newPadding
,
0
,
paddingRight
,
0
);
if
(
avatarView
.
getWidth
()
!=
newAvatarSize
)
{
avatarView
.
getLayoutParams
().
width
=
newAvatarSize
;
avatarView
.
getLayoutParams
().
height
=
newAvatarSize
;
}
}
}
private
void
setHeight
(
int
scrollY
)
{
int
newHeight
=
toolbarHeight
-
scrollY
;
int
newHeight
=
toolbarHeight
-
scrollY
;
if
(
newHeight
<
actionBarSize
)
{
if
(
newHeight
<
actionBarSize
)
{
newHeight
=
actionBarSize
;
newHeight
=
actionBarSize
;
}
}
actionBarView
.
setLayoutParams
(
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
MATCH_PARENT
,
newHeight
));
titleView
.
setLayoutParams
(
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
MATCH_PARENT
,
newHeight
));
}
private
void
setLeftPadding
(
int
scrollY
)
{
int
paddingLeft
=
(
int
)
round
(
sqrt
(
pow
(
avatarRadius
,
2
)
-
pow
(
scrollY
-
avatarRadius
,
2
)));
if
(
scrollY
<
0
)
{
paddingLeft
=
paddingLeftMin
;
}
if
(
scrollY
>
avatarRadius
)
{
paddingLeft
=
avatarRadius
;
}
if
(
paddingLeft
<
paddingLeftMin
)
{
paddingLeft
=
paddingLeftMin
;
}
titleView
.
setPadding
(
paddingLeft
,
0
,
paddingRight
,
0
);
}
}
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
...
...
app/src/main/res/layout/activity_contact_viewer.xml
View file @
03668ace
...
@@ -30,18 +30,88 @@
...
@@ -30,18 +30,88 @@
</com.github.ksoichiro.android.observablescrollview.ObservableScrollView>
</com.github.ksoichiro.android.observablescrollview.ObservableScrollView>
<include
layout=
"@layout/contact_title"
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/title"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/toolbar_height"
android:layout_height=
"@dimen/toolbar_height"
android:background=
"@color/green_500"
android:elevation=
"8dp"
>
<LinearLayout
android:id=
"@+id/contact_name_panel"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:id=
"@+id/title"
android:layout_height=
"wrap_content"
android:minHeight=
"?android:attr/actionBarSize"
android:orientation=
"horizontal"
android:layout_gravity=
"bottom"
android:paddingBottom=
"10dp"
>
<ImageView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/avatar"
android:layout_width=
"@dimen/avatar_large_size"
android:layout_height=
"@dimen/avatar_large_size"
android:src=
"@drawable/ic_avatar_1"
android:layout_gravity=
"center_vertical"
/>
<LinearLayout
android:id=
"@+id/name_holder"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
>
<TextView
android:id=
"@+id/name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:singleLine=
"true"
android:textColor=
"@color/primary_text_default_material_dark"
android:text=
"Lorem Ipsum"
android:layout_marginLeft=
"6dp"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/status_text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:singleLine=
"true"
android:textColor=
"@color/grey_200"
android:text=
"Lorem ipsum dolor sit amet"
android:layout_marginTop=
"3dp"
android:layout_marginLeft=
"6dp"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/status_mode"
android:src=
"@drawable/ic_status"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
/>
/>
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.Toolbar
<android.support.v7.widget.Toolbar
android:id=
"@+id/contact_viewer_toolbar"
android:id=
"@+id/contact_viewer_toolbar"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
android:layout_height=
"?attr/actionBarSize"
app:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
android:background=
"@null"
android:elevation=
"8dp"
/>
/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/contact_title.xml
View file @
03668ace
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"?android:attr/actionBarSize"
android:layout_height=
"wrap_content"
android:minHeight=
"?android:attr/actionBarSize"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
...
...
app/src/main/res/values/dimens.xml
View file @
03668ace
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<dimen
name=
"toolbar_height"
>
1
0
8dp
</dimen>
<dimen
name=
"toolbar_height"
>
1
3
8dp
</dimen>
<dimen
name=
"contact_title_padding_left"
>
10dp
</dimen>
<dimen
name=
"contact_title_padding_left"
>
10dp
</dimen>
<dimen
name=
"contact_title_padding_right"
>
10dp
</dimen>
<dimen
name=
"contact_title_padding_right"
>
10dp
</dimen>
<dimen
name=
"contact_title_padding_bottom"
>
10dp
</dimen>
<dimen
name=
"contact_title_padding_bottom_small"
>
2dp
</dimen>
<dimen
name=
"contact_title_padding_bottom_big"
>
10dp
</dimen>
<dimen
name=
"avatar_large_size"
>
72dp
</dimen>
<dimen
name=
"avatar_normal_size"
>
48dp
</dimen>
<dimen
name=
"avatar_radius"
>
56dp
</dimen>
</resources>
</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