gt:         String url = "sms:" + Uri.encode(contactPojo.phone);
context: package fr.neamar.kiss.result;
  
  import android.content.Context;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.content.pm.PackageManager;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.drawable.BitmapDrawable;
  import android.graphics.drawable.Drawable;
  import android.net.Uri;
  import android.os.Build;
  import android.preference.PreferenceManager;
  import android.provider.ContactsContract;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageButton;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.InputStream;
  
  import androidx.annotation.NonNull;
  import fr.neamar.kiss.R;
  import fr.neamar.kiss.UIColors;
  import fr.neamar.kiss.adapter.RecordAdapter;
  import fr.neamar.kiss.pojo.ContactsPojo;
  import fr.neamar.kiss.searcher.QueryInterface;
  import fr.neamar.kiss.ui.ImprovedQuickContactBadge;
  import fr.neamar.kiss.ui.ListPopup;
  import fr.neamar.kiss.ui.ShapedContactBadge;
  import fr.neamar.kiss.utils.FuzzyScore;
  
  public class ContactsResult extends CallResult {
      private final ContactsPojo contactPojo;
      private final QueryInterface queryInterface;
      private Drawable icon = null;
  
      ContactsResult(QueryInterface queryInterface, ContactsPojo contactPojo) {
          super(contactPojo);
          this.contactPojo = contactPojo;
          this.queryInterface = queryInterface;
      }
  
      @NonNull
      @Override
      public View display(Context context, View view, @NonNull ViewGroup parent, FuzzyScore fuzzyScore) {
          if (view == null)
              view = inflateFromId(context, R.layout.item_contact, parent);
  
          // Contact name
          TextView contactName = view.findViewById(R.id.item_contact_name);
          displayHighlighted(contactPojo.normalizedName, contactPojo.getName(), fuzzyScore, contactName, context);
  
          // Contact phone
          TextView contactPhone = view.findViewById(R.id.item_contact_phone);
          displayHighlighted(contactPojo.normalizedPhone, contactPojo.phone, fuzzyScore, contactPhone, context);
  
          // Contact nickname
          TextView contactNickname = view.findViewById(R.id.item_contact_nickname);
          if (contactPojo.getNickname().isEmpty()) {
              contactNickname.setVisibility(View.GONE);
          } else {
              contactNickname.setVisibility(View.VISIBLE);
              displayHighlighted(contactPojo.normalizedNickname, contactPojo.getNickname(), fuzzyScore, contactNickname, context);
          }
  
          // Contact photo
          ImprovedQuickContactBadge contactIcon = view
                  .findViewById(R.id.item_contact_icon);
  
          SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
          if (!prefs.getBoolean("icons-hide", false)) {
              if (contactIcon.getTag() instanceof ContactsPojo && contactPojo.equals(contactIcon.getTag())) {
                  icon = contactIcon.getDrawable();
              }
              this.setAsyncDrawable(contactIcon);
          } else {
              contactIcon.setImageDrawable(null);
          }
  
          contactIcon.assignContactUri(Uri.withAppendedPath(
                  ContactsContract.Contacts.CONTENT_LOOKUP_URI,
                  String.valueOf(contactPojo.lookupKey)));
          contactIcon.setExtraOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  recordLaunch(v.getContext(), queryInterface);
              }
          });
  
          int primaryColor = UIColors.getPrimaryColor(context);
          // Phone action
          ImageButton phoneButton = view.findViewById(R.id.item_contact_action_phone);
          phoneButton.setColorFilter(primaryColor);
          // Message action
          ImageButton messageButton = view.findViewById(R.id.item_contact_action_message);
          messageButton.setColorFilter(primaryColor);
  
          PackageManager pm = context.getPackageManager();
  
          if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
              phoneButton.setVisibility(View.VISIBLE);
              messageButton.setVisibility(View.VISIBLE);
              phoneButton.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      launchCall(v.getContext(), v, contactPojo.phone);
                      recordLaunch(context, queryInterface);
                  }
              });
  
              messageButton.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      launchMessaging(v.getContext());
                      recordLaunch(context, queryInterface);
                  }
              });
  
              if (contactPojo.homeNumber)
                  messageButton.setVisibility(View.INVISIBLE);
              else
                  messageButton.setVisibility(View.VISIBLE);
  
          } else {
              phoneButton.setVisibility(View.INVISIBLE);
              messageButton.setVisibility(View.INVISIBLE);
          }
  
          return view;
      }
  
      @Override
      protected ListPopup buildPopupMenu(Context context, ArrayAdapter<ListPopup.Item> adapter, final RecordAdapter parent, View parentView) {
          adapter.add(new ListPopup.Item(context, R.string.menu_remove));
          adapter.add(new ListPopup.Item(context, R.string.menu_contact_copy_phone));
          adapter.add(new ListPopup.Item(context, R.string.menu_favorites_add));
          adapter.add(new ListPopup.Item(context, R.string.menu_favorites_remove));
  
          return inflatePopupMenu(adapter, context);
      }
  
      @Override
      protected boolean popupMenuClickHandler(Context context, RecordAdapter parent, int stringId, View parentView) {
          switch (stringId) {
              case R.string.menu_contact_copy_phone:
                  copyPhone(context, contactPojo);
                  return true;
          }
  
          return super.popupMenuClickHandler(context, parent, stringId, parentView);
      }
  
      @SuppressWarnings("deprecation")
      private void copyPhone(Context context, ContactsPojo contactPojo) {
          android.content.ClipboardManager clipboard =
                  (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
          assert clipboard != null;
          android.content.ClipData clip = android.content.ClipData.newPlainText(
                  "Phone number for " + contactPojo.getName(),
                  contactPojo.phone);
          clipboard.setPrimaryClip(clip);
      }
  
      @Override
      boolean isDrawableCached() {
          return icon != null;
      }
  
      @Override
      void setDrawableCache(Drawable drawable) {
          icon = drawable;
      }
  
      @Override
      public Drawable getDrawable(Context context) {
          synchronized (this) {
              if (isDrawableCached())
                  return icon;
              if (contactPojo.icon != null) {
                  InputStream inputStream = null;
                  try {
                      inputStream = context.getContentResolver()
                              .openInputStream(contactPojo.icon);
                      return icon = Drawable.createFromStream(inputStream, null);
                  } catch (FileNotFoundException ignored) {
                  } finally {
                      if (inputStream != null) {
                          try {
                              inputStream.close();
                          } catch (IOException ignored) {
                          }
                      }
                  }
              }
  
              // Default icon
              return icon = context.getResources()
                      .getDrawable(R.drawable.ic_contact);
          }
      }
  
      @NonNull
      @Override
      public View inflateFavorite(@NonNull Context context, @NonNull ViewGroup parent) {
          Drawable drawable = getDrawable(context);
          if ( drawable != null ) {
              drawable = ShapedContactBadge.getShapedDrawable(context, drawable);
          }
          View favoriteView = super.inflateFavorite(context, parent);
          ImageView favoriteImage = favoriteView.findViewById(R.id.favorite);
          favoriteImage.setImageDrawable(drawable);
          return favoriteView;
      }
  
      private void launchContactView(Context context, View v) {
          Intent viewContact = new Intent(Intent.ACTION_VIEW);
  
          viewContact.setData(Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI,
                  String.valueOf(contactPojo.lookupKey)));
          if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
              viewContact.setSourceBounds(v.getClipBounds());
          }
  
          viewContact.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          viewContact.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
          context.startActivity(viewContact);
  
      }
  
  
      @Override
      public void doLaunch(Context context, View v) {
          SharedPreferences settingPrefs = PreferenceManager.getDefaultSharedPreferences(v.getContext());
          boolean callContactOnClick = settingPrefs.getBoolean("call-contact-on-click", false);
  
          if (callContactOnClick) {
              launchCall(context, v, contactPojo.phone);
          } else {
              launchContactView(context, v);
          }
      }
  
      private void launchMessaging(final Context context) {
  