[android]: Remove checks for JellyBean and Lollipop

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2021-04-10 12:38:15 +03:00
parent fda516626f
commit 725560cab9
7 changed files with 24 additions and 55 deletions

View file

@ -21,10 +21,10 @@ import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.android.billingclient.api.SkuDetails;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.PrivateVariables;
@ -206,8 +206,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
final WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUserAgentString(Framework.nativeGetUserAgent());
if (Utils.isLollipopOrLater())
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
@NonNull

View file

@ -1,17 +1,16 @@
package com.mapswithme.maps.location;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import android.util.Log;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.scheduling.JobIdMap;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
@ -69,20 +68,17 @@ public class TrackRecorderWakeService extends JobIntentService
Intent intent = new Intent(app, TrackRecorderWakeService.class);
final int jobId = JobIdMap.getId(TrackRecorderWakeService.class);
if (Utils.isLollipopOrLater())
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
Objects.requireNonNull(scheduler);
List<JobInfo> pendingJobs = scheduler.getAllPendingJobs();
String jobsRepresentation = Arrays.toString(pendingJobs.toArray());
for (JobInfo each : pendingJobs)
{
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
Objects.requireNonNull(scheduler);
List<JobInfo> pendingJobs = scheduler.getAllPendingJobs();
String jobsRepresentation = Arrays.toString(pendingJobs.toArray());
for (JobInfo each : pendingJobs)
if (TrackRecorderWakeService.class.getName().equals(each.getService().getClassName()))
{
if (TrackRecorderWakeService.class.getName().equals(each.getService().getClassName()))
{
scheduler.cancel(each.getId());
String logMsg = "Canceled job: " + each + ". All jobs: " + jobsRepresentation;
CrashlyticsUtils.INSTANCE.log(Log.INFO, TAG, logMsg);
}
scheduler.cancel(each.getId());
String logMsg = "Canceled job: " + each + ". All jobs: " + jobsRepresentation;
CrashlyticsUtils.INSTANCE.log(Log.INFO, TAG, logMsg);
}
}
JobIntentService.enqueueWork(app, TrackRecorderWakeService.class, jobId, intent);

View file

@ -4,15 +4,14 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import com.mapswithme.maps.R;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
public class TrafficButton
{
@ -36,9 +35,7 @@ public class TrafficButton
Context context = trafficBtn.getContext();
Resources res = context.getResources();
final int animResId = ThemeUtils.getResource(context, R.attr.trafficLoadingAnimation);
return Utils.isLollipopOrLater()
? (AnimationDrawable) res.getDrawable(animResId, context.getTheme())
: (AnimationDrawable) res.getDrawable(animResId);
return (AnimationDrawable) res.getDrawable(animResId, context.getTheme());
}
void turnOff()

View file

@ -8,12 +8,11 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import com.mapswithme.util.Utils;
import uk.co.samuelwall.materialtaptargetprompt.extras.PromptBackground;
import uk.co.samuelwall.materialtaptargetprompt.extras.PromptOptions;
import uk.co.samuelwall.materialtaptargetprompt.extras.PromptUtils;
@ -69,10 +68,7 @@ public class ImmersiveModeCompatPromptBackground extends PromptBackground
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void initDisplayMetrics()
{
if (Utils.isJellyBeanOrLater())
mWindowManager.getDefaultDisplay().getRealMetrics(mBaseMetrics);
else
mWindowManager.getDefaultDisplay().getMetrics(mBaseMetrics);
mWindowManager.getDefaultDisplay().getRealMetrics(mBaseMetrics);
}
@Override

View file

@ -3,7 +3,6 @@ package com.mapswithme.maps.widget;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
@ -13,13 +12,13 @@ import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
public class SubscriptionButton extends FrameLayout
{
@ -125,10 +124,7 @@ public class SubscriptionButton extends FrameLayout
private void setProgressBarColor()
{
if (Utils.isLollipopOrLater())
mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mProgressColor));
else
mProgressBar.getIndeterminateDrawable().setColorFilter(mProgressColor, PorterDuff.Mode.SRC_IN);
mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mProgressColor));
}
public void setName(@NonNull String name)

View file

@ -23,13 +23,10 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.AnyRes;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
@ -41,6 +38,7 @@ import androidx.annotation.StringRes;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.textfield.TextInputLayout;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
@ -62,10 +60,7 @@ public final class UiUtils
public static void bringViewToFrontOf(@NonNull View frontView, @NonNull View backView)
{
if (Utils.isLollipopOrLater())
frontView.setZ(backView.getZ() + 1);
else
frontView.bringToFront();
frontView.setZ(backView.getZ() + 1);
}
public static void linkifyView(@NonNull View view, @IdRes int id, @StringRes int stringId,

View file

@ -68,16 +68,6 @@ public class Utils
private Utils() {}
public static boolean isJellyBeanOrLater()
{
return isTargetOrLater(Build.VERSION_CODES.JELLY_BEAN_MR1);
}
public static boolean isLollipopOrLater()
{
return isTargetOrLater(Build.VERSION_CODES.LOLLIPOP);
}
public static boolean isMarshmallowOrLater()
{
return isTargetOrLater(Build.VERSION_CODES.M);