2017-01-20 09:09:10 +01:00
|
|
|
/* Copyright 2017 Andrew Dawson
|
|
|
|
*
|
2017-04-10 02:12:31 +02:00
|
|
|
* This file is a part of Tusky.
|
2017-01-20 09:09:10 +01:00
|
|
|
*
|
2017-04-10 02:12:31 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2017-01-20 09:09:10 +01:00
|
|
|
*
|
|
|
|
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
2017-04-10 02:12:31 +02:00
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
2017-01-20 09:09:10 +01:00
|
|
|
*
|
2017-04-10 02:12:31 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
2017-01-20 09:09:10 +01:00
|
|
|
|
2017-05-05 00:55:34 +02:00
|
|
|
package com.keylesspalace.tusky.fragment;
|
2017-01-07 23:24:02 +01:00
|
|
|
|
2017-11-13 19:05:23 +01:00
|
|
|
import android.app.Activity;
|
2017-01-07 23:24:02 +01:00
|
|
|
import android.content.Context;
|
2019-04-12 00:13:06 +02:00
|
|
|
import android.content.DialogInterface;
|
2017-03-11 19:20:10 +01:00
|
|
|
import android.content.SharedPreferences;
|
2017-01-07 23:24:02 +01:00
|
|
|
import android.os.Bundle;
|
2017-05-23 21:34:31 +02:00
|
|
|
import android.util.Log;
|
2019-04-09 19:13:54 +02:00
|
|
|
import android.util.SparseBooleanArray;
|
2017-01-07 23:24:02 +01:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2019-04-09 19:13:54 +02:00
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.ListView;
|
|
|
|
import android.widget.PopupWindow;
|
2018-05-27 10:22:12 +02:00
|
|
|
import android.widget.ProgressBar;
|
2017-01-07 23:24:02 +01:00
|
|
|
|
2019-06-11 16:41:15 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.arch.core.util.Function;
|
|
|
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
|
|
import androidx.core.util.Pair;
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
2019-10-22 21:18:20 +02:00
|
|
|
import androidx.preference.PreferenceManager;
|
2019-06-11 16:41:15 +02:00
|
|
|
import androidx.recyclerview.widget.AsyncDifferConfig;
|
|
|
|
import androidx.recyclerview.widget.AsyncListDiffer;
|
|
|
|
import androidx.recyclerview.widget.DiffUtil;
|
|
|
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
import androidx.recyclerview.widget.ListUpdateCallback;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import androidx.recyclerview.widget.SimpleItemAnimator;
|
|
|
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|
|
|
|
2019-04-09 19:13:54 +02:00
|
|
|
import com.google.android.material.appbar.AppBarLayout;
|
2019-01-28 19:02:31 +01:00
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
2018-03-09 20:39:08 +01:00
|
|
|
import com.keylesspalace.tusky.R;
|
2017-05-05 00:55:34 +02:00
|
|
|
import com.keylesspalace.tusky.adapter.NotificationsAdapter;
|
2019-03-25 13:44:31 +01:00
|
|
|
import com.keylesspalace.tusky.adapter.StatusBaseViewHolder;
|
2018-05-27 10:22:12 +02:00
|
|
|
import com.keylesspalace.tusky.appstore.BlockEvent;
|
2019-11-19 10:15:32 +01:00
|
|
|
import com.keylesspalace.tusky.appstore.BookmarkEvent;
|
2018-08-22 21:18:56 +02:00
|
|
|
import com.keylesspalace.tusky.appstore.EventHub;
|
2018-05-27 10:22:12 +02:00
|
|
|
import com.keylesspalace.tusky.appstore.FavoriteEvent;
|
2018-11-12 21:09:39 +01:00
|
|
|
import com.keylesspalace.tusky.appstore.PreferenceChangedEvent;
|
2018-05-27 10:22:12 +02:00
|
|
|
import com.keylesspalace.tusky.appstore.ReblogEvent;
|
2018-02-03 22:45:14 +01:00
|
|
|
import com.keylesspalace.tusky.db.AccountEntity;
|
|
|
|
import com.keylesspalace.tusky.db.AccountManager;
|
2018-03-27 19:47:00 +02:00
|
|
|
import com.keylesspalace.tusky.di.Injectable;
|
2017-03-09 00:27:37 +01:00
|
|
|
import com.keylesspalace.tusky.entity.Notification;
|
2019-04-22 10:11:00 +02:00
|
|
|
import com.keylesspalace.tusky.entity.Poll;
|
2020-03-19 22:02:10 +01:00
|
|
|
import com.keylesspalace.tusky.entity.Relationship;
|
2017-03-09 00:27:37 +01:00
|
|
|
import com.keylesspalace.tusky.entity.Status;
|
2020-03-19 22:02:10 +01:00
|
|
|
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
2017-08-05 11:34:50 +02:00
|
|
|
import com.keylesspalace.tusky.interfaces.ActionButtonActivity;
|
2019-04-08 15:40:16 +02:00
|
|
|
import com.keylesspalace.tusky.interfaces.ReselectableFragment;
|
2017-05-05 00:55:34 +02:00
|
|
|
import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
2020-12-23 19:13:37 +01:00
|
|
|
import com.keylesspalace.tusky.settings.PrefKeys;
|
2020-03-02 19:34:31 +01:00
|
|
|
import com.keylesspalace.tusky.util.CardViewMode;
|
2017-11-05 17:11:00 +01:00
|
|
|
import com.keylesspalace.tusky.util.Either;
|
2017-06-30 08:31:58 +02:00
|
|
|
import com.keylesspalace.tusky.util.HttpHeaderLink;
|
2019-03-04 19:24:27 +01:00
|
|
|
import com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate;
|
2017-07-15 05:23:14 +02:00
|
|
|
import com.keylesspalace.tusky.util.ListUtils;
|
2019-04-09 19:13:54 +02:00
|
|
|
import com.keylesspalace.tusky.util.NotificationTypeConverterKt;
|
2017-07-12 21:54:52 +02:00
|
|
|
import com.keylesspalace.tusky.util.PairedList;
|
2019-12-30 21:37:20 +01:00
|
|
|
import com.keylesspalace.tusky.util.StatusDisplayOptions;
|
2017-07-12 21:54:52 +02:00
|
|
|
import com.keylesspalace.tusky.util.ViewDataUtils;
|
2019-01-28 19:02:31 +01:00
|
|
|
import com.keylesspalace.tusky.view.BackgroundMessageView;
|
2017-05-29 12:14:09 +02:00
|
|
|
import com.keylesspalace.tusky.view.EndlessOnScrollListener;
|
2017-07-12 21:54:52 +02:00
|
|
|
import com.keylesspalace.tusky.viewdata.NotificationViewData;
|
|
|
|
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
2017-01-07 23:24:02 +01:00
|
|
|
|
2019-01-28 19:02:31 +01:00
|
|
|
import java.io.IOException;
|
2019-03-25 13:44:31 +01:00
|
|
|
import java.util.ArrayList;
|
2019-09-17 18:44:33 +02:00
|
|
|
import java.util.Collections;
|
2019-04-09 19:13:54 +02:00
|
|
|
import java.util.HashSet;
|
2017-07-12 21:54:52 +02:00
|
|
|
import java.util.Iterator;
|
2017-01-07 23:24:02 +01:00
|
|
|
import java.util.List;
|
2018-05-27 10:22:12 +02:00
|
|
|
import java.util.Objects;
|
2019-04-09 19:13:54 +02:00
|
|
|
import java.util.Set;
|
2019-03-25 13:44:31 +01:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2017-01-07 23:24:02 +01:00
|
|
|
|
2018-03-27 19:47:00 +02:00
|
|
|
import javax.inject.Inject;
|
|
|
|
|
2019-03-07 19:31:18 +01:00
|
|
|
import at.connyduck.sparkbutton.helpers.Utils;
|
2019-03-25 13:44:31 +01:00
|
|
|
import io.reactivex.Observable;
|
2020-03-19 22:02:10 +01:00
|
|
|
import io.reactivex.Single;
|
2018-05-27 10:22:12 +02:00
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
2021-01-31 19:34:33 +01:00
|
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
|
|
import io.reactivex.disposables.Disposable;
|
2019-01-28 19:02:31 +01:00
|
|
|
import kotlin.Unit;
|
2019-01-11 22:07:40 +01:00
|
|
|
import kotlin.collections.CollectionsKt;
|
2019-04-21 08:24:06 +02:00
|
|
|
import kotlin.jvm.functions.Function1;
|
2017-03-09 00:27:37 +01:00
|
|
|
|
2019-01-31 19:03:34 +01:00
|
|
|
import static com.keylesspalace.tusky.util.StringUtils.isLessThan;
|
2018-05-27 10:22:12 +02:00
|
|
|
import static com.uber.autodispose.AutoDispose.autoDisposable;
|
|
|
|
import static com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider.from;
|
|
|
|
|
2017-01-23 00:42:05 +01:00
|
|
|
public class NotificationsFragment extends SFragment implements
|
2018-03-27 19:47:00 +02:00
|
|
|
SwipeRefreshLayout.OnRefreshListener,
|
|
|
|
StatusActionListener,
|
2017-06-06 23:15:29 +02:00
|
|
|
NotificationsAdapter.NotificationActionListener,
|
2020-03-19 22:02:10 +01:00
|
|
|
AccountActionListener,
|
2019-04-08 15:40:16 +02:00
|
|
|
Injectable, ReselectableFragment {
|
2017-11-03 22:17:31 +01:00
|
|
|
private static final String TAG = "NotificationF"; // logging tag
|
|
|
|
|
|
|
|
private static final int LOAD_AT_ONCE = 30;
|
2019-03-07 19:31:18 +01:00
|
|
|
private int maxPlaceholderId = 0;
|
2017-02-07 08:05:50 +01:00
|
|
|
|
2021-01-31 19:34:33 +01:00
|
|
|
private final Set<Notification.Type> notificationFilter = new HashSet<>();
|
2019-04-09 19:13:54 +02:00
|
|
|
|
2021-01-31 19:34:33 +01:00
|
|
|
private final CompositeDisposable disposables = new CompositeDisposable();
|
2019-04-09 19:13:54 +02:00
|
|
|
|
2017-06-30 08:31:58 +02:00
|
|
|
private enum FetchEnd {
|
|
|
|
TOP,
|
2017-11-03 22:17:31 +01:00
|
|
|
BOTTOM,
|
|
|
|
MIDDLE
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
|
|
|
|
2017-11-05 17:11:00 +01:00
|
|
|
/**
|
2018-02-03 22:45:14 +01:00
|
|
|
* Placeholder for the notificationsEnabled. Consider moving to the separate class to hide constructor
|
2017-11-05 17:11:00 +01:00
|
|
|
* and reuse in different places as needed.
|
|
|
|
*/
|
|
|
|
private static final class Placeholder {
|
2019-03-07 19:31:18 +01:00
|
|
|
final long id;
|
2017-11-05 17:11:00 +01:00
|
|
|
|
2019-03-07 19:31:18 +01:00
|
|
|
public static Placeholder getInstance(long id) {
|
|
|
|
return new Placeholder(id);
|
2017-11-05 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
2019-03-07 19:31:18 +01:00
|
|
|
private Placeholder(long id) {
|
|
|
|
this.id = id;
|
2017-11-05 17:11:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-27 19:47:00 +02:00
|
|
|
@Inject
|
2018-04-22 17:20:01 +02:00
|
|
|
AccountManager accountManager;
|
2018-05-27 10:22:12 +02:00
|
|
|
@Inject
|
|
|
|
EventHub eventHub;
|
2018-03-27 19:47:00 +02:00
|
|
|
|
2017-01-07 23:24:02 +01:00
|
|
|
private SwipeRefreshLayout swipeRefreshLayout;
|
2017-04-22 10:41:49 +02:00
|
|
|
private RecyclerView recyclerView;
|
2018-05-27 10:22:12 +02:00
|
|
|
private ProgressBar progressBar;
|
2019-01-28 19:02:31 +01:00
|
|
|
private BackgroundMessageView statusView;
|
2019-04-09 19:13:54 +02:00
|
|
|
private AppBarLayout appBarOptions;
|
2018-05-27 10:22:12 +02:00
|
|
|
|
|
|
|
private LinearLayoutManager layoutManager;
|
2017-02-13 06:18:17 +01:00
|
|
|
private EndlessOnScrollListener scrollListener;
|
2017-01-07 23:24:02 +01:00
|
|
|
private NotificationsAdapter adapter;
|
2019-04-09 19:13:54 +02:00
|
|
|
private Button buttonFilter;
|
2017-04-22 10:41:49 +02:00
|
|
|
private boolean hideFab;
|
2017-06-30 08:31:58 +02:00
|
|
|
private boolean topLoading;
|
|
|
|
private boolean bottomLoading;
|
2017-07-12 21:54:52 +02:00
|
|
|
private String bottomId;
|
2017-11-30 20:12:09 +01:00
|
|
|
private boolean alwaysShowSensitiveMedia;
|
2019-07-28 19:59:52 +02:00
|
|
|
private boolean alwaysOpenSpoiler;
|
2019-06-11 16:41:15 +02:00
|
|
|
private boolean showNotificationsFilter;
|
2020-02-25 19:57:28 +01:00
|
|
|
private boolean showingError;
|
2017-07-12 21:54:52 +02:00
|
|
|
|
2017-11-05 17:11:00 +01:00
|
|
|
// Each element is either a Notification for loading data or a Placeholder
|
|
|
|
private final PairedList<Either<Placeholder, Notification>, NotificationViewData> notifications
|
|
|
|
= new PairedList<>(new Function<Either<Placeholder, Notification>, NotificationViewData>() {
|
2017-07-12 21:54:52 +02:00
|
|
|
@Override
|
2017-11-05 17:11:00 +01:00
|
|
|
public NotificationViewData apply(Either<Placeholder, Notification> input) {
|
|
|
|
if (input.isRight()) {
|
2020-12-23 12:52:39 +01:00
|
|
|
Notification notification = input.asRight()
|
|
|
|
.rewriteToStatusTypeIfNeeded(accountManager.getActiveAccount().getAccountId());
|
|
|
|
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
return ViewDataUtils.notificationToViewData(
|
|
|
|
notification,
|
2019-07-28 19:59:52 +02:00
|
|
|
alwaysShowSensitiveMedia,
|
|
|
|
alwaysOpenSpoiler
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
);
|
2017-11-05 17:11:00 +01:00
|
|
|
} else {
|
2019-03-07 19:31:18 +01:00
|
|
|
return new NotificationViewData.Placeholder(input.asLeft().id, false);
|
2017-11-05 17:11:00 +01:00
|
|
|
}
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-07 23:24:02 +01:00
|
|
|
|
|
|
|
public static NotificationsFragment newInstance() {
|
|
|
|
NotificationsFragment fragment = new NotificationsFragment();
|
|
|
|
Bundle arguments = new Bundle();
|
|
|
|
fragment.setArguments(arguments);
|
|
|
|
return fragment;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
2017-11-13 19:05:23 +01:00
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
2017-04-22 10:41:49 +02:00
|
|
|
@Nullable Bundle savedInstanceState) {
|
2019-04-09 19:13:54 +02:00
|
|
|
View rootView = inflater.inflate(R.layout.fragment_timeline_notifications, container, false);
|
2017-01-07 23:24:02 +01:00
|
|
|
|
2017-11-13 19:05:23 +01:00
|
|
|
@NonNull Context context = inflater.getContext(); // from inflater to silence warning
|
2019-06-11 16:41:15 +02:00
|
|
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
|
|
|
|
|
|
|
boolean showNotificationsFilterSetting = preferences.getBoolean("showNotificationsFilter", true);
|
|
|
|
//Clear notifications on filter visibility change to force refresh
|
|
|
|
if (showNotificationsFilterSetting != showNotificationsFilter)
|
|
|
|
notifications.clear();
|
|
|
|
showNotificationsFilter = showNotificationsFilterSetting;
|
|
|
|
|
2017-01-07 23:24:02 +01:00
|
|
|
// Setup the SwipeRefreshLayout.
|
2019-02-12 19:22:37 +01:00
|
|
|
swipeRefreshLayout = rootView.findViewById(R.id.swipeRefreshLayout);
|
|
|
|
recyclerView = rootView.findViewById(R.id.recyclerView);
|
|
|
|
progressBar = rootView.findViewById(R.id.progressBar);
|
2019-01-28 19:02:31 +01:00
|
|
|
statusView = rootView.findViewById(R.id.statusView);
|
2019-04-09 19:13:54 +02:00
|
|
|
appBarOptions = rootView.findViewById(R.id.appBarOptions);
|
2018-05-27 10:22:12 +02:00
|
|
|
|
2017-01-07 23:24:02 +01:00
|
|
|
swipeRefreshLayout.setOnRefreshListener(this);
|
2018-12-17 15:25:35 +01:00
|
|
|
swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue);
|
2019-04-09 19:13:54 +02:00
|
|
|
|
|
|
|
loadNotificationsFilter();
|
|
|
|
|
2017-01-07 23:24:02 +01:00
|
|
|
// Setup the RecyclerView.
|
|
|
|
recyclerView.setHasFixedSize(true);
|
2017-02-13 06:18:17 +01:00
|
|
|
layoutManager = new LinearLayoutManager(context);
|
2017-01-07 23:24:02 +01:00
|
|
|
recyclerView.setLayoutManager(layoutManager);
|
2019-03-04 19:24:27 +01:00
|
|
|
recyclerView.setAccessibilityDelegateCompat(
|
|
|
|
new ListStatusAccessibilityDelegate(recyclerView, this, (pos) -> {
|
2019-04-07 16:32:58 +02:00
|
|
|
NotificationViewData notification = notifications.getPairedItemOrNull(pos);
|
2019-03-04 19:24:27 +01:00
|
|
|
// We support replies only for now
|
|
|
|
if (notification instanceof NotificationViewData.Concrete) {
|
|
|
|
return ((NotificationViewData.Concrete) notification).getStatusViewData();
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}));
|
2019-02-26 18:28:20 +01:00
|
|
|
|
|
|
|
recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
|
2017-04-22 10:41:49 +02:00
|
|
|
|
2019-12-30 21:37:20 +01:00
|
|
|
StatusDisplayOptions statusDisplayOptions = new StatusDisplayOptions(
|
|
|
|
preferences.getBoolean("animateGifAvatars", false),
|
|
|
|
accountManager.getActiveAccount().getMediaPreviewEnabled(),
|
|
|
|
preferences.getBoolean("absoluteTimeView", false),
|
|
|
|
preferences.getBoolean("showBotOverlay", true),
|
2020-03-02 19:34:31 +01:00
|
|
|
preferences.getBoolean("useBlurhash", true),
|
2020-03-03 21:27:26 +01:00
|
|
|
CardViewMode.NONE,
|
2020-12-23 19:13:37 +01:00
|
|
|
preferences.getBoolean("confirmReblogs", true),
|
|
|
|
preferences.getBoolean(PrefKeys.WELLBEING_HIDE_STATS_POSTS, false)
|
2019-12-30 21:37:20 +01:00
|
|
|
);
|
|
|
|
|
2019-05-02 19:44:35 +02:00
|
|
|
adapter = new NotificationsAdapter(accountManager.getActiveAccount().getAccountId(),
|
2020-03-19 22:02:10 +01:00
|
|
|
dataSource, statusDisplayOptions, this, this, this);
|
2018-11-12 21:09:39 +01:00
|
|
|
alwaysShowSensitiveMedia = accountManager.getActiveAccount().getAlwaysShowSensitiveMedia();
|
2019-07-28 19:59:52 +02:00
|
|
|
alwaysOpenSpoiler = accountManager.getActiveAccount().getAlwaysOpenSpoiler();
|
2017-01-07 23:24:02 +01:00
|
|
|
recyclerView.setAdapter(adapter);
|
|
|
|
|
2017-07-14 23:09:44 +02:00
|
|
|
topLoading = false;
|
|
|
|
bottomLoading = false;
|
|
|
|
bottomId = null;
|
|
|
|
|
2019-03-13 09:32:59 +01:00
|
|
|
updateAdapter();
|
|
|
|
|
2019-04-09 19:13:54 +02:00
|
|
|
Button buttonClear = rootView.findViewById(R.id.buttonClear);
|
2019-04-12 00:13:06 +02:00
|
|
|
buttonClear.setOnClickListener(v -> confirmClearNotifications());
|
2019-04-09 19:13:54 +02:00
|
|
|
buttonFilter = rootView.findViewById(R.id.buttonFilter);
|
|
|
|
buttonFilter.setOnClickListener(v -> showFilterMenu());
|
|
|
|
|
2019-03-13 09:32:59 +01:00
|
|
|
if (notifications.isEmpty()) {
|
2019-09-03 18:34:00 +02:00
|
|
|
swipeRefreshLayout.setEnabled(false);
|
2019-03-13 09:32:59 +01:00
|
|
|
sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1);
|
|
|
|
} else {
|
|
|
|
progressBar.setVisibility(View.GONE);
|
|
|
|
}
|
2018-05-27 10:22:12 +02:00
|
|
|
|
2019-03-13 09:32:59 +01:00
|
|
|
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
|
2018-08-22 21:18:56 +02:00
|
|
|
|
2019-06-11 16:41:15 +02:00
|
|
|
updateFilterVisibility();
|
|
|
|
|
2017-06-26 11:15:47 +02:00
|
|
|
return rootView;
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:41:15 +02:00
|
|
|
private void updateFilterVisibility() {
|
|
|
|
CoordinatorLayout.LayoutParams params =
|
|
|
|
(CoordinatorLayout.LayoutParams) swipeRefreshLayout.getLayoutParams();
|
2020-05-30 10:10:47 +02:00
|
|
|
if (showNotificationsFilter && !showingError) {
|
2019-06-11 16:41:15 +02:00
|
|
|
appBarOptions.setExpanded(true, false);
|
|
|
|
appBarOptions.setVisibility(View.VISIBLE);
|
|
|
|
//Set content behaviour to hide filter on scroll
|
|
|
|
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
|
|
|
} else {
|
|
|
|
appBarOptions.setExpanded(false, false);
|
|
|
|
appBarOptions.setVisibility(View.GONE);
|
|
|
|
//Clear behaviour to hide app bar
|
|
|
|
params.setBehavior(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void confirmClearNotifications() {
|
2019-05-03 20:41:55 +02:00
|
|
|
new AlertDialog.Builder(getContext())
|
|
|
|
.setMessage(R.string.notification_clear_text)
|
|
|
|
.setPositiveButton(android.R.string.yes, (DialogInterface dia, int which) -> clearNotifications())
|
|
|
|
.setNegativeButton(android.R.string.no, null)
|
|
|
|
.show();
|
2019-04-12 00:13:06 +02:00
|
|
|
}
|
|
|
|
|
2018-05-27 10:22:12 +02:00
|
|
|
private void handleFavEvent(FavoriteEvent event) {
|
|
|
|
Pair<Integer, Notification> posAndNotification =
|
|
|
|
findReplyPosition(event.getStatusId());
|
|
|
|
if (posAndNotification == null) return;
|
|
|
|
//noinspection ConstantConditions
|
2019-05-03 20:42:13 +02:00
|
|
|
setFavouriteForStatus(posAndNotification.first,
|
2018-05-27 10:22:12 +02:00
|
|
|
posAndNotification.second.getStatus(),
|
|
|
|
event.getFavourite());
|
|
|
|
}
|
|
|
|
|
2019-11-19 10:15:32 +01:00
|
|
|
private void handleBookmarkEvent(BookmarkEvent event) {
|
|
|
|
Pair<Integer, Notification> posAndNotification =
|
|
|
|
findReplyPosition(event.getStatusId());
|
|
|
|
if (posAndNotification == null) return;
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
setBookmarkForStatus(posAndNotification.first,
|
|
|
|
posAndNotification.second.getStatus(),
|
|
|
|
event.getBookmark());
|
|
|
|
}
|
|
|
|
|
2018-05-27 10:22:12 +02:00
|
|
|
private void handleReblogEvent(ReblogEvent event) {
|
|
|
|
Pair<Integer, Notification> posAndNotification = findReplyPosition(event.getStatusId());
|
|
|
|
if (posAndNotification == null) return;
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
setReblogForStatus(posAndNotification.first,
|
|
|
|
posAndNotification.second.getStatus(),
|
|
|
|
event.getReblog());
|
|
|
|
}
|
|
|
|
|
2017-06-26 11:15:47 +02:00
|
|
|
@Override
|
|
|
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
|
|
super.onActivityCreated(savedInstanceState);
|
2019-04-08 15:40:16 +02:00
|
|
|
Activity activity = getActivity();
|
2017-11-13 19:05:23 +01:00
|
|
|
if (activity == null) throw new AssertionError("Activity is null");
|
2017-06-26 11:15:47 +02:00
|
|
|
|
2017-04-22 10:41:49 +02:00
|
|
|
/* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't
|
|
|
|
* guaranteed to be set until then.
|
2018-02-03 22:45:14 +01:00
|
|
|
* Use a modified scroll listener that both loads more notificationsEnabled as it goes, and hides
|
2017-04-22 10:41:49 +02:00
|
|
|
* the compose button on down-scroll. */
|
2017-08-05 11:34:50 +02:00
|
|
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
2017-04-22 10:41:49 +02:00
|
|
|
hideFab = preferences.getBoolean("fabHide", false);
|
|
|
|
scrollListener = new EndlessOnScrollListener(layoutManager) {
|
|
|
|
@Override
|
2019-05-03 20:42:13 +02:00
|
|
|
public void onScrolled(@NonNull RecyclerView view, int dx, int dy) {
|
2017-04-22 10:41:49 +02:00
|
|
|
super.onScrolled(view, dx, dy);
|
|
|
|
|
2017-08-05 11:34:50 +02:00
|
|
|
ActionButtonActivity activity = (ActionButtonActivity) getActivity();
|
|
|
|
FloatingActionButton composeButton = activity.getActionButton();
|
|
|
|
|
2017-11-05 17:11:00 +01:00
|
|
|
if (composeButton != null) {
|
2017-08-04 11:44:10 +02:00
|
|
|
if (hideFab) {
|
|
|
|
if (dy > 0 && composeButton.isShown()) {
|
|
|
|
composeButton.hide(); // hides the button if we're scrolling down
|
|
|
|
} else if (dy < 0 && !composeButton.isShown()) {
|
|
|
|
composeButton.show(); // shows it if we are scrolling up
|
|
|
|
}
|
|
|
|
} else if (!composeButton.isShown()) {
|
|
|
|
composeButton.show();
|
2017-04-22 10:41:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-05-27 10:22:12 +02:00
|
|
|
public void onLoadMore(int totalItemsCount, RecyclerView view) {
|
2017-07-12 21:54:52 +02:00
|
|
|
NotificationsFragment.this.onLoadMore();
|
2017-04-22 10:41:49 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
recyclerView.addOnScrollListener(scrollListener);
|
2018-07-12 21:21:53 +02:00
|
|
|
|
|
|
|
eventHub.getEvents()
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY)))
|
|
|
|
.subscribe(event -> {
|
|
|
|
if (event instanceof FavoriteEvent) {
|
|
|
|
handleFavEvent((FavoriteEvent) event);
|
2019-11-19 10:15:32 +01:00
|
|
|
} else if (event instanceof BookmarkEvent) {
|
|
|
|
handleBookmarkEvent((BookmarkEvent) event);
|
2018-07-12 21:21:53 +02:00
|
|
|
} else if (event instanceof ReblogEvent) {
|
|
|
|
handleReblogEvent((ReblogEvent) event);
|
|
|
|
} else if (event instanceof BlockEvent) {
|
|
|
|
removeAllByAccountId(((BlockEvent) event).getAccountId());
|
2018-11-12 21:09:39 +01:00
|
|
|
} else if (event instanceof PreferenceChangedEvent) {
|
|
|
|
onPreferenceChanged(((PreferenceChangedEvent) event).getPreferenceKey());
|
2018-07-12 21:21:53 +02:00
|
|
|
}
|
|
|
|
});
|
2017-04-22 10:41:49 +02:00
|
|
|
}
|
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2017-01-07 23:24:02 +01:00
|
|
|
public void onRefresh() {
|
2019-01-28 19:02:31 +01:00
|
|
|
this.statusView.setVisibility(View.GONE);
|
2020-02-25 19:57:28 +01:00
|
|
|
this.showingError = false;
|
2019-01-11 22:07:40 +01:00
|
|
|
Either<Placeholder, Notification> first = CollectionsKt.firstOrNull(this.notifications);
|
|
|
|
String topId;
|
|
|
|
if (first != null && first.isRight()) {
|
2019-01-14 22:29:12 +01:00
|
|
|
topId = first.asRight().getId();
|
2019-01-11 22:07:40 +01:00
|
|
|
} else {
|
|
|
|
topId = null;
|
|
|
|
}
|
2017-11-03 22:17:31 +01:00
|
|
|
sendFetchNotificationsRequest(null, topId, FetchEnd.TOP, -1);
|
2017-01-23 00:42:05 +01:00
|
|
|
}
|
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2017-01-23 00:42:05 +01:00
|
|
|
public void onReply(int position) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
super.reply(notifications.get(position).asRight().getStatus());
|
2017-01-23 00:42:05 +01:00
|
|
|
}
|
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2017-10-27 23:39:36 +02:00
|
|
|
public void onReblog(final boolean reblog, final int position) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
final Notification notification = notifications.get(position).asRight();
|
2018-03-03 13:24:03 +01:00
|
|
|
final Status status = notification.getStatus();
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Objects.requireNonNull(status, "Reblog on notification without status");
|
|
|
|
timelineCases.reblog(status, reblog)
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this)))
|
|
|
|
.subscribe(
|
|
|
|
(newStatus) -> setReblogForStatus(position, status, reblog),
|
|
|
|
(t) -> Log.d(getClass().getSimpleName(),
|
|
|
|
"Failed to reblog status: " + status.getId(), t)
|
|
|
|
);
|
2017-01-23 00:42:05 +01:00
|
|
|
}
|
|
|
|
|
2018-05-27 10:22:12 +02:00
|
|
|
private void setReblogForStatus(int position, Status status, boolean reblog) {
|
|
|
|
status.setReblogged(reblog);
|
|
|
|
|
|
|
|
if (status.getReblog() != null) {
|
|
|
|
status.getReblog().setReblogged(reblog);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationViewData.Concrete viewdata = (NotificationViewData.Concrete) notifications.getPairedItem(position);
|
|
|
|
|
|
|
|
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
|
|
|
|
viewDataBuilder.setReblogged(reblog);
|
|
|
|
|
|
|
|
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
|
|
|
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
2020-04-18 13:45:07 +02:00
|
|
|
viewDataBuilder.createStatusViewData());
|
2018-05-27 10:22:12 +02:00
|
|
|
|
|
|
|
notifications.setPairedItem(position, newViewData);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2018-05-27 10:22:12 +02:00
|
|
|
}
|
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2017-10-27 23:39:36 +02:00
|
|
|
public void onFavourite(final boolean favourite, final int position) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
final Notification notification = notifications.get(position).asRight();
|
2018-03-03 13:24:03 +01:00
|
|
|
final Status status = notification.getStatus();
|
2017-10-27 23:39:36 +02:00
|
|
|
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
timelineCases.favourite(status, favourite)
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this)))
|
|
|
|
.subscribe(
|
2019-05-03 20:42:13 +02:00
|
|
|
(newStatus) -> setFavouriteForStatus(position, status, favourite),
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
(t) -> Log.d(getClass().getSimpleName(),
|
|
|
|
"Failed to favourite status: " + status.getId(), t)
|
|
|
|
);
|
2017-01-23 00:42:05 +01:00
|
|
|
}
|
|
|
|
|
2019-05-03 20:42:13 +02:00
|
|
|
private void setFavouriteForStatus(int position, Status status, boolean favourite) {
|
2018-05-27 10:22:12 +02:00
|
|
|
status.setFavourited(favourite);
|
|
|
|
|
|
|
|
if (status.getReblog() != null) {
|
|
|
|
status.getReblog().setFavourited(favourite);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationViewData.Concrete viewdata = (NotificationViewData.Concrete) notifications.getPairedItem(position);
|
|
|
|
|
|
|
|
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
|
|
|
|
viewDataBuilder.setFavourited(favourite);
|
|
|
|
|
|
|
|
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
|
|
|
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
2020-04-18 13:45:07 +02:00
|
|
|
viewDataBuilder.createStatusViewData());
|
2019-11-19 10:15:32 +01:00
|
|
|
|
|
|
|
notifications.setPairedItem(position, newViewData);
|
|
|
|
updateAdapter();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBookmark(final boolean bookmark, final int position) {
|
|
|
|
final Notification notification = notifications.get(position).asRight();
|
|
|
|
final Status status = notification.getStatus();
|
|
|
|
|
|
|
|
timelineCases.bookmark(status, bookmark)
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this)))
|
|
|
|
.subscribe(
|
|
|
|
(newStatus) -> setBookmarkForStatus(position, status, bookmark),
|
|
|
|
(t) -> Log.d(getClass().getSimpleName(),
|
|
|
|
"Failed to bookmark status: " + status.getId(), t)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setBookmarkForStatus(int position, Status status, boolean bookmark) {
|
|
|
|
status.setBookmarked(bookmark);
|
|
|
|
|
|
|
|
if (status.getReblog() != null) {
|
|
|
|
status.getReblog().setBookmarked(bookmark);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationViewData.Concrete viewdata = (NotificationViewData.Concrete) notifications.getPairedItem(position);
|
|
|
|
|
|
|
|
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
|
|
|
|
viewDataBuilder.setBookmarked(bookmark);
|
|
|
|
|
|
|
|
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
|
|
|
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
2020-04-18 13:45:07 +02:00
|
|
|
viewDataBuilder.createStatusViewData());
|
2018-05-27 10:22:12 +02:00
|
|
|
|
|
|
|
notifications.setPairedItem(position, newViewData);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2018-05-27 10:22:12 +02:00
|
|
|
}
|
|
|
|
|
2019-04-22 10:11:00 +02:00
|
|
|
public void onVoteInPoll(int position, @NonNull List<Integer> choices) {
|
|
|
|
final Notification notification = notifications.get(position).asRight();
|
|
|
|
final Status status = notification.getStatus();
|
|
|
|
|
|
|
|
timelineCases.voteInPoll(status, choices)
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this)))
|
|
|
|
.subscribe(
|
|
|
|
(newPoll) -> setVoteForPoll(position, newPoll),
|
|
|
|
(t) -> Log.d(TAG,
|
|
|
|
"Failed to vote in poll: " + status.getId(), t)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setVoteForPoll(int position, Poll poll) {
|
2019-05-03 20:42:13 +02:00
|
|
|
|
|
|
|
NotificationViewData.Concrete viewdata = (NotificationViewData.Concrete) notifications.getPairedItem(position);
|
|
|
|
|
|
|
|
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
|
|
|
|
viewDataBuilder.setPoll(poll);
|
|
|
|
|
|
|
|
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
|
|
|
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
2020-04-18 13:45:07 +02:00
|
|
|
viewDataBuilder.createStatusViewData());
|
2019-05-03 20:42:13 +02:00
|
|
|
|
|
|
|
notifications.setPairedItem(position, newViewData);
|
|
|
|
updateAdapter();
|
2019-04-22 10:11:00 +02:00
|
|
|
}
|
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2019-02-12 19:22:37 +01:00
|
|
|
public void onMore(@NonNull View view, int position) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification notification = notifications.get(position).asRight();
|
2018-03-03 13:24:03 +01:00
|
|
|
super.more(notification.getStatus(), view, position);
|
2017-01-23 00:42:05 +01:00
|
|
|
}
|
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2019-05-03 20:42:13 +02:00
|
|
|
public void onViewMedia(int position, int attachmentIndex, @Nullable View view) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification notification = notifications.get(position).asRightOrNull();
|
2018-05-10 20:13:25 +02:00
|
|
|
if (notification == null || notification.getStatus() == null) return;
|
|
|
|
super.viewMedia(attachmentIndex, notification.getStatus(), view);
|
2017-01-23 00:42:05 +01:00
|
|
|
}
|
2017-01-23 06:19:30 +01:00
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2017-01-23 06:19:30 +01:00
|
|
|
public void onViewThread(int position) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification notification = notifications.get(position).asRight();
|
2018-03-03 13:24:03 +01:00
|
|
|
super.viewThread(notification.getStatus());
|
2017-01-23 06:19:30 +01:00
|
|
|
}
|
2017-01-27 01:34:32 +01:00
|
|
|
|
2017-06-28 10:10:56 +02:00
|
|
|
@Override
|
|
|
|
public void onOpenReblog(int position) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification notification = notifications.get(position).asRight();
|
2018-03-03 13:24:03 +01:00
|
|
|
onViewAccount(notification.getAccount().getId());
|
2017-06-28 10:10:56 +02:00
|
|
|
}
|
|
|
|
|
2017-07-12 21:54:52 +02:00
|
|
|
@Override
|
|
|
|
public void onExpandedChange(boolean expanded, int position) {
|
2017-11-05 17:11:00 +01:00
|
|
|
NotificationViewData.Concrete old =
|
|
|
|
(NotificationViewData.Concrete) notifications.getPairedItem(position);
|
2017-11-06 16:19:15 +01:00
|
|
|
StatusViewData.Concrete statusViewData =
|
2017-07-12 21:54:52 +02:00
|
|
|
new StatusViewData.Builder(old.getStatusViewData())
|
|
|
|
.setIsExpanded(expanded)
|
|
|
|
.createStatusViewData();
|
2017-11-05 17:11:00 +01:00
|
|
|
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(),
|
2020-04-18 13:45:07 +02:00
|
|
|
old.getId(), old.getAccount(), statusViewData);
|
2017-07-12 21:54:52 +02:00
|
|
|
notifications.setPairedItem(position, notificationViewData);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onContentHiddenChange(boolean isShowing, int position) {
|
2017-11-05 17:11:00 +01:00
|
|
|
NotificationViewData.Concrete old =
|
|
|
|
(NotificationViewData.Concrete) notifications.getPairedItem(position);
|
2017-11-06 16:19:15 +01:00
|
|
|
StatusViewData.Concrete statusViewData =
|
2017-07-12 21:54:52 +02:00
|
|
|
new StatusViewData.Builder(old.getStatusViewData())
|
|
|
|
.setIsShowingSensitiveContent(isShowing)
|
|
|
|
.createStatusViewData();
|
2017-11-05 17:11:00 +01:00
|
|
|
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(),
|
2020-04-18 13:45:07 +02:00
|
|
|
old.getId(), old.getAccount(), statusViewData);
|
2017-07-12 21:54:52 +02:00
|
|
|
notifications.setPairedItem(position, notificationViewData);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
|
2017-11-03 22:17:31 +01:00
|
|
|
@Override
|
|
|
|
public void onLoadMore(int position) {
|
|
|
|
//check bounds before accessing list,
|
|
|
|
if (notifications.size() >= position && position > 0) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification previous = notifications.get(position - 1).asRightOrNull();
|
|
|
|
Notification next = notifications.get(position + 1).asRightOrNull();
|
2017-11-06 16:19:15 +01:00
|
|
|
if (previous == null || next == null) {
|
|
|
|
Log.e(TAG, "Failed to load more, invalid placeholder position: " + position);
|
|
|
|
return;
|
|
|
|
}
|
2018-03-03 13:24:03 +01:00
|
|
|
sendFetchNotificationsRequest(previous.getId(), next.getId(), FetchEnd.MIDDLE, position);
|
2019-03-07 19:31:18 +01:00
|
|
|
Placeholder placeholder = notifications.get(position).asLeft();
|
2017-11-05 17:11:00 +01:00
|
|
|
NotificationViewData notificationViewData =
|
2019-03-07 19:31:18 +01:00
|
|
|
new NotificationViewData.Placeholder(placeholder.id, true);
|
2017-11-03 22:17:31 +01:00
|
|
|
notifications.setPairedItem(position, notificationViewData);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-11-03 22:17:31 +01:00
|
|
|
} else {
|
|
|
|
Log.d(TAG, "error loading more");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
@Override
|
|
|
|
public void onContentCollapsedChange(boolean isCollapsed, int position) {
|
|
|
|
if (position < 0 || position >= notifications.size()) {
|
|
|
|
Log.e(TAG, String.format("Tried to access out of bounds status position: %d of %d", position, notifications.size() - 1));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationViewData notification = notifications.getPairedItem(position);
|
|
|
|
if (!(notification instanceof NotificationViewData.Concrete)) {
|
|
|
|
Log.e(TAG, String.format(
|
|
|
|
"Expected NotificationViewData.Concrete, got %s instead at position: %d of %d",
|
|
|
|
notification == null ? "null" : notification.getClass().getSimpleName(),
|
|
|
|
position,
|
|
|
|
notifications.size() - 1
|
|
|
|
));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusViewData.Concrete status = ((NotificationViewData.Concrete) notification).getStatusViewData();
|
|
|
|
StatusViewData.Concrete updatedStatus = new StatusViewData.Builder(status)
|
|
|
|
.setCollapsed(isCollapsed)
|
|
|
|
.createStatusViewData();
|
|
|
|
|
|
|
|
NotificationViewData.Concrete concreteNotification = (NotificationViewData.Concrete) notification;
|
|
|
|
NotificationViewData updatedNotification = new NotificationViewData.Concrete(
|
|
|
|
concreteNotification.getType(),
|
|
|
|
concreteNotification.getId(),
|
|
|
|
concreteNotification.getAccount(),
|
2020-04-18 13:45:07 +02:00
|
|
|
updatedStatus
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
);
|
|
|
|
notifications.setPairedItem(position, updatedNotification);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
|
|
|
|
// Since we cannot notify to the RecyclerView right away because it may be scrolling
|
|
|
|
// we run this when the RecyclerView is done doing measurements and other calculations.
|
|
|
|
// To test this is not bs: try getting a notification while scrolling, without wrapping
|
|
|
|
// notifyItemChanged in a .post() call. App will crash.
|
|
|
|
recyclerView.post(() -> adapter.notifyItemChanged(position, notification));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNotificationContentCollapsedChange(boolean isCollapsed, int position) {
|
|
|
|
onContentCollapsedChange(isCollapsed, position);
|
|
|
|
}
|
|
|
|
|
2019-04-09 19:13:54 +02:00
|
|
|
private void clearNotifications() {
|
|
|
|
//Cancel all ongoing requests
|
|
|
|
swipeRefreshLayout.setRefreshing(false);
|
2019-06-11 16:41:15 +02:00
|
|
|
resetNotificationsLoad();
|
2019-04-09 19:13:54 +02:00
|
|
|
|
|
|
|
//Show friend elephant
|
|
|
|
this.statusView.setVisibility(View.VISIBLE);
|
|
|
|
this.statusView.setup(R.drawable.elephant_friend_empty, R.string.message_empty, null);
|
2020-02-25 19:57:28 +01:00
|
|
|
updateFilterVisibility();
|
2019-04-09 19:13:54 +02:00
|
|
|
|
|
|
|
//Update adapter
|
|
|
|
updateAdapter();
|
|
|
|
|
|
|
|
//Execute clear notifications request
|
2021-01-31 19:34:33 +01:00
|
|
|
mastodonApi.clearNotifications()
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY)))
|
|
|
|
.subscribe(
|
|
|
|
response -> {
|
|
|
|
// nothing to do
|
|
|
|
},
|
|
|
|
throwable -> {
|
|
|
|
//Reload notifications on failure
|
|
|
|
fullyRefreshWithProgressBar(true);
|
|
|
|
});
|
2019-04-09 19:13:54 +02:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:41:15 +02:00
|
|
|
private void resetNotificationsLoad() {
|
2021-01-31 19:34:33 +01:00
|
|
|
disposables.clear();
|
2019-06-11 16:41:15 +02:00
|
|
|
bottomLoading = false;
|
|
|
|
topLoading = false;
|
|
|
|
|
|
|
|
//Disable load more
|
|
|
|
bottomId = null;
|
|
|
|
|
|
|
|
//Clear exists notifications
|
|
|
|
notifications.clear();
|
|
|
|
}
|
|
|
|
|
2019-04-09 19:13:54 +02:00
|
|
|
|
|
|
|
private void showFilterMenu() {
|
|
|
|
List<Notification.Type> notificationsList = Notification.Type.Companion.getAsList();
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
for (Notification.Type type : notificationsList) {
|
|
|
|
list.add(getNotificationText(type));
|
|
|
|
}
|
|
|
|
|
|
|
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_multiple_choice, list);
|
|
|
|
PopupWindow window = new PopupWindow(getContext());
|
|
|
|
View view = LayoutInflater.from(getContext()).inflate(R.layout.notifications_filter, (ViewGroup) getView(), false);
|
|
|
|
final ListView listView = view.findViewById(R.id.listView);
|
|
|
|
view.findViewById(R.id.buttonApply)
|
|
|
|
.setOnClickListener(v -> {
|
|
|
|
SparseBooleanArray checkedItems = listView.getCheckedItemPositions();
|
|
|
|
Set<Notification.Type> excludes = new HashSet<>();
|
|
|
|
for (int i = 0; i < notificationsList.size(); i++) {
|
|
|
|
if (!checkedItems.get(i, false))
|
|
|
|
excludes.add(notificationsList.get(i));
|
|
|
|
}
|
|
|
|
window.dismiss();
|
|
|
|
applyFilterChanges(excludes);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
listView.setAdapter(adapter);
|
|
|
|
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
|
|
|
for (int i = 0; i < notificationsList.size(); i++) {
|
|
|
|
if (!notificationFilter.contains(notificationsList.get(i)))
|
|
|
|
listView.setItemChecked(i, true);
|
|
|
|
}
|
|
|
|
window.setContentView(view);
|
|
|
|
window.setFocusable(true);
|
2019-05-03 20:41:55 +02:00
|
|
|
window.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
window.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
2019-04-09 19:13:54 +02:00
|
|
|
window.showAsDropDown(buttonFilter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private String getNotificationText(Notification.Type type) {
|
|
|
|
switch (type) {
|
|
|
|
case MENTION:
|
2019-05-02 19:44:35 +02:00
|
|
|
return getString(R.string.notification_mention_name);
|
2019-04-09 19:13:54 +02:00
|
|
|
case FAVOURITE:
|
2019-05-02 19:44:35 +02:00
|
|
|
return getString(R.string.notification_favourite_name);
|
2019-04-09 19:13:54 +02:00
|
|
|
case REBLOG:
|
2019-05-02 19:44:35 +02:00
|
|
|
return getString(R.string.notification_boost_name);
|
2019-04-09 19:13:54 +02:00
|
|
|
case FOLLOW:
|
2019-05-02 19:44:35 +02:00
|
|
|
return getString(R.string.notification_follow_name);
|
2020-03-19 22:02:10 +01:00
|
|
|
case FOLLOW_REQUEST:
|
|
|
|
return getString(R.string.notification_follow_request_name);
|
2019-05-02 19:44:35 +02:00
|
|
|
case POLL:
|
|
|
|
return getString(R.string.notification_poll_name);
|
2020-12-23 12:52:39 +01:00
|
|
|
case STATUS:
|
|
|
|
return getString(R.string.notification_subscription_name);
|
2019-04-09 19:13:54 +02:00
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void applyFilterChanges(Set<Notification.Type> newSet) {
|
|
|
|
List<Notification.Type> notifications = Notification.Type.Companion.getAsList();
|
|
|
|
boolean isChanged = false;
|
|
|
|
for (Notification.Type type : notifications) {
|
|
|
|
if (notificationFilter.contains(type) && !newSet.contains(type)) {
|
|
|
|
notificationFilter.remove(type);
|
|
|
|
isChanged = true;
|
|
|
|
} else if (!notificationFilter.contains(type) && newSet.contains(type)) {
|
|
|
|
notificationFilter.add(type);
|
|
|
|
isChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isChanged) {
|
|
|
|
saveNotificationsFilter();
|
|
|
|
fullyRefreshWithProgressBar(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void loadNotificationsFilter() {
|
|
|
|
AccountEntity account = accountManager.getActiveAccount();
|
|
|
|
if (account != null) {
|
2020-12-23 19:13:37 +01:00
|
|
|
notificationFilter.clear();
|
2019-04-09 19:13:54 +02:00
|
|
|
notificationFilter.addAll(NotificationTypeConverterKt.deserialize(
|
|
|
|
account.getNotificationsFilter()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void saveNotificationsFilter() {
|
|
|
|
AccountEntity account = accountManager.getActiveAccount();
|
|
|
|
if (account != null) {
|
|
|
|
account.setNotificationsFilter(NotificationTypeConverterKt.serialize(notificationFilter));
|
|
|
|
accountManager.saveAccount(account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2017-01-27 01:34:32 +01:00
|
|
|
public void onViewTag(String tag) {
|
|
|
|
super.viewTag(tag);
|
|
|
|
}
|
2017-01-28 04:33:43 +01:00
|
|
|
|
2017-06-25 07:07:41 +02:00
|
|
|
@Override
|
2017-03-03 01:25:35 +01:00
|
|
|
public void onViewAccount(String id) {
|
|
|
|
super.viewAccount(id);
|
2017-01-28 04:33:43 +01:00
|
|
|
}
|
2017-04-22 10:41:49 +02:00
|
|
|
|
2020-03-19 22:02:10 +01:00
|
|
|
@Override
|
2020-07-27 10:28:59 +02:00
|
|
|
public void onMute(boolean mute, String id, int position, boolean notifications) {
|
2020-03-19 22:02:10 +01:00
|
|
|
// No muting from notifications yet
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBlock(boolean block, String id, int position) {
|
|
|
|
// No blocking from notifications yet
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRespondToFollowRequest(boolean accept, String id, int position) {
|
|
|
|
Single<Relationship> request = accept ?
|
2021-01-31 19:34:33 +01:00
|
|
|
mastodonApi.authorizeFollowRequest(id) :
|
|
|
|
mastodonApi.rejectFollowRequest(id);
|
2020-03-19 22:02:10 +01:00
|
|
|
request.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY)))
|
|
|
|
.subscribe(
|
|
|
|
(relationship) -> fullyRefreshWithProgressBar(true),
|
|
|
|
(error) -> Log.e(TAG, String.format("Failed to %s account id %s", accept ? "accept" : "reject", id))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-11-07 20:36:19 +01:00
|
|
|
@Override
|
|
|
|
public void onViewStatusForNotificationId(String notificationId) {
|
|
|
|
for (Either<Placeholder, Notification> either : notifications) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification notification = either.asRightOrNull();
|
2018-03-03 13:24:03 +01:00
|
|
|
if (notification != null && notification.getId().equals(notificationId)) {
|
|
|
|
super.viewThread(notification.getStatus());
|
2017-11-07 20:36:19 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Log.w(TAG, "Didn't find a notification for ID: " + notificationId);
|
|
|
|
}
|
|
|
|
|
2019-05-26 08:46:08 +02:00
|
|
|
private void onPreferenceChanged(String key) {
|
2017-06-26 11:15:47 +02:00
|
|
|
switch (key) {
|
|
|
|
case "fabHide": {
|
2018-11-12 21:09:39 +01:00
|
|
|
hideFab = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("fabHide", false);
|
2017-06-26 11:15:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "mediaPreviewEnabled": {
|
2018-11-12 21:09:39 +01:00
|
|
|
boolean enabled = accountManager.getActiveAccount().getMediaPreviewEnabled();
|
2018-08-24 19:47:27 +02:00
|
|
|
if (enabled != adapter.isMediaPreviewEnabled()) {
|
|
|
|
adapter.setMediaPreviewEnabled(enabled);
|
|
|
|
fullyRefresh();
|
|
|
|
}
|
2017-06-26 11:15:47 +02:00
|
|
|
}
|
2019-06-11 16:41:15 +02:00
|
|
|
case "showNotificationsFilter": {
|
|
|
|
if (isAdded()) {
|
|
|
|
showNotificationsFilter = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("showNotificationsFilter", true);
|
|
|
|
updateFilterVisibility();
|
|
|
|
fullyRefreshWithProgressBar(true);
|
|
|
|
}
|
|
|
|
}
|
2017-04-22 10:41:49 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-26 11:15:47 +02:00
|
|
|
|
2017-07-12 21:54:52 +02:00
|
|
|
@Override
|
|
|
|
public void removeItem(int position) {
|
|
|
|
notifications.remove(position);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
|
2018-05-27 10:22:12 +02:00
|
|
|
private void removeAllByAccountId(String accountId) {
|
2017-07-12 21:54:52 +02:00
|
|
|
// using iterator to safely remove items while iterating
|
2017-11-05 17:11:00 +01:00
|
|
|
Iterator<Either<Placeholder, Notification>> iterator = notifications.iterator();
|
2017-07-12 21:54:52 +02:00
|
|
|
while (iterator.hasNext()) {
|
2017-11-05 17:11:00 +01:00
|
|
|
Either<Placeholder, Notification> notification = iterator.next();
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification maybeNotification = notification.asRightOrNull();
|
2018-03-03 13:24:03 +01:00
|
|
|
if (maybeNotification != null && maybeNotification.getAccount().getId().equals(accountId)) {
|
2017-07-12 21:54:52 +02:00
|
|
|
iterator.remove();
|
|
|
|
}
|
|
|
|
}
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onLoadMore() {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
if (bottomId == null) {
|
2018-08-26 21:10:38 +02:00
|
|
|
// already loaded everything
|
|
|
|
return;
|
|
|
|
}
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
|
|
|
|
// Check for out-of-bounds when loading
|
|
|
|
// This is required to allow full-timeline reloads of collapsible statuses when the settings
|
|
|
|
// change.
|
|
|
|
if (notifications.size() > 0) {
|
|
|
|
Either<Placeholder, Notification> last = notifications.get(notifications.size() - 1);
|
|
|
|
if (last.isRight()) {
|
2019-03-07 19:31:18 +01:00
|
|
|
final Placeholder placeholder = newPlaceholder();
|
|
|
|
notifications.add(new Either.Left<>(placeholder));
|
|
|
|
NotificationViewData viewData =
|
|
|
|
new NotificationViewData.Placeholder(placeholder.id, true);
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
notifications.setPairedItem(notifications.size() - 1, viewData);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
Add support for collapsible statuses when they exceed 500 characters (#825)
* Update Gradle plugin to work with Android Studio 3.3 Canary
Android Studio 3.1.4 Stable doesn't render layout previews in this project
for whatever reason. Switching to the latest 3.3 Canary release fixes the
issue without affecting Gradle scripts but requires the new Android Gradle
plugin to match the new Android Studio release.
This commit will be reverted once development on the feature is done.
* Update gradle build script to allow installing debug builds alongside store version
This will allow developers, testers, etc to work on Tusky will not having to worry
about overwriting, uninstalling, fiddling with a preinstalled application which would
mean having to login again every time the development cycle starts/finishes and
manually reinstalling the app.
* Add UI changes to support collapsing statuses
The button uses subtle styling to not be distracting like the CW button on the timeline
The button is toggleable, full width to match the status textbox hitbox width and also
is shorter to not be too intrusive between the status text and images, or the post below
* Update status data model to store whether the message has been collapsed
* Update status action listener to notify of collapsed state changing
Provide stubs in all implementing classes and mark as TODO the stubs that
require a proper implementation for the feature to work.
* Add implementation code to handle status collapse/expand in timeline
Code has not been added elsewhere to simplify testing.
Once the code will be considered stable it will be also included in other
status action listener implementers.
* Add preferences so that users can toggle the collapsing of long posts
This is currently limited to a simple toggle, it would be nice to implement
a more advanced UI to offer the user more control over the feature.
* Update Gradle plugin to work with latest Android Studio 3.3 Canary 8
Just like the other commit, this will be reverted once the feature is working.
I simply don't want to deal with what changes in my installation of Android
Studio 3.1.4 Stable which breaks the layout preview rendering.
* Update data models and utils for statuses to better handle collapsing
I forgot that data isn't available from the API and can't really be built
from scratch using existing data due to preferences.
A new, extra boolean should fix the issue.
* Fix search breaking due to newly introduced variables in utils classes
* Fix timeline breaking due to newly introduced variables in utils classes
* Fix item status text for collapsed toggle being shown in the wrong state
* Update timeline fragment to refresh the list when collapsed settings change
* Add support for status content collapse in timeline viewholder
* Fix view holder truncating posts using temporary debug settings at 50 chars
* Add toggle support to notification layout as well
* Add support for collapsed statuses to search results
* Add support for expandable content to notifications too
* Update codebase with some suggested changes by @charlang
* Update more code with more suggestions and move null-safety into view data
* Update even more code with even more suggested code changes
* Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates)
* Add an input filter utility class to reuse code for trimming statuses
* Update UI of statuses to show a taller collapsible button
* Update notification fragment logging to simplify null checks
* Add smartness to SmartLengthInputFilter such as word trimming and runway
* Fix posts with show more button even if bad ratio didn't collapse
* Fix thread view showing button but not collapsing by implementing the feature
* Fix spannable losing spans when collapsed and restore length to 500 characters
* Remove debug build suffix as per request
* Fix all the merging happened in f66d689, 623cad2 and 7056ba5
* Fix notification button spanning full width rather than content width
* Add a way to access a singleton to smart filter and use clearer code
* Update view holders using smart input filters to use more singletons
* Fix code style lacking spaces before boolean checks in ifs and others
* Remove all code related to collapsibility preferences, strings included
* Update style to match content warning toggle button
* Update strings to give cleaner differentiation between CW and collapse
* Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
|
|
|
}
|
2018-08-22 21:18:56 +02:00
|
|
|
}
|
|
|
|
|
2017-11-03 22:17:31 +01:00
|
|
|
sendFetchNotificationsRequest(bottomId, null, FetchEnd.BOTTOM, -1);
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
|
|
|
|
2019-03-07 19:31:18 +01:00
|
|
|
private Placeholder newPlaceholder() {
|
|
|
|
Placeholder placeholder = Placeholder.getInstance(maxPlaceholderId);
|
|
|
|
maxPlaceholderId--;
|
|
|
|
return placeholder;
|
|
|
|
}
|
|
|
|
|
2017-06-30 08:31:58 +02:00
|
|
|
private void jumpToTop() {
|
2019-04-08 15:40:16 +02:00
|
|
|
if (isAdded()) {
|
2019-06-11 16:41:15 +02:00
|
|
|
appBarOptions.setExpanded(true, false);
|
2019-04-08 15:40:16 +02:00
|
|
|
layoutManager.scrollToPosition(0);
|
|
|
|
scrollListener.reset();
|
|
|
|
}
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void sendFetchNotificationsRequest(String fromId, String uptoId,
|
2017-11-03 22:17:31 +01:00
|
|
|
final FetchEnd fetchEnd, final int pos) {
|
2017-06-30 08:31:58 +02:00
|
|
|
/* If there is a fetch already ongoing, record however many fetches are requested and
|
|
|
|
* fulfill them after it's complete. */
|
|
|
|
if (fetchEnd == FetchEnd.TOP && topLoading) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fetchEnd == FetchEnd.BOTTOM && bottomLoading) {
|
|
|
|
return;
|
|
|
|
}
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
if (fetchEnd == FetchEnd.TOP) {
|
2018-08-22 21:18:56 +02:00
|
|
|
topLoading = true;
|
|
|
|
}
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
if (fetchEnd == FetchEnd.BOTTOM) {
|
2018-08-22 21:18:56 +02:00
|
|
|
bottomLoading = true;
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
|
|
|
|
2021-01-31 19:34:33 +01:00
|
|
|
Disposable notificationCall = mastodonApi.notifications(fromId, uptoId, LOAD_AT_ONCE, showNotificationsFilter ? notificationFilter : null)
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY)))
|
|
|
|
.subscribe(
|
|
|
|
response -> {
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
String linkHeader = response.headers().get("Link");
|
|
|
|
onFetchNotificationsSuccess(response.body(), linkHeader, fetchEnd, pos);
|
|
|
|
} else {
|
|
|
|
onFetchNotificationsFailure(new Exception(response.message()), fetchEnd, pos);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
throwable -> onFetchNotificationsFailure(throwable, fetchEnd, pos));
|
|
|
|
disposables.add(notificationCall);
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onFetchNotificationsSuccess(List<Notification> notifications, String linkHeader,
|
2017-11-03 22:17:31 +01:00
|
|
|
FetchEnd fetchEnd, int pos) {
|
2017-06-30 08:31:58 +02:00
|
|
|
List<HttpHeaderLink> links = HttpHeaderLink.parse(linkHeader);
|
2019-06-11 16:41:15 +02:00
|
|
|
HttpHeaderLink next = HttpHeaderLink.findByRelationType(links, "next");
|
|
|
|
String fromId = null;
|
|
|
|
if (next != null) {
|
|
|
|
fromId = next.uri.getQueryParameter("max_id");
|
|
|
|
}
|
|
|
|
|
2017-06-30 08:31:58 +02:00
|
|
|
switch (fetchEnd) {
|
|
|
|
case TOP: {
|
2019-06-11 16:41:15 +02:00
|
|
|
update(notifications, this.notifications.isEmpty() ? fromId : null);
|
2017-06-30 08:31:58 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-11-03 22:17:31 +01:00
|
|
|
case MIDDLE: {
|
2017-11-05 17:11:00 +01:00
|
|
|
replacePlaceholderWithNotifications(notifications, pos);
|
2017-11-03 22:17:31 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-06-30 08:31:58 +02:00
|
|
|
case BOTTOM: {
|
2018-08-22 21:18:56 +02:00
|
|
|
|
|
|
|
if (!this.notifications.isEmpty()
|
|
|
|
&& !this.notifications.get(this.notifications.size() - 1).isRight()) {
|
|
|
|
this.notifications.remove(this.notifications.size() - 1);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2018-08-22 21:18:56 +02:00
|
|
|
}
|
|
|
|
|
2019-04-09 19:13:54 +02:00
|
|
|
if (adapter.getItemCount() > 1) {
|
2017-07-12 21:54:52 +02:00
|
|
|
addItems(notifications, fromId);
|
2017-06-30 08:31:58 +02:00
|
|
|
} else {
|
2019-01-11 22:07:40 +01:00
|
|
|
update(notifications, fromId);
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
2018-02-03 22:45:14 +01:00
|
|
|
|
2017-06-30 08:31:58 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-02-03 22:45:14 +01:00
|
|
|
|
|
|
|
saveNewestNotificationId(notifications);
|
|
|
|
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
if (fetchEnd == FetchEnd.TOP) {
|
2018-08-22 21:18:56 +02:00
|
|
|
topLoading = false;
|
|
|
|
}
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
if (fetchEnd == FetchEnd.BOTTOM) {
|
2018-08-22 21:18:56 +02:00
|
|
|
bottomLoading = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notifications.size() == 0 && adapter.getItemCount() == 0) {
|
2019-01-28 19:02:31 +01:00
|
|
|
this.statusView.setVisibility(View.VISIBLE);
|
|
|
|
this.statusView.setup(R.drawable.elephant_friend_empty, R.string.message_empty, null);
|
2019-09-03 18:34:00 +02:00
|
|
|
} else {
|
|
|
|
swipeRefreshLayout.setEnabled(true);
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
2020-02-25 19:57:28 +01:00
|
|
|
updateFilterVisibility();
|
2017-06-30 08:31:58 +02:00
|
|
|
swipeRefreshLayout.setRefreshing(false);
|
2018-05-27 10:22:12 +02:00
|
|
|
progressBar.setVisibility(View.GONE);
|
2017-06-30 08:31:58 +02:00
|
|
|
}
|
|
|
|
|
2021-01-31 19:34:33 +01:00
|
|
|
private void onFetchNotificationsFailure(Throwable throwable, FetchEnd fetchEnd, int position) {
|
2017-11-07 12:59:46 +01:00
|
|
|
swipeRefreshLayout.setRefreshing(false);
|
|
|
|
if (fetchEnd == FetchEnd.MIDDLE && !notifications.get(position).isRight()) {
|
2019-03-07 19:31:18 +01:00
|
|
|
Placeholder placeholder = notifications.get(position).asLeft();
|
2017-11-07 12:59:46 +01:00
|
|
|
NotificationViewData placeholderVD =
|
2019-03-07 19:31:18 +01:00
|
|
|
new NotificationViewData.Placeholder(placeholder.id, false);
|
2017-11-07 12:59:46 +01:00
|
|
|
notifications.setPairedItem(position, placeholderVD);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2019-01-28 19:02:31 +01:00
|
|
|
} else if (this.notifications.isEmpty()) {
|
|
|
|
this.statusView.setVisibility(View.VISIBLE);
|
|
|
|
swipeRefreshLayout.setEnabled(false);
|
2020-02-25 19:57:28 +01:00
|
|
|
this.showingError = true;
|
2021-01-31 19:34:33 +01:00
|
|
|
if (throwable instanceof IOException) {
|
2019-01-28 19:02:31 +01:00
|
|
|
this.statusView.setup(R.drawable.elephant_offline, R.string.error_network, __ -> {
|
|
|
|
this.progressBar.setVisibility(View.VISIBLE);
|
|
|
|
this.onRefresh();
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.statusView.setup(R.drawable.elephant_error, R.string.error_generic, __ -> {
|
|
|
|
this.progressBar.setVisibility(View.VISIBLE);
|
|
|
|
this.onRefresh();
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
});
|
|
|
|
}
|
2020-02-25 19:57:28 +01:00
|
|
|
updateFilterVisibility();
|
2017-11-07 12:59:46 +01:00
|
|
|
}
|
2021-01-31 19:34:33 +01:00
|
|
|
Log.e(TAG, "Fetch failure: " + throwable.getMessage());
|
2020-01-14 21:58:35 +01:00
|
|
|
|
|
|
|
if (fetchEnd == FetchEnd.TOP) {
|
|
|
|
topLoading = false;
|
|
|
|
}
|
|
|
|
if (fetchEnd == FetchEnd.BOTTOM) {
|
|
|
|
bottomLoading = false;
|
|
|
|
}
|
|
|
|
|
2018-05-27 10:22:12 +02:00
|
|
|
progressBar.setVisibility(View.GONE);
|
2017-11-07 12:59:46 +01:00
|
|
|
}
|
|
|
|
|
2018-02-03 22:45:14 +01:00
|
|
|
private void saveNewestNotificationId(List<Notification> notifications) {
|
2018-04-22 17:20:01 +02:00
|
|
|
|
2018-02-03 22:45:14 +01:00
|
|
|
AccountEntity account = accountManager.getActiveAccount();
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
if (account != null) {
|
2019-01-31 19:03:34 +01:00
|
|
|
String lastNotificationId = account.getLastNotificationId();
|
2018-02-03 22:45:14 +01:00
|
|
|
|
2018-09-03 21:23:12 +02:00
|
|
|
for (Notification noti : notifications) {
|
2019-01-31 19:03:34 +01:00
|
|
|
if (isLessThan(lastNotificationId, noti.getId())) {
|
|
|
|
lastNotificationId = noti.getId();
|
2018-09-03 21:23:12 +02:00
|
|
|
}
|
2018-02-03 22:45:14 +01:00
|
|
|
}
|
|
|
|
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
if (!account.getLastNotificationId().equals(lastNotificationId)) {
|
2018-09-03 21:23:12 +02:00
|
|
|
Log.d(TAG, "saving newest noti id: " + lastNotificationId);
|
|
|
|
account.setLastNotificationId(lastNotificationId);
|
|
|
|
accountManager.saveAccount(account);
|
|
|
|
}
|
|
|
|
}
|
2018-02-03 22:45:14 +01:00
|
|
|
}
|
|
|
|
|
2019-01-11 22:07:40 +01:00
|
|
|
private void update(@Nullable List<Notification> newNotifications, @Nullable String fromId) {
|
2017-07-15 05:23:14 +02:00
|
|
|
if (ListUtils.isEmpty(newNotifications)) {
|
2019-07-16 19:51:44 +02:00
|
|
|
updateAdapter();
|
2017-07-12 21:54:52 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fromId != null) {
|
|
|
|
bottomId = fromId;
|
|
|
|
}
|
2017-11-05 17:11:00 +01:00
|
|
|
List<Either<Placeholder, Notification>> liftedNew =
|
|
|
|
liftNotificationList(newNotifications);
|
2017-07-12 21:54:52 +02:00
|
|
|
if (notifications.isEmpty()) {
|
2017-11-05 17:11:00 +01:00
|
|
|
notifications.addAll(liftedNew);
|
2017-07-12 21:54:52 +02:00
|
|
|
} else {
|
2017-11-05 17:11:00 +01:00
|
|
|
int index = notifications.indexOf(liftedNew.get(newNotifications.size() - 1));
|
2017-07-12 21:54:52 +02:00
|
|
|
for (int i = 0; i < index; i++) {
|
|
|
|
notifications.remove(0);
|
|
|
|
}
|
2017-11-05 17:11:00 +01:00
|
|
|
|
|
|
|
int newIndex = liftedNew.indexOf(notifications.get(0));
|
2017-07-12 21:54:52 +02:00
|
|
|
if (newIndex == -1) {
|
2017-11-05 17:11:00 +01:00
|
|
|
if (index == -1 && liftedNew.size() >= LOAD_AT_ONCE) {
|
2019-03-07 19:31:18 +01:00
|
|
|
liftedNew.add(new Either.Left<>(newPlaceholder()));
|
2017-11-03 22:17:31 +01:00
|
|
|
}
|
2017-11-05 17:11:00 +01:00
|
|
|
notifications.addAll(0, liftedNew);
|
2017-07-12 21:54:52 +02:00
|
|
|
} else {
|
2017-11-05 17:11:00 +01:00
|
|
|
notifications.addAll(0, liftedNew.subList(0, newIndex));
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
}
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
|
2017-11-03 22:17:31 +01:00
|
|
|
private void addItems(List<Notification> newNotifications, @Nullable String fromId) {
|
2018-08-26 21:10:38 +02:00
|
|
|
bottomId = fromId;
|
2017-07-15 05:23:14 +02:00
|
|
|
if (ListUtils.isEmpty(newNotifications)) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-12 21:54:52 +02:00
|
|
|
int end = notifications.size();
|
2017-11-05 17:11:00 +01:00
|
|
|
List<Either<Placeholder, Notification>> liftedNew = liftNotificationList(newNotifications);
|
|
|
|
Either<Placeholder, Notification> last = notifications.get(end - 1);
|
|
|
|
if (last != null && liftedNew.indexOf(last) == -1) {
|
|
|
|
notifications.addAll(liftedNew);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-07-12 21:54:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-05 17:11:00 +01:00
|
|
|
private void replacePlaceholderWithNotifications(List<Notification> newNotifications, int pos) {
|
|
|
|
// Remove placeholder
|
2017-11-03 22:17:31 +01:00
|
|
|
notifications.remove(pos);
|
|
|
|
|
|
|
|
if (ListUtils.isEmpty(newNotifications)) {
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-11-03 22:17:31 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-05 17:11:00 +01:00
|
|
|
List<Either<Placeholder, Notification>> liftedNew = liftNotificationList(newNotifications);
|
|
|
|
|
|
|
|
// If we fetched less posts than in the limit, it means that the hole is not filled
|
|
|
|
// If we fetched at least as much it means that there are more posts to load and we should
|
|
|
|
// insert new placeholder
|
|
|
|
if (newNotifications.size() >= LOAD_AT_ONCE) {
|
2019-03-07 19:31:18 +01:00
|
|
|
liftedNew.add(new Either.Left<>(newPlaceholder()));
|
2017-11-03 22:17:31 +01:00
|
|
|
}
|
|
|
|
|
2017-11-05 17:11:00 +01:00
|
|
|
notifications.addAll(pos, liftedNew);
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-11-05 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
2019-04-21 08:24:06 +02:00
|
|
|
private final Function1<Notification, Either<Placeholder, Notification>> notificationLifter =
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Either.Right::new;
|
2017-11-03 22:17:31 +01:00
|
|
|
|
2017-11-05 17:11:00 +01:00
|
|
|
private List<Either<Placeholder, Notification>> liftNotificationList(List<Notification> list) {
|
2019-04-21 08:24:06 +02:00
|
|
|
return CollectionsKt.map(list, notificationLifter);
|
2017-11-03 22:17:31 +01:00
|
|
|
}
|
|
|
|
|
2019-04-09 19:13:54 +02:00
|
|
|
private void fullyRefreshWithProgressBar(boolean isShow) {
|
2019-06-11 16:41:15 +02:00
|
|
|
resetNotificationsLoad();
|
|
|
|
if (isShow) {
|
2019-04-09 19:13:54 +02:00
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
|
|
|
statusView.setVisibility(View.GONE);
|
|
|
|
}
|
2019-03-07 19:31:18 +01:00
|
|
|
updateAdapter();
|
2017-11-03 22:17:31 +01:00
|
|
|
sendFetchNotificationsRequest(null, null, FetchEnd.TOP, -1);
|
2017-06-26 11:15:47 +02:00
|
|
|
}
|
2018-05-27 10:22:12 +02:00
|
|
|
|
2019-04-09 19:13:54 +02:00
|
|
|
private void fullyRefresh() {
|
|
|
|
fullyRefreshWithProgressBar(false);
|
|
|
|
}
|
|
|
|
|
2018-05-27 10:22:12 +02:00
|
|
|
@Nullable
|
|
|
|
private Pair<Integer, Notification> findReplyPosition(@NonNull String statusId) {
|
|
|
|
for (int i = 0; i < notifications.size(); i++) {
|
Caching toots (#809)
* Initial timeline cache implementation
* Fix build/DI errors for caching
* Rename timeline entities tables. Add migration. Add DB scheme file.
* Fix uniqueness problem, change offline strategy, improve mapping
* Try to merge in new statuses, fix bottom loading, fix saving spans.
* Fix reblogs IDs, fix inserting elements from top
* Send one more request to get latest timeline statuses
* Give Timeline placeholders string id. Rewrite Either in Kotlin
* Initial placeholder implementation for caching
* Fix crash on removing overlap statuses
* Migrate counters to long
* Remove unused counters. Add minimal TimelineDAOTest
* Fix bug with placeholder ID
* Update cache in response to events. Refactor TimelineCases
* Fix crash, reduce number of placeholders
* Fix crash, fix filtering, improve placeholder handling
* Fix migration, add 8-9 migration test
* Fix initial timeline update, remove more placeholders
* Add cleanup for old statuses
* Fix cleanup
* Delete ExampleInstrumentedTest
* Improve timeline UX regarding caching
* Fix typos
* Fix initial timeline update
* Cleanup/fix initial timeline update
* Workaround for weird behavior of first post on initial tl update.
* Change counter types back to int
* Clear timeline cache on logout
* Fix loading when timeline is completely empty
* Fix androidx migration issues
* Fix tests
* Apply caching feedback
* Save account emojis to cache
* Fix warnings and bugs
2019-01-14 22:05:08 +01:00
|
|
|
Notification notification = notifications.get(i).asRightOrNull();
|
2018-05-27 10:22:12 +02:00
|
|
|
if (notification != null
|
|
|
|
&& notification.getStatus() != null
|
|
|
|
&& notification.getType() == Notification.Type.MENTION
|
|
|
|
&& (statusId.equals(notification.getStatus().getId())
|
|
|
|
|| (notification.getStatus().getReblog() != null
|
|
|
|
&& statusId.equals(notification.getStatus().getReblog().getId())))) {
|
|
|
|
return new Pair<>(i, notification);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2019-03-07 19:31:18 +01:00
|
|
|
|
|
|
|
private void updateAdapter() {
|
|
|
|
differ.submitList(notifications.getPairedCopy());
|
|
|
|
}
|
|
|
|
|
|
|
|
private final ListUpdateCallback listUpdateCallback = new ListUpdateCallback() {
|
|
|
|
@Override
|
|
|
|
public void onInserted(int position, int count) {
|
|
|
|
if (isAdded()) {
|
|
|
|
adapter.notifyItemRangeInserted(position, count);
|
|
|
|
Context context = getContext();
|
2020-08-21 18:51:05 +02:00
|
|
|
// scroll up when new items at the top are loaded while being at the start
|
|
|
|
// https://github.com/tuskyapp/Tusky/pull/1905#issuecomment-677819724
|
|
|
|
if (position == 0 && context != null && adapter.getItemCount() != count) {
|
2019-03-07 19:31:18 +01:00
|
|
|
recyclerView.scrollBy(0, Utils.dpToPx(context, -30));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRemoved(int position, int count) {
|
|
|
|
adapter.notifyItemRangeRemoved(position, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMoved(int fromPosition, int toPosition) {
|
|
|
|
adapter.notifyItemMoved(fromPosition, toPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChanged(int position, int count, Object payload) {
|
|
|
|
adapter.notifyItemRangeChanged(position, count, payload);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private final AsyncListDiffer<NotificationViewData>
|
|
|
|
differ = new AsyncListDiffer<>(listUpdateCallback,
|
|
|
|
new AsyncDifferConfig.Builder<>(diffCallback).build());
|
|
|
|
|
|
|
|
private final NotificationsAdapter.AdapterDataSource<NotificationViewData> dataSource =
|
|
|
|
new NotificationsAdapter.AdapterDataSource<NotificationViewData>() {
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
return differ.getCurrentList().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public NotificationViewData getItemAt(int pos) {
|
|
|
|
return differ.getCurrentList().get(pos);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private static final DiffUtil.ItemCallback<NotificationViewData> diffCallback
|
|
|
|
= new DiffUtil.ItemCallback<NotificationViewData>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean areItemsTheSame(NotificationViewData oldItem, NotificationViewData newItem) {
|
|
|
|
return oldItem.getViewDataId() == newItem.getViewDataId();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-03 20:42:13 +02:00
|
|
|
public boolean areContentsTheSame(@NonNull NotificationViewData oldItem, @NonNull NotificationViewData newItem) {
|
2019-03-25 13:44:31 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public Object getChangePayload(@NonNull NotificationViewData oldItem, @NonNull NotificationViewData newItem) {
|
|
|
|
if (oldItem.deepEquals(newItem)) {
|
|
|
|
//If items are equal - update timestamp only
|
2019-09-17 18:44:33 +02:00
|
|
|
return Collections.singletonList(StatusBaseViewHolder.Key.KEY_CREATED);
|
2019-03-25 13:44:31 +01:00
|
|
|
} else
|
|
|
|
// If items are different - update a whole view holder
|
|
|
|
return null;
|
2019-03-07 19:31:18 +01:00
|
|
|
}
|
|
|
|
};
|
2019-03-25 13:44:31 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
2020-12-23 19:13:37 +01:00
|
|
|
String rawAccountNotificationFilter = accountManager.getActiveAccount().getNotificationsFilter();
|
|
|
|
Set<Notification.Type> accountNotificationFilter = NotificationTypeConverterKt.deserialize(rawAccountNotificationFilter);
|
|
|
|
if (!notificationFilter.equals(accountNotificationFilter)) {
|
|
|
|
loadNotificationsFilter();
|
|
|
|
fullyRefreshWithProgressBar(true);
|
|
|
|
}
|
2019-03-25 13:44:31 +01:00
|
|
|
startUpdateTimestamp();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start to update adapter every minute to refresh timestamp
|
|
|
|
* If setting absoluteTimeView is false
|
|
|
|
* Auto dispose observable on pause
|
|
|
|
*/
|
|
|
|
private void startUpdateTimestamp() {
|
|
|
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
|
|
|
boolean useAbsoluteTime = preferences.getBoolean("absoluteTimeView", false);
|
|
|
|
if (!useAbsoluteTime) {
|
|
|
|
Observable.interval(1, TimeUnit.MINUTES)
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.as(autoDisposable(from(this, Lifecycle.Event.ON_PAUSE)))
|
|
|
|
.subscribe(
|
|
|
|
interval -> updateAdapter()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-04-08 15:40:16 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReselect() {
|
|
|
|
jumpToTop();
|
|
|
|
}
|
2017-01-07 23:24:02 +01:00
|
|
|
}
|