Copy e-mail in shownotes (#5235)

This commit is contained in:
ueen 2021-06-25 19:01:59 +02:00 committed by GitHub
parent e26507e41d
commit d041b86114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package de.danoeh.antennapod.view;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
@ -15,10 +16,15 @@ import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.core.content.ContextCompat;
import androidx.core.util.Consumer;
import androidx.core.view.ViewCompat;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.util.Converter;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.core.util.NetworkUtils;
@ -94,6 +100,19 @@ public class ShownotesWebView extends WebView implements View.OnLongClickListene
selectedUrl = r.getExtra();
showContextMenu();
return true;
} else if (r != null && r.getType() == HitTestResult.EMAIL_TYPE) {
Log.d(TAG, "E-Mail of webview was long-pressed. Extra: " + r.getExtra());
ClipboardManager clipboardManager = ContextCompat.getSystemService(this.getContext(),
ClipboardManager.class);
if (clipboardManager != null) {
clipboardManager.setPrimaryClip(ClipData.newPlainText("AntennaPod", r.getExtra()));
}
if (this.getContext() instanceof MainActivity) {
((MainActivity) this.getContext()).showSnackbarAbovePlayer(
getResources().getString(R.string.copied_to_clipboard),
Snackbar.LENGTH_SHORT);
}
return true;
}
selectedUrl = null;
return false;