From 94560df05ff5a3d58e1e80d8c9951f2f2b1522c4 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Tue, 11 Apr 2017 17:51:28 +0800 Subject: [PATCH] Fixed wrong exclude_reply_user_ids for updating status --- .../library/twitter/model/StatusUpdate.java | 4 +- twidere/build.gradle | 4 +- .../twidere/util/MicroBlogAPIFactory.java | 3 +- .../util/api/TwitterMacExtraHeaders.kt | 58 +++++++++++++++++++ 4 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 twidere/src/main/kotlin/org/mariotaku/twidere/util/api/TwitterMacExtraHeaders.kt diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/StatusUpdate.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/StatusUpdate.java index ec2dfab4a..97c7e7b2e 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/StatusUpdate.java +++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/StatusUpdate.java @@ -55,9 +55,9 @@ public class StatusUpdate extends SimpleValueMap { public StatusUpdate excludeReplyUserIds(@Nullable final String[] ids) { if (ids == null) { - remove("exclude_reply_userids"); + remove("exclude_reply_user_ids"); } else { - put("exclude_reply_userids", RestFuUtils.toString(ids, ',')); + put("exclude_reply_user_ids", RestFuUtils.toString(ids, ',')); } return this; } diff --git a/twidere/build.gradle b/twidere/build.gradle index 988c6d055..9219b47e3 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -36,8 +36,8 @@ android { applicationId "org.mariotaku.twidere" minSdkVersion project.properties['overrideMinSdkVersion'] ?: 14 targetSdkVersion 25 - versionCode 326 - versionName '3.5.9' + versionCode 327 + versionName '3.5.10' multiDexEnabled true buildConfigField 'boolean', 'LEAK_CANARY_ENABLED', 'Boolean.parseBoolean("true")' diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/MicroBlogAPIFactory.java b/twidere/src/main/java/org/mariotaku/twidere/util/MicroBlogAPIFactory.java index 298edef1d..34c622b43 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/MicroBlogAPIFactory.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/MicroBlogAPIFactory.java @@ -25,6 +25,7 @@ import org.mariotaku.twidere.model.UserKey; import org.mariotaku.twidere.model.account.cred.Credentials; import org.mariotaku.twidere.model.util.AccountUtils; import org.mariotaku.twidere.util.api.TwitterAndroidExtraHeaders; +import org.mariotaku.twidere.util.api.TwitterMacExtraHeaders; import org.mariotaku.twidere.util.api.UserAgentExtraHeaders; import java.util.List; @@ -176,7 +177,7 @@ public class MicroBlogAPIFactory implements TwidereConstants { return new UserAgentExtraHeaders("Twitter/6.75.2 CFNetwork/811.4.18 Darwin/16.5.0"); } case TWITTER_FOR_MAC: { - return new UserAgentExtraHeaders("Twitter-Mac/5002734 Mac/10.12.3 (;x86_64)"); + return TwitterMacExtraHeaders.INSTANCE; } case TWEETDECK: { return new UserAgentExtraHeaders(UserAgentUtils.getDefaultUserAgentStringSafe(context)); diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/api/TwitterMacExtraHeaders.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/api/TwitterMacExtraHeaders.kt new file mode 100644 index 000000000..2ada1ff31 --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/api/TwitterMacExtraHeaders.kt @@ -0,0 +1,58 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2017 Mariotaku Lee + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.util.api + +import android.os.Build +import org.mariotaku.ktextension.bcp47Tag +import org.mariotaku.twidere.util.MicroBlogAPIFactory.ExtraHeaders +import java.util.* + +/** + * Created by mariotaku on 2017/2/25. + */ +object TwitterMacExtraHeaders : ExtraHeaders { + + const val clientName = "Twitter-Mac" + const val versionName = "6.41.0" + const val platformName = "Mac" + const val platformVersion = "10.12.3" + const val platformArchitecture = "x86_64" + const val internalVersionName = "5002734" + + override fun get(): List> { + val result = ArrayList>() + val language = Locale.getDefault().bcp47Tag + result.add(Pair("User-Agent", userAgent)) + result.add(Pair("Accept-Language", language)) + result.add(Pair("X-Twitter-Client", clientName)) + result.add(Pair("X-Twitter-Client-Version", versionName)) + return result + } + + val userAgent: String get() { + val model = Build.MODEL + val manufacturer = Build.MANUFACTURER + val sdkRelease = Build.VERSION.RELEASE + val brand = Build.BRAND + val product = Build.PRODUCT + return "$clientName/($internalVersionName) $platformName/$platformVersion (;$platformArchitecture)" + } + +}