From cf270b72fc01c621fa66ed89dcdd83c606144bf3 Mon Sep 17 00:00:00 2001 From: Tlaster Date: Tue, 22 Dec 2020 17:05:12 +0800 Subject: [PATCH] Revert "Add yandex translate support" This reverts commit 0fc88a40766aece8e17a314309de7b244d870961. --- .../mariotaku/twidere/TwidereConstants.java | 2 - .../constant/SharedPreferenceConstants.java | 2 - .../java/org/mariotaku/yandex/YandexAPI.kt | 11 ---- .../org/mariotaku/yandex/YandexAPIFactory.kt | 50 ------------------- .../org/mariotaku/yandex/YandexException.kt | 8 --- .../yandex/model/YandexTranslateResult.kt | 14 ------ .../twidere/constant/PreferenceKeys.kt | 2 - .../twidere/fragment/status/StatusFragment.kt | 34 ++++--------- .../holder/status/DetailStatusViewHolder.kt | 16 +++--- twidere/src/main/res/values/strings.xml | 2 - .../res/xml/preferences_advanced_network.xml | 6 --- 11 files changed, 17 insertions(+), 130 deletions(-) delete mode 100644 twidere/src/main/java/org/mariotaku/yandex/YandexAPI.kt delete mode 100644 twidere/src/main/java/org/mariotaku/yandex/YandexAPIFactory.kt delete mode 100644 twidere/src/main/java/org/mariotaku/yandex/YandexException.kt delete mode 100644 twidere/src/main/java/org/mariotaku/yandex/model/YandexTranslateResult.kt diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/TwidereConstants.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/TwidereConstants.java index 798908478..7eaf7ad44 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/TwidereConstants.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/TwidereConstants.java @@ -67,8 +67,6 @@ public interface TwidereConstants extends SharedPreferenceConstants, IntentConst String TWITTER_CONSUMER_KEY = "MUUBibXUognm6e9vbzrUIqPkt"; String TWITTER_CONSUMER_SECRET = "l2uWAgQkoHvDfM2PrRFx2WN4h7QIUIktmxyeTAqRo6TkGCtNKy"; - String YANDEX_KEY = "trnsl.1.1.20200513T065609Z.8e72845b632aa04f.fe1297e42c152de9e8773e1bc71162b1e498e2a8"; - String DEFAULT_TWITTER_API_URL_FORMAT = "https://[DOMAIN].twitter.com/"; String SCHEME_HTTP = "http"; diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/SharedPreferenceConstants.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/SharedPreferenceConstants.java index 5cc0c2d2e..d1e656ba7 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/SharedPreferenceConstants.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/SharedPreferenceConstants.java @@ -285,8 +285,6 @@ public interface SharedPreferenceConstants { String KEY_OVERRIDE_LANGUAGE = "override_language"; @ExportablePreference(STRING) String KEY_TAB_POSITION = "tab_position"; - @ExportablePreference(STRING) - String KEY_YANDEX_KEY = "yandex_key"; @ExportablePreference(BOOLEAN) String KEY_AUTO_HIDE_TABS = "auto_hide_tabs"; @ExportablePreference(BOOLEAN) diff --git a/twidere/src/main/java/org/mariotaku/yandex/YandexAPI.kt b/twidere/src/main/java/org/mariotaku/yandex/YandexAPI.kt deleted file mode 100644 index e5401b703..000000000 --- a/twidere/src/main/java/org/mariotaku/yandex/YandexAPI.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.mariotaku.yandex - -import org.mariotaku.restfu.annotation.method.POST -import org.mariotaku.restfu.annotation.param.Query -import org.mariotaku.yandex.model.YandexTranslateResult - -interface YandexAPI { - @POST("/api/v1.5/tr.json/translate") - fun search(@Query("text") text: String, - @Query("lang") lang: String): YandexTranslateResult -} \ No newline at end of file diff --git a/twidere/src/main/java/org/mariotaku/yandex/YandexAPIFactory.kt b/twidere/src/main/java/org/mariotaku/yandex/YandexAPIFactory.kt deleted file mode 100644 index 2d05e5d37..000000000 --- a/twidere/src/main/java/org/mariotaku/yandex/YandexAPIFactory.kt +++ /dev/null @@ -1,50 +0,0 @@ -package org.mariotaku.yandex - -import org.mariotaku.restfu.RestAPIFactory -import org.mariotaku.restfu.RestConverter -import org.mariotaku.restfu.RestMethod -import org.mariotaku.restfu.RestRequest -import org.mariotaku.restfu.http.Endpoint -import org.mariotaku.restfu.http.RestHttpClient -import org.mariotaku.restfu.http.ValueMap -import org.mariotaku.restfu.logansqaure.LoganSquareConverterFactory - - -class YandexAPIFactory(apiKey: String, endpoint: String) { - private val factory: RestAPIFactory = RestAPIFactory() - - init { - factory.setEndpoint(Endpoint(endpoint)) - factory.setExceptionFactory { cause, _, _ -> - cause?.let { YandexException(it) } - ?: YandexException() - } - factory.setRestConverterFactory(LoganSquareConverterFactory()) - factory.setRestRequestFactory(object : RestRequest.DefaultFactory() { - override fun create(restMethod: RestMethod, - factory: RestConverter.Factory, valuePool: ValueMap?): RestRequest { - val method = restMethod.method - val path = restMethod.path - val headers = restMethod.getHeaders(valuePool) - val queries = restMethod.getQueries(valuePool) - val params = restMethod.getParams(factory, valuePool) - val rawValue = restMethod.rawValue - val bodyType = restMethod.bodyType - val extras = restMethod.extras - queries.add("key", apiKey) - return RestRequest(method.value, method.allowBody, path, headers, queries, - params, rawValue, bodyType, extras) - } - }) - } - - fun setHttpClient(restClient: RestHttpClient): YandexAPIFactory { - factory.setHttpClient(restClient) - return this - } - - fun build(): YandexAPI { - return factory.build(YandexAPI::class.java) - } -} - diff --git a/twidere/src/main/java/org/mariotaku/yandex/YandexException.kt b/twidere/src/main/java/org/mariotaku/yandex/YandexException.kt deleted file mode 100644 index f4285db76..000000000 --- a/twidere/src/main/java/org/mariotaku/yandex/YandexException.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.mariotaku.yandex - -class YandexException : Exception { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) -} \ No newline at end of file diff --git a/twidere/src/main/java/org/mariotaku/yandex/model/YandexTranslateResult.kt b/twidere/src/main/java/org/mariotaku/yandex/model/YandexTranslateResult.kt deleted file mode 100644 index 32b6f27bc..000000000 --- a/twidere/src/main/java/org/mariotaku/yandex/model/YandexTranslateResult.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.mariotaku.yandex.model - -import com.bluelinelabs.logansquare.annotation.JsonField -import com.bluelinelabs.logansquare.annotation.JsonObject - -@JsonObject -data class YandexTranslateResult( - @JsonField(name = ["code"]) - var code: Int? = null, - @JsonField(name = ["lang"]) - var lang: String? = null, - @JsonField(name = ["text"]) - var text: List? = null -) \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt index 92a480336..132ebba64 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt @@ -10,7 +10,6 @@ import org.mariotaku.ktextension.bcp47Tag import org.mariotaku.ktextension.toLongOr import org.mariotaku.twidere.BuildConfig import org.mariotaku.twidere.Constants.* -import org.mariotaku.twidere.TwidereConstants import org.mariotaku.twidere.TwidereConstants.KEY_MEDIA_PRELOAD import org.mariotaku.twidere.annotation.AccountType import org.mariotaku.twidere.annotation.ImageShapeStyle @@ -87,7 +86,6 @@ val lastLaunchTimeKey = KLongKey("last_launch_time", -1) val promotionsEnabledKey = KBooleanKey("promotions_enabled", false) val translationDestinationKey = KNullableStringKey(KEY_TRANSLATION_DESTINATION, null) val tabPositionKey = KStringKey(KEY_TAB_POSITION, SharedPreferenceConstants.DEFAULT_TAB_POSITION) -val yandexKeyKey = KStringKey(SharedPreferenceConstants.KEY_YANDEX_KEY, TwidereConstants.YANDEX_KEY) val autoHideTabs = KBooleanKey(SharedPreferenceConstants.KEY_AUTO_HIDE_TABS, true) val hideCardNumbersKey = KBooleanKey(KEY_HIDE_CARD_NUMBERS, false) val showLinkPreviewKey = KBooleanKey(KEY_SHOW_LINK_PREVIEW, false) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt index eea9202aa..537b41e0f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt @@ -32,19 +32,19 @@ import android.nfc.NdefMessage import android.nfc.NdefRecord import android.nfc.NfcAdapter.CreateNdefMessageCallback import android.os.Bundle -import android.text.TextUtils -import android.view.* -import android.widget.Toast -import androidx.appcompat.app.AlertDialog import androidx.loader.app.LoaderManager import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.hasRunningLoadersSafe import androidx.loader.content.FixedAsyncTaskLoader import androidx.loader.content.Loader +import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.FixedLinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.ViewHolder +import android.text.TextUtils +import android.view.* +import android.widget.Toast import com.squareup.otto.Subscribe import kotlinx.android.synthetic.main.fragment_status.* import kotlinx.android.synthetic.main.layout_content_fragment_common.* @@ -72,11 +72,13 @@ import org.mariotaku.twidere.annotation.AccountType import org.mariotaku.twidere.constant.KeyboardShortcutConstants.* import org.mariotaku.twidere.constant.displaySensitiveContentsKey import org.mariotaku.twidere.constant.newDocumentApiKey -import org.mariotaku.twidere.constant.yandexKeyKey import org.mariotaku.twidere.extension.* -import org.mariotaku.twidere.extension.model.* import org.mariotaku.twidere.extension.model.api.key import org.mariotaku.twidere.extension.model.api.toParcelable +import org.mariotaku.twidere.extension.model.getAccountType +import org.mariotaku.twidere.extension.model.media_type +import org.mariotaku.twidere.extension.model.newMicroBlogInstance +import org.mariotaku.twidere.extension.model.originalId import org.mariotaku.twidere.extension.view.calculateSpaceItemHeight import org.mariotaku.twidere.fragment.AbsStatusesFragment import org.mariotaku.twidere.fragment.AbsStatusesFragment.Companion.handleActionClick @@ -99,14 +101,12 @@ import org.mariotaku.twidere.util.* import org.mariotaku.twidere.util.ContentScrollHandler.ContentListSupport import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback import org.mariotaku.twidere.util.RecyclerViewScrollHandler.RecyclerViewCallback -import org.mariotaku.twidere.util.dagger.DependencyHolder import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener import org.mariotaku.twidere.view.ExtendedRecyclerView import org.mariotaku.twidere.view.holder.GapViewHolder import org.mariotaku.twidere.view.holder.StatusViewHolder import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder.StatusClickListener -import org.mariotaku.yandex.YandexAPIFactory import java.lang.ref.WeakReference import kotlin.math.max import kotlin.math.min @@ -692,8 +692,8 @@ class StatusFragment : BaseFragment(), LoaderCallbacksDNS Server Set DNS Server for network requests. - Yandex Api Key - Draft saved Your unsent tweets will save here diff --git a/twidere/src/main/res/xml/preferences_advanced_network.xml b/twidere/src/main/res/xml/preferences_advanced_network.xml index d1e13bb70..a8515683d 100644 --- a/twidere/src/main/res/xml/preferences_advanced_network.xml +++ b/twidere/src/main/res/xml/preferences_advanced_network.xml @@ -36,12 +36,6 @@ android:summary="@string/custom_host_mapping_summary" android:title="@string/custom_host_mapping"/> - -