mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-07 00:20:08 +02:00
Display media (always/wifi/ask)
This commit is contained in:
parent
dc8243fd19
commit
5e5257b01c
7 changed files with 240 additions and 153 deletions
|
@ -104,6 +104,7 @@ public class Status implements Serializable, Cloneable {
|
|||
public boolean isChecked = false;
|
||||
public String translationContent;
|
||||
public boolean translationShown;
|
||||
public boolean canLoadMedia = false;
|
||||
public transient boolean isFocused = false;
|
||||
public transient boolean setCursorToEnd = false;
|
||||
public transient int cursorPosition = 0;
|
||||
|
|
|
@ -15,6 +15,8 @@ package app.fedilab.android.helper;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.text.Html;
|
||||
|
||||
|
@ -239,4 +241,19 @@ public class TimelineHelper {
|
|||
return notifications;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if WIFI is opened
|
||||
*
|
||||
* @param context Context
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isOnWIFI(Context context) {
|
||||
ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (connManager != null) {
|
||||
NetworkInfo activeNetwork = connManager.getActiveNetworkInfo();
|
||||
return (activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ import app.fedilab.android.helper.MastodonHelper;
|
|||
import app.fedilab.android.helper.MediaHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.helper.TimelineHelper;
|
||||
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonContext;
|
||||
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
|
||||
import app.fedilab.android.viewmodel.mastodon.SearchVM;
|
||||
|
@ -342,6 +343,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
boolean displayBookmark = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_BOOKMARK), false);
|
||||
boolean long_press_media = sharedpreferences.getBoolean(context.getString(R.string.SET_LONG_PRESS_STORE_MEDIA), false);
|
||||
boolean displayCounters = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COUNTER_FAV_BOOST), false);
|
||||
String loadMediaType = sharedpreferences.getString(context.getString(R.string.SET_LOAD_MEDIA_TYPE), "ALWAYS");
|
||||
|
||||
if (MainActivity.currentAccount != null && MainActivity.currentAccount.api == Account.API.PLEROMA) {
|
||||
if (status.pleroma != null && status.pleroma.emoji_reactions != null && status.pleroma.emoji_reactions.size() > 0) {
|
||||
|
@ -1112,189 +1114,210 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
holder.binding.mediaContainer.removeAllViews();
|
||||
//If only one attachment
|
||||
if (statusToDeal.media_attachments.size() == 1) {
|
||||
LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
|
||||
RelativeLayout.LayoutParams lp;
|
||||
if (fullAttachement) {
|
||||
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, MediaHelper.returnMaxHeightForPreviews(context, statusToDeal.media_attachments));
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
} else {
|
||||
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) Helper.convertDpToPixel(200, context));
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
}
|
||||
if (statusToDeal.sensitive) {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.red_1);
|
||||
} else {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.white);
|
||||
}
|
||||
layoutMediaBinding.media.setLayoutParams(lp);
|
||||
layoutMediaBinding.media.setOnClickListener(v -> {
|
||||
if (statusToDeal.isMediaObfuscated && mediaObfuscated(statusToDeal) && !expand_media) {
|
||||
statusToDeal.isMediaObfuscated = false;
|
||||
if ((loadMediaType.equals("ASK") || (loadMediaType.equals("WIFI") && !TimelineHelper.isOnWIFI(context))) && !statusToDeal.canLoadMedia) {
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.displayMedia.setVisibility(View.VISIBLE);
|
||||
holder.binding.displayMedia.setOnClickListener(v -> {
|
||||
statusToDeal.canLoadMedia = true;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
|
||||
if (timeout > 0) {
|
||||
new CountDownTimer((timeout * 1000L), 1000) {
|
||||
public void onTick(long millisUntilFinished) {
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
status.isMediaObfuscated = true;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putInt(Helper.ARG_MEDIA_POSITION, 1);
|
||||
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
|
||||
mediaIntent.putExtras(b);
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
|
||||
// start the new activity
|
||||
context.startActivity(mediaIntent, options.toBundle());
|
||||
});
|
||||
if (statusToDeal.media_attachments.get(0).type != null && (statusToDeal.media_attachments.get(0).type.equalsIgnoreCase("video") || statusToDeal.media_attachments.get(0).type.equalsIgnoreCase("gifv"))) {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.VISIBLE);
|
||||
});
|
||||
} else {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.GONE);
|
||||
}
|
||||
if (statusToDeal.media_attachments.get(0).type != null && statusToDeal.media_attachments.get(0).type.equalsIgnoreCase("audio")) {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.GONE);
|
||||
}
|
||||
String finalUrl;
|
||||
if (statusToDeal.media_attachments.get(0).url == null) {
|
||||
finalUrl = statusToDeal.media_attachments.get(0).remote_url;
|
||||
} else {
|
||||
finalUrl = statusToDeal.media_attachments.get(0).url;
|
||||
}
|
||||
layoutMediaBinding.media.setOnLongClickListener(v -> {
|
||||
if (long_press_media) {
|
||||
MediaHelper.manageMove(context, finalUrl, false);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
float focusX = 0.f;
|
||||
float focusY = 0.f;
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
||||
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
||||
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
||||
}
|
||||
|
||||
if (!mediaObfuscated(statusToDeal) || expand_media) {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_24);
|
||||
RequestBuilder<Drawable> requestBuilder = Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(statusToDeal.media_attachments.get(0).preview_url);
|
||||
if (!fullAttachement) {
|
||||
requestBuilder = requestBuilder.apply(new RequestOptions().transform(new GlideFocus(focusX, focusY)));
|
||||
}
|
||||
requestBuilder.into(layoutMediaBinding.media);
|
||||
} else {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_off_24);
|
||||
Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(statusToDeal.media_attachments.get(0).preview_url)
|
||||
.apply(new RequestOptions().transform(new BlurTransformation(50, 3)))
|
||||
// .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
|
||||
.into(layoutMediaBinding.media);
|
||||
}
|
||||
layoutMediaBinding.viewHide.setOnClickListener(v -> {
|
||||
statusToDeal.sensitive = !statusToDeal.sensitive;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
});
|
||||
holder.binding.mediaContainer.addView(layoutMediaBinding.getRoot());
|
||||
holder.binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.GONE);
|
||||
} else { //Several media
|
||||
int mediaPosition = 1;
|
||||
for (Attachment attachment : statusToDeal.media_attachments) {
|
||||
holder.binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||
holder.binding.displayMedia.setVisibility(View.GONE);
|
||||
LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
|
||||
RelativeLayout.LayoutParams lp;
|
||||
float focusX = 0.f;
|
||||
float focusY = 0.f;
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
||||
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
||||
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
||||
}
|
||||
|
||||
String finalUrl;
|
||||
if (attachment.url == null) {
|
||||
finalUrl = attachment.remote_url;
|
||||
} else {
|
||||
finalUrl = attachment.url;
|
||||
}
|
||||
layoutMediaBinding.media.setOnLongClickListener(v -> {
|
||||
if (long_press_media) {
|
||||
MediaHelper.manageMove(context, finalUrl, false);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (fullAttachement) {
|
||||
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, MediaHelper.returnMaxHeightForPreviews(context, statusToDeal.media_attachments));
|
||||
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, MediaHelper.returnMaxHeightForPreviews(context, statusToDeal.media_attachments));
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
} else {
|
||||
lp = new RelativeLayout.LayoutParams((int) Helper.convertDpToPixel(200, context), (int) Helper.convertDpToPixel(200, context));
|
||||
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) Helper.convertDpToPixel(200, context));
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
}
|
||||
if (attachment.type != null && (attachment.type.equalsIgnoreCase("video") || attachment.type.equalsIgnoreCase("gifv"))) {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.GONE);
|
||||
}
|
||||
if (attachment.type != null && attachment.type.equalsIgnoreCase("audio")) {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.GONE);
|
||||
}
|
||||
lp.setMargins(0, 0, (int) Helper.convertDpToPixel(5, context), 0);
|
||||
if (!mediaObfuscated(statusToDeal) || expand_media) {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_24);
|
||||
RequestBuilder<Drawable> requestBuilder = Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(attachment.preview_url);
|
||||
if (!fullAttachement) {
|
||||
requestBuilder = requestBuilder.apply(new RequestOptions().transform(new GlideFocus(focusX, focusY)));
|
||||
}
|
||||
requestBuilder.into(layoutMediaBinding.media);
|
||||
} else {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_off_24);
|
||||
Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(attachment.preview_url)
|
||||
.apply(new RequestOptions().transform(new BlurTransformation(50, 3)))
|
||||
// .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
|
||||
.into(layoutMediaBinding.media);
|
||||
}
|
||||
if (statusToDeal.sensitive) {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.red_1);
|
||||
} else {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.white);
|
||||
}
|
||||
layoutMediaBinding.media.setLayoutParams(lp);
|
||||
int finalMediaPosition = mediaPosition;
|
||||
layoutMediaBinding.media.setOnClickListener(v -> {
|
||||
if (statusToDeal.isMediaObfuscated && mediaObfuscated(statusToDeal) && !expand_media) {
|
||||
statusToDeal.isMediaObfuscated = false;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
|
||||
if (timeout > 0) {
|
||||
new CountDownTimer((timeout * 1000L), 1000) {
|
||||
public void onTick(long millisUntilFinished) {
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
status.isMediaObfuscated = true;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
|
||||
b.putInt(Helper.ARG_MEDIA_POSITION, 1);
|
||||
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
|
||||
mediaIntent.putExtras(b);
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(finalMediaPosition - 1).url);
|
||||
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
|
||||
// start the new activity
|
||||
context.startActivity(mediaIntent, options.toBundle());
|
||||
});
|
||||
if (statusToDeal.media_attachments.get(0).type != null && (statusToDeal.media_attachments.get(0).type.equalsIgnoreCase("video") || statusToDeal.media_attachments.get(0).type.equalsIgnoreCase("gifv"))) {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.GONE);
|
||||
}
|
||||
if (statusToDeal.media_attachments.get(0).type != null && statusToDeal.media_attachments.get(0).type.equalsIgnoreCase("audio")) {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.GONE);
|
||||
}
|
||||
String finalUrl;
|
||||
if (statusToDeal.media_attachments.get(0).url == null) {
|
||||
finalUrl = statusToDeal.media_attachments.get(0).remote_url;
|
||||
} else {
|
||||
finalUrl = statusToDeal.media_attachments.get(0).url;
|
||||
}
|
||||
layoutMediaBinding.media.setOnLongClickListener(v -> {
|
||||
if (long_press_media) {
|
||||
MediaHelper.manageMove(context, finalUrl, false);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
float focusX = 0.f;
|
||||
float focusY = 0.f;
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
||||
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
||||
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
||||
}
|
||||
|
||||
if (!mediaObfuscated(statusToDeal) || expand_media) {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_24);
|
||||
RequestBuilder<Drawable> requestBuilder = Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(statusToDeal.media_attachments.get(0).preview_url);
|
||||
if (!fullAttachement) {
|
||||
requestBuilder = requestBuilder.apply(new RequestOptions().transform(new GlideFocus(focusX, focusY)));
|
||||
}
|
||||
requestBuilder.into(layoutMediaBinding.media);
|
||||
} else {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_off_24);
|
||||
Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(statusToDeal.media_attachments.get(0).preview_url)
|
||||
.apply(new RequestOptions().transform(new BlurTransformation(50, 3)))
|
||||
// .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
|
||||
.into(layoutMediaBinding.media);
|
||||
}
|
||||
layoutMediaBinding.viewHide.setOnClickListener(v -> {
|
||||
statusToDeal.sensitive = !statusToDeal.sensitive;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
});
|
||||
holder.binding.attachmentsList.addView(layoutMediaBinding.getRoot());
|
||||
mediaPosition++;
|
||||
holder.binding.mediaContainer.addView(layoutMediaBinding.getRoot());
|
||||
holder.binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.GONE);
|
||||
}
|
||||
} else { //Several media
|
||||
if ((loadMediaType.equals("ASK") || (loadMediaType.equals("WIFI") && !TimelineHelper.isOnWIFI(context))) && !statusToDeal.canLoadMedia) {
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.displayMedia.setVisibility(View.VISIBLE);
|
||||
holder.binding.displayMedia.setOnClickListener(v -> {
|
||||
statusToDeal.canLoadMedia = true;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
});
|
||||
} else {
|
||||
int mediaPosition = 1;
|
||||
for (Attachment attachment : statusToDeal.media_attachments) {
|
||||
LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
|
||||
RelativeLayout.LayoutParams lp;
|
||||
float focusX = 0.f;
|
||||
float focusY = 0.f;
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
||||
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
||||
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
||||
}
|
||||
|
||||
String finalUrl;
|
||||
if (attachment.url == null) {
|
||||
finalUrl = attachment.remote_url;
|
||||
} else {
|
||||
finalUrl = attachment.url;
|
||||
}
|
||||
layoutMediaBinding.media.setOnLongClickListener(v -> {
|
||||
if (long_press_media) {
|
||||
MediaHelper.manageMove(context, finalUrl, false);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (fullAttachement) {
|
||||
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, MediaHelper.returnMaxHeightForPreviews(context, statusToDeal.media_attachments));
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
} else {
|
||||
lp = new RelativeLayout.LayoutParams((int) Helper.convertDpToPixel(200, context), (int) Helper.convertDpToPixel(200, context));
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
}
|
||||
if (attachment.type != null && (attachment.type.equalsIgnoreCase("video") || attachment.type.equalsIgnoreCase("gifv"))) {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.GONE);
|
||||
}
|
||||
if (attachment.type != null && attachment.type.equalsIgnoreCase("audio")) {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.GONE);
|
||||
}
|
||||
lp.setMargins(0, 0, (int) Helper.convertDpToPixel(5, context), 0);
|
||||
if (!mediaObfuscated(statusToDeal) || expand_media) {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_24);
|
||||
RequestBuilder<Drawable> requestBuilder = Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(attachment.preview_url);
|
||||
if (!fullAttachement) {
|
||||
requestBuilder = requestBuilder.apply(new RequestOptions().transform(new GlideFocus(focusX, focusY)));
|
||||
}
|
||||
requestBuilder.into(layoutMediaBinding.media);
|
||||
} else {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_off_24);
|
||||
Glide.with(layoutMediaBinding.media.getContext())
|
||||
.load(attachment.preview_url)
|
||||
.apply(new RequestOptions().transform(new BlurTransformation(50, 3)))
|
||||
// .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
|
||||
.into(layoutMediaBinding.media);
|
||||
}
|
||||
if (statusToDeal.sensitive) {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.red_1);
|
||||
} else {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.white);
|
||||
}
|
||||
layoutMediaBinding.media.setLayoutParams(lp);
|
||||
int finalMediaPosition = mediaPosition;
|
||||
layoutMediaBinding.media.setOnClickListener(v -> {
|
||||
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
|
||||
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
|
||||
mediaIntent.putExtras(b);
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(finalMediaPosition - 1).url);
|
||||
// start the new activity
|
||||
context.startActivity(mediaIntent, options.toBundle());
|
||||
});
|
||||
layoutMediaBinding.viewHide.setOnClickListener(v -> {
|
||||
statusToDeal.sensitive = !statusToDeal.sensitive;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
});
|
||||
holder.binding.attachmentsList.addView(layoutMediaBinding.getRoot());
|
||||
mediaPosition++;
|
||||
}
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
holder.binding.displayMedia.setVisibility(View.GONE);
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ package app.fedilab.android.ui.fragment.settings;
|
|||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
|
||||
public class FragmentTimelinesSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
|
@ -31,7 +33,10 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
}
|
||||
|
||||
private void createPref() {
|
||||
|
||||
ListPreference SET_LOAD_MEDIA_TYPE = findPreference(getString(R.string.SET_LOAD_MEDIA_TYPE));
|
||||
if (SET_LOAD_MEDIA_TYPE != null) {
|
||||
SET_LOAD_MEDIA_TYPE.getContext().setTheme(Helper.dialogStyle());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -382,6 +382,21 @@
|
|||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/display_media"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:text="@string/display_media"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="gone"
|
||||
app:iconTint="@color/cyanea_accent_reference"
|
||||
app:strokeColor="@color/cyanea_accent_dark_reference" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/media_container"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -747,6 +747,12 @@
|
|||
<item>No notifications</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="set_load_media_type_value">
|
||||
<item>Always</item>
|
||||
<item>Wifi only</item>
|
||||
<item>Ask</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="set_notification_delay_values">
|
||||
<item>15 minutes</item>
|
||||
<item>30 minutes</item>
|
||||
|
@ -769,6 +775,8 @@
|
|||
<string name="SET_CUSTOM_USER_AGENT" translatable="false">SET_CUSTOM_USER_AGENT</string>
|
||||
<string name="SET_NSFW_TIMEOUT" translatable="false">SET_NSFW_TIMEOUT</string>
|
||||
<string name="SET_NOTIFICATION_TYPE" translatable="false">SET_NOTIFICATION_TYPE</string>
|
||||
<string name="SET_LOAD_MEDIA_TYPE" translatable="false">SET_LOAD_MEDIA_TYPE</string>
|
||||
|
||||
<string name="SET_NOTIFICATION_DELAY_VALUE" translatable="false">SET_NOTIFICATION_DELAY_VALUE</string>
|
||||
<string name="SET_PUSH_DISTRIBUTOR" translatable="false">SET_PUSH_DISTRIBUTOR</string>
|
||||
|
||||
|
@ -777,6 +785,13 @@
|
|||
<item>REPEAT_NOTIFICATIONS</item>
|
||||
<item>NO_NOTIFICATIONS</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="SET_LOAD_MEDIA_TYPE_VALUE" translatable="false">
|
||||
<item>ALWAYS</item>
|
||||
<item>WIFI</item>
|
||||
<item>ASK</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="SET_NOTIFICATION_DELAYS_VALUES" translatable="false">
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
|
@ -1453,4 +1468,6 @@
|
|||
<string name="set_display_counter">Display counters for messages</string>
|
||||
<string name="set_use_cache">Use cache</string>
|
||||
<string name="set_use_cache_indication">Timelines will be cached so the application will be faster.</string>
|
||||
<string name="load_media_type_title">Load thumbnails for media</string>
|
||||
<string name="display_media">Display media</string>
|
||||
</resources>
|
||||
|
|
|
@ -25,6 +25,15 @@
|
|||
app:key="@string/SET_DISPLAY_BOOKMARK"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_display_bookmark_indication" />
|
||||
<ListPreference
|
||||
app:defaultValue="ALWAYS"
|
||||
app:dialogTitle="@string/load_media_type_title"
|
||||
app:entries="@array/set_load_media_type_value"
|
||||
app:entryValues="@array/SET_LOAD_MEDIA_TYPE_VALUE"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_LOAD_MEDIA_TYPE"
|
||||
app:title="@string/load_media_type_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
|
|
Loading…
Reference in a new issue