Added saved search order

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

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

File diff suppressed because it is too large Load Diff

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

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

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

@ -71,7 +71,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 239,
version = 240,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2404,6 +2404,12 @@ public abstract class DB extends RoomDatabase {
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) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

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

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

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

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

@ -1573,6 +1573,11 @@
<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_time">Time</string>
<string name="title_sort_on_unread">Unread</string>

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

Loading…
Cancel
Save