Added saved search order

pull/209/head
M66B 3 years ago
parent df6b115aa2
commit 17f401340d

@ -6,6 +6,7 @@
### Next version ### Next version
* Added saved search order
* Added editing saved search name and color * Added editing saved search name and color
* Small improvements and minor bug fixes * Small improvements and minor bug fixes
* Updated libraries * Updated libraries

File diff suppressed because it is too large Load Diff

@ -6,6 +6,7 @@
### Next version ### Next version
* Added saved search order
* Added editing saved search name and color * Added editing saved search name and color
* Small improvements and minor bug fixes * Small improvements and minor bug fixes
* Updated libraries * Updated libraries

@ -113,6 +113,7 @@ public class AdapterNavSearch extends RecyclerView.Adapter<AdapterNavSearch.View
BoundaryCallbackMessages.SearchCriteria.fromJSON(json); BoundaryCallbackMessages.SearchCriteria.fromJSON(json);
criteria.id = search.id; criteria.id = search.id;
criteria.name = search.name; criteria.name = search.name;
criteria.order = search.order;
criteria.color = search.color; criteria.color = search.color;
FragmentMessages.search( FragmentMessages.search(
context, owner, manager, context, owner, manager,

@ -861,13 +861,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
} }
} }
static class SearchCriteria implements Serializable { static class SearchCriteria extends EntitySearch implements Serializable {
// Search record
long id = -1;
String name;
int color = Color.TRANSPARENT;
// Search query
String query; String query;
boolean fts = false; boolean fts = false;
boolean in_senders = true; boolean in_senders = true;

@ -71,7 +71,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 239, version = 240,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -2404,6 +2404,12 @@ public abstract class DB extends RoomDatabase {
Log.e(ex); Log.e(ex);
} }
} }
}).addMigrations(new Migration(239, 240) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `search` ADD COLUMN `order` INTEGER");
}
}).addMigrations(new Migration(998, 999) { }).addMigrations(new Migration(998, 999) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase db) { public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -30,7 +30,7 @@ import java.util.List;
@Dao @Dao
public interface DaoSearch { public interface DaoSearch {
@Query("SELECT * FROM search" + @Query("SELECT * FROM search" +
" ORDER BY name COLLATE NOCASE") " ORDER BY `order`, name COLLATE NOCASE")
LiveData<List<EntitySearch>> liveSearch(); LiveData<List<EntitySearch>> liveSearch();
@Insert @Insert

@ -39,6 +39,7 @@ public class EntitySearch {
public Long id; public Long id;
@NonNull @NonNull
public String name; public String name;
public Integer order;
public Integer color; public Integer color;
@NonNull @NonNull
public String data; public String data;
@ -49,6 +50,7 @@ public class EntitySearch {
EntitySearch other = (EntitySearch) obj; EntitySearch other = (EntitySearch) obj;
return (this.id.equals(other.id) && return (this.id.equals(other.id) &&
this.name.equals(other.name) && this.name.equals(other.name) &&
Objects.equals(this.order, other.order) &&
Objects.equals(this.color, other.color) && Objects.equals(this.color, other.color) &&
this.data.equals(other.data)); this.data.equals(other.data));
} else } else

@ -5094,10 +5094,10 @@ public class FragmentMessages extends FragmentBase
menu.findItem(R.id.menu_save_search).setVisible( menu.findItem(R.id.menu_save_search).setVisible(
viewType == AdapterMessage.ViewType.SEARCH && viewType == AdapterMessage.ViewType.SEARCH &&
criteria != null && criteria.id < 0); criteria != null && criteria.id == null);
menu.findItem(R.id.menu_edit_search).setVisible( menu.findItem(R.id.menu_edit_search).setVisible(
viewType == AdapterMessage.ViewType.SEARCH && viewType == AdapterMessage.ViewType.SEARCH &&
criteria != null && criteria.id >= 0); criteria != null && criteria.id != null);
menu.findItem(R.id.menu_folders).setVisible( menu.findItem(R.id.menu_folders).setVisible(
viewType == AdapterMessage.ViewType.UNIFIED && viewType == AdapterMessage.ViewType.UNIFIED &&
@ -5769,7 +5769,10 @@ public class FragmentMessages extends FragmentBase
if (search == null) if (search == null)
search = new EntitySearch(); search = new EntitySearch();
int order = args.getInt("order");
search.name = args.getString("name"); search.name = args.getString("name");
search.order = (order < 0 ? null : order);
search.color = args.getInt("color", Color.TRANSPARENT); search.color = args.getInt("color", Color.TRANSPARENT);
search.data = criteria.toJson().toString(); search.data = criteria.toJson().toString();
@ -10497,6 +10500,7 @@ public class FragmentMessages extends FragmentBase
final Context context = getContext(); final Context context = getContext();
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_save_search, null); View dview = LayoutInflater.from(context).inflate(R.layout.dialog_save_search, null);
EditText etName = dview.findViewById(R.id.etName); EditText etName = dview.findViewById(R.id.etName);
EditText etOrder = dview.findViewById(R.id.etOrder);
btnColor = dview.findViewById(R.id.btnColor); btnColor = dview.findViewById(R.id.btnColor);
btnColor.setOnClickListener(new View.OnClickListener() { btnColor.setOnClickListener(new View.OnClickListener() {
@ -10517,14 +10521,19 @@ public class FragmentMessages extends FragmentBase
}); });
etName.setText(criteria.name == null ? criteria.getTitle(context) : criteria.name); etName.setText(criteria.name == null ? criteria.getTitle(context) : criteria.name);
etOrder.setText(criteria.order == null ? null : Integer.toString(criteria.order));
btnColor.setColor(criteria.color); btnColor.setColor(criteria.color);
return new AlertDialog.Builder(context) AlertDialog.Builder dialog = new AlertDialog.Builder(context)
.setView(dview) .setView(dview)
.setPositiveButton(R.string.title_save, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.title_save, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String order = etOrder.getText().toString();
args.putString("name", etName.getText().toString()); args.putString("name", etName.getText().toString());
args.putInt("order",
!TextUtils.isEmpty(order) && TextUtils.isDigitsOnly(order)
? Integer.parseInt(order) : -1);
args.putInt("color", btnColor.getColor()); args.putInt("color", btnColor.getColor());
sendResult(Activity.RESULT_OK); sendResult(Activity.RESULT_OK);
} }
@ -10534,14 +10543,17 @@ public class FragmentMessages extends FragmentBase
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
sendResult(Activity.RESULT_CANCELED); sendResult(Activity.RESULT_CANCELED);
} }
}) });
.setNeutralButton(R.string.title_delete, new DialogInterface.OnClickListener() {
@Override if (criteria.id != null)
public void onClick(DialogInterface dialogInterface, int i) { dialog.setNeutralButton(R.string.title_delete, new DialogInterface.OnClickListener() {
sendResult(Activity.RESULT_FIRST_USER); @Override
} public void onClick(DialogInterface dialogInterface, int i) {
}) sendResult(Activity.RESULT_FIRST_USER);
.create(); }
});
return dialog.create();
} }
@Override @Override

@ -11,8 +11,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:drawableStart="@drawable/twotone_search_24" android:drawableStart="@drawable/twotone_search_24"
android:drawablePadding="6dp" android:drawablePadding="6dp"
android:labelFor="@+id/etName" android:text="@string/title_save_search"
android:text="@string/title_search"
android:textAppearance="@style/TextAppearance.AppCompat.Large" android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -22,9 +21,9 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp" android:layout_marginTop="24dp"
android:hint="@string/title_save_search_name"
android:imeOptions="actionDone" android:imeOptions="actionDone"
android:inputType="textCapSentences" android:inputType="textCapSentences"
android:text="Name"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -33,6 +32,19 @@
<requestFocus /> <requestFocus />
</eu.faircode.email.EditTextPlain> </eu.faircode.email.EditTextPlain>
<eu.faircode.email.EditTextPlain
android:id="@+id/etOrder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/title_save_search_order"
android:inputType="number"
android:maxLength="9"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" />
<eu.faircode.email.ViewButtonColor <eu.faircode.email.ViewButtonColor
android:id="@+id/btnColor" android:id="@+id/btnColor"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -40,7 +52,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:paddingHorizontal="6dp" android:paddingHorizontal="6dp"
android:text="@string/title_color" android:text="@string/title_save_search_color"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" /> app:layout_constraintTop_toBottomOf="@id/etOrder" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -1573,6 +1573,11 @@
<string name="title_search_delete">Delete saved search?</string> <string name="title_search_delete">Delete saved search?</string>
<string name="title_save_search">Saved search</string>
<string name="title_save_search_name">Name</string>
<string name="title_save_search_order">Order</string>
<string name="title_save_search_color">Color</string>
<string name="title_sort_on">Sort on</string> <string name="title_sort_on">Sort on</string>
<string name="title_sort_on_time">Time</string> <string name="title_sort_on_time">Time</string>
<string name="title_sort_on_unread">Unread</string> <string name="title_sort_on_unread">Unread</string>

@ -6,6 +6,7 @@ Kinnareemimus
Next version Next version
* Added saved search order
* Added editing saved search name and color * Added editing saved search name and color
* Small improvements and minor bug fixes * Small improvements and minor bug fixes
* Updated libraries * Updated libraries

Loading…
Cancel
Save