improve media description

This commit is contained in:
Thomas 2023-03-08 15:50:05 +01:00
parent 70a66ae4cd
commit 5782fe9da6
2 changed files with 38 additions and 52 deletions

View file

@ -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);

View file

@ -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" />
tools:context=".mastodon.activities.ComposeActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<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>