Favs/Opts/About: adaptar al rediseño (búsqueda+cards, TimePicker+autoguardado, header con volver)
This commit is contained in:
1 parent
a7dc176318
commit
082569f8a7
3 files changed
+266
-146
No files matched your search
@@ -1,19 +1,29 @@
|
||||
package com.jkanetwork.st.calendariodefrases;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
/**
|
||||
* Created by kprkpr on 24/03/17.
|
||||
* Rediseño 2026-10: header con volver + card de créditos.
|
||||
*/
|
||||
|
||||
public class AboutOfActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
UiUtils.applySystemBarsInsets(this);
|
||||
}
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
UiUtils.applySystemBarsInsets(this, findViewById(R.id.main_root),
|
||||
ContextCompat.getColor(this, R.color.bgCard), UiUtils.isDarkTheme(this));
|
||||
|
||||
ImageButton btnBack = findViewById(R.id.btn_back);
|
||||
btnBack.setOnClickListener(v -> finish());
|
||||
}
|
||||
}
|
||||
@@ -5,69 +5,188 @@ import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by kprkpr on 21/03/17.
|
||||
* Help from: http://androidexample.com/Create_A_Simple_Listview_-_Android_Example/index.php?view=article_discription&aid=65
|
||||
* Rediseño 2026-10 (mockup SVG): header + búsqueda + cards con autor y
|
||||
* estrella. Long-press en card: copiar / compartir / borrar.
|
||||
*/
|
||||
|
||||
public class FavsActivity extends AppCompatActivity {
|
||||
|
||||
DatabaseHelper db;
|
||||
|
||||
/** Fila de una card de favorito */
|
||||
static class CardItem {
|
||||
final int idf;
|
||||
final String sentence;
|
||||
final String autor;
|
||||
|
||||
CardItem(int idf, String sentence, String autor) {
|
||||
this.idf = idf;
|
||||
this.sentence = sentence;
|
||||
this.autor = autor;
|
||||
}
|
||||
}
|
||||
|
||||
/** Adapter de cards (item_quote_card.xml): autor accent, estrella quita fav */
|
||||
class QuoteCardAdapter extends BaseAdapter {
|
||||
private List<CardItem> items = new ArrayList<>();
|
||||
|
||||
void update(List<CardItem> newItems) {
|
||||
items = newItems;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View v = convertView != null ? convertView
|
||||
: getLayoutInflater().inflate(R.layout.item_quote_card, parent, false);
|
||||
CardItem item = items.get(position);
|
||||
TextView autor = v.findViewById(R.id.card_autor);
|
||||
TextView sentence = v.findViewById(R.id.card_sentence);
|
||||
ImageView star = v.findViewById(R.id.card_star);
|
||||
autor.setText(item.autor);
|
||||
sentence.setText(item.sentence);
|
||||
star.setOnClickListener(x -> onUnfav(item));
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
private final QuoteCardAdapter adapter = new QuoteCardAdapter();
|
||||
private final List<CardItem> allItems = new ArrayList<>();
|
||||
/* IDs de la vista FILTRADA, en el mismo orden que el adapter: si el
|
||||
adapter se reordena tras filtrar, el long-press debe actuar sobre la
|
||||
frase visible (esta lista), no sobre la BD en crudo */
|
||||
private final List<Integer> listIDFrases = new ArrayList<>();
|
||||
private String query = "";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_favs);
|
||||
UiUtils.applySystemBarsInsets(this);
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
UiUtils.applySystemBarsInsets(this, findViewById(R.id.main_root),
|
||||
ContextCompat.getColor(this, R.color.bgCard), UiUtils.isDarkTheme(this));
|
||||
UiUtils.setupBottomNav(this, UiUtils.NavTab.FAVORITOS);
|
||||
UiUtils.loadBannerAd(this, (android.widget.FrameLayout) findViewById(R.id.adContainer));
|
||||
|
||||
db = new DatabaseHelper(this);
|
||||
|
||||
final ListView listFavs = (ListView) findViewById(R.id.listSentences);
|
||||
ListView list = findViewById(R.id.view_list);
|
||||
list.setAdapter(adapter);
|
||||
list.setEmptyView(findViewById(R.id.empty_list));
|
||||
registerForContextMenu(list);
|
||||
|
||||
// Defined Array values to show in ListView
|
||||
/* Búsqueda: refiltra al teclear */
|
||||
EditText search = findViewById(R.id.search_input);
|
||||
search.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
query = s.toString().trim();
|
||||
applyFilters();
|
||||
}
|
||||
|
||||
//Get IDs of sentences that are favs, and create an array of same length
|
||||
final Integer[] IDFavs = db.getIDFavs();
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int a, int b, int c) {
|
||||
}
|
||||
|
||||
final String[] sentences = new String[IDFavs.length];
|
||||
final String[] authorNames = new String[IDFavs.length];
|
||||
//Follow all IDFavs recovering sentence
|
||||
if (IDFavs.length != 0) {
|
||||
for (int x = 0; x <= IDFavs.length - 1; x++) {
|
||||
sentences[x] = db.getFraseFromID(IDFavs[x]);
|
||||
authorNames[x] = db.getAutorFromID(IDFavs[x]);
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int a, int b, int c) {
|
||||
}
|
||||
});
|
||||
|
||||
/* Restaurar búsqueda tras recrear la activity (giro, etc.) */
|
||||
if (savedInstanceState != null) {
|
||||
query = savedInstanceState.getString("query", "");
|
||||
if (!query.isEmpty()) {
|
||||
search.setText(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IDFavs.length != 0) {
|
||||
ArrayList<HashMap<String, String>> items = new ArrayList<>();
|
||||
HashMap<String, String> listItem;
|
||||
for (int x = 0; x <= IDFavs.length - 1; x++) {
|
||||
listItem = new HashMap<>();
|
||||
listItem.put("item", sentences[x]);
|
||||
listItem.put("subitem", authorNames[x]);
|
||||
items.add(listItem);
|
||||
}
|
||||
SimpleAdapter adapter = new SimpleAdapter(this, items, android.R.layout.simple_list_item_2, new String[]{"item", "subitem"}, new int[]{android.R.id.text1, android.R.id.text2});
|
||||
listFavs.setAdapter(adapter);
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString("query", query);
|
||||
}
|
||||
|
||||
/* Register context menu */
|
||||
registerForContextMenu(listFavs);
|
||||
/** Carga todos los favoritos y refresca la lista */
|
||||
private void loadAll() {
|
||||
allItems.clear();
|
||||
Integer[] ids = db.getIDFavs();
|
||||
for (Integer id : ids) {
|
||||
allItems.add(new CardItem(id, db.getFraseFromID(id), db.getAutorFromID(id)));
|
||||
}
|
||||
applyFilters();
|
||||
}
|
||||
|
||||
/** Aplica la búsqueda sobre allItems */
|
||||
private void applyFilters() {
|
||||
List<CardItem> filtered = new ArrayList<>();
|
||||
String q = query.toLowerCase(Locale.getDefault());
|
||||
for (CardItem item : allItems) {
|
||||
if (q.isEmpty()
|
||||
|| item.sentence.toLowerCase(Locale.getDefault()).contains(q)
|
||||
|| item.autor.toLowerCase(Locale.getDefault()).contains(q)) {
|
||||
filtered.add(item);
|
||||
}
|
||||
}
|
||||
listIDFrases.clear();
|
||||
for (CardItem item : filtered) {
|
||||
listIDFrases.add(item.idf);
|
||||
}
|
||||
adapter.update(filtered);
|
||||
}
|
||||
|
||||
/** Quitar de favoritos (estrella) y recargar */
|
||||
private void onUnfav(CardItem item) {
|
||||
db.delFav(item.idf);
|
||||
loadAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
loadAll(); /* los favoritos pueden cambiar desde la main */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
@@ -79,30 +198,31 @@ public class FavsActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
|
||||
ListView listFavs = (ListView) findViewById(R.id.listSentences);
|
||||
AdapterView.AdapterContextMenuInfo info =
|
||||
(AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
@SuppressWarnings("unchecked") /* Because next line has a type change without checking it */
|
||||
HashMap<String, String> obj = (HashMap<String,String>) listFavs.getItemAtPosition(info.position);
|
||||
android.widget.AdapterView.AdapterContextMenuInfo info =
|
||||
(android.widget.AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
int position = info.position;
|
||||
if (position < 0 || position >= listIDFrases.size()) {
|
||||
return false;
|
||||
}
|
||||
int idf = listIDFrases.get(position);
|
||||
String sentence = db.getFraseFromID(idf);
|
||||
String autor = db.getAutorFromID(idf);
|
||||
String shared = sentence + " (" + autor + ")\n" + getString(R.string.sharefrom);
|
||||
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.copy) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText("Sentence", obj.get("item")+this.getString(R.string.sharefrom)));
|
||||
Toast.makeText(getApplicationContext(), R.string.copied, Toast.LENGTH_LONG ).show();
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText("Sentence", shared));
|
||||
Toast.makeText(getApplicationContext(), R.string.copied, Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
} else if (id == R.id.delfav) {
|
||||
Integer[] IDFavs = db.getIDFavs();
|
||||
db.delFav(IDFavs[info.position]);
|
||||
/* Restart activity for refresh favs */
|
||||
finish();
|
||||
startActivity(getIntent());
|
||||
db.delFav(idf);
|
||||
loadAll();
|
||||
return true;
|
||||
} else if (id == R.id.share) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_TEXT,obj.get("item")+this.getString(R.string.sharefrom));
|
||||
intent.putExtra(Intent.EXTRA_TEXT, shared);
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.share_with)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,109 +1,97 @@
|
||||
package com.jkanetwork.st.calendariodefrases;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Spinner;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.String.valueOf;
|
||||
|
||||
|
||||
/**
|
||||
* Created by kprkpr on 21/03/17.
|
||||
* Rediseño 2026-10 (mockup SVG): cards de ajustes con título+descripción.
|
||||
* La hora se elige con TimePicker (antes dos spinners); card Acerca de;
|
||||
* banner + barra de navegación inferior. Guardado automático: cada cambio
|
||||
* se aplica al momento, no hay botón Guardar.
|
||||
*/
|
||||
|
||||
public class OptsActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
Config conf;
|
||||
CheckBox chkAlarm;
|
||||
CheckBox chkPersistent;
|
||||
TextView txtHora;
|
||||
View cardHora;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_opts);
|
||||
UiUtils.applySystemBarsInsets(this);
|
||||
final Config conf = new Config(this);
|
||||
/* Do variables of objects */
|
||||
final Spinner spinnerHour = (Spinner) findViewById(R.id.spinnerHour);
|
||||
final Spinner spinnerMinute = (Spinner) findViewById(R.id.spinnerMinute);
|
||||
final CheckBox chkalarm = (CheckBox) findViewById(R.id.chk_alarm);
|
||||
final CheckBox chkpersistent = (CheckBox) findViewById(R.id.chk_persistent);
|
||||
/* Set texts and checks from configs */
|
||||
chkalarm.setChecked(conf.getNotifOn());
|
||||
chkpersistent.setChecked(conf.getPersistNotifOn());
|
||||
|
||||
// Hour and minute elements create
|
||||
|
||||
// Spinner Drop down elements
|
||||
List<Integer> Hours = new ArrayList<>();
|
||||
for (int x = 0; x <= 23; x++) {
|
||||
Hours.add(x);
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
List<Integer> Minutes = new ArrayList<>();
|
||||
for (int x = 0; x <= 59; x++) {
|
||||
Minutes.add(x);
|
||||
}
|
||||
// Creating adapter for spinner
|
||||
ArrayAdapter<Integer> hourAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Hours);
|
||||
ArrayAdapter<Integer> minuteAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Minutes);
|
||||
// Drop down layout style - list view with radio button
|
||||
hourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
minuteAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
// attaching data adapter to spinner
|
||||
spinnerHour.setAdapter(hourAdapter);
|
||||
spinnerMinute.setAdapter(minuteAdapter);
|
||||
UiUtils.applySystemBarsInsets(this, findViewById(R.id.main_root),
|
||||
ContextCompat.getColor(this, R.color.bgCard), UiUtils.isDarkTheme(this));
|
||||
UiUtils.setupBottomNav(this, UiUtils.NavTab.OPCIONES);
|
||||
UiUtils.loadBannerAd(this, (android.widget.FrameLayout) findViewById(R.id.adContainer));
|
||||
|
||||
spinnerHour.setSelection(conf.getHour());
|
||||
spinnerMinute.setSelection(conf.getMinute());
|
||||
conf = new Config(this);
|
||||
chkAlarm = findViewById(R.id.chk_alarm);
|
||||
chkPersistent = findViewById(R.id.chk_persistent);
|
||||
txtHora = findViewById(R.id.txt_hora);
|
||||
cardHora = findViewById(R.id.card_hora);
|
||||
|
||||
chkAlarm.setChecked(conf.getNotifOn());
|
||||
chkPersistent.setChecked(conf.getPersistNotifOn());
|
||||
|
||||
setEnabledParts();
|
||||
updateHoraTxt();
|
||||
|
||||
/* Disable options if notification is disabled */
|
||||
chkalarm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
/* Guardado automático en cada interacción */
|
||||
chkAlarm.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
setEnabledParts();
|
||||
}
|
||||
saveAndApply();
|
||||
});
|
||||
/* For not set date if persistent is enabled */
|
||||
chkpersistent.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
chkPersistent.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
setEnabledParts();
|
||||
}
|
||||
saveAndApply();
|
||||
});
|
||||
|
||||
/* Hora: TimePicker sobre la card */
|
||||
cardHora.setOnClickListener(v -> new TimePickerDialog(this, (view, hour, minute) -> {
|
||||
conf.setHour(hour);
|
||||
conf.setMinute(minute);
|
||||
updateHoraTxt();
|
||||
saveAndApply();
|
||||
}, conf.getHour(), conf.getMinute(), true).show());
|
||||
|
||||
Button btnsave = (Button) findViewById(R.id.btnSaveNotif);
|
||||
btnsave.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Integer hourSave, minuteSave;
|
||||
/* Acerca de desde Opciones */
|
||||
findViewById(R.id.card_about).setOnClickListener(
|
||||
v -> startActivity(new Intent(this, AboutOfActivity.class)));
|
||||
}
|
||||
|
||||
hourSave = Integer.decode(String.valueOf(spinnerHour.getSelectedItemPosition()));
|
||||
/** Hora guardada en la card, en gris */
|
||||
private void updateHoraTxt() {
|
||||
txtHora.setText(String.format("%d:%02d", conf.getHour(), conf.getMinute()));
|
||||
}
|
||||
|
||||
minuteSave = Integer.decode(String.valueOf(spinnerMinute.getSelectedItemPosition()));
|
||||
/** Guarda prefs y reprograma el trabajo. Se llama tras cada cambio. */
|
||||
private void saveAndApply() {
|
||||
conf.setNotifOn(chkAlarm.isChecked());
|
||||
conf.setPersistNotifOn(chkPersistent.isChecked());
|
||||
|
||||
conf.setHour(hourSave);
|
||||
conf.setMinute(minuteSave);
|
||||
//Log.d("EnabledNotif", String.valueOf(chkalarm.isChecked()));
|
||||
/* Enable or disable notification and persistent */
|
||||
conf.setNotifOn(chkalarm.isChecked());
|
||||
conf.setPersistNotifOn(chkpersistent.isChecked());
|
||||
|
||||
if (chkalarm.isChecked() && !notificationsEnabled()) {
|
||||
if (chkAlarm.isChecked() && !notificationsEnabled()) {
|
||||
/* Android 13+: pedir permiso para poder mostrar la notificación */
|
||||
ActivityCompat.requestPermissions(OptsActivity.this,
|
||||
new String[]{Manifest.permission.POST_NOTIFICATIONS}, 1);
|
||||
@@ -111,14 +99,26 @@ public class OptsActivity extends AppCompatActivity {
|
||||
|
||||
/* Cancel notif when save changes first */
|
||||
Notif.cancel(OptsActivity.this);
|
||||
|
||||
NotifScheduler.schedule(OptsActivity.this);
|
||||
if (chkpersistent.isChecked() && chkalarm.isChecked()) {
|
||||
if (chkPersistent.isChecked() && chkAlarm.isChecked()) {
|
||||
Notif.show(OptsActivity.this, conf); /* Auto show notif for persistent mode */
|
||||
}
|
||||
}
|
||||
});
|
||||
Toast.makeText(this, R.string.guardado, Toast.LENGTH_SHORT).show();
|
||||
|
||||
/* Si la notificación queda activa sin permiso (Android 13+), el
|
||||
diálogo del sistema ya no se mostrará tras 2 denegaciones */
|
||||
if (chkAlarm.isChecked() && Build.VERSION.SDK_INT >= 33
|
||||
&& ContextCompat.checkSelfPermission(OptsActivity.this,
|
||||
Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.opts_notif_title)
|
||||
.setMessage(R.string.opts_notif_perm_msg)
|
||||
.setPositiveButton(R.string.opts_notif_perm_ok, (d, w) ->
|
||||
startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
||||
.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName())))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean notificationsEnabled() {
|
||||
@@ -128,27 +128,17 @@ public class OptsActivity extends AppCompatActivity {
|
||||
return ContextCompat.checkSelfPermission(OptsActivity.this,
|
||||
Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
public void setEnabledParts(){
|
||||
/* I have to set vars again because is out of onCreate */
|
||||
Spinner notifHour = findViewById(R.id.spinnerHour);
|
||||
Spinner notifMinute = findViewById(R.id.spinnerMinute);
|
||||
CheckBox chkalarm = findViewById(R.id.chk_alarm);
|
||||
CheckBox chkpersistent = findViewById(R.id.chk_persistent);
|
||||
if (chkalarm.isChecked()){
|
||||
chkpersistent.setEnabled(true);
|
||||
/* This other checks is chkpersistent checked dependent */
|
||||
if (chkpersistent.isChecked()){
|
||||
notifHour.setEnabled(false);
|
||||
notifMinute.setEnabled(false);
|
||||
}else{
|
||||
notifHour.setEnabled(true);
|
||||
notifMinute.setEnabled(true);
|
||||
}
|
||||
}else{
|
||||
chkpersistent.setEnabled(false);
|
||||
notifHour.setEnabled(false);
|
||||
notifMinute.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabledParts() {
|
||||
if (chkAlarm.isChecked()) {
|
||||
chkPersistent.setEnabled(true);
|
||||
/* La hora no aplica con notificación persistente */
|
||||
cardHora.setEnabled(!chkPersistent.isChecked());
|
||||
cardHora.setAlpha(chkPersistent.isChecked() ? 0.5f : 1f);
|
||||
} else {
|
||||
chkPersistent.setEnabled(false);
|
||||
cardHora.setEnabled(false);
|
||||
cardHora.setAlpha(0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user