From 427c69d315e99eaa5fce027f5f64036628a221dd Mon Sep 17 00:00:00 2001 From: Adolfo Santiago Date: Sat, 28 May 2022 08:34:01 +0200 Subject: [PATCH] Update version for API 31 The app now compiles pointing to API 31 level (Android 12). --- husky/app/src/main/AndroidManifest.xml | 64 +++++++++-- .../keylesspalace/tusky/TuskyApplication.kt | 4 +- .../components/compose/view/EditTextTyped.kt | 58 ++++++---- .../keylesspalace/tusky/util/OkHttpUtils.java | 99 ----------------- .../keylesspalace/tusky/util/OkHttpUtils.kt | 100 ++++++++++++++++++ husky/appinfo.gradle | 6 +- husky/versions.gradle | 34 +++--- 7 files changed, 214 insertions(+), 151 deletions(-) delete mode 100644 husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java create mode 100644 husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.kt diff --git a/husky/app/src/main/AndroidManifest.xml b/husky/app/src/main/AndroidManifest.xml index aefa614..e319f9e 100644 --- a/husky/app/src/main/AndroidManifest.xml +++ b/husky/app/src/main/AndroidManifest.xml @@ -23,7 +23,9 @@ + @@ -33,15 +35,19 @@ - + + android:configChanges="orientation|screenSize|keyboardHidden" + android:exported="false" /> + + @@ -52,9 +58,12 @@ android:scheme="@string/oauth_scheme" /> + + android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize" + android:exported="false"> + @@ -62,6 +71,7 @@ + @@ -69,6 +79,7 @@ + @@ -76,6 +87,7 @@ + @@ -83,6 +95,7 @@ + @@ -90,6 +103,7 @@ + @@ -101,37 +115,52 @@ - + + + + + + + + + + + + + + + @@ -140,19 +169,31 @@ android:name="android.app.searchable" android:resource="@xml/searchable" /> + + + + + + + + + - + + + tools:node="merge"> + + + diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt b/husky/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt index 65b92a4..c671fe3 100644 --- a/husky/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt +++ b/husky/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt @@ -135,14 +135,14 @@ class TuskyApplication : Application(), HasAndroidInjector { APP_VERSION_CODE, BUILD_CONFIG, STACK_TRACE - ).toTypedArray() + ) notification { title = getString(R.string.acra_notification_title) text = getString(R.string.acra_notification_body) channelName = getString(R.string.acra_notification_channel_title) channelDescription = getString(R.string.acra_notification_channel_body) - resChannelImportance = NotificationManagerCompat.IMPORTANCE_DEFAULT + channelImportance = NotificationManagerCompat.IMPORTANCE_DEFAULT //resIcon = R.drawable.notification_icon sendButtonText = getString(R.string.acra_notification_report) //resSendButtonIcon = R.drawable.notification_send diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt b/husky/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt index 0a5e1c3..98b7281 100644 --- a/husky/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt +++ b/husky/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt @@ -1,34 +1,40 @@ -/* Copyright 2018 Conny Duck +/* + * Husky -- A Pleroma client for Android * - * This file is a part of Tusky. + * Copyright (C) 2021 The Husky Developers + * Copyright (C) 2018 Conny Duck * - * 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 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. * - * Tusky 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. + * 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 Tusky; if not, - * see . */ + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package com.keylesspalace.tusky.components.compose.view import android.content.Context -import androidx.emoji.widget.EmojiEditTextHelper -import androidx.core.view.inputmethod.EditorInfoCompat -import androidx.core.view.inputmethod.InputConnectionCompat -import androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView import android.text.InputType import android.text.method.KeyListener import android.util.AttributeSet import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputConnection +import androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView +import androidx.core.view.inputmethod.EditorInfoCompat +import androidx.core.view.inputmethod.InputConnectionCompat +import androidx.emoji.widget.EmojiEditTextHelper -class EditTextTyped @JvmOverloads constructor(context: Context, - attributeSet: AttributeSet? = null) - : AppCompatMultiAutoCompleteTextView(context, attributeSet) { +class EditTextTyped @JvmOverloads constructor( + context: Context, + attributeSet: AttributeSet? = null +) : AppCompatMultiAutoCompleteTextView(context, attributeSet) { private var onCommitContentListener: InputConnectionCompat.OnCommitContentListener? = null private val emojiEditTextHelper: EmojiEditTextHelper = EmojiEditTextHelper(this) @@ -40,8 +46,12 @@ class EditTextTyped @JvmOverloads constructor(context: Context, super.setKeyListener(getEmojiEditTextHelper().getKeyListener(keyListener)) } - override fun setKeyListener(input: KeyListener) { - super.setKeyListener(getEmojiEditTextHelper().getKeyListener(input)) + override fun setKeyListener(input: KeyListener?) { + if(input != null) { + super.setKeyListener(getEmojiEditTextHelper().getKeyListener(input)) + } else { + super.setKeyListener(input) + } } fun setOnCommitContentListener(listener: InputConnectionCompat.OnCommitContentListener) { @@ -50,10 +60,14 @@ class EditTextTyped @JvmOverloads constructor(context: Context, override fun onCreateInputConnection(editorInfo: EditorInfo): InputConnection { val connection = super.onCreateInputConnection(editorInfo) - return if (onCommitContentListener != null) { + return if(onCommitContentListener != null) { EditorInfoCompat.setContentMimeTypes(editorInfo, arrayOf("image/*")) - getEmojiEditTextHelper().onCreateInputConnection(InputConnectionCompat.createWrapper(connection, editorInfo, - onCommitContentListener!!), editorInfo)!! + getEmojiEditTextHelper().onCreateInputConnection( + InputConnectionCompat.createWrapper( + connection, editorInfo, + onCommitContentListener!! + ), editorInfo + )!! } else { connection } diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java b/husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java deleted file mode 100644 index 9bd137d..0000000 --- a/husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Husky -- A Pleroma client for Android - * - * Copyright (C) 2021 The Husky Developers - * Copyright (C) 2017 Andrew Dawson - * - * 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 com.keylesspalace.tusky.util; - -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Build; -import androidx.annotation.NonNull; -import androidx.preference.PreferenceManager; -import com.keylesspalace.tusky.BuildConfig; -import com.keylesspalace.tusky.core.utils.ApplicationUtils; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.util.concurrent.TimeUnit; -import okhttp3.Cache; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.brotli.BrotliInterceptor; -import okhttp3.logging.HttpLoggingInterceptor; - -public class OkHttpUtils { - - @NonNull - public static OkHttpClient.Builder getCompatibleClientBuilder(@NonNull Context context) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - - boolean httpProxyEnabled = preferences.getBoolean("httpProxyEnabled", false); - String httpServer = preferences.getString("httpProxyServer", ""); - int httpPort; - try { - httpPort = Integer.parseInt(preferences.getString("httpProxyPort", "-1")); - } catch(NumberFormatException e) { - // user has entered wrong port, fall back to no proxy - httpPort = -1; - } - - int cacheSize = 25 * 1024 * 1024; // 25 MiB - - OkHttpClient.Builder builder = new OkHttpClient.Builder() - .addInterceptor(getUserAgentInterceptor()) - .addInterceptor(BrotliInterceptor.INSTANCE) - .readTimeout(30, TimeUnit.SECONDS) - .writeTimeout(30, TimeUnit.SECONDS) - .cache(new Cache(context.getCacheDir(), cacheSize)); - - if(ApplicationUtils.INSTANCE.isDebug()) { - builder.addInterceptor(getDebugInformation()); - } - - if(httpProxyEnabled && !httpServer.isEmpty() && (httpPort > 0) && (httpPort < 65535)) { - InetSocketAddress address = InetSocketAddress.createUnresolved(httpServer, httpPort); - builder.proxy(new Proxy(Proxy.Type.HTTP, address)); - } - - return builder; - } - - /** - * Add a custom User-Agent that contains Tusky & Android Version to all requests - * Example: - * User-Agent: Tusky/1.1.2 Android/5.0.2 - */ - @NonNull - private static Interceptor getUserAgentInterceptor() { - return chain -> { - Request originalRequest = chain.request(); - Request requestWithUserAgent = originalRequest.newBuilder() - .header("User-Agent", BuildConfig.APPLICATION_NAME + "/" + BuildConfig.VERSION_NAME + " Android/" + Build.VERSION.RELEASE) - .build(); - return chain.proceed(requestWithUserAgent); - }; - } - - @NonNull - private static Interceptor getDebugInformation() { - HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); - interceptor.level(HttpLoggingInterceptor.Level.BODY); - return interceptor; - } -} diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.kt b/husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.kt new file mode 100644 index 0000000..4dd6767 --- /dev/null +++ b/husky/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.kt @@ -0,0 +1,100 @@ +/* + * Husky -- A Pleroma client for Android + * + * Copyright (C) 2021 The Husky Developers + * Copyright (C) 2017 Andrew Dawson + * + * 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 com.keylesspalace.tusky.util + +import android.content.Context +import android.os.Build.VERSION +import androidx.preference.PreferenceManager +import com.keylesspalace.tusky.BuildConfig +import com.keylesspalace.tusky.core.utils.ApplicationUtils.isDebug +import java.net.InetSocketAddress +import java.net.Proxy +import java.util.concurrent.TimeUnit.SECONDS +import okhttp3.Cache +import okhttp3.Interceptor +import okhttp3.Interceptor.Chain +import okhttp3.OkHttpClient +import okhttp3.brotli.BrotliInterceptor +import okhttp3.logging.HttpLoggingInterceptor +import okhttp3.logging.HttpLoggingInterceptor.Level.BODY + +object OkHttpUtils { + + fun getCompatibleClientBuilder(context: Context): OkHttpClient.Builder { + val preferences = PreferenceManager.getDefaultSharedPreferences(context) + + val httpProxyEnabled = preferences.getBoolean("httpProxyEnabled", false) + val httpServer = preferences.getString("httpProxyServer", "") ?: "" + val httpPort = kotlin.runCatching { + preferences.getString("httpProxyPort", "-1") ?: "-1" + }.map { + it.toInt() + }.getOrElse { -1 } + + val cacheSize: Long = 25 * (1024 * 1024) + + val builder = OkHttpClient.Builder() + .addInterceptor(getUserAgentInterceptor()) + .addInterceptor(BrotliInterceptor) + .readTimeout(60, SECONDS) + .writeTimeout(60, SECONDS) + .cache(Cache(context.cacheDir, cacheSize)) + + if(isDebug()) { + builder.addInterceptor(getDebugInformation()) + } + + if(httpProxyEnabled && httpServer.isNotEmpty() && httpPort in 0..65535) { + builder.proxy( + Proxy( + Proxy.Type.HTTP, + InetSocketAddress.createUnresolved(httpServer, httpPort) + ) + ) + } + + return builder + } + + /** + * Add a custom User-Agent that contains Tusky & Android Version to all requests + * Example: + * User-Agent: Tusky/1.1.2 Android/5.0.2 + */ + private fun getUserAgentInterceptor(): Interceptor { + return Interceptor { chain: Chain -> + val originalRequest = chain.request() + val requestWithUserAgent = originalRequest.newBuilder() + .header( + "User-Agent", + "${BuildConfig.APPLICATION_NAME}/${BuildConfig.VERSION_NAME} Android/${VERSION.RELEASE}" + ) + .build() + chain.proceed(requestWithUserAgent) + } + } + + private fun getDebugInformation(): Interceptor { + val interceptor = HttpLoggingInterceptor() + interceptor.level = BODY + return interceptor + } +} diff --git a/husky/appinfo.gradle b/husky/appinfo.gradle index 54bc137..7ffbde8 100644 --- a/husky/appinfo.gradle +++ b/husky/appinfo.gradle @@ -1,8 +1,8 @@ def buildVersions = [:] buildVersions.applicationId = "su.xash.husky" -buildVersions.compileSdk = 30 +buildVersions.compileSdk = 31 buildVersions.minSdk = 23 -buildVersions.targetSdk = 30 +buildVersions.targetSdk = 31 buildVersions.buildTools = "32.0.0" buildVersions.javaCompat = JavaVersion.VERSION_11 buildVersions.jdkVersion = "${buildVersions.javaCompat}" @@ -24,7 +24,7 @@ dev.suffix = "dev" dev.applicationId = "su.xash.husky.${dev.suffix}" dev.minSdk = 23 -dev.targetSdk = 30 +dev.targetSdk = 31 dev.versionCode = 1 dev.versionName = "1.0.0" diff --git a/husky/versions.gradle b/husky/versions.gradle index 307f28b..f16fb82 100644 --- a/husky/versions.gradle +++ b/husky/versions.gradle @@ -5,36 +5,36 @@ ext.kotlin_version = "1.6.21" def versions = [:] def gradle = [:] -gradle.androidGradlePlugin = "7.2.0" +gradle.androidGradlePlugin = "7.2.1" gradle.gradleVersions = "0.42.0" versions.gradle = gradle -versions.acra = "5.8.4" +versions.acra = "5.9.3" versions.androidImageCropper = "2.8.0" versions.androidSvg = "1.4" -versions.appcompat = "1.3.1" +versions.appcompat = "1.4.1" versions.autodispose = "1.4.0" -versions.bigImageViewer = "1.7.0" -versions.browser = "1.3.0" +versions.bigImageViewer = "1.8.1" +versions.browser = "1.4.0" versions.cardView = "1.0.0" versions.conscryptAndroid = "2.5.2" -versions.constraintlayout = "2.1.3" -versions.coreKtx = "1.3.2" -versions.dagger = "2.38.1" +versions.constraintlayout = "2.1.4" +versions.coreKtx = "1.7.0" +versions.dagger = "2.42" versions.emoji = "1.1.0" versions.exifInterface = "1.3.3" -versions.exoplayer = "2.16.0" +versions.exoplayer = "2.17.1" versions.filemojiCompat = "1.0.17" versions.flexbox = "2.0.1" -versions.fragmentKtx = "1.2.5" +versions.fragmentKtx = "1.4.1" versions.fragmentviewbindingdelegateKt = "1.0.0" versions.glide = "4.13.2" versions.glideImage = "1.8.1" -versions.glidePluginAnimation = "2.21.0" +versions.glidePluginAnimation = "2.22.0" versions.kotlinx = "1.6.1" -versions.lifecycle = "2.3.1" +versions.lifecycle = "2.4.1" versions.markdownEdit = "1.0.0" -versions.materialDesign = "1.4.0" +versions.materialDesign = "1.6.0" versions.materialDrawer = "8.4.5" versions.materialDrawerTypeface = "3.0.1.4.original-kotlin@aar" versions.pagingRuntimeKtx = "2.1.2" @@ -46,14 +46,14 @@ versions.room = "2.2.5" versions.rxAndroid = "2.1.1" versions.rxJava = "2.2.21" versions.rxKotlin = "2.4.0" -versions.shareTarget = "1.0.0" -versions.simplestack = "2.6.3" -versions.simplestackext = "2.2.2" +versions.shareTarget = "1.2.0-rc01" +versions.simplestack = "2.6.4" +versions.simplestackext = "2.2.4" versions.sparkButton = "4.1.0" versions.swipeRefreshLayout = "1.1.0" versions.timber = "5.0.1" versions.viewpager2 = "1.0.0" -versions.workRuntime = "2.4.0" +versions.workRuntime = "2.7.1" def testing = [:] testing.espresso = "3.4.0"