mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
HACK: make Resources.mDrawableCache of type ThemedResourceCache, but only for F-Droid
This field is directly accessed by androidx and some androidx version expect it to be a Map while other expect a ThemedResourceCache. This mess is probably caused by reporting an age old Build.SDK_INT.
This commit is contained in:
parent
df4d4721ce
commit
820b9d7ec5
2 changed files with 16 additions and 1 deletions
|
@ -125,6 +125,8 @@ public class Context extends Object {
|
|||
application_info.nativeLibraryDir = (new File(Environment.getExternalStorageDirectory(), "lib")).getAbsolutePath();
|
||||
application_info.sourceDir = native_get_apk_path();
|
||||
package_manager = new PackageManager();
|
||||
|
||||
r.applyPackageQuirks(application_info.packageName);
|
||||
}
|
||||
|
||||
private static native String native_get_apk_path();
|
||||
|
|
|
@ -109,7 +109,7 @@ public class Resources {
|
|||
/*package*/ final Object mAccessLock = new Object();
|
||||
/*package*/ final Configuration mTmpConfig = new Configuration();
|
||||
/*package*/ TypedValue mTmpValue = new TypedValue();
|
||||
/*package*/ final Map<Long,WeakReference<Drawable.ConstantState>> mDrawableCache = new HashMap<Long,WeakReference<Drawable.ConstantState>>(0);
|
||||
/*package*/ Object mDrawableCache = new HashMap<Long,WeakReference<Drawable.ConstantState>>(0);
|
||||
private final ConfigurationBoundResourceCache<ComplexColor> mComplexColorCache = new ConfigurationBoundResourceCache<>(this);
|
||||
/*package*/ final LongSparseArray<WeakReference<Drawable.ConstantState>> mColorDrawableCache = new LongSparseArray<WeakReference<Drawable.ConstantState>>(0);
|
||||
/*package*/ boolean mPreloading;
|
||||
|
@ -213,6 +213,19 @@ public class Resources {
|
|||
// assets.ensureStringBlocks();
|
||||
}
|
||||
|
||||
public void applyPackageQuirks(String packageName) {
|
||||
// F-Droid expects mDrawableCache to be a ThemedResourceCache while most other apps expect a Map
|
||||
if ("org.fdroid.fdroid".equals(packageName)) {
|
||||
mDrawableCache = new ThemedResourceCache<Drawable>() {
|
||||
@Override
|
||||
protected boolean shouldInvalidateEntry(Drawable entry, int configChanges) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'shouldInvalidateEntry'");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a global shared Resources object that provides access to only
|
||||
* system resources (no application resources), and is not configured for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue