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;
20 import android.app.Dialog;
21 import android.content.Context;
22 import android.os.Bundle;
24 import net.ktnx.mobileledger.R;
25 import net.ktnx.mobileledger.utils.Colors;
27 import androidx.annotation.NonNull;
29 public class HueRingDialog extends Dialog {
30 private int initialHue;
31 private HueRing hueRing;
32 private HueSelectedListener listener;
34 public HueRingDialog(@NonNull Context context, int initialHue) {
36 this.initialHue = initialHue;
39 protected void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState);
41 setContentView(R.layout.hue_dialog);
42 hueRing = findViewById(R.id.ring);
43 hueRing.setInitialHue(initialHue);
44 hueRing.setHue(initialHue);
46 findViewById(R.id.btn_ok).setOnClickListener(v -> {
47 if (listener != null) listener.onHueSelected(hueRing.getHueDegrees());
52 findViewById(R.id.btn_cancel).setOnClickListener(v -> dismiss());
54 findViewById(R.id.btn_default)
55 .setOnClickListener(v -> hueRing.setHue(Colors.DEFAULT_HUE_DEG));
57 public void setColorSelectedListener(HueSelectedListener listener) {
58 this.listener = listener;
60 public interface HueSelectedListener {
61 void onHueSelected(int hue);