Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump minSdk to 21, cleanup #364

Merged
merged 9 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
apply plugin: "com.android.application"
plugins {
id 'com.android.application'
}

android {
namespace 'com.perflyst.twire'
compileSdkVersion 33
buildToolsVersion "30.0.3"
ndkVersion "22.1.7171670"
namespace "com.perflyst.twire"
compileSdk 33
buildToolsVersion "32.0.0"
ndkVersion "25.0.8775105"

defaultConfig {
applicationId "com.perflyst.twire"
minSdkVersion 16
targetSdkVersion 33
minSdk 21
targetSdk 33
versionCode 531
versionName "2.10.7"

multiDexEnabled true
vectorDrawables.useSupportLibrary true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -64,7 +65,6 @@ dependencies {
implementation "androidx.browser:browser:1.3.0"
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.1"
implementation "androidx.multidex:multidex:2.0.1"
implementation "androidx.palette:palette:1.0.0"
implementation "androidx.preference:preference:1.1.1"
implementation "androidx.recyclerview:recyclerview:1.2.1"
Expand All @@ -76,9 +76,10 @@ dependencies {

//https://github.com/bumptech/glide/releases
def glideVersion = "4.12.0"
implementation "com.github.zjupure:webpdecoder:2.0.${glideVersion}"
implementation "com.github.bumptech.glide:glide:$glideVersion"
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
//https://github.com/zjupure/GlideWebpDecoder
implementation "com.github.zjupure:webpdecoder:2.0.$glideVersion"

//https://github.com/balysv/material-ripple/blob/master/CHANGELOG.md
implementation "com.balysv:material-ripple:1.0.2"
Expand Down Expand Up @@ -106,9 +107,6 @@ dependencies {
implementation "com.google.android.exoplayer:exoplayer-ui:$exoPlayer"
implementation "com.google.android.exoplayer:extension-mediasession:$exoPlayer"

//https://github.com/google/conscrypt/releases
implementation "org.conscrypt:conscrypt-android:2.5.2"

//https://github.com/square/okhttp
implementation "com.squareup.okhttp3:okhttp:3.12.13"

Expand Down
14 changes: 0 additions & 14 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-dontobfuscate

# OkHttp / Okio: https://github.com/square/okhttp/blob/okhttp_3.12.x/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform

# GlideWebpDecoder uses native code to decode webp, keep the jni interface.
-keep public class com.bumptech.glide.integration.webp.WebpImage { *; }
-keep public class com.bumptech.glide.integration.webp.WebpFrame { *; }
Expand Down
29 changes: 2 additions & 27 deletions app/src/main/java/com/perflyst/twire/TwireApplication.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,18 @@
package com.perflyst.twire;

import android.annotation.SuppressLint;
import android.content.Context;
import android.app.Application;

import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.perflyst.twire.utils.TLSSocketFactoryCompat;
import com.techyourchance.threadposter.BackgroundThreadPoster;
import com.techyourchance.threadposter.UiThreadPoster;

import org.conscrypt.Conscrypt;

import java.security.Security;

/**
* Created by SebastianRask on 20-02-2016.
*/
@SuppressLint("StaticFieldLeak") // It is alright to store application context statically
public class TwireApplication extends MultiDexApplication {
public class TwireApplication extends Application {
public static final boolean isCrawlerUpdate = false; //ToDo remember to disable for crawler updates

public static final UiThreadPoster uiThreadPoster = new UiThreadPoster();
public static final BackgroundThreadPoster backgroundPoster = new BackgroundThreadPoster();

@Override
public void onCreate() {
super.onCreate();

// Twitch API requires TLS 1.2, which may be unavailable/not enabled on Android 4.1 - 4.4.
// Install modern TLS protocols using a security provider, and enable them by default in a
// custom SSLSocketFactory.
Security.insertProviderAt(Conscrypt.newProvider(), 1);
TLSSocketFactoryCompat.setAsDefault();
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -114,11 +113,7 @@ protected void onCreate(Bundle savedInstanceState) {
streamerInfoName.setText(info.getDisplayName());
info.getFollowers(getApplicationContext(), followers -> Utils.setNumber(streamerFollowers, followers), 0);
Utils.setNumber(streamerViewers, info.getViews());

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
streamerImage.setTransitionName(getString(R.string.streamerInfo_transition));
}

streamerImage.setTransitionName(getString(R.string.streamerInfo_transition));
setUpTabs();
initStreamerImageAndColors();
initiateFAB();
Expand Down Expand Up @@ -263,11 +258,9 @@ public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super
mFab.setBackgroundTintList(ColorStateList.valueOf(compositeNewColor));
mTabLayout.setSelectedTabIndicatorColor(compositeNewColor);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(newColorDark);
}
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(newColorDark);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

//Service.isTranslucentActionbar(LOG_TAG, getBaseContext(), toolbar, this);
twitchNameView = findViewById(R.id.general_current_twitch_name);
startPageSubText = findViewById(R.id.start_page_sub_text);
filterTopStreamsByLanguageView = findViewById(R.id.language_filter_title);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.perflyst.twire.activities.setup;

import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
Expand Down Expand Up @@ -133,9 +132,7 @@ private SupportAnimator showTransitionAnimation() {
int dy = Math.max(cy, mTransitionViewWhite.getHeight() - cy);
float finalRadius = (float) Math.hypot(dx, dy);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mTransitionViewWhite.isAttachedToWindow();
}
mTransitionViewWhite.isAttachedToWindow();

final SupportAnimator blueTransitionAnimation =
ViewAnimationUtils.createCircularReveal(mTransitionViewWhite, cx, cy, 0, finalRadius);
Expand Down Expand Up @@ -273,7 +270,7 @@ public void onAnimationRepeat() {
}
};

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !mTransitionViewWhite.isAttachedToWindow()) {
if (!mTransitionViewWhite.isAttachedToWindow()) {
animator.onAnimationEnd();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,14 @@ protected void onCreate(Bundle savedInstanceState) {

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

if (Build.VERSION.SDK_INT >= 21) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.black));
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.black));
}
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.black));
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.black));

if (savedInstanceState == null) {
FragmentManager fm = getSupportFragmentManager();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setEnterTransition(constructTransitions());
getWindow().setReturnTransition(constructTransitions());
}
getWindow().setEnterTransition(constructTransitions());
getWindow().setReturnTransition(constructTransitions());

// If the Fragment is non-null, then it is currently being
// retained across a configuration change.
Expand Down Expand Up @@ -149,7 +145,6 @@ public void onUserLeaveHint() {
}
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private TransitionSet constructTransitions() {
int[] slideTargets = {R.id.ChatRecyclerView, R.id.chat_input, R.id.chat_input_divider};

Expand Down Expand Up @@ -270,15 +265,14 @@ public void onPictureInPictureModeChanged(boolean enabled, Configuration newConf

@Override
public void finish() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mBackstackLost) {
if (mBackstackLost) {
navToLauncherTask(getApplicationContext());
finishAndRemoveTask();
} else {
super.finish();
}
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void navToLauncherTask(@NonNull Context appContext) {
ActivityManager activityManager = ContextCompat.getSystemService(appContext, ActivityManager.class);
// iterate app tasks available and navigate to launcher task (browse task)
Expand Down
50 changes: 20 additions & 30 deletions app/src/main/java/com/perflyst/twire/adapters/ChannelsAdapter.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.perflyst.twire.adapters;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityOptions;
import android.app.SharedElementCallback;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -16,7 +15,6 @@
import android.widget.TextView;

import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityOptionsCompat;

import com.perflyst.twire.R;
import com.perflyst.twire.activities.ChannelActivity;
Expand Down Expand Up @@ -87,35 +85,27 @@ void handleElementOnClick(final View view) {
intent.putExtra(getContext().getString(R.string.channel_info_intent_object), item);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
View sharedView = view.findViewById(R.id.profileLogoImageView);
sharedView.setTransitionName(getContext().getString(R.string.streamerInfo_transition));
final ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.streamerInfo_transition));

activity.setExitSharedElementCallback(new SharedElementCallback() {
@SuppressLint("NewApi")
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

if (!sharedElements.isEmpty() && sharedElements.get(0) != null && previewTarget != null) {
View element = sharedElements.get(0);
Animation anim = new RoundImageAnimation(element.getWidth() / 2, 0, (ImageView) element, previewTarget.getPreview());
anim.setDuration(200);
anim.setInterpolator(new DecelerateInterpolator());
view.startAnimation(anim);
}
activity.setExitSharedElementCallback(null);
View sharedView = view.findViewById(R.id.profileLogoImageView);
sharedView.setTransitionName(getContext().getString(R.string.streamerInfo_transition));
final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
activity, sharedView, getContext().getString(R.string.streamerInfo_transition));

activity.setExitSharedElementCallback(new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

if (!sharedElements.isEmpty() && sharedElements.get(0) != null && previewTarget != null) {
View element = sharedElements.get(0);
Animation anim = new RoundImageAnimation(element.getWidth() / 2, 0, (ImageView) element, previewTarget.getPreview());
anim.setDuration(200);
anim.setInterpolator(new DecelerateInterpolator());
view.startAnimation(anim);
}
});
activity.startActivity(intent, options.toBundle());
} else {
getContext().startActivity(intent);
if (activity != null) {
activity.overridePendingTransition(R.anim.slide_in_right_anim, R.anim.fade_out_semi_anim);
activity.setExitSharedElementCallback(null);
}
}
});
activity.startActivity(intent, options.toBundle());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -17,7 +16,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
Expand All @@ -29,7 +28,6 @@
import com.bumptech.glide.signature.ObjectKey;
import com.perflyst.twire.R;
import com.perflyst.twire.misc.PreviewTarget;
import com.perflyst.twire.misc.RoundedTopTransformation;
import com.perflyst.twire.model.MainElement;
import com.perflyst.twire.service.AnimationService;
import com.perflyst.twire.service.Settings;
Expand All @@ -45,7 +43,6 @@
*/
public abstract class MainActivityAdapter<E extends Comparable<E> & MainElement,
T extends MainActivityAdapter.ElementsViewHolder> extends RecyclerView.Adapter<T> {
private final boolean isBelowLollipop;
private final HashMap<CharSequence, PreviewTarget> mTargets;
private final AutoSpanRecyclerView mRecyclerView;
private final int translateLength, cardWidth;
Expand All @@ -70,7 +67,6 @@ public MainActivityAdapter(AutoSpanRecyclerView recyclerView, Context aContext)
topMargin = (int) context.getResources().getDimension(getTopMarginResource());
cardWidth = calculateCardWidth();
translateLength = context.getResources().getDisplayMetrics().heightPixels - topMargin;
isBelowLollipop = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP;
sortElements = true;
animateInsert = true;
mOnClickListener = this::handleElementOnClick;
Expand Down Expand Up @@ -149,18 +145,11 @@ private void loadImagePreview(String previewURL, E element,
.signature(new ObjectKey(
System.currentTimeMillis() / TimeUnit.MINUTES.toMillis(5)))
// Image to show while loading, on failure, or if previewURL is null
.placeholder(
ContextCompat.getDrawable(context, element.getPlaceHolder(getContext())))
.placeholder(AppCompatResources.getDrawable(
context, element.getPlaceHolder(getContext())))
// Fade from placeholder image to loaded image over 300ms with cross fade
.transition(BitmapTransitionOptions.withWrapped(new DrawableCrossFadeFactory
.Builder(300).setCrossFadeEnabled(true).build()));
if (isBelowLollipop) {
/* On platforms before Lollipop the CardView that holds the preview image does not
* clip its children that intersect with rounded corners. Round the image corners so
* the rounded corners still appear. */
creator = creator.transform(new RoundedTopTransformation(
context.getResources().getDimension(getCornerRadiusResource())));
}
PreviewTarget mTarget = new PreviewTarget() {
private boolean loaded = false;

Expand Down
Loading