update to SDK 30 and fix deprecations (#2173)

* update to SDk 30 and fix deprecations

* remove unnecessary .run

* revert ViewMediaActivity change
This commit is contained in:
Konrad Pozniak 2021-06-01 19:46:07 +02:00 committed by GitHub
parent e032d38d56
commit 3301643c1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 33 deletions

View file

@ -15,11 +15,11 @@ def getGitSha = {
} }
android { android {
compileSdkVersion 29 compileSdkVersion 30
defaultConfig { defaultConfig {
applicationId APP_ID applicationId APP_ID
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 30
versionCode 83 versionCode 83
versionName "15.1" versionName "15.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View file

@ -34,13 +34,16 @@ import androidx.annotation.Px
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.app.ActivityOptionsCompat import androidx.core.app.ActivityOptionsCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsCompat.Type.systemBars
import androidx.emoji.text.EmojiCompat import androidx.emoji.text.EmojiCompat
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.viewpager2.widget.MarginPageTransformer import androidx.viewpager2.widget.MarginPageTransformer
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.shape.MaterialShapeDrawable import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.shape.ShapeAppearanceModel import com.google.android.material.shape.ShapeAppearanceModel
@ -170,7 +173,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
binding.accountFieldList.layoutManager = LinearLayoutManager(this) binding.accountFieldList.layoutManager = LinearLayoutManager(this)
binding.accountFieldList.adapter = accountFieldAdapter binding.accountFieldList.adapter = accountFieldAdapter
val accountListClickListener = { v: View -> val accountListClickListener = { v: View ->
val type = when (v.id) { val type = when (v.id) {
R.id.accountFollowers -> AccountListActivity.Type.FOLLOWERS R.id.accountFollowers -> AccountListActivity.Type.FOLLOWERS
@ -237,13 +239,11 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
private fun setupToolbar() { private fun setupToolbar() {
// set toolbar top margin according to system window insets // set toolbar top margin according to system window insets
binding.accountCoordinatorLayout.setOnApplyWindowInsetsListener { _, insets -> ViewCompat.setOnApplyWindowInsetsListener(binding.accountCoordinatorLayout) { _, insets ->
val top = insets.systemWindowInsetTop val top = insets.getInsets(systemBars()).top
val toolbarParams = binding.accountToolbar.layoutParams as ViewGroup.MarginLayoutParams
val toolbarParams = binding.accountToolbar.layoutParams as CollapsingToolbarLayout.LayoutParams
toolbarParams.topMargin = top toolbarParams.topMargin = top
WindowInsetsCompat.CONSUMED
insets.consumeSystemWindowInsets()
} }
// Setup the toolbar. // Setup the toolbar.
@ -318,8 +318,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
} }
private fun makeNotificationBarTransparent() { private fun makeNotificationBarTransparent() {
val decorView = window.decorView WindowCompat.setDecorFitsSystemWindows(window, false)
decorView.systemUiVisibility = decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
window.statusBarColor = statusBarColorTransparent window.statusBarColor = statusBarColorTransparent
} }

View file

@ -614,7 +614,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setTitle(R.string.action_logout) .setTitle(R.string.action_logout)
.setMessage(getString(R.string.action_logout_confirm, activeAccount.fullName)) .setMessage(getString(R.string.action_logout_confirm, activeAccount.fullName))
.setPositiveButton(android.R.string.yes) { _: DialogInterface?, _: Int -> .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
NotificationHelper.deleteNotificationChannelsForAccount(activeAccount, this) NotificationHelper.deleteNotificationChannelsForAccount(activeAccount, this)
cacheUpdater.clearForUser(activeAccount.id) cacheUpdater.clearForUser(activeAccount.id)
conversationRepository.deleteCacheForAccount(activeAccount.id) conversationRepository.deleteCacheForAccount(activeAccount.id)
@ -632,7 +632,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
startActivity(intent) startActivity(intent)
finishWithoutSlideOutAnimation() finishWithoutSlideOutAnimation()
} }
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.cancel, null)
.show() .show()
} }
} }

View file

@ -49,8 +49,8 @@ import com.keylesspalace.tusky.BuildConfig.APPLICATION_ID
import com.keylesspalace.tusky.databinding.ActivityViewMediaBinding import com.keylesspalace.tusky.databinding.ActivityViewMediaBinding
import com.keylesspalace.tusky.entity.Attachment import com.keylesspalace.tusky.entity.Attachment
import com.keylesspalace.tusky.fragment.ViewImageFragment import com.keylesspalace.tusky.fragment.ViewImageFragment
import com.keylesspalace.tusky.pager.SingleImagePagerAdapter
import com.keylesspalace.tusky.pager.ImagePagerAdapter import com.keylesspalace.tusky.pager.ImagePagerAdapter
import com.keylesspalace.tusky.pager.SingleImagePagerAdapter
import com.keylesspalace.tusky.util.getTemporaryMediaFilename import com.keylesspalace.tusky.util.getTemporaryMediaFilename
import com.keylesspalace.tusky.util.viewBinding import com.keylesspalace.tusky.util.viewBinding
import com.keylesspalace.tusky.viewdata.AttachmentViewData import com.keylesspalace.tusky.viewdata.AttachmentViewData
@ -138,6 +138,7 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener
} }
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE
window.statusBarColor = Color.BLACK window.statusBarColor = Color.BLACK
window.sharedElementEnterTransition.addListener(object : NoopTransitionListener { window.sharedElementEnterTransition.addListener(object : NoopTransitionListener {
override fun onTransitionEnd(transition: Transition) { override fun onTransitionEnd(transition: Transition) {

View file

@ -47,7 +47,7 @@ class AddPollOptionsAdapter(
binding.optionEditText.filters = arrayOf(InputFilter.LengthFilter(maxOptionLength)) binding.optionEditText.filters = arrayOf(InputFilter.LengthFilter(maxOptionLength))
binding.optionEditText.onTextChanged { s, _, _, _ -> binding.optionEditText.onTextChanged { s, _, _, _ ->
val pos = holder.adapterPosition val pos = holder.bindingAdapterPosition
if(pos != RecyclerView.NO_POSITION) { if(pos != RecyclerView.NO_POSITION) {
options[pos] = s.toString() options[pos] = s.toString()
onOptionChanged(validateInput()) onOptionChanged(validateInput())
@ -68,8 +68,8 @@ class AddPollOptionsAdapter(
holder.binding.deleteButton.setOnClickListener { holder.binding.deleteButton.setOnClickListener {
holder.binding.optionEditText.clearFocus() holder.binding.optionEditText.clearFocus()
options.removeAt(holder.adapterPosition) options.removeAt(holder.bindingAdapterPosition)
notifyItemRemoved(holder.adapterPosition) notifyItemRemoved(holder.bindingAdapterPosition)
onOptionRemoved(validateInput()) onOptionRemoved(validateInput())
} }
} }

View file

@ -21,7 +21,6 @@ import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.text.InputFilter import android.text.InputFilter
import android.text.InputType import android.text.InputType
import android.util.DisplayMetrics
import android.view.WindowManager import android.view.WindowManager
import android.widget.EditText import android.widget.EditText
import android.widget.LinearLayout import android.widget.LinearLayout
@ -54,9 +53,6 @@ fun <T> T.makeCaptionDialog(existingDescription: String?,
maximumScale = 6f maximumScale = 6f
} }
val displayMetrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(displayMetrics)
val margin = Utils.dpToPx(this, 4) val margin = Utils.dpToPx(this, 4)
dialogLayout.addView(imageView) dialogLayout.addView(imageView)
(imageView.layoutParams as LinearLayout.LayoutParams).weight = 1f (imageView.layoutParams as LinearLayout.LayoutParams).weight = 1f

View file

@ -41,22 +41,22 @@ object AppInjector {
handleActivity(activity) handleActivity(activity)
} }
override fun onActivityPaused(activity: Activity?) { override fun onActivityPaused(activity: Activity) {
} }
override fun onActivityResumed(activity: Activity?) { override fun onActivityResumed(activity: Activity) {
} }
override fun onActivityStarted(activity: Activity?) { override fun onActivityStarted(activity: Activity) {
} }
override fun onActivityDestroyed(activity: Activity?) { override fun onActivityDestroyed(activity: Activity) {
} }
override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) { override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
} }
override fun onActivityStopped(activity: Activity?) { override fun onActivityStopped(activity: Activity) {
} }
}) })

View file

@ -306,8 +306,8 @@ public class NotificationsFragment extends SFragment implements
private void confirmClearNotifications() { private void confirmClearNotifications() {
new AlertDialog.Builder(getContext()) new AlertDialog.Builder(getContext())
.setMessage(R.string.notification_clear_text) .setMessage(R.string.notification_clear_text)
.setPositiveButton(android.R.string.yes, (DialogInterface dia, int which) -> clearNotifications()) .setPositiveButton(android.R.string.ok, (DialogInterface dia, int which) -> clearNotifications())
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.cancel, null)
.show(); .show();
} }

View file

@ -51,8 +51,8 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
val senderFullName = intent.getStringExtra(NotificationHelper.KEY_SENDER_ACCOUNT_FULL_NAME) val senderFullName = intent.getStringExtra(NotificationHelper.KEY_SENDER_ACCOUNT_FULL_NAME)
val citedStatusId = intent.getStringExtra(NotificationHelper.KEY_CITED_STATUS_ID) val citedStatusId = intent.getStringExtra(NotificationHelper.KEY_CITED_STATUS_ID)
val visibility = intent.getSerializableExtra(NotificationHelper.KEY_VISIBILITY) as Status.Visibility val visibility = intent.getSerializableExtra(NotificationHelper.KEY_VISIBILITY) as Status.Visibility
val spoiler = intent.getStringExtra(NotificationHelper.KEY_SPOILER) val spoiler = intent.getStringExtra(NotificationHelper.KEY_SPOILER) ?: ""
val mentions = intent.getStringArrayExtra(NotificationHelper.KEY_MENTIONS) val mentions = intent.getStringArrayExtra(NotificationHelper.KEY_MENTIONS) ?: emptyArray()
val citedText = intent.getStringExtra(NotificationHelper.KEY_CITED_TEXT) val citedText = intent.getStringExtra(NotificationHelper.KEY_CITED_TEXT)
val localAuthorId = intent.getStringExtra(NotificationHelper.KEY_CITED_AUTHOR_LOCAL) val localAuthorId = intent.getStringExtra(NotificationHelper.KEY_CITED_AUTHOR_LOCAL)
@ -69,7 +69,7 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
val builder = NotificationCompat.Builder(context, NotificationHelper.CHANNEL_MENTION + senderIdentifier) val builder = NotificationCompat.Builder(context, NotificationHelper.CHANNEL_MENTION + senderIdentifier)
.setSmallIcon(R.drawable.ic_notify) .setSmallIcon(R.drawable.ic_notify)
.setColor(ContextCompat.getColor(context, (R.color.tusky_blue))) .setColor(ContextCompat.getColor(context, R.color.tusky_blue))
.setGroup(senderFullName) .setGroup(senderFullName)
.setDefaults(0) // So it doesn't ring twice, notify only in Target callback .setDefaults(0) // So it doesn't ring twice, notify only in Target callback