update minSdkVersion to 23 (#2638)

closes #2606
This commit is contained in:
Konrad Pozniak 2022-08-04 16:48:26 +02:00 committed by GitHub
parent 2d2d7569e3
commit 55796c9a30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 21 additions and 45 deletions

View file

@ -22,7 +22,7 @@ android {
compileSdkVersion 31 compileSdkVersion 31
defaultConfig { defaultConfig {
applicationId APP_ID applicationId APP_ID
minSdkVersion 21 minSdkVersion 23
targetSdkVersion 31 targetSdkVersion 31
versionCode 94 versionCode 94
versionName "19.0" versionName "19.0"

View file

@ -7,9 +7,6 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" /> <!-- For notifications --> <uses-permission android:name="android.permission.VIBRATE" /> <!-- For notifications -->
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="22" /> <!-- for day/night mode -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application <application

View file

@ -33,7 +33,6 @@ import android.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
@ -376,7 +375,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
closeDrawerOnProfileListClick = true closeDrawerOnProfileListClick = true
} }
header.accountHeaderBackground.setColorFilter(ContextCompat.getColor(this, R.color.headerBackgroundFilter)) header.accountHeaderBackground.setColorFilter(getColor(R.color.headerBackgroundFilter))
header.accountHeaderBackground.setBackgroundColor(ThemeUtils.getColor(this, R.attr.colorBackgroundAccent)) header.accountHeaderBackground.setBackgroundColor(ThemeUtils.getColor(this, R.attr.colorBackgroundAccent))
val animateAvatars = preferences.getBoolean("animateGifAvatars", false) val animateAvatars = preferences.getBoolean("animateGifAvatars", false)

View file

@ -491,7 +491,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
Drawable getIconWithColor(Context context, @DrawableRes int drawable, @ColorRes int color) { Drawable getIconWithColor(Context context, @DrawableRes int drawable, @ColorRes int color) {
Drawable icon = ContextCompat.getDrawable(context, drawable); Drawable icon = ContextCompat.getDrawable(context, drawable);
if (icon != null) { if (icon != null) {
icon.setColorFilter(ContextCompat.getColor(context, color), PorterDuff.Mode.SRC_ATOP); icon.setColorFilter(context.getColor(color), PorterDuff.Mode.SRC_ATOP);
} }
return icon; return icon;
} }

View file

@ -18,7 +18,6 @@ package com.keylesspalace.tusky.adapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.keylesspalace.tusky.R import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.databinding.ItemPollBinding import com.keylesspalace.tusky.databinding.ItemPollBinding
@ -97,7 +96,7 @@ class PollAdapter : RecyclerView.Adapter<BindingHolder<ItemPollBinding>>() {
} }
resultTextView.background.level = level resultTextView.background.level = level
resultTextView.background.setTint(ContextCompat.getColor(resultTextView.context, optionColor)) resultTextView.background.setTint(resultTextView.context.getColor(optionColor))
resultTextView.setOnClickListener(resultClickListener) resultTextView.setOnClickListener(resultClickListener)
} }
SINGLE -> { SINGLE -> {

View file

@ -31,7 +31,6 @@ import androidx.annotation.ColorInt
import androidx.annotation.Px 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.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
@ -171,7 +170,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
*/ */
private fun loadResources() { private fun loadResources() {
toolbarColor = ThemeUtils.getColor(this, R.attr.colorSurface) toolbarColor = ThemeUtils.getColor(this, R.attr.colorSurface)
statusBarColorTransparent = ContextCompat.getColor(this, R.color.transparent_statusbar_background) statusBarColorTransparent = getColor(R.color.transparent_statusbar_background)
statusBarColorOpaque = ThemeUtils.getColor(this, R.attr.colorPrimaryDark) statusBarColorOpaque = ThemeUtils.getColor(this, R.attr.colorPrimaryDark)
avatarSize = resources.getDimension(R.dimen.account_activity_avatar_size) avatarSize = resources.getDimension(R.dimen.account_activity_avatar_size)
titleVisibleHeight = resources.getDimensionPixelSize(R.dimen.account_activity_scroll_title_visible_height) titleVisibleHeight = resources.getDimensionPixelSize(R.dimen.account_activity_scroll_title_visible_height)

View file

@ -595,12 +595,12 @@ class ComposeActivity :
@ColorInt val color = if (contentWarningShown) { @ColorInt val color = if (contentWarningShown) {
binding.composeHideMediaButton.setImageResource(R.drawable.ic_hide_media_24dp) binding.composeHideMediaButton.setImageResource(R.drawable.ic_hide_media_24dp)
binding.composeHideMediaButton.isClickable = false binding.composeHideMediaButton.isClickable = false
ContextCompat.getColor(this, R.color.transparent_tusky_blue) getColor(R.color.transparent_tusky_blue)
} else { } else {
binding.composeHideMediaButton.isClickable = true binding.composeHideMediaButton.isClickable = true
if (markMediaSensitive) { if (markMediaSensitive) {
binding.composeHideMediaButton.setImageResource(R.drawable.ic_hide_media_24dp) binding.composeHideMediaButton.setImageResource(R.drawable.ic_hide_media_24dp)
ContextCompat.getColor(this, R.color.tusky_blue) getColor(R.color.tusky_blue)
} else { } else {
binding.composeHideMediaButton.setImageResource(R.drawable.ic_eye_24dp) binding.composeHideMediaButton.setImageResource(R.drawable.ic_eye_24dp)
ThemeUtils.getColor(this, android.R.attr.textColorTertiary) ThemeUtils.getColor(this, android.R.attr.textColorTertiary)
@ -614,7 +614,7 @@ class ComposeActivity :
@ColorInt val color = if (binding.composeScheduleView.time == null) { @ColorInt val color = if (binding.composeScheduleView.time == null) {
ThemeUtils.getColor(this, android.R.attr.textColorTertiary) ThemeUtils.getColor(this, android.R.attr.textColorTertiary)
} else { } else {
ContextCompat.getColor(this, R.color.tusky_blue) getColor(R.color.tusky_blue)
} }
binding.composeScheduleButton.drawable.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN) binding.composeScheduleButton.drawable.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
} }
@ -797,7 +797,7 @@ class ComposeActivity :
binding.composeCharactersLeftView.text = String.format(Locale.getDefault(), "%d", remainingLength) binding.composeCharactersLeftView.text = String.format(Locale.getDefault(), "%d", remainingLength)
val textColor = if (remainingLength < 0) { val textColor = if (remainingLength < 0) {
ContextCompat.getColor(this, R.color.tusky_red) getColor(R.color.tusky_red)
} else { } else {
ThemeUtils.getColor(this, android.R.attr.textColorTertiary) ThemeUtils.getColor(this, android.R.attr.textColorTertiary)
} }
@ -969,7 +969,7 @@ class ComposeActivity :
binding.composeContentWarningBar.show() binding.composeContentWarningBar.show()
binding.composeContentWarningField.setSelection(binding.composeContentWarningField.text.length) binding.composeContentWarningField.setSelection(binding.composeContentWarningField.text.length)
binding.composeContentWarningField.requestFocus() binding.composeContentWarningField.requestFocus()
ContextCompat.getColor(this, R.color.tusky_blue) getColor(R.color.tusky_blue)
} else { } else {
binding.composeContentWarningBar.hide() binding.composeContentWarningBar.hide()
binding.composeEditField.requestFocus() binding.composeEditField.requestFocus()

View file

@ -58,15 +58,14 @@ public final class ProgressImageView extends AppCompatImageView {
} }
private void init() { private void init() {
circlePaint.setColor(ContextCompat.getColor(getContext(), R.color.tusky_blue)); circlePaint.setColor(getContext().getColor(R.color.tusky_blue));
circlePaint.setStrokeWidth(Utils.dpToPx(getContext(), 4)); circlePaint.setStrokeWidth(Utils.dpToPx(getContext(), 4));
circlePaint.setStyle(Paint.Style.STROKE); circlePaint.setStyle(Paint.Style.STROKE);
clearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); clearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
markBgPaint.setStyle(Paint.Style.FILL); markBgPaint.setStyle(Paint.Style.FILL);
markBgPaint.setColor(ContextCompat.getColor(getContext(), markBgPaint.setColor(getContext().getColor(R.color.tusky_grey_10));
R.color.tusky_grey_10));
captionDrawable = AppCompatResources.getDrawable(getContext(), R.drawable.spellcheck); captionDrawable = AppCompatResources.getDrawable(getContext(), R.drawable.spellcheck);
} }
@ -81,8 +80,7 @@ public final class ProgressImageView extends AppCompatImageView {
} }
public void setChecked(boolean checked) { public void setChecked(boolean checked) {
this.markBgPaint.setColor(ContextCompat.getColor(getContext(), this.markBgPaint.setColor(getContext().getColor(checked ? R.color.tusky_blue : R.color.tusky_grey_10));
checked ? R.color.tusky_blue : R.color.tusky_grey_10));
invalidate(); invalidate();
} }

View file

@ -296,7 +296,7 @@ public class NotificationHelper {
.setSmallIcon(R.drawable.ic_notify) .setSmallIcon(R.drawable.ic_notify)
.setContentIntent(summary ? summaryResultPendingIntent : eventResultPendingIntent) .setContentIntent(summary ? summaryResultPendingIntent : eventResultPendingIntent)
.setDeleteIntent(deletePendingIntent) .setDeleteIntent(deletePendingIntent)
.setColor(ContextCompat.getColor(context, R.color.notification_color)) .setColor(context.getColor(R.color.notification_color))
.setGroup(account.getAccountId()) .setGroup(account.getAccountId())
.setAutoCancel(true) .setAutoCancel(true)
.setShortcutId(Long.toString(account.getId())) .setShortcutId(Long.toString(account.getId()))

View file

@ -354,7 +354,7 @@ public abstract class SFragment extends Fragment implements Injectable {
urlIndex); urlIndex);
if (view != null) { if (view != null) {
String url = active.getAttachment().getUrl(); String url = active.getAttachment().getUrl();
ViewCompat.setTransitionName(view, url); view.setTransitionName(url);
ActivityOptionsCompat options = ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
view, url); view, url);

View file

@ -18,13 +18,10 @@ package com.keylesspalace.tusky.receiver
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Color
import android.util.Log import android.util.Log
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
import androidx.core.app.RemoteInput import androidx.core.app.RemoteInput
import androidx.core.content.ContextCompat
import com.keylesspalace.tusky.BuildConfig
import com.keylesspalace.tusky.R import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.components.notifications.NotificationHelper import com.keylesspalace.tusky.components.notifications.NotificationHelper
import com.keylesspalace.tusky.db.AccountManager import com.keylesspalace.tusky.db.AccountManager
@ -66,7 +63,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(context.getColor(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
@ -107,15 +104,9 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
context.startService(sendIntent) context.startService(sendIntent)
val color = if (BuildConfig.FLAVOR == "green") {
Color.parseColor("#19A341")
} else {
ContextCompat.getColor(context, R.color.tusky_blue)
}
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(color) .setColor(context.getColor(R.color.notification_color))
.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

View file

@ -14,7 +14,6 @@ import android.os.Parcelable
import android.util.Log import android.util.Log
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.ServiceCompat import androidx.core.app.ServiceCompat
import androidx.core.content.ContextCompat
import at.connyduck.calladapter.networkresult.fold import at.connyduck.calladapter.networkresult.fold
import com.keylesspalace.tusky.R import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.EventHub
@ -88,7 +87,7 @@ class SendStatusService : Service(), Injectable {
.setContentText(notificationText) .setContentText(notificationText)
.setProgress(1, 0, true) .setProgress(1, 0, true)
.setOngoing(true) .setOngoing(true)
.setColor(ContextCompat.getColor(this, R.color.notification_color)) .setColor(getColor(R.color.notification_color))
.addAction(0, getString(android.R.string.cancel), cancelSendingIntent(sendingNotificationId)) .addAction(0, getString(android.R.string.cancel), cancelSendingIntent(sendingNotificationId))
if (statusesToSend.size == 0 || Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (statusesToSend.size == 0 || Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@ -189,12 +188,7 @@ class SendStatusService : Service(), Injectable {
.setSmallIcon(R.drawable.ic_notify) .setSmallIcon(R.drawable.ic_notify)
.setContentTitle(getString(R.string.send_post_notification_error_title)) .setContentTitle(getString(R.string.send_post_notification_error_title))
.setContentText(getString(R.string.send_post_notification_saved_content)) .setContentText(getString(R.string.send_post_notification_saved_content))
.setColor( .setColor(getColor(R.color.notification_color))
ContextCompat.getColor(
this@SendStatusService,
R.color.notification_color
)
)
notificationManager.cancel(statusId) notificationManager.cancel(statusId)
notificationManager.notify(errorNotificationId--, builder.build()) notificationManager.notify(errorNotificationId--, builder.build())
@ -237,7 +231,7 @@ class SendStatusService : Service(), Injectable {
.setSmallIcon(R.drawable.ic_notify) .setSmallIcon(R.drawable.ic_notify)
.setContentTitle(getString(R.string.send_post_notification_cancel_title)) .setContentTitle(getString(R.string.send_post_notification_cancel_title))
.setContentText(getString(R.string.send_post_notification_saved_content)) .setContentText(getString(R.string.send_post_notification_saved_content))
.setColor(ContextCompat.getColor(this@SendStatusService, R.color.notification_color)) .setColor(getColor(R.color.notification_color))
notificationManager.notify(statusId, builder.build()) notificationManager.notify(statusId, builder.build())

View file

@ -23,7 +23,6 @@ import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.keylesspalace.tusky.R import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.entity.Attachment import com.keylesspalace.tusky.entity.Attachment
@ -319,7 +318,7 @@ class StatusViewHelper(private val itemView: View) {
} }
pollResults[i].background.level = level pollResults[i].background.level = level
pollResults[i].background.setTint(ContextCompat.getColor(pollResults[i].context, optionColor)) pollResults[i].background.setTint(pollResults[i].context.getColor(optionColor))
} else { } else {
pollResults[i].visibility = View.GONE pollResults[i].visibility = View.GONE
} }