bug fix, added error handling for filter dialog

This commit is contained in:
nuclearfog 2023-06-25 20:51:01 +02:00
parent 842fd13b01
commit df6761ae45
No known key found for this signature in database
GPG Key ID: 03488A185C476379
8 changed files with 28 additions and 22 deletions

View File

@ -15,9 +15,4 @@ public class Filters extends LinkedList<Filter> {
public Filters() {
super();
}
public Filters(Filters filters) {
super(filters);
}
}

View File

@ -89,10 +89,17 @@ public class FilterDialog extends Dialog implements OnClickListener, OnCheckedCh
@Override
public void onClick(View v) {
if (v.getId() == R.id.dialog_filter_create) {
update.setTitle(txt_title.getText().toString());
update.setKeywords(txt_keywords.getText().toString().split("\n"));
FilterActionParam param = new FilterActionParam(FilterActionParam.UPDATE, 0L, update);
filterAction.execute(param, this);
if (txt_title.length() == 0) {
Toast.makeText(getContext(), R.string.error_empty_filter_title, Toast.LENGTH_SHORT).show();
} else if (!sw_home.isChecked() && !sw_notification.isChecked() && !sw_public.isChecked() && !sw_user.isChecked() && !sw_thread.isChecked()) {
Toast.makeText(getContext(), R.string.error_empty_filter_selection, Toast.LENGTH_SHORT).show();
} else {
if (txt_keywords.length() > 0)
update.setKeywords(txt_keywords.getText().toString().split("\n"));
update.setTitle(txt_title.getText().toString());
FilterActionParam param = new FilterActionParam(FilterActionParam.UPDATE, 0L, update);
filterAction.execute(param, this);
}
}
}
@ -165,7 +172,7 @@ public class FilterDialog extends Dialog implements OnClickListener, OnCheckedCh
update = new FilterUpdate();
sw_home.setCheckedImmediately(false);
sw_notification.setCheckedImmediately(false);
sw_public.setCheckedImmediately(false);
sw_public.setCheckedImmediately(true);
sw_user.setCheckedImmediately(false);
sw_thread.setCheckedImmediately(false);
txt_title.setText("");

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dialog_filter_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dialog_filter_root_padding"
xmlns:app="http://schemas.android.com/apk/res-auto">
tools:context=".ui.dialogs.FilterDialog">
<TextView
android:id="@+id/dialog_filter_title_dialog"
@ -59,7 +61,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/dialog_filter_home"
android:lines="1"
android:maxLines="2"
android:textSize="@dimen/dialog_filter_textsize_label"
android:layout_margin="@dimen/dialog_filter_margin_items_layout"
app:layout_constraintHorizontal_weight="1"
@ -82,7 +84,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/dialog_filter_notification"
android:lines="1"
android:maxLines="2"
android:textSize="@dimen/dialog_filter_textsize_label"
android:layout_margin="@dimen/dialog_filter_margin_items_layout"
app:layout_constraintHorizontal_weight="1"
@ -105,7 +107,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/dialog_filter_public"
android:lines="1"
android:maxLines="2"
android:textSize="@dimen/dialog_filter_textsize_label"
android:layout_margin="@dimen/dialog_filter_margin_items_layout"
app:layout_constraintHorizontal_weight="1"
@ -128,7 +130,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/dialog_filter_user"
android:lines="1"
android:maxLines="2"
android:textSize="@dimen/dialog_filter_textsize_label"
android:layout_margin="@dimen/dialog_filter_margin_items_layout"
app:layout_constraintHorizontal_weight="1"
@ -151,7 +153,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/dialog_filter_threads"
android:lines="1"
android:maxLines="2"
android:textSize="@dimen/dialog_filter_textsize_label"
android:layout_margin="@dimen/dialog_filter_margin_items_layout"
app:layout_constraintHorizontal_weight="1"

View File

@ -335,7 +335,7 @@
<string name="dialog_status_language">Sprache</string>
<string name="filter_hide">verstecke Posts die diese Wörter enthalten</string>
<string name="filter_warn">warne vor Posts die diese Wörter enthalten</string>
<string name="dialog_filter_edit_hint_exclude">Wort_1 Wort_2\n\"wzusammenhängendes Wort\"</string>
<string name="dialog_filter_edit_hint_exclude">Wort-1 Wort-2\n\"zusammenhängendes Wort\"</string>
<string name="description_filter_home_timeline">Filter für Home-Timeline aktiviert</string>
<string name="description_filter_notification">Filter für Benachrichtigungen aktiviert</string>
<string name="description_filter_public_timeline">Filter für öffentliche Timeline aktiviert</string>
@ -351,6 +351,7 @@
<string name="dialog_filter_public">öffentliche Timeline</string>
<string name="dialog_filter_user">Nutzer-Timeline</string>
<string name="dialog_filter_threads">Threads</string>
<string name="dialog_filter_whole_words">ganze Wörter filtern</string>
<string name="dialog_filter_title_keywords">Zu filterne Wörter</string>
<string name="error_empty_filter_title">Filterbezeichnung darf nicht leer sein</string>
<string name="error_empty_filter_selection">es muss mindestens ein Filter aktiviert sein</string>
</resources>

View File

@ -33,7 +33,7 @@
<string name="info_dm_removed">Se eliminó el mensaje directo</string>
<string name="info_image_saved">Se guardó la imagen</string>
<string name="info_status_link_copied">Se copió el enlace al portapapeles</string>
<string name="info_loading">Cargando...</string>
<string name="info_loading">Cargando</string>
<string name="info_profile_updated">Se actualizó el perfil actualizado</string>
<string name="info_followed">Siguiendo</string>
<string name="info_unfollowed">Sin seguir</string>

View File

@ -344,7 +344,7 @@
<dimen name="dialog_filter_root_padding">2dp</dimen>
<dimen name="dialog_filter_textsize_title">22sp</dimen>
<dimen name="dialog_filter_textsize_title_sub">16sp</dimen>
<dimen name="dialog_filter_textsize_label">12sp</dimen>
<dimen name="dialog_filter_textsize_label">11sp</dimen>
<dimen name="dialog_filter_margin_items_layout">4dp</dimen>
</resources>

View File

@ -132,6 +132,8 @@
<string name="error_adding_media">Error occurred while adding media!</string>
<string name="error_media_init">Error while preparing media files for upload!</string>
<string name="error_translating_status">Could not translate status</string>
<string name="error_empty_filter_title">Filter description must not be empty</string>
<string name="error_empty_filter_selection">It must be at least one filter enabled</string>
<string name="error_empty_text">Empty text!</string>
<!-- menu icon strings -->
@ -370,7 +372,6 @@
<string name="dialog_filter_public">Public timeline</string>
<string name="dialog_filter_user">User timeline</string>
<string name="dialog_filter_threads">Threads</string>
<string name="dialog_filter_whole_words">filter whole words</string>
<string name="dialog_filter_title_keywords">Words to exclude</string>
<string name="dialog_filter_edit_hint_exclude">word anotherword\n\"whole word\"</string>
</resources>

View File

@ -70,7 +70,7 @@
</style>
<style name="FilterDialog" parent="Theme.AppCompat.Dialog">
<item name="android:windowMinWidthMinor">80%</item>
<item name="android:windowMinWidthMinor">90%</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>