mirror of
https://framagit.org/tom79/nitterizeme
synced 2025-02-09 16:28:51 +01:00
New button in app picker to copy the url
This commit is contained in:
parent
ffb8de9012
commit
a83124e70a
@ -15,6 +15,9 @@ package app.fedilab.nitterizeme.activities;
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@ -27,6 +30,7 @@ import android.widget.GridView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
@ -210,6 +214,13 @@ public class AppsPickerActivity extends Activity {
|
||||
});
|
||||
}
|
||||
|
||||
ImageView copyLink = findViewById(R.id.copy_link);
|
||||
copyLink.setOnClickListener(v -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("", url);
|
||||
clipboard.setPrimaryClip(clipData);
|
||||
Toast.makeText(this, getString(R.string.copy_done), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
10
app/src/main/res/drawable/ic_copy.xml
Normal file
10
app/src/main/res/drawable/ic_copy.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#ffffff"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z" />
|
||||
</vector>
|
@ -43,21 +43,34 @@
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/scroll_url"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:padding="2dp"
|
||||
android:scrollbars="none"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/copy_link"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/url"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:singleLine="true"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/colorAccent" />
|
||||
</HorizontalScrollView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/copy_link"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:padding="2dp"
|
||||
android:layout_margin="5dp"
|
||||
android:src="@drawable/ic_copy"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/indication"
|
||||
|
@ -75,4 +75,5 @@
|
||||
<string name="delete">Delete</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="delete_app_from_default">Delete %1$s from default apps?</string>
|
||||
<string name="copy_done">Copied</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user