]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/ui/profiles/MoLeColoredTextView.java
update copyright notices
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / MoLeColoredTextView.java
1 /*
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
16  */
17
18 package net.ktnx.mobileledger.ui.profiles;
19
20 import android.content.Context;
21 import android.util.AttributeSet;
22
23 import net.ktnx.mobileledger.utils.Colors;
24
25 import androidx.appcompat.widget.AppCompatTextView;
26
27 public class MoLeColoredTextView extends AppCompatTextView {
28     public MoLeColoredTextView(Context context) {
29         super(context);
30     }
31     public MoLeColoredTextView(Context context, AttributeSet attrs) {
32         super(context, attrs);
33     }
34     public MoLeColoredTextView(Context context, AttributeSet attrs, int defStyleAttr) {
35         super(context, attrs, defStyleAttr);
36     }
37     @Override
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));
43     }
44 }