fixed tab type
This commit is contained in:
parent
43a80bdb70
commit
4bd54354fa
|
@ -45,7 +45,6 @@ public @interface CustomTabType {
|
|||
String NOTIFICATIONS_TIMELINE = "notifications_timeline";
|
||||
String TRENDS_SUGGESTIONS = "trends_suggestions";
|
||||
String DIRECT_MESSAGES = "direct_messages";
|
||||
String DIRECT_MESSAGES_NEXT = "direct_messages_next";
|
||||
String FAVORITES = "favorites";
|
||||
String USER_TIMELINE = "user_timeline";
|
||||
String SEARCH_STATUSES = "search_statuses";
|
||||
|
|
|
@ -146,6 +146,10 @@ public class ParcelableMessageConversation implements Parcelable {
|
|||
@CursorField(value = Conversations.LAST_READ_ID)
|
||||
public String last_read_id;
|
||||
|
||||
@JsonField(name = "last_read_timestamp")
|
||||
@CursorField(value = Conversations.LAST_READ_TIMESTAMP)
|
||||
public long last_read_timestamp;
|
||||
|
||||
/**
|
||||
* True if this is a temporary conversation, i.e. Created by user but haven't send any message
|
||||
* yet.
|
||||
|
|
|
@ -121,7 +121,7 @@ public class Tab implements Parcelable {
|
|||
|
||||
@CustomTabType
|
||||
public String getType() {
|
||||
return type;
|
||||
return getTypeAlias(type);
|
||||
}
|
||||
|
||||
public void setType(@CustomTabType String type) {
|
||||
|
@ -272,7 +272,7 @@ public class Tab implements Parcelable {
|
|||
}
|
||||
|
||||
@JsonObject
|
||||
static class InternalExtras {
|
||||
static class InternalExtras {
|
||||
|
||||
@JsonField(name = "base")
|
||||
TabExtras base;
|
||||
|
|
|
@ -383,6 +383,7 @@ public interface TwidereDataStore {
|
|||
String RECIPIENT_KEY = "recipient_key";
|
||||
String REQUEST_CURSOR = "request_cursor";
|
||||
String LAST_READ_ID = "last_read_id";
|
||||
String LAST_READ_TIMESTAMP = "last_read_timestamp";
|
||||
String IS_OUTGOING = "is_outgoing";
|
||||
String IS_TEMP = "is_temp";
|
||||
String CONVERSATION_EXTRAS = "conversation_extras";
|
||||
|
|
|
@ -34,7 +34,7 @@ import static org.mariotaku.twidere.annotation.PreferenceType.STRING;
|
|||
public interface Constants extends TwidereConstants {
|
||||
|
||||
String DATABASES_NAME = "twidere.sqlite";
|
||||
int DATABASES_VERSION = 177;
|
||||
int DATABASES_VERSION = 179;
|
||||
|
||||
int EXTRA_FEATURES_NOTICE_VERSION = 0;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class CustomTabUtils implements Constants {
|
|||
List<SupportTabSpec> specs = new ArrayList<>();
|
||||
for (Tab tab : getTabs(context)) {
|
||||
@CustomTabType
|
||||
final String type = Tab.getTypeAlias(tab.getType());
|
||||
final String type = tab.getType();
|
||||
final int position = tab.getPosition();
|
||||
final String iconType = tab.getIcon();
|
||||
final String name = tab.getName();
|
||||
|
@ -148,7 +148,7 @@ public class CustomTabUtils implements Constants {
|
|||
return icon.createDrawable(context);
|
||||
}
|
||||
|
||||
public static String getTabTypeName(final Context context, final String type) {
|
||||
public static String getTabTypeName(final Context context, @CustomTabType final String type) {
|
||||
if (context == null) return null;
|
||||
final TabConfiguration conf = TabConfiguration.ofType(type);
|
||||
if (conf == null) return null;
|
||||
|
@ -172,7 +172,7 @@ public class CustomTabUtils implements Constants {
|
|||
}
|
||||
|
||||
public static boolean hasAccountId(final Context context, @NonNull final Bundle args,
|
||||
final UserKey[] activatedAccountKeys, UserKey accountKey) {
|
||||
final UserKey[] activatedAccountKeys, UserKey accountKey) {
|
||||
final UserKey[] accountKeys = Utils.getAccountKeys(context, args);
|
||||
if (accountKeys != null) {
|
||||
return ArrayUtils.contains(accountKeys, accountKey);
|
||||
|
|
|
@ -180,7 +180,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
|||
}
|
||||
|
||||
override fun onItemCheckedStateChanged(mode: ActionMode, position: Int, id: Long,
|
||||
checked: Boolean) {
|
||||
checked: Boolean) {
|
||||
updateTitle(mode)
|
||||
}
|
||||
|
||||
|
@ -466,15 +466,16 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
|||
R.layout.list_item_custom_tab, null, emptyArray(), intArrayOf(), 0) {
|
||||
|
||||
private val iconColor: Int = ThemeUtils.getThemeForegroundColor(context)
|
||||
private val tempTab: Tab = Tab()
|
||||
private var indices: TabCursorIndices? = null
|
||||
|
||||
override fun bindView(view: View, context: Context?, cursor: Cursor) {
|
||||
super.bindView(view, context, cursor)
|
||||
val holder = view.tag as TwoLineWithIconViewHolder
|
||||
val indices = indices!!
|
||||
val type = Tab.getTypeAlias(cursor.getString(indices.type))
|
||||
val name = cursor.getString(indices.name)
|
||||
val iconKey = cursor.getString(indices.icon)
|
||||
indices?.parseFields(tempTab, cursor)
|
||||
val type = tempTab.type
|
||||
val name = tempTab.name
|
||||
val iconKey = tempTab.icon
|
||||
if (type != null && CustomTabUtils.isTabTypeValid(type)) {
|
||||
val typeName = CustomTabUtils.getTabTypeName(context, type)
|
||||
holder.text1.text = if (TextUtils.isEmpty(name)) typeName else name
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.annotation.SuppressLint
|
|||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import org.mariotaku.ktextension.toInt
|
||||
import org.mariotaku.ktextension.toLong
|
||||
import org.mariotaku.ktextension.useCursor
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
|
@ -372,7 +373,7 @@ class GetMessagesTask(
|
|||
}
|
||||
val messagesMap = messages.groupBy(ParcelableMessage::conversation_id)
|
||||
for ((k, v) in respConversations) {
|
||||
val message = messagesMap[k]?.maxBy(ParcelableMessage::message_timestamp) ?: continue
|
||||
val recentMessage = messagesMap[k]?.maxBy(ParcelableMessage::message_timestamp) ?: continue
|
||||
val participants = respUsers.filterKeys { userId ->
|
||||
v.participants.any { it.userId == userId }
|
||||
}.values
|
||||
|
@ -381,13 +382,20 @@ class GetMessagesTask(
|
|||
DMResponse.Conversation.Type.GROUP_DM -> ConversationType.GROUP
|
||||
else -> ConversationType.ONE_TO_ONE
|
||||
}
|
||||
val conversation = conversations.addConversation(k, account, message, participants,
|
||||
val conversation = conversations.addConversation(k, account, recentMessage, participants,
|
||||
conversationType)
|
||||
conversation.conversation_name = v.name
|
||||
conversation.conversation_avatar = v.avatarImageHttps
|
||||
conversation.request_cursor = response.cursor
|
||||
conversation.conversation_extras_type = ParcelableMessageConversation.ExtrasType.TWITTER_OFFICIAL
|
||||
conversation.last_read_id = v.lastReadEventId
|
||||
val longEventId = v.lastReadEventId.toLong(-1)
|
||||
// Find recent message timestamp
|
||||
conversation.last_read_timestamp = messagesMap[k]?.filter { message ->
|
||||
if (message.id == v.lastReadEventId) return@filter true
|
||||
if (longEventId > 0 && longEventId < message.id.toLong(-1)) return@filter true
|
||||
return@filter false
|
||||
}?.maxBy(ParcelableMessage::message_timestamp)?.message_timestamp ?: -1
|
||||
conversation.conversation_extras = TwitterOfficialConversationExtras().apply {
|
||||
this.minEntryId = v.minEntryId
|
||||
this.maxEntryId = v.maxEntryId
|
||||
|
|
Loading…
Reference in New Issue