Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Fixes 3026: auto-copy URL for old devices #3162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/src/main/java/me/ccrama/redditslide/Reddit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.annotation.TargetApi;
import android.app.*;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
Expand Down Expand Up @@ -132,6 +134,15 @@ public static void defaultShareText(String title, String url, Context c) {
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, url);
c.startActivity(Intent.createChooser(sharingIntent, c.getString(R.string.title_share)));

//Fixes #3026, copy URL when showing chooser for older devices.
ClipboardManager clipboard = (ClipboardManager) c.getSystemService(
Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Link", url);
clipboard.setPrimaryClip(clip);
Toast.makeText( c, R.string.submission_link_copied,
Toast.LENGTH_SHORT).show();

}

public static boolean isPackageInstalled(String s) {
Expand Down