mirror of https://github.com/M66B/FairEmail.git
Suggest account categories
This commit is contained in:
parent
424eb1cd19
commit
c67007d13c
|
@ -161,6 +161,12 @@ public interface DaoAccount {
|
|||
" AND tbd IS NULL")
|
||||
List<EntityAccount> getAccounts(String user, int protocol);
|
||||
|
||||
@Query("SELECT DISTINCT category" +
|
||||
" FROM account" +
|
||||
" WHERE NOT (category IS NULL OR category = '')" +
|
||||
" ORDER BY category COLLATE NOCASE")
|
||||
List<String> getAccountCategories();
|
||||
|
||||
@Query("SELECT * FROM account WHERE `primary`")
|
||||
EntityAccount getPrimaryAccount();
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
|
@ -110,7 +111,8 @@ public class FragmentAccount extends FragmentBase {
|
|||
private EditText etRealm;
|
||||
|
||||
private EditText etName;
|
||||
private EditText etCategory;
|
||||
private ArrayAdapter<String> adapterCategory;
|
||||
private AutoCompleteTextView etCategory;
|
||||
private ViewButtonColor btnColor;
|
||||
private TextView tvColorPro;
|
||||
|
||||
|
@ -434,6 +436,10 @@ public class FragmentAccount extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
adapterCategory = new ArrayAdapter<>(getContext(), R.layout.spinner_item1_dropdown, android.R.id.text1);
|
||||
etCategory.setThreshold(1);
|
||||
etCategory.setAdapter(adapterCategory);
|
||||
|
||||
btnColor.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -1597,6 +1603,11 @@ public class FragmentAccount extends FragmentBase {
|
|||
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
List<String> categories = db.account().getAccountCategories();
|
||||
if (categories == null)
|
||||
categories = new ArrayList<>();
|
||||
args.putStringArrayList("categories", new ArrayList<>(categories));
|
||||
|
||||
List<EntityIdentity> identities = db.identity().getIdentities(id);
|
||||
if (identities != null && identities.size() == 1)
|
||||
args.putString("personal", identities.get(0).name);
|
||||
|
@ -1617,6 +1628,9 @@ public class FragmentAccount extends FragmentBase {
|
|||
aaProvider.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
||||
spProvider.setAdapter(aaProvider);
|
||||
|
||||
adapterCategory.clear();
|
||||
adapterCategory.addAll(args.getStringArrayList("categories"));
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
JSONObject jcondition = new JSONObject();
|
||||
try {
|
||||
|
|
|
@ -41,6 +41,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
|
@ -81,7 +82,8 @@ public class FragmentPop extends FragmentBase {
|
|||
private TextView tvPasswordStorage;
|
||||
|
||||
private EditText etName;
|
||||
private EditText etCategory;
|
||||
private ArrayAdapter<String> adapterCategory;
|
||||
private AutoCompleteTextView etCategory;
|
||||
private ViewButtonColor btnColor;
|
||||
private TextView tvColorPro;
|
||||
|
||||
|
@ -247,6 +249,10 @@ public class FragmentPop extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
adapterCategory = new ArrayAdapter<>(getContext(), R.layout.spinner_item1_dropdown, android.R.id.text1);
|
||||
etCategory.setThreshold(1);
|
||||
etCategory.setAdapter(adapterCategory);
|
||||
|
||||
btnColor.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -787,11 +793,20 @@ public class FragmentPop extends FragmentBase {
|
|||
long id = args.getLong("id");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
List<String> categories = db.account().getAccountCategories();
|
||||
if (categories == null)
|
||||
categories = new ArrayList<>();
|
||||
args.putStringArrayList("categories", new ArrayList<>(categories));
|
||||
|
||||
return db.account().getAccount(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, final EntityAccount account) {
|
||||
adapterCategory.clear();
|
||||
adapterCategory.addAll(args.getStringArrayList("categories"));
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
JSONObject jcondition = new JSONObject();
|
||||
try {
|
||||
|
|
|
@ -404,7 +404,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etName" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
<eu.faircode.email.EditTextAutoComplete
|
||||
android:id="@+id/etCategory"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -276,7 +276,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etName" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
<eu.faircode.email.EditTextAutoComplete
|
||||
android:id="@+id/etCategory"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
Loading…
Reference in New Issue