From 1413a1155b074cdef030d162bdd21c4427740347 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 3 Dec 2018 11:22:57 +0100 Subject: [PATCH] remove unnecessary compat code (#932) --- .../com/keylesspalace/tusky/AccountActivity.kt | 8 +++----- .../keylesspalace/tusky/ComposeActivity.java | 17 +++++++---------- .../keylesspalace/tusky/EditProfileActivity.kt | 3 +-- .../com/keylesspalace/tusky/ListsActivity.kt | 3 +-- .../tusky/fragment/ViewVideoFragment.kt | 3 +-- .../tusky/view/ProgressImageView.java | 3 +-- 6 files changed, 14 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt index a6b373dc..2668c09a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt @@ -32,8 +32,6 @@ import android.support.text.emoji.EmojiCompat import android.support.v4.app.ActivityOptionsCompat import android.support.v4.app.Fragment import android.support.v4.content.ContextCompat -import android.support.v4.view.ViewCompat -import android.support.v4.widget.TextViewCompat import android.support.v7.app.AlertDialog import android.support.v7.widget.LinearLayoutManager import android.view.Menu @@ -142,7 +140,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF accountId = intent.getStringExtra(KEY_ACCOUNT_ID) // set toolbar top margin according to system window insets - ViewCompat.setOnApplyWindowInsetsListener(accountCoordinatorLayout) { _, insets -> + accountCoordinatorLayout.setOnApplyWindowInsetsListener { _, insets -> val top = insets.systemWindowInsetTop val toolbarParams = accountToolbar.layoutParams as CollapsingToolbarLayout.LayoutParams @@ -317,7 +315,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF accountAvatarImageView.setOnClickListener { avatarView -> val intent = ViewMediaActivity.newAvatarIntent(avatarView.context, account.avatar) - ViewCompat.setTransitionName(avatarView, account.avatar) + avatarView.transitionName = account.avatar val options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, avatarView, account.avatar) startActivity(intent, options.toBundle()) @@ -352,7 +350,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF val textColor = ThemeUtils.getColor(this, android.R.attr.textColorTertiary) movedIcon?.setColorFilter(textColor, PorterDuff.Mode.SRC_IN) - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(accountMovedText, movedIcon, null, null, null) + accountMovedText.setCompoundDrawablesRelativeWithIntrinsicBounds(movedIcon, null, null, null) accountFollowers.hide() accountFollowing.hide() diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 8894249b..fe921a82 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -52,8 +52,6 @@ import android.support.v13.view.inputmethod.InputContentInfoCompat; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; -import android.support.v4.view.ViewCompat; -import android.support.v4.widget.TextViewCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.content.res.AppCompatResources; @@ -360,10 +358,10 @@ public final class ComposeActivity int textColor = ThemeUtils.getColor(this, android.R.attr.textColorTertiary); Drawable cameraIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_camera_alt).color(textColor).sizeDp(18); - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(actionPhotoTake, cameraIcon, null, null, null); + actionPhotoTake.setCompoundDrawablesRelativeWithIntrinsicBounds(cameraIcon, null, null, null); Drawable imageIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_image).color(textColor).sizeDp(18); - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(actionPhotoPick, imageIcon, null, null, null); + actionPhotoPick.setCompoundDrawablesRelativeWithIntrinsicBounds(imageIcon, null, null, null); actionPhotoTake.setOnClickListener(v -> initiateCameraApp()); actionPhotoPick.setOnClickListener(v -> onMediaPick()); @@ -466,7 +464,7 @@ public final class ComposeActivity Drawable arrowDownIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_arrow_drop_down).sizeDp(12); ThemeUtils.setDrawableTint(this, arrowDownIcon, android.R.attr.textColorTertiary); - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(replyTextView, null, null, arrowDownIcon, null); + replyTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, arrowDownIcon, null); replyTextView.setOnClickListener(v -> { TransitionManager.beginDelayedTransition((ViewGroup)replyContentTextView.getParent()); @@ -476,11 +474,10 @@ public final class ComposeActivity Drawable arrowUpIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_arrow_drop_up).sizeDp(12); ThemeUtils.setDrawableTint(this, arrowUpIcon, android.R.attr.textColorTertiary); - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(replyTextView, null, null, arrowUpIcon, null); + replyTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, arrowUpIcon, null); } else { replyContentTextView.setVisibility(View.GONE); - - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(replyTextView, null, null, arrowDownIcon, null); + replyTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, arrowDownIcon, null); } }); } @@ -662,14 +659,14 @@ public final class ComposeActivity Snackbar.LENGTH_SHORT); bar.setAction(actionId, listener); //necessary so snackbar is shown over everything - ViewCompat.setElevation(bar.getView(), getResources().getDimensionPixelSize(R.dimen.compose_activity_snackbar_elevation)); + bar.getView().setElevation(getResources().getDimensionPixelSize(R.dimen.compose_activity_snackbar_elevation)); bar.show(); } private void displayTransientError(@StringRes int stringId) { Snackbar bar = Snackbar.make(findViewById(R.id.activity_compose), stringId, Snackbar.LENGTH_LONG); //necessary so snackbar is shown over everything - ViewCompat.setElevation(bar.getView(), getResources().getDimensionPixelSize(R.dimen.compose_activity_snackbar_elevation)); + bar.getView().setElevation(getResources().getDimensionPixelSize(R.dimen.compose_activity_snackbar_elevation)); bar.show(); } diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt index 63b03bf3..02a1e10c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -29,7 +29,6 @@ import android.os.Bundle import android.support.design.widget.Snackbar import android.support.v4.app.ActivityCompat import android.support.v4.content.ContextCompat -import android.support.v4.widget.TextViewCompat import android.support.v7.widget.LinearLayoutManager import android.view.Menu import android.view.MenuItem @@ -98,7 +97,7 @@ class EditProfileActivity : BaseActivity(), Injectable { val plusDrawable = IconicsDrawable(this, GoogleMaterial.Icon.gmd_add).sizeDp(12).color(Color.WHITE) - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(addFieldButton, plusDrawable, null, null, null) + addFieldButton.setCompoundDrawablesRelativeWithIntrinsicBounds(plusDrawable, null, null, null) addFieldButton.setOnClickListener { accountFieldEditAdapter.addField() diff --git a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt index 890e52e3..086ce741 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt @@ -3,7 +3,6 @@ package com.keylesspalace.tusky import android.content.Context import android.content.Intent import android.os.Bundle -import android.support.v4.widget.TextViewCompat import android.support.v7.widget.DividerItemDecoration import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.RecyclerView @@ -175,7 +174,7 @@ class ListsActivity : BaseActivity(), ListsView, Injectable { val icon = IconicsDrawable(context, GoogleMaterial.Icon.gmd_list).sizeDp(20) ThemeUtils.setDrawableTint(context, icon, android.R.attr.textColorTertiary) - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(nameTextView, icon, null, null, null) + nameTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt index 483af195..827305d4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt @@ -21,7 +21,6 @@ import android.annotation.SuppressLint import android.os.Bundle import android.os.Handler import android.os.Looper -import android.support.v4.view.ViewCompat import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -72,7 +71,7 @@ class ViewVideoFragment : ViewMediaFragment() { override fun setupMediaView(url: String) { descriptionView = mediaDescription val videoView = videoPlayer - ViewCompat.setTransitionName(videoView, url) + videoView.transitionName = url videoView.setVideoPath(url) mediaController = MediaController(mediaActivity) mediaController.setMediaPlayer(videoPlayer) diff --git a/app/src/main/java/com/keylesspalace/tusky/view/ProgressImageView.java b/app/src/main/java/com/keylesspalace/tusky/view/ProgressImageView.java index 5fe807f7..1e908b12 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/ProgressImageView.java +++ b/app/src/main/java/com/keylesspalace/tusky/view/ProgressImageView.java @@ -25,7 +25,6 @@ import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; -import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.content.res.AppCompatResources; import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; @@ -117,7 +116,7 @@ public final class ProgressImageView extends AppCompatImageView { getHeight() - circleMargin - circleRadius, getWidth() - circleMargin, getHeight() - circleMargin); - DrawableCompat.setTint(captionDrawable, Color.WHITE); + captionDrawable.setTint(Color.WHITE); captionDrawable.draw(canvas); } }