diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt index 56bc8ae0e..6dac78b20 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt @@ -135,9 +135,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF val decorView = window.decorView decorView.systemUiVisibility = decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - window.statusBarColor = Color.TRANSPARENT - } + window.statusBarColor = Color.TRANSPARENT setContentView(R.layout.activity_account) @@ -218,9 +216,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF var transparencyPercent = Math.abs(verticalOffset) / titleVisibleHeight.toFloat() if (transparencyPercent > 1) transparencyPercent = 1f - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - window.statusBarColor = argbEvaluator.evaluate(transparencyPercent, statusBarColorTransparent, statusBarColorOpaque) as Int - } + window.statusBarColor = argbEvaluator.evaluate(transparencyPercent, statusBarColorTransparent, statusBarColorOpaque) as Int val evaluatedToolbarColor = argbEvaluator.evaluate(transparencyPercent, Color.TRANSPARENT, toolbarColor) as Int val evaluatedTabBarColor = argbEvaluator.evaluate(transparencyPercent, backgroundColor, toolbarColor) as Int diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.java index ef9882b3a..11cbcedb8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.java @@ -179,9 +179,8 @@ public final class ViewMediaActivity extends BaseActivity View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE; decorView.setSystemUiVisibility(uiOptions); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - getWindow().setStatusBarColor(Color.BLACK); - } + getWindow().setStatusBarColor(Color.BLACK); + } @Override diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java index 539995a5b..1e182ef93 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java @@ -19,7 +19,6 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.graphics.Color; import android.media.MediaPlayer; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -85,9 +84,8 @@ public class ViewVideoActivity extends BaseActivity { } }); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - getWindow().setStatusBarColor(Color.BLACK); - } + getWindow().setStatusBarColor(Color.BLACK); + } @Override diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusDetailedViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusDetailedViewHolder.java index d0ab5b8ae..0cc40a7cd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusDetailedViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusDetailedViewHolder.java @@ -3,7 +3,6 @@ package com.keylesspalace.tusky.adapter; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; -import android.os.Build; import android.support.annotation.Nullable; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -137,9 +136,7 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder { cardInfo.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - cardView.setClipToOutline(true); - } + cardView.setClipToOutline(true); Picasso.with(cardImage.getContext()) .load(card.getImage()) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java index 2a9500d9e..91212c8f4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/OkHttpUtils.java @@ -24,11 +24,8 @@ import android.util.Log; import com.keylesspalace.tusky.BuildConfig; -import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Proxy; -import java.net.Socket; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -39,7 +36,6 @@ import java.util.List; import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; @@ -106,7 +102,7 @@ public class OkHttpUtils { builder.proxy(new Proxy(Proxy.Type.HTTP, address)); } - return enableHigherTlsOnPreLollipop(builder); + return builder; } /** @@ -168,98 +164,4 @@ public class OkHttpUtils { specList.add(spec); } - private static OkHttpClient.Builder enableHigherTlsOnPreLollipop(OkHttpClient.Builder builder) { - if (Build.VERSION.SDK_INT < 22) { - try { - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance( - TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init((KeyStore) null); - TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); - if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { - throw new IllegalStateException("Unexpected default trust managers:" - + Arrays.toString(trustManagers)); - } - - X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; - - SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(null, new TrustManager[] { trustManager }, null); - SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); - - builder.sslSocketFactory(new SSLSocketFactoryCompat(sslSocketFactory), - trustManager); - } catch (NoSuchAlgorithmException|KeyStoreException|KeyManagementException e) { - Log.e(TAG, "Failed enabling TLS 1.1 & 1.2. " + e.getMessage()); - } - } - - return builder; - } - - private static class SSLSocketFactoryCompat extends SSLSocketFactory { - private static final String[] DESIRED_TLS_VERSIONS = { "TLSv1", "TLSv1.1", "TLSv1.2", - "TLSv1.3" }; - - final SSLSocketFactory delegate; - - SSLSocketFactoryCompat(SSLSocketFactory base) { - this.delegate = base; - } - - @Override - public String[] getDefaultCipherSuites() { - return delegate.getDefaultCipherSuites(); - } - - @Override - public String[] getSupportedCipherSuites() { - return delegate.getSupportedCipherSuites(); - } - - @Override - public Socket createSocket(Socket s, String host, int port, boolean autoClose) - throws IOException { - return patch(delegate.createSocket(s, host, port, autoClose)); - } - - @Override - public Socket createSocket(String host, int port) throws IOException { - return patch(delegate.createSocket(host, port)); - } - - @Override - public Socket createSocket(String host, int port, InetAddress localHost, int localPort) - throws IOException { - return patch(delegate.createSocket(host, port, localHost, localPort)); - } - - @Override - public Socket createSocket(InetAddress host, int port) throws IOException { - return patch(delegate.createSocket(host, port)); - } - - @Override - public Socket createSocket(InetAddress address, int port, InetAddress localAddress, - int localPort) throws IOException { - return patch(delegate.createSocket(address, port, localAddress, localPort)); - } - - @NonNull - private static String[] getMatches(String[] wanted, String[] have) { - List a = new ArrayList<>(Arrays.asList(wanted)); - List b = Arrays.asList(have); - a.retainAll(b); - return a.toArray(new String[0]); - } - - private Socket patch(Socket socket) { - if (socket instanceof SSLSocket) { - SSLSocket sslSocket = (SSLSocket) socket; - String[] protocols = getMatches(DESIRED_TLS_VERSIONS, - sslSocket.getSupportedProtocols()); - sslSocket.setEnabledProtocols(protocols); - } - return socket; - } - } } diff --git a/app/src/main/java/com/keylesspalace/tusky/view/ComposeOptionsView.kt b/app/src/main/java/com/keylesspalace/tusky/view/ComposeOptionsView.kt index 3202a5dfa..b7f2518a9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/ComposeOptionsView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/ComposeOptionsView.kt @@ -31,12 +31,10 @@ class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: Attr init { inflate(context, R.layout.view_compose_options, this) - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - publicRadioButton.setButtonDrawable(R.drawable.ic_public_24dp) - unlistedRadioButton.setButtonDrawable(R.drawable.ic_lock_open_24dp) - privateRadioButton.setButtonDrawable(R.drawable.ic_lock_outline_24dp) - directRadioButton.setButtonDrawable(R.drawable.ic_email_24dp) - } + publicRadioButton.setButtonDrawable(R.drawable.ic_public_24dp) + unlistedRadioButton.setButtonDrawable(R.drawable.ic_lock_open_24dp) + privateRadioButton.setButtonDrawable(R.drawable.ic_lock_outline_24dp) + directRadioButton.setButtonDrawable(R.drawable.ic_email_24dp) visibilityRadioGroup.setOnCheckedChangeListener { _, checkedId -> val visibility = when (checkedId) { diff --git a/app/src/main/java/com/keylesspalace/tusky/view/RoundedImageView.java b/app/src/main/java/com/keylesspalace/tusky/view/RoundedImageView.java index dc07d27d7..b5f0733b8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/RoundedImageView.java +++ b/app/src/main/java/com/keylesspalace/tusky/view/RoundedImageView.java @@ -33,9 +33,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.support.annotation.DrawableRes; -import android.support.annotation.RequiresApi; import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; import android.view.View; @@ -96,9 +94,7 @@ public class RoundedImageView extends AppCompatImageView { super.setScaleType(SCALE_TYPE); mReady = true; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - setOutlineProvider(new OutlineProvider()); - } + setOutlineProvider(new OutlineProvider()); if (mSetupPending) { setup(); @@ -317,7 +313,6 @@ public class RoundedImageView extends AppCompatImageView { mBitmapShader.setLocalMatrix(mShaderMatrix); } - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private class OutlineProvider extends ViewOutlineProvider { @Override