2 * Copyright © 2019 Damyan Ivanov.
3 * This file is part of MoLe.
4 * MoLe is free software: you can distribute it and/or modify it
5 * under the term of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your opinion), any later version.
9 * MoLe is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License terms for details.
14 * You should have received a copy of the GNU General Public License
15 * along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
18 package net.ktnx.mobileledger.ui.profiles;
20 import android.content.Context;
21 import android.util.AttributeSet;
23 import net.ktnx.mobileledger.utils.Colors;
25 import androidx.appcompat.widget.AppCompatTextView;
27 public class MoLeColoredTextView extends AppCompatTextView {
28 public MoLeColoredTextView(Context context) {
31 public MoLeColoredTextView(Context context, AttributeSet attrs) {
32 super(context, attrs);
34 public MoLeColoredTextView(Context context, AttributeSet attrs, int defStyleAttr) {
35 super(context, attrs, defStyleAttr);
38 public void setText(CharSequence text, BufferType type) {
39 super.setText(text, type);
40 int deg = (text == null || text.equals("")) ? -1 : Integer.valueOf(String.valueOf(text));
41 if (deg == -1) deg = Colors.DEFAULT_HUE_DEG;
42 setBackgroundColor(Colors.getPrimaryColorForHue(deg));