Added searching for invites

pull/182/head
M66B 4 years ago
parent 25229c60aa
commit 8379b3b6cd

File diff suppressed because it is too large Load Diff

@ -240,6 +240,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
criteria.with_hidden,
criteria.with_encrypted,
criteria.with_attachments,
criteria.with_types,
criteria.with_size,
criteria.after,
criteria.before,
@ -620,6 +621,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
boolean with_hidden;
boolean with_encrypted;
boolean with_attachments;
String[] with_types;
Integer with_size = null;
Long after = null;
Long before = null;
@ -647,6 +649,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
with_hidden ||
with_encrypted ||
with_attachments ||
with_types != null ||
with_size != null);
}
@ -724,6 +727,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
flags.add(context.getString(R.string.title_search_flag_encrypted));
if (with_attachments)
flags.add(context.getString(R.string.title_search_flag_attachments));
if (with_types != null)
if (with_types.length == 1 && "text/calendar".equals(with_types[0]))
flags.add(context.getString(R.string.title_search_flag_invite));
else
flags.add(TextUtils.join(", ", with_types));
if (with_size != null)
flags.add(context.getString(R.string.title_search_flag_size,
Helper.humanReadableByteCount(with_size, true)));
@ -747,6 +755,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
this.with_hidden == other.with_hidden &&
this.with_encrypted == other.with_encrypted &&
this.with_attachments == other.with_attachments &&
Objects.equals(this.with_types, other.with_types) &&
Objects.equals(this.with_size, other.with_size) &&
Objects.equals(this.after, other.after) &&
Objects.equals(this.before, other.before));
@ -768,6 +777,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
" hidden=" + with_hidden +
" encrypted=" + with_encrypted +
" attachments=" + with_attachments +
" type=" + (with_types == null ? null : TextUtils.join(",", with_types)) +
" size=" + with_size +
" after=" + (after == null ? "" : new Date(after)) +
" before=" + (before == null ? "" : new Date(before));

@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 164,
version = 165,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1628,6 +1628,14 @@ public abstract class DB extends RoomDatabase {
db.execSQL("DROP TRIGGER attachment_delete");
createTriggers(db);
}
})
.addMigrations(new Migration(164, 165) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE INDEX IF NOT EXISTS `index_attachment_message_type` ON `attachment` (`message`, `type`)");
createTriggers(db);
}
});
}

@ -303,7 +303,7 @@ public interface DaoMessage {
" ORDER BY message.received")
Cursor getMessageFts();
@Query("SELECT id, account, thread, (:find IS NULL" +
@Query("SELECT message.id, account, thread, (:find IS NULL" +
" OR (:senders AND `from` LIKE :find COLLATE NOCASE)" + // no index
" OR (:recipients AND `to` LIKE :find COLLATE NOCASE)" + // no index
" OR (:recipients AND `cc` LIKE :find COLLATE NOCASE)" + // no index
@ -312,6 +312,7 @@ public interface DaoMessage {
" OR (:keywords AND `keywords` LIKE :find COLLATE NOCASE)" + // no index
" OR (:message AND `preview` LIKE :find COLLATE NOCASE)) AS matched" + // no index
" FROM message" +
" LEFT JOIN attachment ON attachment.message = message.id" +
" WHERE NOT ui_hide" +
" AND (:account IS NULL OR account = :account)" +
" AND (:folder IS NULL OR folder = :folder)" +
@ -320,6 +321,7 @@ public interface DaoMessage {
" AND (NOT :hidden OR NOT ui_snoozed IS NULL)" +
" AND (NOT :encrypted OR ui_encrypt > 0)" +
" AND (NOT :attachments OR attachments > 0)" +
" AND (:types IS NULL OR attachment.type IN (:types))" +
" AND (:size IS NULL OR total > :size)" +
" AND (:after IS NULL OR received > :after)" +
" AND (:before IS NULL OR received < :before)" +
@ -329,6 +331,7 @@ public interface DaoMessage {
Long account, Long folder, String find,
boolean senders, boolean recipients, boolean subject, boolean keywords, boolean message,
boolean unseen, boolean flagged, boolean hidden, boolean encrypted, boolean attachments,
String[] types,
Integer size,
Long after, Long before,
int limit, int offset);

@ -50,6 +50,7 @@ import static androidx.room.ForeignKey.CASCADE;
indices = {
@Index(value = {"message"}),
@Index(value = {"message", "sequence"}, unique = true),
@Index(value = {"message", "type"}),
@Index(value = {"message", "cid"})
}
)

@ -59,6 +59,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_search, null);
final AutoCompleteTextView etQuery = dview.findViewById(R.id.etQuery);
final ImageButton ibEvent = dview.findViewById(R.id.ibInvite);
final ImageButton ibUnseen = dview.findViewById(R.id.ibUnseen);
final ImageButton ibFlagged = dview.findViewById(R.id.ibFlagged);
final ImageButton ibInfo = dview.findViewById(R.id.ibInfo);
@ -313,6 +314,10 @@ public class FragmentDialogSearch extends FragmentDialogBase {
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
switch (v.getId()) {
case R.id.ibInvite:
criteria.with_attachments = true;
criteria.with_types = new String[]{"text/calendar"};
break;
case R.id.ibUnseen:
criteria.with_unseen = true;
break;
@ -327,6 +332,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
}
};
ibEvent.setOnClickListener(onClick);
ibUnseen.setOnClickListener(onClick);
ibFlagged.setOnClickListener(onClick);

@ -1118,7 +1118,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fabCompose.hide();
if (viewType == AdapterMessage.ViewType.SEARCH && criteria != null && !server) {
if (criteria.with_hidden || criteria.with_encrypted || criteria.with_attachments)
if (criteria.with_hidden ||
criteria.with_encrypted ||
criteria.with_attachments ||
criteria.with_types != null)
fabSearch.hide();
else
fabSearch.show();

@ -19,16 +19,30 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/ibInvite"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_search_flag_invite"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_search_flag_invite"
app:layout_constraintEnd_toStartOf="@+id/ibUnseen"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_event_24" />
<ImageButton
android:id="@+id/ibUnseen"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_info"
android:contentDescription="@string/title_search_flag_unseen"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_info"
android:tooltipText="@string/title_search_flag_unseen"
app:layout_constraintEnd_toStartOf="@+id/ibFlagged"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_mail_24" />
@ -39,10 +53,10 @@
android:layout_height="36dp"
android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_accessibility_flagged"
android:contentDescription="@string/title_search_flag_flagged"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_info"
android:tooltipText="@string/title_search_flag_flagged"
app:layout_constraintEnd_toStartOf="@+id/ibInfo"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_star_24" />

@ -972,6 +972,7 @@
<string name="title_search_flag_hidden">hidden</string>
<string name="title_search_flag_encrypted">encrypted</string>
<string name="title_search_flag_attachments">attachments</string>
<string name="title_search_flag_invite">invitation</string>
<string name="title_search_flag_size">size &gt; %1$s</string>
<string name="title_search_device">Search on device</string>

Loading…
Cancel
Save