Commit 2e66b1da authored by Thomas's avatar Thomas
Browse files

Fix issue #1152 - Add a pinned Trending timeline (can be hidden in Manage Timelines)

parent 1b711d03
Loading
Loading
Loading
Loading
+41 −11
Original line number Diff line number Diff line
@@ -183,7 +183,8 @@ public class PinnedTimelineHelper {
                }
            }
        }
        if (extraFeatures) {

        //Create other default timelines
        try {
            Pinned pinnedAll = new Pinned(activity).getAllPinned(Helper.getCurrentAccount(activity));
            if (pinnedAll == null) {
@@ -192,6 +193,8 @@ public class PinnedTimelineHelper {
                pinnedAll.instance = currentInstance;
                pinnedAll.pinnedTimelines = new ArrayList<>();
            }
            if (extraFeatures) {
                //Bubble timeline
                boolean createDefaultBubbleAtTop = true;
                for (PinnedTimeline pinnedTimeline : pinnedAll.pinnedTimelines) {
                    if (pinnedTimeline.type == Timeline.TimeLineEnum.BUBBLE) {
@@ -211,10 +214,33 @@ public class PinnedTimelineHelper {
                        new Pinned(activity).insertPinned(pinned);
                    }
                }
            }
            //Trend timeline
            boolean createDefaultTrendAtTop = true;
            for (PinnedTimeline pinnedTimeline : pinnedAll.pinnedTimelines) {
                if (pinnedTimeline.type == Timeline.TimeLineEnum.TREND_MESSAGE) {
                    createDefaultTrendAtTop = false;
                    break;
                }
            }
            if (createDefaultTrendAtTop) {
                PinnedTimeline pinnedTimelineBubble = new PinnedTimeline();
                pinnedTimelineBubble.type = Timeline.TimeLineEnum.TREND_MESSAGE;
                pinnedTimelineBubble.position = pinnedAll.pinnedTimelines != null ? pinnedAll.pinnedTimelines.size() : 0;
                pinned.pinnedTimelines.add(pinnedTimelineBubble);
                boolean exist = new Pinned(activity).pinnedExist(pinned);
                if (exist) {
                    new Pinned(activity).updatePinned(pinned);
                } else {
                    new Pinned(activity).insertPinned(pinned);
                }
            }
        } catch (DBException e) {
            e.printStackTrace();
        }
        }




        sortPositionAsc(pinnedTimelines);
        //Check if changes occurred, if mastodonLists is null it does need, because it is the first call to draw pinned
@@ -413,6 +439,9 @@ public class PinnedTimelineHelper {
                        case BUBBLE:
                            tabCustomDefaultViewBinding.icon.setImageResource(R.drawable.ic_baseline_bubble_chart_24);
                            break;
                        case TREND_MESSAGE:
                            tabCustomDefaultViewBinding.icon.setImageResource(R.drawable.baseline_moving_24);
                            break;
                    }
                    tab.setCustomView(tabCustomDefaultViewBinding.getRoot());
                }
@@ -535,6 +564,7 @@ public class PinnedTimelineHelper {
                        break;
                    case HOME:
                    case LOCAL:
                    case TREND_MESSAGE:
                    case PUBLIC:
                        defaultClick(activity, pinnedTimelineVisibleList.get(position).type, v, activityMainBinding, finalI);
                        break;
+4 −0
Original line number Diff line number Diff line
@@ -150,6 +150,10 @@ public class ReorderTabAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
                holder.binding.icon.setImageResource(R.drawable.ic_baseline_bubble_chart_24);
                holder.binding.text.setText(R.string.bubble);
                break;
            case TREND_MESSAGE:
                holder.binding.icon.setImageResource(R.drawable.baseline_moving_24);
                holder.binding.text.setText(R.string.trending);
                break;
        }


+5 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp"     android:tint="?attr/colorControlNormal" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
      
    <path android:fillColor="@android:color/white" android:pathData="M19.71,9.71L22,12V6h-6l2.29,2.29l-4.17,4.17c-0.39,0.39 -1.02,0.39 -1.41,0l-1.17,-1.17c-1.17,-1.17 -3.07,-1.17 -4.24,0L2,16.59L3.41,18l5.29,-5.29c0.39,-0.39 1.02,-0.39 1.41,0l1.17,1.17c1.17,1.17 3.07,1.17 4.24,0L19.71,9.71z"/>
    
</vector>