update minSdkVersion to 21 (#843)

* set minSdkVersion to 21

* use elevation instead of additional views for shadow

* clean up code occurrences

* remove drawable compat code

* remove no longer needed resources

* remove unneeded android:clipChildren="false"

* Revert "remove no longer needed resources"

This reverts commit 67a4d6f8d87b3f116b95d90dfb48f350d342f503.

* remove no longer needed resources (this time the right ones)
This commit is contained in:
Konrad Pozniak 2018-09-16 18:54:12 +02:00 committed by GitHub
parent ef9ac3939e
commit 6a7ec93b98
40 changed files with 35 additions and 249 deletions

View File

@ -17,12 +17,11 @@ android {
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.keylesspalace.tusky"
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 27
versionCode 49
versionName "3.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary true
}
buildTypes {
release {

View File

@ -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

View File

@ -24,7 +24,6 @@ import android.content.Context;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.text.emoji.EmojiCompat;
import android.support.v7.app.AppCompatDelegate;
import com.evernote.android.job.JobManager;
import com.jakewharton.picasso.OkHttp3Downloader;
@ -95,8 +94,6 @@ public class TuskyApplication extends Application implements HasActivityInjector
JobManager.create(this).addJobCreator(notificationPullJobCreator);
//necessary for Android < API 21
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
/**

View File

@ -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

View File

@ -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

View File

@ -257,9 +257,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
usernameView = itemView.findViewById(R.id.notification_username);
displayNameView = itemView.findViewById(R.id.notification_display_name);
avatar = itemView.findViewById(R.id.notification_avatar);
//workaround because Android < API 21 does not support setting drawableLeft from xml when it is a vector image
Drawable followIcon = ContextCompat.getDrawable(message.getContext(), R.drawable.ic_person_add_24dp);
message.setCompoundDrawablesWithIntrinsicBounds(followIcon, null, null, null);
}
void setMessage(Account account, BidiFormatter bidiFormatter) {

View File

@ -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())

View File

@ -16,7 +16,6 @@
package com.keylesspalace.tusky.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
@ -24,7 +23,6 @@ import android.widget.TextView;
import com.keylesspalace.tusky.R;
import com.keylesspalace.tusky.interfaces.StatusActionListener;
import com.keylesspalace.tusky.util.ThemeUtils;
import com.keylesspalace.tusky.viewdata.StatusViewData;
import com.squareup.picasso.Picasso;
@ -38,10 +36,6 @@ public class StatusViewHolder extends StatusBaseViewHolder {
super(itemView, useAbsoluteTime);
avatarReblog = itemView.findViewById(R.id.status_avatar_reblog);
rebloggedBar = itemView.findViewById(R.id.status_reblogged);
//workaround because Android < API 21 does not support setting drawableLeft from xml when it is a vector image
Drawable rebloggedIcon = ThemeUtils.getDrawable(rebloggedBar.getContext(),
R.attr.status_reblog_small_drawable, R.drawable.ic_reblog_dark_18dp);
rebloggedBar.setCompoundDrawablesWithIntrinsicBounds(rebloggedIcon, null, null, null);
}
@Override

View File

@ -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<String> a = new ArrayList<>(Arrays.asList(wanted));
List<String> 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;
}
}
}

View File

@ -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) {

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/color_background_dark" />
<corners android:radius="4dp" />
</shape>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#dedede" />
<corners android:radius="4dp" />
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -1,21 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#6000"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="@color/color_background_dark"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/color_background_dark" />
<corners android:radius="4dp" />
</shape>

View File

@ -1,21 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#6000"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#dedede"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#dedede" />
<corners android:radius="4dp" />
</shape>

View File

@ -109,8 +109,6 @@
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
<include layout="@layout/toolbar_shadow_shim" />
<include layout="@layout/item_status_bottom_sheet" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -15,6 +15,4 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/toolbar_shadow_shim" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -173,8 +173,6 @@
</android.support.v4.widget.NestedScrollView>
<include layout="@layout/toolbar_shadow_shim" />
<ProgressBar
android:id="@+id/saveProgressBar"
android:layout_width="wrap_content"

View File

@ -15,8 +15,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/toolbar_shadow_shim" />
<include layout="@layout/item_status_bottom_sheet"/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -205,8 +205,6 @@
</ScrollView>
<include layout="@layout/toolbar_shadow_shim" />
<include layout="@layout/item_status_bottom_sheet" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -7,14 +7,6 @@
<include layout="@layout/toolbar_basic" />
<include
layout="@layout/toolbar_shadow_shim"
android:layout_width="0dp"
android:layout_height="4dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/appbar" />
<android.support.v7.widget.RecyclerView
android:id="@+id/lists_recycler"
android:layout_width="0dp"
@ -22,7 +14,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar_shadow_shim" />
app:layout_constraintTop_toBottomOf="parent" />
<ProgressBar
android:id="@+id/progress_bar"

View File

@ -9,7 +9,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:clipChildren="false">
<ImageButton
android:id="@+id/drawer_toggle"
@ -20,6 +21,7 @@
android:layout_alignParentTop="true"
android:background="?android:colorBackground"
android:contentDescription="@string/action_open_drawer"
android:elevation="@dimen/actionbar_elevation"
app:layout_anchor="@id/pager"
app:layout_anchorGravity="top|left"
app:srcCompat="@drawable/ic_menu_24dp" />
@ -32,6 +34,7 @@
android:layout_alignParentTop="true"
android:layout_toEndOf="@id/drawer_toggle"
android:background="?android:colorBackground"
android:elevation="@dimen/actionbar_elevation"
app:tabGravity="fill"
app:tabIndicatorHeight="3dp"
app:tabMaxWidth="0dp"
@ -71,15 +74,6 @@
</RelativeLayout>
<View
android:id="@+id/tab_bottom_shadow"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/material_drawer_shadow_bottom"
android:visibility="visible"
app:layout_anchor="@id/tab_layout"
app:layout_anchorGravity="bottom" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/floating_btn"
android:layout_width="wrap_content"
@ -90,6 +84,6 @@
app:layout_anchorGravity="bottom|end"
app:srcCompat="@drawable/ic_create_24dp" />
<include layout="@layout/item_status_bottom_sheet"/>
<include layout="@layout/item_status_bottom_sheet" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -15,8 +15,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/toolbar_shadow_shim" />
<include layout="@layout/item_status_bottom_sheet"/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -15,6 +15,4 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/toolbar_shadow_shim" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -37,6 +37,4 @@
android:hint="@string/report_comment_hint" />
</LinearLayout>
<include layout="@layout/toolbar_shadow_shim" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -29,6 +29,4 @@
</RelativeLayout>
<include layout="@layout/toolbar_shadow_shim" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -29,8 +29,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/toolbar_shadow_shim" />
<include layout="@layout/item_status_bottom_sheet"/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -15,8 +15,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/toolbar_shadow_shim" />
<include layout="@layout/item_status_bottom_sheet"/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -15,8 +15,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/toolbar_shadow_shim" />
<include layout="@layout/item_status_bottom_sheet"/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -18,6 +18,7 @@
android:layout_marginBottom="4dp"
android:layout_marginTop="8dp"
android:drawablePadding="10dp"
android:drawableStart="@drawable/ic_person_add_24dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"

View File

@ -13,6 +13,7 @@
<android.support.text.emoji.widget.EmojiTextView
android:id="@+id/status_reblogged"
android:drawableStart="?attr/status_reblog_small_drawable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/status_reblogged_bar_padding_top"

View File

@ -6,8 +6,7 @@
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stateListAnimator="@null"
android:elevation="0dp"
android:elevation="@dimen/actionbar_elevation"
app:layout_collapseMode="pin">
<android.support.v7.widget.Toolbar

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_shadow_shim"
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/material_drawer_shadow_bottom"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_collapseMode="pin" />

View File

@ -26,4 +26,6 @@
<dimen name="compose_activity_scrollview_height">-1px</dimen> <!-- match_parent -->
<dimen name="timeline_width">-1px</dimen> <!-- match_parent -->
<dimen name="actionbar_elevation">4dp</dimen>
</resources>