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
30a3ab3a
Commit
30a3ab3a
authored
Mar 26, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New ActionBarPainter extracted from ContactTitleActionBarInflater. Used in ContactAdd activity.
parent
f275952b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
58 deletions
+95
-58
ContactAdd.java
app/src/main/java/com/xabber/android/ui/ContactAdd.java
+10
-17
ContactAddFragment.java
...c/main/java/com/xabber/android/ui/ContactAddFragment.java
+21
-0
GroupEditor.java
app/src/main/java/com/xabber/android/ui/GroupEditor.java
+0
-1
ActionBarPainter.java
...n/java/com/xabber/android/ui/helper/ActionBarPainter.java
+57
-0
ContactTitleActionBarInflater.java
...bber/android/ui/helper/ContactTitleActionBarInflater.java
+7
-40
No files found.
app/src/main/java/com/xabber/android/ui/ContactAdd.java
View file @
30a3ab3a
...
...
@@ -21,28 +21,15 @@ import android.support.v7.widget.Toolbar;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
import
android.widget.Spinner
;
import
android.widget.Toast
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.roster.PresenceManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.adapter.AccountChooseAdapter
;
import
com.xabber.android.ui.dialog.ContactDeleteDialogFragment
;
import
com.xabber.android.ui.helper.ActionBarPainter
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
import
java.util.Collection
;
import
java.util.HashSet
;
public
class
ContactAdd
extends
ManagedActivity
implements
ContactAddFragment
.
Listener
{
public
class
ContactAdd
extends
ManagedActivity
{
ActionBarPainter
actionBarPainter
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -54,6 +41,8 @@ public class ContactAdd extends ManagedActivity {
getSupportActionBar
().
setHomeAsUpIndicator
(
R
.
drawable
.
ic_clear_white_24dp
);
getSupportActionBar
().
setTitle
(
null
);
actionBarPainter
=
new
ActionBarPainter
(
this
);
Intent
intent
=
getIntent
();
if
(
savedInstanceState
==
null
)
{
...
...
@@ -109,4 +98,8 @@ public class ContactAdd extends ManagedActivity {
return
EntityIntentBuilder
.
getUser
(
intent
);
}
@Override
public
void
onAccountSelected
(
String
account
)
{
actionBarPainter
.
update
(
account
);
}
}
app/src/main/java/com/xabber/android/ui/ContactAddFragment.java
View file @
30a3ab3a
package
com
.
xabber
.
android
.
ui
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
...
...
@@ -32,6 +33,8 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
private
EditText
nameView
;
private
View
selectGroupsView
;
Listener
listenerActivity
;
public
static
ContactAddFragment
newInstance
(
String
account
,
String
user
)
{
ContactAddFragment
fragment
=
new
ContactAddFragment
();
Bundle
args
=
new
Bundle
();
...
...
@@ -41,6 +44,12 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
return
fragment
;
}
@Override
public
void
onAttach
(
Activity
activity
)
{
super
.
onAttach
(
activity
);
listenerActivity
=
(
Listener
)
activity
;
}
@Override
public
void
onActivityCreated
(
Bundle
savedInstanceState
)
{
super
.
onActivityCreated
(
savedInstanceState
);
...
...
@@ -110,6 +119,12 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
}
@Override
public
void
onDetach
()
{
super
.
onDetach
();
listenerActivity
=
null
;
}
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
String
selectedAccount
=
(
String
)
accountView
.
getSelectedItem
();
...
...
@@ -118,6 +133,8 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
onNothingSelected
(
parent
);
setAccount
(
selectedAccount
);
}
else
{
listenerActivity
.
onAccountSelected
(
selectedAccount
);
if
(!
selectedAccount
.
equals
(
getAccount
()))
{
setAccount
(
selectedAccount
);
setAccountGroups
();
...
...
@@ -159,4 +176,8 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
MessageManager
.
getInstance
().
openChat
(
account
,
user
);
getActivity
().
finish
();
}
public
interface
Listener
{
public
void
onAccountSelected
(
String
account
);
}
}
app/src/main/java/com/xabber/android/ui/GroupEditor.java
View file @
30a3ab3a
...
...
@@ -28,7 +28,6 @@ import com.xabber.android.data.roster.AbstractContact;
import
com.xabber.android.data.roster.OnContactChangedListener
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.helper.ContactTitleActionBarInflater
;
import
com.xabber.android.ui.helper.ContactTitleExpandableToolbarInflater
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
import
com.xabber.xmpp.address.Jid
;
...
...
app/src/main/java/com/xabber/android/ui/helper/ActionBarPainter.java
0 → 100644
View file @
30a3ab3a
package
com
.
xabber
.
android
.
ui
.
helper
;
import
android.content.res.TypedArray
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.support.v7.app.ActionBarActivity
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.androiddev.R
;
public
class
ActionBarPainter
{
private
int
[]
accountActionBarColors
;
private
int
[]
accountStatusBarColors
;
private
Window
window
;
private
int
defaultStatusBarColor
;
private
ColorDrawable
defaultActionBarBackground
;
private
final
ActionBarActivity
activity
;
public
ActionBarPainter
(
ActionBarActivity
activity
)
{
this
.
activity
=
activity
;
accountActionBarColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
accountStatusBarColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_status_bar
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
=
this
.
activity
.
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
);
defaultStatusBarColor
=
window
.
getStatusBarColor
();
}
TypedArray
a
=
activity
.
getTheme
().
obtainStyledAttributes
(
R
.
style
.
Theme
,
new
int
[]
{
R
.
attr
.
colorPrimary
});
int
attributeResourceId
=
a
.
getResourceId
(
0
,
0
);
defaultActionBarBackground
=
new
ColorDrawable
(
activity
.
getResources
().
getColor
(
attributeResourceId
));
}
public
void
update
(
String
account
)
{
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
account
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
}
activity
.
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
accountActionBarColors
[
colorLevel
]));
}
public
void
restore
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
.
setStatusBarColor
(
defaultStatusBarColor
);
}
activity
.
getSupportActionBar
().
setBackgroundDrawable
(
defaultActionBarBackground
);
}
}
app/src/main/java/com/xabber/android/ui/helper/ContactTitleActionBarInflater.java
View file @
30a3ab3a
package
com
.
xabber
.
android
.
ui
.
helper
;
import
android.content.res.TypedArray
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.ActionBarActivity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.TextView
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.androiddev.R
;
...
...
@@ -22,71 +16,44 @@ public class ContactTitleActionBarInflater {
private
final
ActionBarActivity
activity
;
private
View
actionBarView
;
private
int
[]
accountActionBarColors
;
private
int
[]
accountStatusBarColors
;
private
Window
window
;
private
int
defaultStatusBarColor
;
private
Animation
shakeAnimation
=
null
;
private
ColorDrawable
defaultActionBarBackground
;
private
ActionBarPainter
actionBarPainter
;
public
ContactTitleActionBarInflater
(
ActionBarActivity
activity
)
{
this
.
activity
=
activity
;
}
public
void
setUpActionBarView
()
{
accountActionBarColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
ac
countStatusBarColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_status_bar
);
ac
tionBarPainter
=
new
ActionBarPainter
(
activity
);
ActionBar
actionBar
=
activity
.
getSupportActionBar
();
actionBar
.
setDisplayShowHomeEnabled
(
false
);
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
actionBarView
=
LayoutInflater
.
from
(
activity
).
inflate
(
R
.
layout
.
contact_title
,
null
);
actionBar
.
setCustomView
(
actionBarView
,
new
ActionBar
.
LayoutParams
(
ActionBar
.
LayoutParams
.
MATCH_PARENT
,
ActionBar
.
LayoutParams
.
MATCH_PARENT
));
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
=
this
.
activity
.
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
);
defaultStatusBarColor
=
window
.
getStatusBarColor
();
}
TypedArray
a
=
activity
.
getTheme
().
obtainStyledAttributes
(
R
.
style
.
Theme
,
new
int
[]
{
R
.
attr
.
colorPrimary
});
int
attributeResourceId
=
a
.
getResourceId
(
0
,
0
);
defaultActionBarBackground
=
new
ColorDrawable
(
activity
.
getResources
().
getColor
(
attributeResourceId
));
}
public
void
update
(
AbstractContact
abstractContact
)
{
actionBarPainter
.
update
(
abstractContact
.
getAccount
());
activity
.
getSupportActionBar
().
setDisplayShowCustomEnabled
(
true
);
activity
.
getSupportActionBar
().
setDisplayShowTitleEnabled
(
false
);
actionBarView
.
setVisibility
(
View
.
VISIBLE
);
ContactTitleInflater
.
updateTitle
(
actionBarView
,
activity
,
abstractContact
);
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
abstractContact
.
getAccount
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
}
activity
.
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
accountActionBarColors
[
colorLevel
]));
}
public
void
restoreDefaultTitleView
(
String
title
)
{
actionBarPainter
.
restore
();
activity
.
getSupportActionBar
().
setDisplayShowCustomEnabled
(
false
);
activity
.
getSupportActionBar
().
setDisplayShowTitleEnabled
(
true
);
actionBarView
.
setVisibility
(
View
.
GONE
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
.
setStatusBarColor
(
defaultStatusBarColor
);
}
activity
.
getSupportActionBar
().
setBackgroundDrawable
(
defaultActionBarBackground
);
activity
.
setTitle
(
title
);
}
...
...
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