Added suggestions for answers

pull/212/head
M66B 2 years ago
parent 06573cd57f
commit f5ebd8e052

@ -74,6 +74,11 @@ public interface DaoAnswer {
" AND (:favorite OR NOT favorite)")
Integer getAnswerCount(boolean favorite);
@Query("SELECT DISTINCT `group` FROM answer" +
" WHERE NOT `group` IS NULL" +
" ORDER by `group` COLLATE NOCASE")
List<String> getGroups();
@Insert
long insertAnswer(EntityAnswer answer);

@ -42,6 +42,8 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.HorizontalScrollView;
@ -58,13 +60,14 @@ import com.google.android.material.snackbar.Snackbar;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.util.ArrayList;
import java.util.List;
public class FragmentAnswer extends FragmentBase {
private ViewGroup view;
private EditText etName;
private EditText etLabel;
private EditText etGroup;
private AutoCompleteTextView etGroup;
private CheckBox cbStandard;
private CheckBox cbReceipt;
private CheckBox cbFavorite;
@ -78,6 +81,8 @@ public class FragmentAnswer extends FragmentBase {
private ContentLoadingProgressBar pbWait;
private Group grpReady;
private ArrayAdapter<String> adapterGroup;
private long id = -1;
private long copy = -1;
@ -133,6 +138,10 @@ public class FragmentAnswer extends FragmentBase {
pbWait = view.findViewById(R.id.pbWait);
grpReady = view.findViewById(R.id.grpReady);
adapterGroup = new ArrayAdapter<>(getContext(), R.layout.spinner_item1_dropdown, android.R.id.text1);
etGroup.setThreshold(1);
etGroup.setAdapter(adapterGroup);
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -248,6 +257,8 @@ public class FragmentAnswer extends FragmentBase {
args.putCharSequence("spanned", spanned);
}
args.putStringArrayList("groups", new ArrayList<>(db.answer().getGroups()));
return answer;
}
@ -274,6 +285,9 @@ public class FragmentAnswer extends FragmentBase {
etText.setText((Spanned) args.getCharSequence("spanned"));
}
adapterGroup.clear();
adapterGroup.addAll(args.getStringArrayList("groups"));
if (answer == null)
bottom_navigation.getMenu().removeItem(R.id.action_delete);

@ -52,7 +52,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etName" />
<eu.faircode.email.EditTextPlain
<eu.faircode.email.EditTextAutoComplete
android:id="@+id/etGroup"
android:layout_width="0dp"
android:layout_height="wrap_content"

Loading…
Cancel
Save