mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
add unread mentions popup-bubble in conversations list
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
cf18bf212b
commit
12e9985cd9
@ -92,6 +92,7 @@ import com.nextcloud.talk.utils.UriUtils;
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||
import com.webianks.library.PopupBubble;
|
||||
import com.yarolegovich.lovelydialog.LovelySaveStateHandler;
|
||||
import com.yarolegovich.lovelydialog.LovelyStandardDialog;
|
||||
|
||||
@ -99,11 +100,13 @@ import org.apache.commons.lang3.builder.CompareToBuilder;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.parceler.Parcels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -136,6 +139,7 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
|
||||
public static final String TAG = "ConvListController";
|
||||
public static final int ID_DELETE_CONVERSATION_DIALOG = 0;
|
||||
public static final int UNREAD_BUBBLE_DELAY = 2500;
|
||||
private static final String KEY_SEARCH_QUERY = "ContactsController.searchQuery";
|
||||
private final Bundle bundle;
|
||||
@Inject
|
||||
@ -168,6 +172,9 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
@BindView(R.id.floatingActionButton)
|
||||
FloatingActionButton floatingActionButton;
|
||||
|
||||
@BindView(R.id.newMentionPopupBubble)
|
||||
PopupBubble newMentionPopupBubble;
|
||||
|
||||
private UserEntity currentUser;
|
||||
private Disposable roomsQueryDisposable;
|
||||
private FlexibleAdapter<AbstractFlexibleItem> adapter;
|
||||
@ -201,6 +208,8 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
|
||||
private boolean forwardMessage = false;
|
||||
|
||||
private SmoothScrollLinearLayoutManager layoutManager;
|
||||
|
||||
public ConversationsListController(Bundle bundle) {
|
||||
super();
|
||||
setHasOptionsMenu(true);
|
||||
@ -517,6 +526,7 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
}
|
||||
|
||||
adapter.updateDataSet(callItems, false);
|
||||
new Handler().postDelayed(this::checkToShowUnreadBubble, UNREAD_BUBBLE_DELAY);
|
||||
|
||||
if (swipeRefreshLayout != null) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
@ -566,12 +576,19 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
}
|
||||
|
||||
private void prepareViews() {
|
||||
SmoothScrollLinearLayoutManager layoutManager =
|
||||
new SmoothScrollLinearLayoutManager(getActivity());
|
||||
layoutManager = new SmoothScrollLinearLayoutManager(Objects.requireNonNull(getActivity()));
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NotNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
checkToShowUnreadBubble();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener(() -> fetchData(false));
|
||||
swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
|
||||
@ -598,6 +615,29 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
newMentionPopupBubble.hide();
|
||||
newMentionPopupBubble.setPopupBubbleListener(new PopupBubble.PopupBubbleClickListener() {
|
||||
@Override
|
||||
public void bubbleClicked(Context context) {
|
||||
recyclerView.smoothScrollToPosition(callItems.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkToShowUnreadBubble() {
|
||||
int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition();
|
||||
for (AbstractFlexibleItem flexItem : callItems) {
|
||||
Conversation conversationItem = ((ConversationItem) flexItem).getModel();
|
||||
int position = adapter.getGlobalPositionOf(flexItem);
|
||||
if (conversationItem.unreadMention && position > lastVisibleItem) {
|
||||
if(!newMentionPopupBubble.isShown()){
|
||||
newMentionPopupBubble.show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
newMentionPopupBubble.hide();
|
||||
}
|
||||
|
||||
private void showNewConversationsScreen() {
|
||||
|
@ -122,4 +122,17 @@
|
||||
app:srcCompat="@drawable/ic_add_white_24px"
|
||||
app:tint="@color/white" />
|
||||
|
||||
<com.webianks.library.PopupBubble
|
||||
android:id="@+id/newMentionPopupBubble"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:layout_margin="16dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="8dp"
|
||||
app:pb_backgroundColor="@color/colorPrimary"
|
||||
app:pb_icon="@drawable/ic_baseline_arrow_downward_24px"
|
||||
app:pb_text="@string/nc_new_mention"
|
||||
app:pb_textColor="@color/textColorOnPrimaryBackground" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -264,6 +264,9 @@
|
||||
<string name="nc_remove_group_and_members">Remove group and members</string>
|
||||
<string name="nc_attendee_pin">Pin: %1$s</string>
|
||||
|
||||
<!-- Conversations List-->
|
||||
<string name="nc_new_mention">More mentions</string>
|
||||
|
||||
<!-- Chat -->
|
||||
<string name="nc_hint_enter_a_message">Enter a message…</string>
|
||||
<string name="nc_date_header_yesterday">Yesterday</string>
|
||||
|
@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 3 errors and 266 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 3 errors and 267 warnings</span>
|
||||
|
Loading…
Reference in New Issue
Block a user