From 634408b8cb1ca6fd25a3b0377aeebabaa42215d6 Mon Sep 17 00:00:00 2001 From: Grishka Date: Sun, 12 Feb 2023 14:25:03 +0300 Subject: [PATCH] Minor onboarding tweaks --- .../onboarding/InstanceCatalogFragment.java | 47 ++----------------- .../InstanceCatalogSignupFragment.java | 7 ++- .../onboarding/InstanceRulesFragment.java | 8 +++- .../layout/fragment_onboarding_activation.xml | 13 ++++- ...fragment_onboarding_follow_suggestions.xml | 8 ++-- 5 files changed, 31 insertions(+), 52 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java index 345a0a4a..ea70ff70 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java @@ -5,15 +5,12 @@ import android.app.ProgressDialog; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.os.LocaleList; import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; -import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.Button; import android.widget.EditText; -import android.widget.RadioButton; import android.widget.TextView; import org.joinmastodon.android.R; @@ -23,7 +20,6 @@ import org.joinmastodon.android.api.requests.instance.GetInstance; import org.joinmastodon.android.model.Instance; import org.joinmastodon.android.model.catalog.CatalogInstance; import org.joinmastodon.android.ui.M3AlertDialogBuilder; -import org.joinmastodon.android.ui.utils.UiUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -52,7 +48,6 @@ import me.grishka.appkit.fragments.BaseRecyclerFragment; import me.grishka.appkit.utils.BindableViewHolder; import me.grishka.appkit.utils.MergeRecyclerAdapter; import me.grishka.appkit.utils.V; -import me.grishka.appkit.views.UsableRecyclerView; import okhttp3.Call; import okhttp3.Request; import okhttp3.Response; @@ -114,46 +109,10 @@ abstract class InstanceCatalogFragment extends BaseRecyclerFragment sortInstances(List result){ - Map> byLang=result.stream().collect(Collectors.groupingBy(ci->ci.language)); - for(List group:byLang.values()){ - Collections.sort(group, (a, b)->{ - double aa=Math.abs(DUNBAR-Math.log(a.lastWeekUsers)); - double bb=Math.abs(DUNBAR-Math.log(b.lastWeekUsers)); - return Double.compare(aa, bb); - }); - } - // get the list of user-configured system languages - List userLangs; - if(Build.VERSION.SDK_INT<24){ - userLangs=Collections.singletonList(getResources().getConfiguration().locale.getLanguage()); - }else{ - LocaleList ll=getResources().getConfiguration().getLocales(); - userLangs=new ArrayList<>(ll.size()); - for(int i=0;i> byLang=result.stream().sorted(Comparator.comparingInt((CatalogInstance ci)->ci.lastWeekUsers).reversed()).collect(Collectors.groupingBy(ci->ci.approvalRequired)); ArrayList sortedList=new ArrayList<>(); - for(String lang:userLangs){ - List langInstances=byLang.remove(lang); - if(langInstances!=null){ - sortedList.addAll(langInstances); - } - } - // sort the remaining language groups by aggregate lastWeekUsers - class InstanceGroup{ - public int activeUsers; - public List instances; - } - byLang.values().stream().map(il->{ - InstanceGroup group=new InstanceGroup(); - group.instances=il; - for(CatalogInstance instance:il){ - group.activeUsers+=instance.lastWeekUsers; - } - return group; - }).sorted(Comparator.comparingInt((InstanceGroup g)->g.activeUsers).reversed()).forEachOrdered(ig->sortedList.addAll(ig.instances)); + sortedList.addAll(byLang.getOrDefault(false, Collections.emptyList())); + sortedList.addAll(byLang.getOrDefault(true, Collections.emptyList())); return sortedList; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogSignupFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogSignupFragment.java index b97bf0e0..798b18ac 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogSignupFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogSignupFragment.java @@ -64,7 +64,7 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple private List languages=Collections.emptyList(); private PopupMenu langFilterMenu, speedFilterMenu; - private SignupSpeedFilter currentSignupSpeedFilter=SignupSpeedFilter.INSTANT; + private SignupSpeedFilter currentSignupSpeedFilter=SignupSpeedFilter.ANY; private String currentLanguage=null; private boolean searchQueryMode; private LinearLayout filtersWrap; @@ -75,7 +75,7 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple private FilterChipView categoryGeneral, categorySpecialInterests; private List regionalFilters; private CatalogInstance.Region chosenRegion; - private CategoryChoice categoryChoice; + private CategoryChoice categoryChoice=CategoryChoice.GENERAL; public InstanceCatalogSignupFragment(){ super(R.layout.fragment_onboarding_common, 10); @@ -371,6 +371,9 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple if(instances.isEmpty()){ instances=data.stream().filter(ci->!ci.approvalRequired && ("general".equals(ci.category) || (ci.categories!=null && ci.categories.contains("general")))).collect(Collectors.toList()); } + if(instances.isEmpty()){ + instances=data.stream().filter(ci->("general".equals(ci.category) || (ci.categories!=null && ci.categories.contains("general")))).collect(Collectors.toList()); + } if(instances.isEmpty()){ return; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java index 224a002c..5eb4a55c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java @@ -2,8 +2,14 @@ package org.joinmastodon.android.fragments.onboarding; import android.annotation.SuppressLint; import android.app.Activity; +import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; +import android.text.Html; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.style.StyleSpan; +import android.text.style.TypefaceSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -64,7 +70,7 @@ public class InstanceRulesFragment extends ToolbarFragment{ list.setLayoutManager(new LinearLayoutManager(getActivity())); View headerView=inflater.inflate(R.layout.item_list_header_simple, list, false); TextView text=headerView.findViewById(R.id.text); - text.setText(getString(R.string.instance_rules_subtitle, instance.uri)); + text.setText(Html.fromHtml(getString(R.string.instance_rules_subtitle, ""+Html.escapeHtml(instance.uri)+""))); adapter=new MergeRecyclerAdapter(); adapter.addAdapter(new SingleViewRecyclerAdapter(headerView)); diff --git a/mastodon/src/main/res/layout/fragment_onboarding_activation.xml b/mastodon/src/main/res/layout/fragment_onboarding_activation.xml index b14f47e2..04618b95 100644 --- a/mastodon/src/main/res/layout/fragment_onboarding_activation.xml +++ b/mastodon/src/main/res/layout/fragment_onboarding_activation.xml @@ -9,7 +9,8 @@ + android:layout_weight="1" + android:fillViewport="true"> + + + + diff --git a/mastodon/src/main/res/layout/fragment_onboarding_follow_suggestions.xml b/mastodon/src/main/res/layout/fragment_onboarding_follow_suggestions.xml index 7872fc04..cc021220 100644 --- a/mastodon/src/main/res/layout/fragment_onboarding_follow_suggestions.xml +++ b/mastodon/src/main/res/layout/fragment_onboarding_follow_suggestions.xml @@ -40,17 +40,17 @@ android:background="@drawable/bg_onboarding_panel">