mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-02-25 18:39:45 +02:00
Some fixes
This commit is contained in:
parent
d27faa3113
commit
b3c6cd57a0
4 changed files with 11 additions and 32 deletions
|
@ -327,7 +327,10 @@ public class ComposeWorker extends Worker {
|
||||||
|
|
||||||
private static String postAttachment(MastodonStatusesService mastodonStatusesService, DataPost dataPost, MultipartBody.Part fileMultipartBody, Attachment attachment) {
|
private static String postAttachment(MastodonStatusesService mastodonStatusesService, DataPost dataPost, MultipartBody.Part fileMultipartBody, Attachment attachment) {
|
||||||
|
|
||||||
RequestBody descriptionBody = RequestBody.create(MediaType.parse("text/plain"), attachment.description);
|
RequestBody descriptionBody = null;
|
||||||
|
if (attachment.description != null && attachment.description.trim().length() > 0) {
|
||||||
|
descriptionBody = RequestBody.create(MediaType.parse("text/plain"), attachment.description);
|
||||||
|
}
|
||||||
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(dataPost.token, fileMultipartBody, null, descriptionBody, attachment.focus);
|
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(dataPost.token, fileMultipartBody, null, descriptionBody, attachment.focus);
|
||||||
|
|
||||||
if (attachmentCall != null) {
|
if (attachmentCall != null) {
|
||||||
|
|
|
@ -728,18 +728,13 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
|
AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
|
||||||
SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class);
|
SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class);
|
||||||
textw = new TextWatcher() {
|
textw = new TextWatcher() {
|
||||||
private int cPosition;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
if (count > 2) {
|
buttonVisibility(holder);
|
||||||
holder.binding.addRemoveStatus.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
cPosition = start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -752,17 +747,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
} else {
|
} else {
|
||||||
holder.binding.characterCount.setTextColor(holder.binding.content.getTextColors());
|
holder.binding.characterCount.setTextColor(holder.binding.content.getTextColors());
|
||||||
}
|
}
|
||||||
/*if (currentLength > max_car + 1) {
|
|
||||||
int from = max_car - holder.binding.contentSpoiler.getText().length();
|
|
||||||
int to = (currentLength - holder.binding.contentSpoiler.getText().length());
|
|
||||||
if (to <= s.length()) {
|
|
||||||
holder.binding.content.setText(s.delete(from, to));
|
|
||||||
}
|
|
||||||
} else if (currentLength > max_car) {
|
|
||||||
if (cPosition + 1 <= s.length()) {
|
|
||||||
holder.binding.content.setText(s.delete(cPosition, cPosition + 1));
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
statusList.get(holder.getBindingAdapterPosition()).text = s.toString();
|
statusList.get(holder.getBindingAdapterPosition()).text = s.toString();
|
||||||
if (s.toString().trim().length() < 2) {
|
if (s.toString().trim().length() < 2) {
|
||||||
buttonVisibility(holder);
|
buttonVisibility(holder);
|
||||||
|
@ -1304,18 +1288,13 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
int max_car = MastodonHelper.getInstanceMaxChars(context);
|
int max_car = MastodonHelper.getInstanceMaxChars(context);
|
||||||
holder.binding.characterProgress.setMax(max_car);
|
holder.binding.characterProgress.setMax(max_car);
|
||||||
holder.binding.contentSpoiler.addTextChangedListener(new TextWatcher() {
|
holder.binding.contentSpoiler.addTextChangedListener(new TextWatcher() {
|
||||||
private int cPosition;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
cPosition = start;
|
buttonVisibility(holder);
|
||||||
if (count > 2) {
|
|
||||||
holder.binding.addRemoveStatus.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1327,13 +1306,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
} else {
|
} else {
|
||||||
holder.binding.characterCount.setTextColor(holder.binding.content.getTextColors());
|
holder.binding.characterCount.setTextColor(holder.binding.content.getTextColors());
|
||||||
}
|
}
|
||||||
/*if (currentLength > max_car + 1) {
|
|
||||||
holder.binding.contentSpoiler.setText(s.delete(max_car - holder.binding.content.getText().length(), (currentLength - holder.binding.content.getText().length())));
|
|
||||||
buttonVisibility(holder);
|
|
||||||
} else if (currentLength > max_car) {
|
|
||||||
buttonVisibility(holder);
|
|
||||||
holder.binding.contentSpoiler.setText(s.delete(cPosition, cPosition + 1));
|
|
||||||
}*/
|
|
||||||
statusList.get(holder.getBindingAdapterPosition()).spoiler_text = s.toString();
|
statusList.get(holder.getBindingAdapterPosition()).spoiler_text = s.toString();
|
||||||
if (s.toString().trim().length() < 2) {
|
if (s.toString().trim().length() < 2) {
|
||||||
buttonVisibility(holder);
|
buttonVisibility(holder);
|
||||||
|
|
|
@ -120,7 +120,10 @@ public class StatusesVM extends AndroidViewModel {
|
||||||
MultipartBody.Part thumbnailMultipartBody;
|
MultipartBody.Part thumbnailMultipartBody;
|
||||||
fileMultipartBody = Helper.getMultipartBody(getApplication(), "file", file);
|
fileMultipartBody = Helper.getMultipartBody(getApplication(), "file", file);
|
||||||
thumbnailMultipartBody = Helper.getMultipartBody(getApplication(), "file", thumbnail);
|
thumbnailMultipartBody = Helper.getMultipartBody(getApplication(), "file", thumbnail);
|
||||||
RequestBody descriptionBody = RequestBody.create(MediaType.parse("text/plain"), description);
|
RequestBody descriptionBody = null;
|
||||||
|
if (description != null && description.trim().length() > 0) {
|
||||||
|
descriptionBody = RequestBody.create(MediaType.parse("text/plain"), description);
|
||||||
|
}
|
||||||
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, thumbnailMultipartBody, descriptionBody, focus);
|
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, thumbnailMultipartBody, descriptionBody, focus);
|
||||||
Attachment attachment = null;
|
Attachment attachment = null;
|
||||||
if (attachmentCall != null) {
|
if (attachmentCall != null) {
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="6dp"
|
android:layout_marginHorizontal="6dp"
|
||||||
|
android:focusable="true"
|
||||||
android:gravity="top|start"
|
android:gravity="top|start"
|
||||||
android:inputType="textMultiLine|textCapSentences"
|
android:inputType="textMultiLine|textCapSentences"
|
||||||
android:minLines="6"
|
android:minLines="6"
|
||||||
|
|
Loading…
Reference in a new issue