re-arrange settings

This commit is contained in:
sk 2023-01-25 15:52:41 +01:00
parent 86e781cdea
commit 5f48870a90
2 changed files with 14 additions and 8 deletions

View File

@ -259,7 +259,6 @@ public class SettingsFragment extends MastodonToolbarFragment{
items.add(new TextItem(R.string.sk_settings_auth, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit"), R.drawable.ic_fluent_open_24_regular)); items.add(new TextItem(R.string.sk_settings_auth, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit"), R.drawable.ic_fluent_open_24_regular));
items.add(new HeaderItem(instanceName)); items.add(new HeaderItem(instanceName));
items.add(new TextItem(R.string.log_out, this::confirmLogOut, R.drawable.ic_fluent_sign_out_24_regular));
items.add(new TextItem(R.string.sk_settings_rules, ()->{ items.add(new TextItem(R.string.sk_settings_rules, ()->{
Bundle args=new Bundle(); Bundle args=new Bundle();
args.putParcelable("instance", Parcels.wrap(instance)); args.putParcelable("instance", Parcels.wrap(instance));
@ -268,6 +267,9 @@ public class SettingsFragment extends MastodonToolbarFragment{
items.add(new TextItem(R.string.sk_settings_about_instance , ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/about"), R.drawable.ic_fluent_info_24_regular)); items.add(new TextItem(R.string.sk_settings_about_instance , ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/about"), R.drawable.ic_fluent_info_24_regular));
items.add(new TextItem(R.string.settings_tos, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular)); items.add(new TextItem(R.string.settings_tos, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular));
items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular)); items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular));
items.add(new TextItem(R.string.log_out, this::confirmLogOut, R.drawable.ic_fluent_sign_out_24_regular));
items.add(new HeaderItem(R.string.sk_instance_features));
items.add(new SwitchItem(R.string.sk_settings_support_local_only, 0, GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID), i->{ items.add(new SwitchItem(R.string.sk_settings_support_local_only, 0, GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID), i->{
glitchModeItem.enabled = i.checked; glitchModeItem.enabled = i.checked;
if (i.checked) { if (i.checked) {
@ -277,9 +279,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.accountsWithLocalOnlySupport.remove(accountID); GlobalUserPreferences.accountsWithLocalOnlySupport.remove(accountID);
GlobalUserPreferences.accountsInGlitchMode.remove(accountID); GlobalUserPreferences.accountsInGlitchMode.remove(accountID);
} }
glitchModeItem.checked = GlobalUserPreferences.accountsInGlitchMode.contains(accountID);
if (list.findViewHolderForAdapterPosition(items.indexOf(glitchModeItem)) instanceof SwitchViewHolder svh) svh.rebind(); if (list.findViewHolderForAdapterPosition(items.indexOf(glitchModeItem)) instanceof SwitchViewHolder svh) svh.rebind();
GlobalUserPreferences.save(); GlobalUserPreferences.save();
})); }));
items.add(new SmallTextItem(getString(R.string.sk_settings_local_only_explanation)));
items.add(glitchModeItem = new SwitchItem(R.string.sk_settings_glitch_instance, 0, GlobalUserPreferences.accountsInGlitchMode.contains(accountID), i->{ items.add(glitchModeItem = new SwitchItem(R.string.sk_settings_glitch_instance, 0, GlobalUserPreferences.accountsInGlitchMode.contains(accountID), i->{
if (i.checked) { if (i.checked) {
GlobalUserPreferences.accountsInGlitchMode.add(accountID); GlobalUserPreferences.accountsInGlitchMode.add(accountID);
@ -289,7 +293,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.save(); GlobalUserPreferences.save();
})); }));
glitchModeItem.enabled = GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID); glitchModeItem.enabled = GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID);
items.add(new SmallTextItem(getString(R.string.sk_settings_local_only_explanation))); items.add(new SmallTextItem(getString(R.string.sk_settings_glitch_mode_explanation)));
items.add(new HeaderItem(R.string.sk_settings_about)); items.add(new HeaderItem(R.string.sk_settings_about));
items.add(new TextItem(R.string.sk_settings_contribute, ()->UiUtils.launchWebBrowser(getActivity(), "https://github.com/sk22/megalodon"), R.drawable.ic_fluent_open_24_regular)); items.add(new TextItem(R.string.sk_settings_contribute, ()->UiUtils.launchWebBrowser(getActivity(), "https://github.com/sk22/megalodon"), R.drawable.ic_fluent_open_24_regular));
@ -975,19 +979,19 @@ public class SettingsFragment extends MastodonToolbarFragment{
private class SmallTextViewHolder extends BindableViewHolder<SmallTextItem> { private class SmallTextViewHolder extends BindableViewHolder<SmallTextItem> {
private final TextView text; private final TextView text;
;
public SmallTextViewHolder(){ public SmallTextViewHolder(){
super(getActivity(), R.layout.item_settings_text, list); super(getActivity(), R.layout.item_settings_text, list);
text = itemView.findViewById(R.id.text); text = itemView.findViewById(R.id.text);
text.setTextColor(UiUtils.getThemeColor(getActivity(), android.R.attr.textColorSecondary));
text.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
text.setPaddingRelative(text.getPaddingStart(), 0, text.getPaddingEnd(), text.getPaddingBottom());
} }
@Override @Override
public void onBind(SmallTextItem item){ public void onBind(SmallTextItem item){
text.setText(item.text); text.setText(item.text);
text.setTextColor(UiUtils.getThemeColor(getActivity(), android.R.attr.textColorSecondary));
text.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
} }
} }

View File

@ -240,7 +240,9 @@
<string name="sk_inline_direct">mentioned-only</string> <string name="sk_inline_direct">mentioned-only</string>
<string name="sk_separator">·</string> <string name="sk_separator">·</string>
<string name="sk_local_only">Local-only</string> <string name="sk_local_only">Local-only</string>
<string name="sk_instance_features">Instance features</string>
<string name="sk_settings_support_local_only">Server supports local-only posting</string> <string name="sk_settings_support_local_only">Server supports local-only posting</string>
<string name="sk_settings_glitch_instance">Use Glitch implementation 👁</string> <string name="sk_settings_local_only_explanation">Your home instance must support local-only posting for this to work. Most modified versions of Mastodon do, but Mastodon doesnt.</string>
<string name="sk_settings_local_only_explanation">Your instance must support local-only posting for these options to work.</string> <string name="sk_settings_glitch_instance">Glitch local-only mode</string>
<string name="sk_settings_glitch_mode_explanation">Enable this if your home instance runs on Glitch. Not needed for Hometown or Akkoma.</string>
</resources> </resources>