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

minSdk 19 #335

Merged
merged 1 commit into from
Jul 10, 2022
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ allprojects {
maven { url "https://plugins.gradle.org/m2/" }
}
ext {
globalMinSdkVersion = 14
globalMinSdkVersion = 19
globalTargetSdkVersion = 30
globalCompileSdkVersion = 30
timberVersion = '4.7.1'
Expand Down
28 changes: 6 additions & 22 deletions tracker/src/main/java/org/matomo/sdk/tools/DeviceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
*/
package org.matomo.sdk.tools;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

import org.matomo.sdk.Matomo;

import java.lang.reflect.Method;
import java.util.Locale;

import timber.log.Timber;
Expand Down Expand Up @@ -71,9 +68,8 @@ public String getUserAgent() {
*
* @return [width, height]
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int[] getResolution() {
int width = -1, height = -1;
int width, height;

Display display;
try {
Expand All @@ -84,23 +80,11 @@ public int[] getResolution() {
return null;
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
// Recommended way to get the resolution but only available since API17
DisplayMetrics dm = new DisplayMetrics();
display.getRealMetrics(dm);
width = dm.widthPixels;
height = dm.heightPixels;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// Reflection bad, still this is the best way to get an accurate screen size on API14-16.
try {
Method getRawWidth = Display.class.getMethod("getRawWidth");
Method getRawHeight = Display.class.getMethod("getRawHeight");
width = (int) getRawWidth.invoke(display);
height = (int) getRawHeight.invoke(display);
} catch (Exception e) {
Timber.tag(TAG).w(e, "Reflection of getRawWidth/getRawHeight failed on API14-16 unexpectedly.");
}
}
// Recommended way to get the resolution but only available since API17
DisplayMetrics displayMetrics = new DisplayMetrics();
display.getRealMetrics(displayMetrics);
width = displayMetrics.widthPixels;
height = displayMetrics.heightPixels;

if (width == -1 || height == -1) {
// This is not accurate on all 4.2+ devices, usually the height is wrong due to statusbar/softkeys
Expand Down
2 changes: 1 addition & 1 deletion tracker/src/test/java/testhelpers/DefaultTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import androidx.test.core.app.ApplicationProvider;

@Config(sdk = 18, manifest = Config.NONE)
@Config(sdk = 19, manifest = Config.NONE)
@RunWith(FullEnvTestRunner.class)
public abstract class DefaultTestCase extends BaseTest {
public Tracker createTracker() {
Expand Down