2 * Copyright © 2020 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 MoLe. 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 androidx.annotation.NonNull;
26 import net.ktnx.mobileledger.R;
27 import net.ktnx.mobileledger.utils.Colors;
29 public class HueRingDialog extends Dialog {
30 private final int currentHue;
31 private final int initialHue;
32 private HueRing hueRing;
33 private HueSelectedListener listener;
35 public HueRingDialog(@NonNull Context context, int initialHue, int currentHue) {
37 this.initialHue = initialHue;
38 this.currentHue = currentHue;
41 protected void onCreate(Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState);
43 setContentView(R.layout.hue_dialog);
44 hueRing = findViewById(R.id.ring);
45 hueRing.setInitialHue(initialHue);
46 hueRing.setHue(currentHue);
48 findViewById(R.id.btn_ok).setOnClickListener(v -> {
49 if (listener != null) listener.onHueSelected(hueRing.getHueDegrees());
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);