Commit a06d73e2 authored by Thomas's avatar Thomas
Browse files

Fix some issues

parent e058b54c
Pipeline #304479 passed with stage
in 5 minutes and 25 seconds
......@@ -6,7 +6,6 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.ActionMode;
import android.view.View;
import android.widget.Toast;
......@@ -25,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.Timer;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.helper.Helper;
import es.dmoral.toasty.Toasty;
......
......@@ -207,6 +207,7 @@ import static app.fedilab.android.helper.Helper.THEME_BLACK;
import static app.fedilab.android.helper.Helper.THEME_DARK;
import static app.fedilab.android.helper.Helper.THEME_LIGHT;
import static app.fedilab.android.helper.Helper.countWithEmoji;
import static app.fedilab.android.helper.Helper.isValidContextForGlide;
/**
......@@ -646,7 +647,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
}
public static String manageMentions(Context context, String userIdReply, Status tootReply) {
public static String manageMentions(String userIdReply, Status tootReply) {
String contentView = "";
//Retrieves mentioned accounts + OP and adds them at the beginin of the toot
ArrayList<String> mentionedAccountsAdded = new ArrayList<>();
......@@ -1340,53 +1341,57 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
it.remove();
}
if (fileName != null) {
Glide.with(imageView.getContext())
.asBitmap()
.load(fileName)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
imageView.setImageBitmap(resource);
}
if (isValidContextForGlide(imageView.getContext())) {
Glide.with(imageView.getContext())
.asBitmap()
.load(fileName)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
imageView.setImageBitmap(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
});
}
}
}
} else {
String finalUrl = url;
Glide.with(imageView.getContext())
.asBitmap()
.load(url)
.error(Glide.with(imageView).asBitmap().load(R.drawable.ic_audio_wave))
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
imageView.setImageBitmap(resource);
if (displayWYSIWYG()) {
url_for_media = finalUrl;
Iterator it = filesMap.entrySet().iterator();
String fileName = null;
while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
fileName = (String) pair.getKey();
it.remove();
}
if (fileName != null && fileName.contains("fedilabins_")) {
wysiwyg.insertImage(resource);
if (isValidContextForGlide(imageView.getContext())) {
String finalUrl = url;
Glide.with(imageView.getContext())
.asBitmap()
.load(url)
.error(Glide.with(imageView).asBitmap().load(R.drawable.ic_audio_wave))
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
imageView.setImageBitmap(resource);
if (displayWYSIWYG()) {
url_for_media = finalUrl;
Iterator it = filesMap.entrySet().iterator();
String fileName = null;
while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
fileName = (String) pair.getKey();
it.remove();
}
if (fileName != null && fileName.contains("fedilabins_")) {
wysiwyg.insertImage(resource);
}
}
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
});
}
}
......@@ -2246,8 +2251,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (namebar != null && namebar.getParent() != null)
((ViewGroup) namebar.getParent()).removeView(namebar);
}
List<Attachment> tmp_attachment = new ArrayList<>();
tmp_attachment.addAll(attachments);
List<Attachment> tmp_attachment = new ArrayList<>(attachments);
attachments.removeAll(tmp_attachment);
tmp_attachment.clear();
}
......@@ -2585,8 +2589,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (namebar != null && namebar.getParent() != null)
((ViewGroup) namebar.getParent()).removeView(namebar);
}
List<Attachment> tmp_attachment = new ArrayList<>();
tmp_attachment.addAll(attachments);
List<Attachment> tmp_attachment = new ArrayList<>(attachments);
attachments.removeAll(tmp_attachment);
tmp_attachment.clear();
}
......@@ -3069,9 +3072,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
});
imageView.setTag(attachment.getId());
imageView.setOnClickListener(view -> {
imageView.setOnClickListener(view1 -> showAddDescription(attachment));
});
imageView.setOnClickListener(view -> imageView.setOnClickListener(view1 -> showAddDescription(attachment)));
imageView.setOnLongClickListener(view -> {
showRemove(imageView.getId());
return false;
......@@ -3396,7 +3397,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private void displayPollPopup() {
AlertDialog.Builder alertPoll = new AlertDialog.Builder(TootActivity.this, style);
alertPoll.setTitle(R.string.create_poll);
View view = getLayoutInflater().inflate(R.layout.popup_poll, null);
View view = getLayoutInflater().inflate(R.layout.popup_poll, new LinearLayout(TootActivity.this), false);
alertPoll.setView(view);
Spinner poll_choice = view.findViewById(R.id.poll_choice);
Spinner poll_duration = view.findViewById(R.id.poll_duration);
......
......@@ -459,7 +459,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
InputMethodManager.SHOW_FORCED, 0);
EditText content_cw = new EditText(context);
content_cw.setText(status.getReblog() != null ? status.getReblog().getSpoiler_text() : status.getSpoiler_text());
String content = TootActivity.manageMentions(context, userId, status.getReblog() != null ? status.getReblog() : status);
String content = TootActivity.manageMentions(userId, status.getReblog() != null ? status.getReblog() : status);
TextWatcher textWatcher = PixelfedComposeActivity.initializeTextWatcher(context, social, holder.quick_reply_text, holder.toot_space_left, null, null, PixelfedListAdapter.this, PixelfedListAdapter.this, PixelfedListAdapter.this);
holder.quick_reply_text.addTextChangedListener(textWatcher);
holder.quick_reply_text.setText(content);
......
......@@ -480,6 +480,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
public void onPostStatusAction(APIResponse apiResponse) {
if (apiResponse.getError() != null) {
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_SHORT).show();
storeToot();
return;
}
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
......@@ -487,7 +488,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
String instance = Helper.getLiveInstance(context);
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS + userId + instance, false);
if (split_toot && splitToot != null && stepSpliToot < splitToot.size()) {
String tootContent = splitToot.get(stepSpliToot);
stepSpliToot += 1;
......
......@@ -126,9 +126,9 @@ public class LiveNotificationDelayedService extends Service {
.setContentTitle(getString(R.string.top_notification))
.setSmallIcon(getNotificationIcon(LiveNotificationDelayedService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
if( notification != null) {
if (notification != null) {
startForeground(1, notification);
}else{
} else {
return;
}
}
......@@ -319,9 +319,9 @@ public class LiveNotificationDelayedService extends Service {
.setSmallIcon(getNotificationIcon(LiveNotificationDelayedService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
if( notificationChannel != null) {
if (notificationChannel != null) {
startForeground(1, notificationChannel);
}else{
} else {
return;
}
}
......
......@@ -140,9 +140,9 @@ public class LiveNotificationService extends Service implements NetworkStateRece
.setSmallIcon(getNotificationIcon(LiveNotificationService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
if( notification != null) {
if (notification != null) {
startForeground(1, notification);
}else{
} else {
return;
}
}
......@@ -321,9 +321,9 @@ public class LiveNotificationService extends Service implements NetworkStateRece
.setContentTitle(getString(R.string.top_notification))
.setSmallIcon(getNotificationIcon(LiveNotificationService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
if( notificationChannel != null) {
if (notificationChannel != null) {
startForeground(1, notificationChannel);
}else{
} else {
return;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment