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
5a4acebb
Commit
5a4acebb
authored
Mar 26, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ActionBarPainter used in AccountEditor and ChatEditor (preferences)
parent
30a3ab3a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
9 deletions
+43
-9
ContactAdd.java
app/src/main/java/com/xabber/android/ui/ContactAdd.java
+1
-1
ActionBarPainter.java
...n/java/com/xabber/android/ui/helper/ActionBarPainter.java
+16
-2
ContactTitleActionBarInflater.java
...bber/android/ui/helper/ContactTitleActionBarInflater.java
+1
-1
AccountEditor.java
...java/com/xabber/android/ui/preferences/AccountEditor.java
+10
-0
AccountEditorFragment.java
.../xabber/android/ui/preferences/AccountEditorFragment.java
+11
-5
ChatEditor.java
...in/java/com/xabber/android/ui/preferences/ChatEditor.java
+4
-0
No files found.
app/src/main/java/com/xabber/android/ui/ContactAdd.java
View file @
5a4acebb
...
...
@@ -100,6 +100,6 @@ public class ContactAdd extends ManagedActivity implements ContactAddFragment.Li
@Override
public
void
onAccountSelected
(
String
account
)
{
actionBarPainter
.
update
(
account
);
actionBarPainter
.
update
WithAccountName
(
account
);
}
}
app/src/main/java/com/xabber/android/ui/helper/ActionBarPainter.java
View file @
5a4acebb
...
...
@@ -14,6 +14,7 @@ public class ActionBarPainter {
private
int
[]
accountActionBarColors
;
private
int
[]
accountStatusBarColors
;
private
String
[]
accountColorNames
;
private
Window
window
;
private
int
defaultStatusBarColor
;
...
...
@@ -26,6 +27,7 @@ public class ActionBarPainter {
accountActionBarColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
accountStatusBarColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_status_bar
);
accountColorNames
=
activity
.
getResources
().
getStringArray
(
R
.
array
.
account_color_names
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
=
this
.
activity
.
getWindow
();
...
...
@@ -39,8 +41,11 @@ public class ActionBarPainter {
defaultActionBarBackground
=
new
ColorDrawable
(
activity
.
getResources
().
getColor
(
attributeResourceId
));
}
public
void
update
(
String
account
)
{
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
account
);
public
void
updateWithAccountName
(
String
account
)
{
updateWithColorLevel
(
AccountManager
.
getInstance
().
getColorLevel
(
account
));
}
public
void
updateWithColorLevel
(
int
colorLevel
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
window
.
setStatusBarColor
(
accountStatusBarColors
[
colorLevel
]);
}
...
...
@@ -54,4 +59,13 @@ public class ActionBarPainter {
activity
.
getSupportActionBar
().
setBackgroundDrawable
(
defaultActionBarBackground
);
}
public
void
updateWithColorName
(
String
targetColorName
)
{
for
(
int
i
=
0
;
i
<
accountColorNames
.
length
;
i
++)
{
String
accountColorName
=
accountColorNames
[
i
];
if
(
accountColorName
.
equals
(
targetColorName
))
{
updateWithColorLevel
(
i
);
}
}
}
}
app/src/main/java/com/xabber/android/ui/helper/ContactTitleActionBarInflater.java
View file @
5a4acebb
...
...
@@ -39,7 +39,7 @@ public class ContactTitleActionBarInflater {
}
public
void
update
(
AbstractContact
abstractContact
)
{
actionBarPainter
.
update
(
abstractContact
.
getAccount
());
actionBarPainter
.
update
WithAccountName
(
abstractContact
.
getAccount
());
activity
.
getSupportActionBar
().
setDisplayShowCustomEnabled
(
true
);
activity
.
getSupportActionBar
().
setDisplayShowTitleEnabled
(
false
);
...
...
app/src/main/java/com/xabber/android/ui/preferences/AccountEditor.java
View file @
5a4acebb
...
...
@@ -28,6 +28,7 @@ import com.xabber.android.data.account.AccountManager;
import
com.xabber.android.data.intent.AccountIntentBuilder
;
import
com.xabber.android.ui.OAuthActivity
;
import
com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder
;
import
com.xabber.android.ui.helper.ActionBarPainter
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
...
...
@@ -46,6 +47,7 @@ public class AccountEditor extends ManagedActivity implements
private
AccountItem
accountItem
;
private
String
token
;
private
ActionBarPainter
actionBarPainter
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -76,6 +78,9 @@ public class AccountEditor extends ManagedActivity implements
setSupportActionBar
((
Toolbar
)
findViewById
(
R
.
id
.
toolbar_default
));
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
setTitle
(
AccountManager
.
getInstance
().
getVerboseName
(
account
));
actionBarPainter
=
new
ActionBarPainter
(
this
);
actionBarPainter
.
updateWithAccountName
(
account
);
}
@Override
...
...
@@ -158,4 +163,9 @@ public class AccountEditor extends ManagedActivity implements
public
void
showOrbotDialog
()
{
showDialog
(
ORBOT_DIALOG_ID
);
}
@Override
public
void
onColorChange
(
String
colorName
)
{
actionBarPainter
.
updateWithColorName
(
colorName
);
}
}
app/src/main/java/com/xabber/android/ui/preferences/AccountEditorFragment.java
View file @
5a4acebb
...
...
@@ -92,6 +92,11 @@ public class AccountEditorFragment extends BaseSettingsFragment
}
}
}
if
(
getString
(
R
.
string
.
account_color_key
).
equals
(
key
))
{
mListener
.
onColorChange
((
String
)
newValue
);
}
return
true
;
}
...
...
@@ -210,10 +215,11 @@ public class AccountEditorFragment extends BaseSettingsFragment
}
public
interface
AccountEditorFragmentInteractionListener
{
public
String
getAccount
();
public
AccountItem
getAccountItem
();
public
String
getToken
();
public
void
onOAuthClick
();
public
void
showOrbotDialog
();
String
getAccount
();
AccountItem
getAccountItem
();
String
getToken
();
void
onOAuthClick
();
void
showOrbotDialog
();
void
onColorChange
(
String
colorName
);
}
}
app/src/main/java/com/xabber/android/ui/preferences/ChatEditor.java
View file @
5a4acebb
...
...
@@ -23,6 +23,7 @@ import com.xabber.android.data.Application;
import
com.xabber.android.data.account.AccountItem
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
import
com.xabber.android.ui.helper.ActionBarPainter
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
...
...
@@ -51,6 +52,9 @@ public class ChatEditor extends ManagedActivity
setSupportActionBar
((
Toolbar
)
findViewById
(
R
.
id
.
toolbar_default
));
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
ActionBarPainter
actionBarPainter
=
new
ActionBarPainter
(
this
);
actionBarPainter
.
updateWithAccountName
(
account
);
if
(
savedInstanceState
==
null
)
{
getFragmentManager
().
beginTransaction
()
.
add
(
R
.
id
.
preferences_activity_container
,
new
ChatEditorFragment
()).
commit
();
...
...
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