Simplify local contact search

pull/153/head
M66B 6 years ago
parent 5c3819970c
commit bd27b9fbeb

@ -59,16 +59,12 @@ public interface DaoContact {
EntityContact getContact(long account, int type, String email);
@Query("SELECT id AS _id, name, email" +
", CASE type" +
" WHEN " + EntityContact.TYPE_TO + " THEN '>'" +
" WHEN " + EntityContact.TYPE_FROM + " THEN '<'" +
" ELSE '?'" +
" END AS type" +
" FROM contact" +
" WHERE (:account IS NULL OR account = :account)" +
" AND (:type IS NULL OR type = :type)" +
" AND (email LIKE :query COLLATE NOCASE OR name LIKE :query COLLATE NOCASE)" +
" AND state <> " + EntityContact.STATE_IGNORE +
" GROUP BY name, email" +
" ORDER BY" +
" CASE WHEN name IS NULL THEN 1 ELSE 0 END" +
", name COLLATE NOCASE, email COLLATE NOCASE")

@ -440,16 +440,9 @@ public class FragmentCompose extends FragmentBase {
contacts
? new String[]{
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Email.DATA
}
: new String[]{
"name",
"email",
"type"
},
contacts
? new int[]{android.R.id.text1, android.R.id.text2}
: new int[]{android.R.id.text1, android.R.id.text2, R.id.tvType},
ContactsContract.CommonDataKinds.Email.DATA}
: new String[]{"name", "email"},
new int[]{android.R.id.text1, android.R.id.text2},
0);
etTo.setAdapter(cadapter);

@ -22,21 +22,11 @@
android:id="@android:id/text2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:ellipsize="middle"
android:singleLine="true"
android:text="Text2"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/tvType"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@android:id/text1" />
<TextView
android:id="@+id/tvType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@android:id/text1" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save