Commit cacc6560 authored by Grigory Fedorov's avatar Grigory Fedorov

Contact list: account action buttons improved: shadow, ripple animation.

makovkastar/FloatingActionButton library used.
parent e87af758
......@@ -27,5 +27,6 @@ dependencies {
compile 'com.android.support:support-v13:22.0.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile project('otr4j')
}
......@@ -6,6 +6,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import com.melnykov.fab.FloatingActionButton;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.androiddev.R;
......@@ -35,6 +36,8 @@ public class AccountActionButtonsAdapter implements UpdatableAdapter {
*/
private final ArrayList<String> accounts;
private int[] accountActionBarColors;
private int[] accountStatusBarColors;
private int[] accountBackgroundColors;
public AccountActionButtonsAdapter(Activity activity,
View.OnClickListener onClickListener, LinearLayout linearLayout) {
......@@ -47,6 +50,8 @@ public class AccountActionButtonsAdapter implements UpdatableAdapter {
Resources resources = activity.getResources();
accountActionBarColors = resources.getIntArray(R.array.account_action_bar);
accountStatusBarColors = resources.getIntArray(R.array.account_status_bar);
accountBackgroundColors = resources.getIntArray(R.array.account_background);
}
/**
......@@ -57,9 +62,14 @@ public class AccountActionButtonsAdapter implements UpdatableAdapter {
public void rebuild() {
accounts.clear();
accounts.addAll(AccountManager.getInstance().getAccounts());
if (accounts.size() <= 1) {
linearLayout.removeAllViews();
return;
}
Collections.sort(accounts);
final int size = accounts.size();
final LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
......@@ -77,13 +87,20 @@ public class AccountActionButtonsAdapter implements UpdatableAdapter {
@Override
public void onChange() {
if (accounts.size() <= 1) {
return;
}
for (int index = 0; index < accounts.size(); index++) {
final CircleImageView floatingActionButton = (CircleImageView) linearLayout.getChildAt(index).findViewById(R.id.account_avatar);
final CircleImageView circleImageView = (CircleImageView) linearLayout.getChildAt(index).findViewById(R.id.account_avatar);
final String account = accounts.get(index);
int colorLevel = AccountManager.getInstance().getColorLevel(account);
circleImageView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
floatingActionButton.setBorderColor(accountActionBarColors[colorLevel]);
floatingActionButton.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
FloatingActionButton floatingActionButton = (FloatingActionButton) linearLayout.getChildAt(index).findViewById(R.id.fab);
int colorLevel = AccountManager.getInstance().getColorLevel(account);
floatingActionButton.setColorNormal(accountActionBarColors[colorLevel]);
floatingActionButton.setColorPressed(accountStatusBarColors[colorLevel]);
floatingActionButton.setColorRipple(accountBackgroundColors[colorLevel]);
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_type="mini"
fab:fab_colorNormal="@android:color/transparent"
fab:fab_colorPressed="@android:color/transparent"
android:clickable="false"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
/>
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/account_avatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_avatar_1"
app:border_width="3dp"
app:border_color="@color/green_500"
app:border_color="@android:color/transparent"
android:elevation="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
/>
</FrameLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment