Empty states for home timeline popup submenus (AND-99)
This commit is contained in:
parent
1f7155a932
commit
d3dc774492
|
@ -7,17 +7,19 @@ import android.text.TextUtils;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.ui.BetterItemAnimator;
|
||||
import org.joinmastodon.android.ui.utils.HideableSingleViewRecyclerAdapter;
|
||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
@ -108,6 +110,17 @@ public abstract class DropdownSubmenuController{
|
|||
return contentView;
|
||||
}
|
||||
|
||||
protected HideableSingleViewRecyclerAdapter createEmptyView(@DrawableRes int icon, @StringRes int title, @StringRes int subtitle){
|
||||
View view=dropdownController.getActivity().getLayoutInflater().inflate(R.layout.popup_menu_empty, list, false);
|
||||
ImageView iconView=view.findViewById(R.id.icon);
|
||||
TextView titleView=view.findViewById(R.id.title);
|
||||
TextView subtitleView=view.findViewById(R.id.subtitle);
|
||||
iconView.setImageResource(icon);
|
||||
titleView.setText(title);
|
||||
subtitleView.setText(subtitle);
|
||||
return new HideableSingleViewRecyclerAdapter(view);
|
||||
}
|
||||
|
||||
protected final class Item<T>{
|
||||
public final String title;
|
||||
public final boolean hasSubmenu;
|
||||
|
|
|
@ -28,6 +28,7 @@ import me.grishka.appkit.utils.V;
|
|||
|
||||
public class HomeTimelineHashtagsMenuController extends DropdownSubmenuController{
|
||||
private HideableSingleViewRecyclerAdapter largeProgressAdapter;
|
||||
private HideableSingleViewRecyclerAdapter emptyAdapter;
|
||||
private APIRequest<?> currentRequest;
|
||||
|
||||
public HomeTimelineHashtagsMenuController(ToolbarDropdownMenuController dropdownController){
|
||||
|
@ -39,6 +40,7 @@ public class HomeTimelineHashtagsMenuController extends DropdownSubmenuControlle
|
|||
@Override
|
||||
protected void createView(){
|
||||
super.createView();
|
||||
emptyAdapter=createEmptyView(R.drawable.ic_tag_24px, R.string.no_followed_hashtags_title, R.string.no_followed_hashtags_subtitle);
|
||||
FrameLayout largeProgressView=new FrameLayout(dropdownController.getActivity());
|
||||
int pad=V.dp(32);
|
||||
largeProgressView.setPadding(0, pad, 0, pad);
|
||||
|
@ -47,6 +49,8 @@ public class HomeTimelineHashtagsMenuController extends DropdownSubmenuControlle
|
|||
largeProgressView.addView(progress, new FrameLayout.LayoutParams(V.dp(48), V.dp(48), Gravity.CENTER));
|
||||
largeProgressAdapter=new HideableSingleViewRecyclerAdapter(largeProgressView);
|
||||
mergeAdapter.addAdapter(0, largeProgressAdapter);
|
||||
emptyAdapter.setVisible(false);
|
||||
mergeAdapter.addAdapter(0, emptyAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,6 +93,7 @@ public class HomeTimelineHashtagsMenuController extends DropdownSubmenuControlle
|
|||
}
|
||||
items.add(new Item<Void>(R.string.manage_hashtags, false, true, i->onManageTagsClick()));
|
||||
itemsAdapter.notifyItemRangeInserted(prevSize, result.size()+1);
|
||||
emptyAdapter.setVisible(result.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
|||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.fragments.ManageListsFragment;
|
||||
import org.joinmastodon.android.model.FollowList;
|
||||
import org.joinmastodon.android.ui.utils.HideableSingleViewRecyclerAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -14,6 +15,7 @@ import me.grishka.appkit.Nav;
|
|||
public class HomeTimelineListsMenuController extends DropdownSubmenuController{
|
||||
private final List<FollowList> lists;
|
||||
private final HomeTimelineMenuController.Callback callback;
|
||||
private HideableSingleViewRecyclerAdapter emptyAdapter;
|
||||
|
||||
public HomeTimelineListsMenuController(ToolbarDropdownMenuController dropdownController, HomeTimelineMenuController.Callback callback){
|
||||
super(dropdownController);
|
||||
|
@ -36,6 +38,15 @@ public class HomeTimelineListsMenuController extends DropdownSubmenuController{
|
|||
return dropdownController.getActivity().getString(R.string.lists);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createView(){
|
||||
super.createView();
|
||||
emptyAdapter=createEmptyView(R.drawable.ic_list_alt_24px, R.string.no_lists_title, R.string.no_lists_subtitle);
|
||||
if(lists.isEmpty()){
|
||||
mergeAdapter.addAdapter(0, emptyAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
private void onListSelected(Item<FollowList> item){
|
||||
callback.onListSelected(item.parentObject);
|
||||
dropdownController.dismiss();
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:background="@drawable/white_circle"
|
||||
android:backgroundTint="?colorM3SecondaryContainer"
|
||||
android:tint="?colorM3OnSecondaryContainer"
|
||||
android:scaleType="center"
|
||||
android:importantForAccessibility="no"
|
||||
tools:src="@drawable/ic_list_alt_24px"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?colorM3Outline"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:gravity="center"
|
||||
android:alpha="0.7"
|
||||
tools:text="Title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?colorM3Outline"
|
||||
android:textAppearance="@style/m3_body_small"
|
||||
android:gravity="center"
|
||||
android:alpha="0.7"
|
||||
tools:text="Subtitle"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -641,6 +641,10 @@
|
|||
<string name="manage_user_lists">Manage the lists %s appears on</string>
|
||||
<string name="remove_from_list">Remove from list</string>
|
||||
<string name="confirm_remove_list_member">Remove member?</string>
|
||||
<string name="no_followed_hashtags_title">Keep up with interests by following hashtags</string>
|
||||
<string name="no_followed_hashtags_subtitle">Follows will appear here</string>
|
||||
<string name="no_lists_title">Organize your home feed with Lists</string>
|
||||
<string name="no_lists_subtitle">Yours will appear here</string>
|
||||
<plurals name="x_posts_recently">
|
||||
<item quantity="one">%,d post recently</item>
|
||||
<item quantity="other">%,d posts recently</item>
|
||||
|
|
Loading…
Reference in New Issue