Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
display recent languages
Browse files Browse the repository at this point in the history
closes #654
  • Loading branch information
sk22 committed Oct 7, 2023
1 parent 44912b7 commit 4428ef7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private int charCount, charLimit, trimmedCharCount;

private Button publishButton, languageButton, scheduleTimeBtn;
private PopupMenu languagePopup, contentTypePopup, visibilityPopup, draftOptionsPopup;
private PopupMenu contentTypePopup, visibilityPopup, draftOptionsPopup;
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, draftsBtn, scheduleDraftDismiss, contentTypeBtn;
private View sensitiveBtn;
private TextView replyText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.MastodonAPIController;
import org.joinmastodon.android.api.session.AccountLocalPreferences;
import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.ui.DividerItemDecoration;
Expand Down Expand Up @@ -66,7 +67,7 @@ public ComposeLanguageAlertViewController(Context context, String preferred, Sel
.collect(Collectors.toList());

if(!TextUtils.isEmpty(preferred)){
MastodonLanguage lang = resolver.fromOrFallback(preferred);
MastodonLanguage lang=resolver.fromOrFallback(preferred);
specialLocales.add(new SpecialLocaleInfo(
lang,
lang.getDisplayName(context),
Expand All @@ -75,7 +76,7 @@ public ComposeLanguageAlertViewController(Context context, String preferred, Sel
}

if(!Locale.getDefault().getLanguage().equals(preferred)){
MastodonLanguage lang = resolver.getDefault();
MastodonLanguage lang=resolver.getDefault();
specialLocales.add(new SpecialLocaleInfo(
lang,
lang.getDisplayName(context),
Expand All @@ -91,8 +92,18 @@ public ComposeLanguageAlertViewController(Context context, String preferred, Sel
detectLanguage(detected, postText);
}

if (session!=null && session.getLocalPreferences().bottomEncoding) {
specialLocales.add(new SpecialLocaleInfo(null, "\uD83E\uDD7A\uD83D\uDC49\uD83D\uDC48", "bottom"));
AccountLocalPreferences lp=session==null ? null : session.getLocalPreferences();
if(lp!=null){
for(String tag : lp.recentLanguages){
if(specialLocales.stream().anyMatch(l->l.language!=null && l.language.languageTag!=null
&& l.language.languageTag.equals(tag))) continue;
resolver.from(tag).ifPresent(lang->specialLocales.add(new SpecialLocaleInfo(
lang, lang.getDisplayName(context), null
)));
}
if(lp.bottomEncoding) {
specialLocales.add(new SpecialLocaleInfo(null, "\uD83E\uDD7A\uD83D\uDC49\uD83D\uDC48", "bottom"));
}
}

if(previouslySelected!=null){
Expand Down Expand Up @@ -323,7 +334,7 @@ public void onBind(SpecialLocaleInfo item){
public void onClick(){
selectItem(getAbsoluteAdapterPosition());
selectedLocale=item.language;
selectedEncoding = item.title.equals("bottom") ? "bottom" : null;
selectedEncoding=item.title != null && item.title.equals("bottom") ? "bottom" : null;
}

@Override
Expand Down

0 comments on commit 4428ef7

Please sign in to comment.