Added search for mailto addresses

pull/203/head
M66B 3 years ago
parent f338214be4
commit a5fa1ed49c

@ -57,6 +57,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.Group;
import androidx.core.net.MailTo;
import androidx.core.util.PatternsCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import java.net.IDN;
@ -156,11 +157,12 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
final ImageButton ibDifferent = dview.findViewById(R.id.ibDifferent);
final EditText etLink = dview.findViewById(R.id.etLink);
final TextView tvLink = dview.findViewById(R.id.tvLink);
final ImageButton ibSearch = dview.findViewById(R.id.ibSearch);
final ImageButton ibShare = dview.findViewById(R.id.ibShare);
final ImageButton ibCopy = dview.findViewById(R.id.ibCopy);
final TextView tvSuspicious = dview.findViewById(R.id.tvSuspicious);
final TextView tvDisconnect = dview.findViewById(R.id.tvDisconnect);
final TextView tvDisconnectCategories = dview.findViewById(R.id.tvDisconnectCategories);
final ImageButton ibShare = dview.findViewById(R.id.ibShare);
final ImageButton ibCopy = dview.findViewById(R.id.ibCopy);
final CheckBox cbSecure = dview.findViewById(R.id.cbSecure);
final CheckBox cbSanitize = dview.findViewById(R.id.cbSanitize);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
@ -241,6 +243,30 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
}
});
MailTo mailto = null;
if ("mailto".equals(uri.getScheme()))
try {
mailto = MailTo.parse(uri);
} catch (Throwable ex) {
Log.w(ex);
}
ibSearch.setVisibility(
mailto != null && !TextUtils.isEmpty(mailto.getTo())
? View.VISIBLE : View.GONE);
ibSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_SEARCH_ADDRESS)
.putExtra("account", -1L)
.putExtra("folder", -1L)
.putExtra("query", MailTo.parse(uri).getTo()));
}
});
ibShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -610,7 +636,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
text = "tel://" + host;
} else if ("mailto".equals(scheme)) {
if (host == null) {
MailTo email = MailTo.parse(uri.toString());
MailTo email = MailTo.parse(uri);
host = UriHelper.getEmailDomain(email.getTo());
}
}

@ -82,10 +82,22 @@
android:singleLine="true"
android:text="Original link"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/ibShare"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etLink" />
<ImageButton
android:id="@+id/ibSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_search"
android:tooltipText="@string/title_search"
app:layout_constraintEnd_toStartOf="@+id/ibShare"
app:layout_constraintTop_toBottomOf="@id/tvLink"
app:srcCompat="@drawable/twotone_search_24" />
<ImageButton
android:id="@+id/ibShare"
android:layout_width="wrap_content"
@ -93,8 +105,9 @@
android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_share"
android:tooltipText="@string/title_share"
app:layout_constraintEnd_toStartOf="@+id/ibCopy"
app:layout_constraintTop_toBottomOf="@id/etLink"
app:layout_constraintTop_toBottomOf="@id/tvLink"
app:srcCompat="@drawable/twotone_share_24" />
<ImageButton
@ -103,8 +116,9 @@
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_clipboard_copy"
android:tooltipText="@string/title_clipboard_copy"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/etLink"
app:layout_constraintTop_toBottomOf="@id/tvLink"
app:srcCompat="@drawable/twotone_file_copy_24" />
<eu.faircode.email.FixedTextView

Loading…
Cancel
Save