Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Fix Failed resolution of ImageOTAUtils (#2)
Browse files Browse the repository at this point in the history
* potentially fix crashes

* Update ResourceDrawableIdHelper.java

* add openDevTools()

* Update AliucordNativeModule.java

* oops

* Update AliucordNativeModule.java
  • Loading branch information
C10udburst authored Jul 9, 2022
1 parent 014cae8 commit e85aefa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
9 changes: 9 additions & 0 deletions app/src/main/java/com/aliucord/AliucordNativeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.ReactApplication;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

Expand Down Expand Up @@ -139,4 +140,12 @@ public void download(String url, String path, Promise p) {
p.reject(e);
}
}

@ReactMethod
public void openDevTools() {
Activity plainActivity = appContext.getCurrentActivity();
if (plainActivity == null) return;

((ReactApplication) plainActivity.getApplication()).getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private int getResourceDrawableId(Context context, String str) {
} catch (NumberFormatException unused) {
synchronized (this) {
if (this.mResourceDrawableIdMap.containsKey(replace)) {
return this.mResourceDrawableIdMap.get(replace);
return this.mResourceDrawableIdMap.get(replace).intValue();
}
// ALIUCORD CHANGED: dynamic package name lookup -> BuildConfig.APPLICATION_ID
int identifier = context.getResources().getIdentifier(replace, "drawable", BuildConfig.APPLICATION_ID);
Expand All @@ -59,10 +59,6 @@ public synchronized void clear() {
}

public Drawable getResourceDrawable(Context context, String str) {
Drawable resourceDrawable = ImageOTAUtils.getResourceDrawable(context, str);
if (resourceDrawable != null) {
return resourceDrawable;
}
int resourceDrawableId = getResourceDrawableId(context, str);
if (resourceDrawableId > 0) {
return context.getResources().getDrawable(resourceDrawableId);
Expand All @@ -71,14 +67,10 @@ public Drawable getResourceDrawable(Context context, String str) {
}

public Uri getResourceDrawableUri(Context context, String str) {
Uri resourceUri = ImageOTAUtils.getResourceUri(context, str);
if (resourceUri != null) {
return resourceUri;
}
int resourceDrawableId = getResourceDrawableId(context, str);
if (resourceDrawableId > 0) {
return new Uri.Builder().scheme(LOCAL_RESOURCE_SCHEME).path(String.valueOf(resourceDrawableId)).build();
}
return Uri.EMPTY;
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

discord_version=125205
discord_version=132205

0 comments on commit e85aefa

Please sign in to comment.