Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mantikafasi committed Jan 6, 2025
1 parent ed625d7 commit 00291d6
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Aliucord/src/main/java/com/aliucord/api/ResourcesExt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.aliucord.api;

import android.content.Context;
import android.content.res.*;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;

import androidx.core.content.res.ResourcesCompat;

import com.aliucord.Utils;

public class ResourcesExt extends Resources {

String packageName;

/**
* Create a new Resources object on top of an existing set of assets in an
* AssetManager.
*
* @param assets Previously created AssetManager.
* @param metrics Current display metrics to consider when
* selecting/computing resource values.
* @param config Desired device configuration to consider when
* selecting/computing resource values (optional).
* @deprecated Resources should not be constructed by apps.
* @param packageName The name of the package this Resources object should be associated with.
* See {@link Context#createConfigurationContext(Configuration)}.
*/
public ResourcesExt(AssetManager assets, DisplayMetrics metrics, Configuration config, String packageName) {
super(assets, metrics, config);
this.packageName = packageName;
}

public View inflate(String defType, String name, ViewGroup root, boolean attachToRoot) {
var xml = getLayout(getIdentifier(name, defType, packageName));

return Utils.appActivity.getLayoutInflater().inflate(xml, root, attachToRoot);
};

public int getIdentifier(String name, String defType) {
return getIdentifier(name, defType, packageName);
};

public Drawable getDrawable(String name) {
return ResourcesCompat.getDrawable(this, getIdentifier(name, "drawable"), null );
};
}

0 comments on commit 00291d6

Please sign in to comment.