Skip to content

Commit

Permalink
Release 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox2Code committed Sep 17, 2022
1 parent ab568cb commit fc7b6f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ repositories {
// Add to existing dependencies block
dependencies {
implementation 'com.github.Fox2Code:FoxCompat:0.1.4'
implementation 'com.github.Fox2Code:FoxCompat:0.1.5'
}
```
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0-rc01' apply false
id 'com.android.library' version '7.3.0-rc01' apply false
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
}

task clean(type: Delete) {
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'com.github.Fox2Code'
version = '0.1.4'
version = '0.1.5'

android {
namespace 'com.fox2code.foxcompat'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public final class FoxCompat {
private static boolean hiddenApiBypass;
private static boolean freeReflection;
private static boolean hiddenApis;
private static Field asMutableMap;

static {
boolean samsungStatusBarManagerTmp, cyanogenModSettingsTmp,
Expand Down Expand Up @@ -170,41 +169,13 @@ public final class FoxCompat {
hiddenApis = true;
} catch (Exception ignored) {}
}
try {
(asMutableMap = Class.forName("java.util.Collections$UnmodifiableMap")
.getDeclaredField("m")).setAccessible(true);
} catch (Exception ignored) {
asMutableMap = null;
}
}

// Hidden API block
public static boolean checkReflection(Context context, int maxTargetSdk) {
return Build.VERSION.SDK_INT <= maxTargetSdk || getHiddenApiStatus(context);
}

public static boolean checkReflectionInternal(int maxTargetSdk) {
tryUnlockHiddenApisInternal();
return Build.VERSION.SDK_INT <= maxTargetSdk || hiddenApis;
}

@Nullable
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> makeMapMutable(Context context, Map<K, V> map) {
if (asMutableMap == null) {
if (!getHiddenApiStatus(context)) return null;
try {
(asMutableMap = Class.forName("java.util.Collections$UnmodifiableMap")
.getDeclaredField("m")).setAccessible(true);
} catch (Exception ignored) {
return null;
}
}
try {
return (Map<K, V>) asMutableMap.get(map);
} catch (Exception e) {
return null;
}
int effectiveTargetSdk = Math.min(Build.VERSION.SDK_INT,
context.getApplicationInfo().targetSdkVersion);
return effectiveTargetSdk <= maxTargetSdk || getHiddenApiStatus(context);
}

public static void tryUnlockHiddenApisInternal() {
Expand Down Expand Up @@ -286,10 +257,11 @@ private static void setEdgeEffect(Object o, Field field, EdgeEffect edgeEffect)
return;
}
}
// Top need bottom direction and bottom need top direction.
setEdgeEffect(view, mEdgeGlowTop, new StretchEdgeEffect(
context, view, StretchEdgeEffect.Direction.TOP));
setEdgeEffect(view, mEdgeGlowBottom, new StretchEdgeEffect(
context, view, StretchEdgeEffect.Direction.BOTTOM));
setEdgeEffect(view, mEdgeGlowBottom, new StretchEdgeEffect(
context, view, StretchEdgeEffect.Direction.TOP));
} else if (view instanceof HorizontalScrollView) {
view.setOverScrollMode(View.OVER_SCROLL_NEVER);
}
Expand Down

0 comments on commit fc7b6f4

Please sign in to comment.