Branding for selected account

This commit is contained in:
Stefan Niedermann 2020-06-04 21:57:25 +02:00
parent caf63c4a07
commit a207574e20
4 changed files with 21 additions and 5 deletions

View file

@ -3,6 +3,7 @@ package it.niedermann.owncloud.notes.accountswitcher;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.os.Bundle;
@ -63,8 +64,10 @@ public class AccountSwitcherDialog extends DialogFragment {
.apply(RequestOptions.circleCropTransform())
.into(binding.currentAccountItemAvatar);
binding.accountLayout.setOnClickListener((v) -> dismiss());
final Drawable wrapped = DrawableCompat.wrap(binding.check.getDrawable()).mutate();
DrawableCompat.setTint(wrapped, currentLocalAccount.getColor());
LayerDrawable ld = (LayerDrawable) binding.check.getDrawable();
Drawable ldDrawable = ld.findDrawableByLayerId(R.id.area);
DrawableCompat.setTint(ldDrawable, currentLocalAccount.getColor());
AccountSwitcherAdapter adapter = new AccountSwitcherAdapter((localAccount -> {
accountSwitcherListener.onAccountChosen(localAccount);
@ -72,6 +75,12 @@ public class AccountSwitcherDialog extends DialogFragment {
}), (localAccount) -> accountSwitcherListener.onAccountDeleted(localAccount));
binding.accountsList.setAdapter(adapter);
List<LocalAccount> localAccounts = db.getAccounts();
for (LocalAccount localAccount : localAccounts) {
if (localAccount.getId() == currentLocalAccount.getId()) {
localAccounts.remove(localAccount);
break;
}
}
adapter.setLocalAccounts(localAccounts);
binding.addAccount.setOnClickListener((v) -> accountSwitcherListener.addAccount());

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<item android:id="@+id/area">
<shape android:shape="oval">
<solid android:color="@android:color/holo_green_light" />
<solid android:color="@color/defaultBrand" />
<stroke
android:width="1dp"
android:color="@android:color/white" />

View file

@ -69,9 +69,15 @@
android:id="@+id/add_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacer_2x"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal"
android:padding="@dimen/spacer_3x">
android:paddingStart="@dimen/spacer_3x"
android:paddingLeft="@dimen/spacer_3x"
android:paddingTop="@dimen/spacer_1x"
android:paddingEnd="@dimen/spacer_3x"
android:paddingRight="@dimen/spacer_3x"
android:paddingBottom="@dimen/spacer_1x">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="36dp"

View file

@ -38,6 +38,7 @@
android:id="@+id/delete"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@null"
android:focusable="false"
android:scaleType="center"