improve local visibility compatibility

This commit is contained in:
sk 2023-01-25 16:49:15 +01:00 committed by LucasGGamerM
parent 84e5983c4c
commit 21f816860f
3 changed files with 16 additions and 4 deletions

View File

@ -937,6 +937,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
if(hasSpoiler){
charCount+=spoilerEdit.length();
}
if (localOnly && GlobalUserPreferences.accountsInGlitchMode.contains(accountID)) {
charCount -= GLITCH_LOCAL_ONLY_SUFFIX.length();
}
charCounter.setText(String.valueOf(charLimit-charCount));
trimmedCharCount=text.toString().trim().length();
updatePublishButtonState();
@ -1854,7 +1857,10 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
Menu m=visibilityPopup.getMenu();
MenuItem localOnlyItem = visibilityPopup.getMenu().findItem(R.id.local_only);
boolean prefsSaysSupported = GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID);
if (localOnly || prefsSaysSupported) {
if (instance.pleroma != null) {
m.findItem(R.id.vis_local).setVisible(true);
} else if (localOnly || prefsSaysSupported) {
localOnlyItem.setVisible(true);
localOnlyItem.setChecked(localOnly);
Status status = editingStatus != null ? editingStatus : replyTo;
if (!prefsSaysSupported) {
@ -1864,8 +1870,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
}
GlobalUserPreferences.save();
}
} else {
localOnlyItem.setVisible(false);
}
UiUtils.enablePopupMenuIcons(getActivity(), visibilityPopup);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) m.setGroupDividerEnabled(true);
@ -1881,6 +1885,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
statusVisibility=StatusPrivacy.PRIVATE;
}else if(id==R.id.vis_private){
statusVisibility=StatusPrivacy.DIRECT;
}else if(id==R.id.vis_local){
statusVisibility=StatusPrivacy.LOCAL;
}
if (id == R.id.local_only) {
localOnly = !item.isChecked();

View File

@ -914,7 +914,8 @@ public class UiUtils{
public static boolean setExtraTextInfo(Context ctx, TextView extraText, StatusPrivacy visibility, boolean localOnly) {
List<String> extraParts = new ArrayList<>();
if (localOnly) extraParts.add(ctx.getString(R.string.sk_inline_local_only));
if (localOnly || (visibility != null && visibility.equals(StatusPrivacy.LOCAL)))
extraParts.add(ctx.getString(R.string.sk_inline_local_only));
if (visibility != null && visibility.equals(StatusPrivacy.DIRECT))
extraParts.add(ctx.getString(R.string.sk_inline_direct));
if (!extraParts.isEmpty()) {

View File

@ -3,10 +3,15 @@
<group android:id="@+id/local_only_group" android:checkableBehavior="all">
<item
android:id="@+id/local_only"
android:visible="false"
android:icon="@drawable/ic_fluent_eye_24_regular"
android:title="@string/sk_local_only" />
</group>
<group android:id="@+id/visibility_group" android:checkableBehavior="single">
<item android:id="@+id/vis_local"
android:visible="false"
android:icon="@drawable/ic_fluent_eye_24_regular"
android:title="@string/sk_local_only"/>
<item android:id="@+id/vis_public"
android:icon="@drawable/ic_fluent_earth_24_regular"
android:title="@string/visibility_public"/>