summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-03-08 15:50:05 +0100
committerThomas <tschneider.ac@gmail.com>2023-03-08 15:50:05 +0100
commit5782fe9da63cf1100594f17ae643b6ee247bbbb3 (patch)
tree737f8f1e4991933ed39b57447a39656378a2e207
parent70a66ae4cde9c8b1d630a48649055bbeb85b086f (diff)
improve media description
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java25
-rw-r--r--app/src/main/res/layouts/mastodon/layout/popup_media_description.xml67
2 files changed, 39 insertions, 53 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java
index 7aa9c4d40..5a3cc06c2 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java
@@ -31,9 +31,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
-import android.graphics.Bitmap;
import android.graphics.Color;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -58,7 +56,6 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.LinearLayoutCompat;
@@ -72,9 +69,8 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
+import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
-import com.bumptech.glide.request.target.CustomTarget;
-import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -1147,24 +1143,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
popupMediaDescriptionBinding.mediaDescription.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1500)});
popupMediaDescriptionBinding.mediaDescription.requestFocus();
Glide.with(popupMediaDescriptionBinding.mediaPicture.getContext())
- .asBitmap()
.load(attachmentPath)
- .into(new CustomTarget<Bitmap>() {
- @Override
- public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
- popupMediaDescriptionBinding.mediaPicture.setImageBitmap(resource);
- }
-
- @Override
- public void onLoadCleared(@Nullable Drawable placeholder) {
-
- }
-
- @Override
- public void onLoadFailed(@Nullable Drawable errorDrawable) {
- super.onLoadFailed(errorDrawable);
- }
- });
+ .apply(new RequestOptions().transform(new RoundedCorners(30)))
+ .into(popupMediaDescriptionBinding.mediaPicture);
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
if (attachment.description != null) {
popupMediaDescriptionBinding.mediaDescription.setText(attachment.description);
diff --git a/app/src/main/res/layouts/mastodon/layout/popup_media_description.xml b/app/src/main/res/layouts/mastodon/layout/popup_media_description.xml
index 1e04d6cab..c26c06fbe 100644
--- a/app/src/main/res/layouts/mastodon/layout/popup_media_description.xml
+++ b/app/src/main/res/layouts/mastodon/layout/popup_media_description.xml
@@ -14,40 +14,45 @@
You should have received a copy of the GNU General Public License along with Fedilab; if not,
see <http://www.gnu.org/licenses>.
-->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
+<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_height="match_parent">
- <androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- tools:context=".mastodon.activities.ComposeActivity">
+ android:layout_height="wrap_content">
- <androidx.appcompat.widget.AppCompatImageView
- android:id="@+id/media_picture"
- android:layout_width="match_parent"
- android:layout_height="300dp"
- android:contentDescription="@string/media_description"
- android:scaleType="fitCenter"
- app:layout_constraintBottom_toTopOf="@+id/media_description"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-
- <androidx.appcompat.widget.AppCompatEditText
- android:id="@+id/media_description"
+ <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/media_picture"
- android:layout_marginHorizontal="6dp"
- android:layout_marginTop="10dp"
- android:textAlignment="textStart"
- android:inputType="textMultiLine|textCapSentences"
- android:minLines="3"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/media_picture" />
-
- </androidx.constraintlayout.widget.ConstraintLayout>
-</ScrollView>
+ tools:context=".mastodon.activities.ComposeActivity">
+
+ <androidx.appcompat.widget.AppCompatImageView
+ android:id="@+id/media_picture"
+ android:layout_width="wrap_content"
+ android:layout_height="300dp"
+ android:contentDescription="@string/media_description"
+ android:padding="5dp"
+ android:scaleType="fitCenter"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:src="@tools:sample/backgrounds/scenic" />
+
+ <androidx.appcompat.widget.AppCompatEditText
+ android:id="@+id/media_description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@+id/media_picture"
+ android:gravity="top"
+ android:inputType="textMultiLine|textCapSentences"
+ android:minLines="10"
+ android:textAlignment="gravity"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/media_picture" />
+ </androidx.constraintlayout.widget.ConstraintLayout>
+ </ScrollView>
+</androidx.appcompat.widget.LinearLayoutCompat>