feat:make the relocated publishButton actually centered

Pain
This commit is contained in:
LucasGGamerM
2023-08-26 18:59:02 -03:00
parent af22bfd790
commit 239a78888b
2 changed files with 34 additions and 19 deletions

View File

@@ -177,7 +177,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private Button publishButton, languageButton, scheduleTimeBtn; private Button publishButton, languageButton, scheduleTimeBtn;
private PopupMenu languagePopup, contentTypePopup, visibilityPopup, draftOptionsPopup; private PopupMenu languagePopup, contentTypePopup, visibilityPopup, draftOptionsPopup;
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, draftsBtn, scheduleDraftDismiss, contentTypeBtn; private ImageButton publishButtonRelocated, mediaBtn, pollBtn, emojiBtn, spoilerBtn, draftsBtn, scheduleDraftDismiss, contentTypeBtn;
private View sensitiveBtn; private View sensitiveBtn;
private TextView replyText; private TextView replyText;
private LinearLayout scheduleDraftView; private LinearLayout scheduleDraftView;
@@ -336,17 +336,16 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
View view=inflater.inflate(R.layout.fragment_compose, container, false); View view=inflater.inflate(R.layout.fragment_compose, container, false);
if(GlobalUserPreferences.relocatePublishButton){ if(GlobalUserPreferences.relocatePublishButton){
publishButton=view.findViewById(R.id.publish); publishButtonRelocated=view.findViewById(R.id.publish);
// publishButton.setText(editingStatus==null || redraftStatus ? R.string.publish : R.string.save); // publishButton.setText(editingStatus==null || redraftStatus ? R.string.publish : R.string.save);
publishButton.setEllipsize(TextUtils.TruncateAt.END); // publishButton.setEllipsize(TextUtils.TruncateAt.END);
publishButton.setOnClickListener(v -> { publishButtonRelocated.setOnClickListener(v -> {
if(GlobalUserPreferences.altTextReminders && editingStatus==null) if(GlobalUserPreferences.altTextReminders && editingStatus==null)
checkAltTextsAndPublish(); checkAltTextsAndPublish();
else else
publish(); publish();
}); });
publishButton.setSingleLine(true); publishButtonRelocated.setVisibility(View.VISIBLE);
publishButton.setVisibility(View.VISIBLE);
draftsBtn=view.findViewById(R.id.drafts_btn); draftsBtn=view.findViewById(R.id.drafts_btn);
draftsBtn.setVisibility(View.VISIBLE); draftsBtn.setVisibility(View.VISIBLE);
@@ -910,12 +909,22 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
languageButton = wrap.findViewById(R.id.language_btn); languageButton = wrap.findViewById(R.id.language_btn);
languageButton.setOnClickListener(v->showLanguageAlert()); languageButton.setOnClickListener(v->showLanguageAlert());
publishButton.setOnClickListener(v -> { if(GlobalUserPreferences.relocatePublishButton){
if(GlobalUserPreferences.altTextReminders && editingStatus==null) publishButtonRelocated.setOnClickListener(v -> {
checkAltTextsAndPublish(); if(GlobalUserPreferences.altTextReminders && editingStatus==null)
else checkAltTextsAndPublish();
publish(); else
}); publish();
});
} else {
publishButton.setOnClickListener(v -> {
if(GlobalUserPreferences.altTextReminders && editingStatus==null)
checkAltTextsAndPublish();
else
publish();
});
}
draftsBtn.setOnClickListener(v-> draftOptionsPopup.show()); draftsBtn.setOnClickListener(v-> draftOptionsPopup.show());
draftsBtn.setOnTouchListener(draftOptionsPopup.getDragToOpenListener()); draftsBtn.setOnTouchListener(draftOptionsPopup.getDragToOpenListener());
updateScheduledAt(scheduledAt != null ? scheduledAt : scheduledStatus != null ? scheduledStatus.scheduledAt : null); updateScheduledAt(scheduledAt != null ? scheduledAt : scheduledStatus != null ? scheduledStatus.scheduledAt : null);
@@ -1016,6 +1025,10 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
public void updatePublishButtonState(){ public void updatePublishButtonState(){
uuid=null; uuid=null;
if(GlobalUserPreferences.relocatePublishButton && publishButtonRelocated != null){
publishButtonRelocated.setEnabled((!isInstancePixelfed() || !mediaViewController.isEmpty()) && (trimmedCharCount>0 || !mediaViewController.isEmpty()) && charCount<=charLimit && mediaViewController.getNonDoneAttachmentCount()==0 && (pollViewController.isEmpty() || pollViewController.getNonEmptyOptionsCount()>1));
}
if(publishButton==null) if(publishButton==null)
return; return;
publishButton.setEnabled((!isInstancePixelfed() || !mediaViewController.isEmpty()) && (trimmedCharCount>0 || !mediaViewController.isEmpty()) && charCount<=charLimit && mediaViewController.getNonDoneAttachmentCount()==0 && (pollViewController.isEmpty() || pollViewController.getNonEmptyOptionsCount()>1)); publishButton.setEnabled((!isInstancePixelfed() || !mediaViewController.isEmpty()) && (trimmedCharCount>0 || !mediaViewController.isEmpty()) && charCount<=charLimit && mediaViewController.getNonDoneAttachmentCount()==0 && (pollViewController.isEmpty() || pollViewController.getNonEmptyOptionsCount()>1));
@@ -1539,8 +1552,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
draftsBtn.setImageDrawable(getContext().getDrawable(GlobalUserPreferences.relocatePublishButton ? R.drawable.ic_fluent_drafts_24_regular : R.drawable.ic_fluent_drafts_20_filled)); draftsBtn.setImageDrawable(getContext().getDrawable(GlobalUserPreferences.relocatePublishButton ? R.drawable.ic_fluent_drafts_24_regular : R.drawable.ic_fluent_drafts_20_filled));
if(GlobalUserPreferences.relocatePublishButton){ if(GlobalUserPreferences.relocatePublishButton){
publishButton.setCompoundDrawablesWithIntrinsicBounds(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT) publishButtonRelocated.setImageResource(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT)
? R.drawable.ic_fluent_save_24_selector : R.drawable.ic_fluent_drafts_24_selector, 0, 0, 0); ? R.drawable.ic_fluent_save_24_selector : R.drawable.ic_fluent_drafts_24_selector);
}else{ }else{
publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT) publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT)
? R.string.save : R.string.sk_draft); ? R.string.save : R.string.sk_draft);
@@ -1560,8 +1573,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
draftsBtn.setImageDrawable(getContext().getDrawable(GlobalUserPreferences.relocatePublishButton ? R.drawable.ic_fluent_clock_24_filled : R.drawable.ic_fluent_clock_20_filled)); draftsBtn.setImageDrawable(getContext().getDrawable(GlobalUserPreferences.relocatePublishButton ? R.drawable.ic_fluent_clock_24_filled : R.drawable.ic_fluent_clock_20_filled));
if(GlobalUserPreferences.relocatePublishButton) if(GlobalUserPreferences.relocatePublishButton)
{ {
publishButton.setCompoundDrawablesWithIntrinsicBounds(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT) publishButtonRelocated.setImageResource(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT)
? R.drawable.ic_fluent_save_24_selector : R.drawable.ic_fluent_clock_24_selector, 0, 0, 0); ? R.drawable.ic_fluent_save_24_selector : R.drawable.ic_fluent_clock_24_selector);
}else{ }else{
publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.equals(scheduledAt) publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.equals(scheduledAt)
? R.string.save : R.string.sk_schedule); ? R.string.save : R.string.sk_schedule);
@@ -1570,7 +1583,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
} else { } else {
draftsBtn.setImageDrawable(getContext().getDrawable(GlobalUserPreferences.relocatePublishButton ? R.drawable.ic_fluent_clock_24_regular : R.drawable.ic_fluent_clock_20_regular)); draftsBtn.setImageDrawable(getContext().getDrawable(GlobalUserPreferences.relocatePublishButton ? R.drawable.ic_fluent_clock_24_regular : R.drawable.ic_fluent_clock_20_regular));
if(GlobalUserPreferences.relocatePublishButton){ if(GlobalUserPreferences.relocatePublishButton){
publishButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_send_24_selector, 0, 0, 0); publishButtonRelocated.setImageResource(R.drawable.ic_fluent_send_24_selector);
} }
resetPublishButtonText(); resetPublishButtonText();
} }

View File

@@ -553,15 +553,17 @@
tools:text="500"/> tools:text="500"/>
<Button <ImageButton
android:id="@+id/publish" android:id="@+id/publish"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:paddingHorizontal="12dp"
android:visibility="gone" android:visibility="gone"
android:tooltipText="@string/publish" android:tooltipText="@string/publish"
android:contentDescription="@string/publish" android:contentDescription="@string/publish"
android:drawableStart="@drawable/ic_fluent_send_24_selector" android:src="@drawable/ic_fluent_send_24_selector"
style="@style/Widget.Mastodon.M3.Button.Filled.Elevated"
/> />
</LinearLayout> </LinearLayout>