mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-04-30 22:34:24 +02:00
create QualifierBuilder
This commit is contained in:
parent
96af0cb6d2
commit
3493a7bd94
@ -669,7 +669,7 @@
|
|||||||
int hash = this.hashCode();
|
int hash = this.hashCode();
|
||||||
if(mQualifiers==null || mQualifiersStamp!=hash){
|
if(mQualifiers==null || mQualifiersStamp!=hash){
|
||||||
try{
|
try{
|
||||||
mQualifiers = ResConfigHelper.toQualifier(this).trim();
|
mQualifiers = new QualifierBuilder(this).build();
|
||||||
mQualifiersStamp = hash;
|
mQualifiersStamp = hash;
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
mQualifiers = "";
|
mQualifiers = "";
|
||||||
@ -1599,6 +1599,130 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class QualifierBuilder{
|
||||||
|
private final ResConfig mConfig;
|
||||||
|
private StringBuilder mBuilder;
|
||||||
|
public QualifierBuilder(ResConfig resConfig){
|
||||||
|
this.mConfig = resConfig;
|
||||||
|
}
|
||||||
|
public String build(){
|
||||||
|
ResConfig resConfig = this.mConfig;
|
||||||
|
if(resConfig.isDefault()){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
this.mBuilder = new StringBuilder();
|
||||||
|
appendNumber("mcc", resConfig.getMcc());
|
||||||
|
appendNumber("mnc", resConfig.getMnc());
|
||||||
|
|
||||||
|
appendLanguageAndRegion();
|
||||||
|
|
||||||
|
appendFlag(resConfig.getOrientation());
|
||||||
|
appendFlag(resConfig.getTouchscreen());
|
||||||
|
appendFlag(resConfig.getDensity());
|
||||||
|
appendFlag(resConfig.getKeyboard());
|
||||||
|
appendFlag(resConfig.getNavigation());
|
||||||
|
appendFlag(resConfig.getInputFlagsKeysHidden());
|
||||||
|
appendFlag(resConfig.getInputFlagsNavHidden());
|
||||||
|
|
||||||
|
appendScreenWidthHeight();
|
||||||
|
|
||||||
|
appendNumber("v", resConfig.getSdkVersion());
|
||||||
|
// append resConfig.getMinorVersion()
|
||||||
|
appendFlag(resConfig.getScreenLayoutSize());
|
||||||
|
appendFlag(resConfig.getScreenLayoutLong());
|
||||||
|
appendFlag(resConfig.getScreenLayoutDir());
|
||||||
|
|
||||||
|
appendFlag(resConfig.getUiModeType());
|
||||||
|
appendFlag(resConfig.getUiModeNight());
|
||||||
|
|
||||||
|
appendDp("sw", resConfig.getSmallestScreenWidthDp());
|
||||||
|
appendDp("w", resConfig.getScreenWidthDp());
|
||||||
|
appendDp("h", resConfig.getScreenHeightDp());
|
||||||
|
|
||||||
|
appendFlag(resConfig.getScreenLayoutRound());
|
||||||
|
|
||||||
|
appendFlag(resConfig.getColorModeWide());
|
||||||
|
appendFlag(resConfig.getColorModeHdr());
|
||||||
|
|
||||||
|
return mBuilder.toString();
|
||||||
|
}
|
||||||
|
private void appendScreenWidthHeight(){
|
||||||
|
ResConfig resConfig = this.mConfig;
|
||||||
|
int width = resConfig.getScreenWidth();
|
||||||
|
int height = resConfig.getScreenHeight();
|
||||||
|
if(width==0 && height==0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mBuilder.append(width).append('x').append(height);
|
||||||
|
}
|
||||||
|
private void appendLanguageAndRegion(){
|
||||||
|
ResConfig resConfig = this.mConfig;
|
||||||
|
String language = resConfig.getLanguage();
|
||||||
|
String region = resConfig.getRegion();
|
||||||
|
String script = resConfig.getLocaleScript();
|
||||||
|
String variant = resConfig.getLocaleVariant();
|
||||||
|
if(language==null && region==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuilder builder = this.mBuilder;
|
||||||
|
char separator;
|
||||||
|
if(script != null || variant != null){
|
||||||
|
builder.append('b');
|
||||||
|
separator = '+';
|
||||||
|
}else {
|
||||||
|
separator = '-';
|
||||||
|
}
|
||||||
|
if(language!=null){
|
||||||
|
builder.append(separator);
|
||||||
|
builder.append(language);
|
||||||
|
}
|
||||||
|
if(region!=null){
|
||||||
|
builder.append(separator);
|
||||||
|
if(region.length()==2){
|
||||||
|
builder.append('r');
|
||||||
|
}
|
||||||
|
builder.append(region);
|
||||||
|
}
|
||||||
|
if(script!=null){
|
||||||
|
builder.append(separator);
|
||||||
|
builder.append(script);
|
||||||
|
}
|
||||||
|
if(variant!=null){
|
||||||
|
builder.append(separator);
|
||||||
|
builder.append(variant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void appendFlag(ResConfig.Flag flag){
|
||||||
|
if(flag==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mBuilder.append('-').append(flag.toString());
|
||||||
|
}
|
||||||
|
private void appendDp(String prefix, int number){
|
||||||
|
if(number == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuilder builder = this.mBuilder;
|
||||||
|
builder.append('-');
|
||||||
|
if(prefix!=null){
|
||||||
|
builder.append(prefix);
|
||||||
|
}
|
||||||
|
builder.append(number);
|
||||||
|
builder.append("dp");
|
||||||
|
}
|
||||||
|
private void appendNumber(String prefix, int number){
|
||||||
|
if(number == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuilder builder = this.mBuilder;
|
||||||
|
builder.append('-');
|
||||||
|
if(prefix!=null){
|
||||||
|
builder.append(prefix);
|
||||||
|
}
|
||||||
|
builder.append(number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final int SIZE_16 = 16;
|
public static final int SIZE_16 = 16;
|
||||||
public static final int SIZE_28 = 28;
|
public static final int SIZE_28 = 28;
|
||||||
public static final int SIZE_32 = 32;
|
public static final int SIZE_32 = 32;
|
||||||
|
@ -27,27 +27,6 @@ public class ResConfigHelper {
|
|||||||
result.refresh();
|
result.refresh();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static String toQualifier(ResConfig resConfig){
|
|
||||||
StringBuilder builder=new StringBuilder();
|
|
||||||
builder.append(decodeLanguageAndCountry(resConfig));
|
|
||||||
builder.append(decodeOrientation(resConfig));
|
|
||||||
builder.append(decodeScreenLayout(resConfig));
|
|
||||||
builder.append(decodeScreenLayout2(resConfig));
|
|
||||||
builder.append(decodeColorMode(resConfig));
|
|
||||||
builder.append(decodeScreenSize(resConfig));
|
|
||||||
builder.append(decodeDensity(resConfig));
|
|
||||||
builder.append(decodeScreenHeightDp(resConfig));
|
|
||||||
builder.append(decodeSmallestScreenWidthDp(resConfig));
|
|
||||||
builder.append(decodeScreenWidthDp(resConfig));
|
|
||||||
builder.append(decodeNavigation(resConfig));
|
|
||||||
builder.append(decodeUiMode(resConfig));
|
|
||||||
builder.append(decodeTouchscreen(resConfig));
|
|
||||||
builder.append(decodeKeyboard(resConfig));
|
|
||||||
builder.append(decodeInputFlags(resConfig));
|
|
||||||
builder.append(decodeMccMnc(resConfig));
|
|
||||||
builder.append(decodeSdkVersion(resConfig));
|
|
||||||
return sortQualifiers(builder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void parseQualifiers(ResConfig resConfig, String name){
|
static void parseQualifiers(ResConfig resConfig, String name){
|
||||||
if(resConfig == null || name==null){
|
if(resConfig == null || name==null){
|
||||||
@ -259,165 +238,37 @@ public class ResConfigHelper {
|
|||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
private static String decodeLanguageAndCountry(ResConfig resConfig) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
String localeVariant = resConfig.getLocaleVariant();
|
|
||||||
String localeScript = resConfig.getLocaleScript();
|
|
||||||
char[] region=resConfig.getRegionChars();
|
|
||||||
char[] language=resConfig.getLanguageChars();
|
|
||||||
if (localeVariant == null && localeScript == null && (region[0] != '\00' || language[0] != '\00') &&
|
|
||||||
region.length != 3) {
|
|
||||||
builder.append("-").append(language);
|
|
||||||
if (region[0] != '\00') {
|
|
||||||
builder.append("-r").append(region);
|
|
||||||
}
|
|
||||||
} else if(language[0] != 0 || region[0] != 0 || localeScript!=null || localeVariant!=null){
|
|
||||||
builder.append("-b");
|
|
||||||
if (language[0] != '\00') {
|
|
||||||
builder.append('+').append(language);
|
|
||||||
}
|
|
||||||
if (localeScript != null) {
|
|
||||||
builder.append('+').append(localeScript);
|
|
||||||
}
|
|
||||||
if ((region.length == 2 || region.length == 3) && region[0] != '\00') {
|
|
||||||
builder.append('+').append(region);
|
|
||||||
}
|
|
||||||
if (localeVariant != null) {
|
|
||||||
builder.append('+').append(localeVariant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeNavigation(ResConfig resConfig, String[] split){
|
private static void encodeNavigation(ResConfig resConfig, String[] split){
|
||||||
resConfig.setNavigation(ResConfig.Navigation.fromQualifiers(split));
|
resConfig.setNavigation(ResConfig.Navigation.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeNavigation(ResConfig resConfig){
|
|
||||||
StringBuilder ret=new StringBuilder();
|
|
||||||
ResConfig.Navigation navigation = resConfig.getNavigation();
|
|
||||||
if(navigation!=null){
|
|
||||||
ret.append('-').append(navigation);
|
|
||||||
}
|
|
||||||
return ret.toString();
|
|
||||||
}
|
|
||||||
private static void encodeInputFlags(ResConfig resConfig, String[] split){
|
private static void encodeInputFlags(ResConfig resConfig, String[] split){
|
||||||
resConfig.setInputFlagsKeysHidden(ResConfig.InputFlagsKeysHidden.fromQualifiers(split));
|
resConfig.setInputFlagsKeysHidden(ResConfig.InputFlagsKeysHidden.fromQualifiers(split));
|
||||||
resConfig.setInputFlagsNavHidden(ResConfig.InputFlagsNavHidden.fromQualifiers(split));
|
resConfig.setInputFlagsNavHidden(ResConfig.InputFlagsNavHidden.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeInputFlags(ResConfig resConfig){
|
|
||||||
StringBuilder builder=new StringBuilder();
|
|
||||||
ResConfig.InputFlagsKeysHidden keysHidden = resConfig.getInputFlagsKeysHidden();
|
|
||||||
if(keysHidden!=null){
|
|
||||||
builder.append('-').append(keysHidden.toString());
|
|
||||||
}
|
|
||||||
ResConfig.InputFlagsNavHidden navHidden = resConfig.getInputFlagsNavHidden();
|
|
||||||
if(navHidden!=null){
|
|
||||||
builder.append('-').append(navHidden.toString());
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeKeyboard(ResConfig resConfig, String[] split){
|
private static void encodeKeyboard(ResConfig resConfig, String[] split){
|
||||||
resConfig.setKeyboard(ResConfig.Keyboard.fromQualifiers(split));
|
resConfig.setKeyboard(ResConfig.Keyboard.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeKeyboard(ResConfig resConfig){
|
|
||||||
ResConfig.Keyboard keyboard=resConfig.getKeyboard();
|
|
||||||
if(keyboard==null){
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return "-"+keyboard.toString();
|
|
||||||
}
|
|
||||||
private static void encodeDensity(ResConfig resConfig, String[] split){
|
private static void encodeDensity(ResConfig resConfig, String[] split){
|
||||||
resConfig.setDensity(ResConfig.Density.fromQualifiers(split));
|
resConfig.setDensity(ResConfig.Density.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeDensity(ResConfig resConfig){
|
|
||||||
StringBuilder ret=new StringBuilder();
|
|
||||||
ResConfig.Density density=resConfig.getDensity();
|
|
||||||
if(density!=null){
|
|
||||||
ret.append('-').append(density.toString());
|
|
||||||
}
|
|
||||||
return ret.toString();
|
|
||||||
}
|
|
||||||
private static void encodeTouchscreen(ResConfig resConfig, String[] split){
|
private static void encodeTouchscreen(ResConfig resConfig, String[] split){
|
||||||
resConfig.setTouchscreen(ResConfig.Touchscreen.fromQualifiers(split));
|
resConfig.setTouchscreen(ResConfig.Touchscreen.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeTouchscreen(ResConfig resConfig){
|
|
||||||
StringBuilder ret=new StringBuilder();
|
|
||||||
ResConfig.Touchscreen touchscreen=resConfig.getTouchscreen();
|
|
||||||
if(touchscreen!=null){
|
|
||||||
ret.append('-').append(touchscreen.toString());
|
|
||||||
}
|
|
||||||
return ret.toString();
|
|
||||||
}
|
|
||||||
private static void encodeUiMode(ResConfig resConfig, String[] split){
|
private static void encodeUiMode(ResConfig resConfig, String[] split){
|
||||||
resConfig.setUiModeNight(ResConfig.UiModeNight.fromQualifiers(split));
|
resConfig.setUiModeNight(ResConfig.UiModeNight.fromQualifiers(split));
|
||||||
resConfig.setUiModeType(ResConfig.UiModeType.fromQualifiers(split));
|
resConfig.setUiModeType(ResConfig.UiModeType.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeUiMode(ResConfig resConfig){
|
|
||||||
StringBuilder ret=new StringBuilder();
|
|
||||||
ResConfig.UiModeType uiModeType = resConfig.getUiModeType();
|
|
||||||
if(uiModeType!=null){
|
|
||||||
ret.append('-').append(uiModeType.toString());
|
|
||||||
}
|
|
||||||
ResConfig.UiModeNight uiModeNight = resConfig.getUiModeNight();
|
|
||||||
if(uiModeNight!=null){
|
|
||||||
ret.append('-').append(uiModeNight.toString());
|
|
||||||
}
|
|
||||||
return ret.toString();
|
|
||||||
}
|
|
||||||
private static void encodeOrientation(ResConfig resConfig, String[] split){
|
private static void encodeOrientation(ResConfig resConfig, String[] split){
|
||||||
resConfig.setOrientation(ResConfig.Orientation.fromQualifiers(split));
|
resConfig.setOrientation(ResConfig.Orientation.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeOrientation(ResConfig resConfig){
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
ResConfig.Orientation orientation=resConfig.getOrientation();
|
|
||||||
if(orientation!=null){
|
|
||||||
builder.append('-').append(orientation);
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeScreenLayout(ResConfig resConfig, String[] split){
|
private static void encodeScreenLayout(ResConfig resConfig, String[] split){
|
||||||
resConfig.setScreenLayoutSize(ResConfig.ScreenLayoutSize.fromQualifiers(split));
|
resConfig.setScreenLayoutSize(ResConfig.ScreenLayoutSize.fromQualifiers(split));
|
||||||
resConfig.setScreenLayoutLong(ResConfig.ScreenLayoutLong.fromQualifiers(split));
|
resConfig.setScreenLayoutLong(ResConfig.ScreenLayoutLong.fromQualifiers(split));
|
||||||
resConfig.setScreenLayoutDir(ResConfig.ScreenLayoutDir.fromQualifiers(split));
|
resConfig.setScreenLayoutDir(ResConfig.ScreenLayoutDir.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeScreenLayout(ResConfig resConfig){
|
|
||||||
StringBuilder builder=new StringBuilder();
|
|
||||||
ResConfig.ScreenLayoutSize layoutSize = resConfig.getScreenLayoutSize();
|
|
||||||
if(layoutSize!=null){
|
|
||||||
builder.append('-').append(layoutSize.toString());
|
|
||||||
}
|
|
||||||
ResConfig.ScreenLayoutLong layoutLong = resConfig.getScreenLayoutLong();
|
|
||||||
if(layoutLong!=null){
|
|
||||||
builder.append('-').append(layoutLong.toString());
|
|
||||||
}
|
|
||||||
ResConfig.ScreenLayoutDir layoutDir = resConfig.getScreenLayoutDir();
|
|
||||||
if(layoutDir!=null){
|
|
||||||
builder.append('-').append(layoutDir.toString());
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeScreenLayout2(ResConfig resConfig, String[] split){
|
private static void encodeScreenLayout2(ResConfig resConfig, String[] split){
|
||||||
resConfig.setScreenLayoutRound(ResConfig.ScreenLayoutRound.fromQualifiers(split));
|
resConfig.setScreenLayoutRound(ResConfig.ScreenLayoutRound.fromQualifiers(split));
|
||||||
}
|
}
|
||||||
private static String decodeScreenLayout2(ResConfig resConfig){
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
ResConfig.ScreenLayoutRound layoutRound = resConfig.getScreenLayoutRound();
|
|
||||||
if(layoutRound!=null){
|
|
||||||
builder.append('-').append(layoutRound.toString());
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static String decodeColorMode(ResConfig resConfig){
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
ResConfig.ColorModeWide colorModeWide = resConfig.getColorModeWide();
|
|
||||||
if(colorModeWide!=null){
|
|
||||||
builder.append('-').append(colorModeWide.toString());
|
|
||||||
}
|
|
||||||
ResConfig.ColorModeHdr colorModeHdr = resConfig.getColorModeHdr();
|
|
||||||
if(colorModeHdr!=null){
|
|
||||||
builder.append('-').append(colorModeHdr.toString());
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeColorMode(ResConfig resConfig, String[] split){
|
private static void encodeColorMode(ResConfig resConfig, String[] split){
|
||||||
resConfig.setColorModeWide(ResConfig.ColorModeWide.fromQualifiers(split));
|
resConfig.setColorModeWide(ResConfig.ColorModeWide.fromQualifiers(split));
|
||||||
resConfig.setColorModeHdr(ResConfig.ColorModeHdr.fromQualifiers(split));
|
resConfig.setColorModeHdr(ResConfig.ColorModeHdr.fromQualifiers(split));
|
||||||
@ -469,36 +320,6 @@ public class ResConfigHelper {
|
|||||||
}
|
}
|
||||||
resConfig.setMnc(sh);
|
resConfig.setMnc(sh);
|
||||||
}
|
}
|
||||||
private static String decodeMccMnc(ResConfig resConfig){
|
|
||||||
int mcc=resConfig.getMcc();
|
|
||||||
int mnc=resConfig.getMnc();
|
|
||||||
int size=resConfig.getConfigSize();
|
|
||||||
StringBuilder ret = new StringBuilder();
|
|
||||||
if (mcc != 0) {
|
|
||||||
ret.append("-mcc").append(String.format("%03d", mcc));
|
|
||||||
if (mnc != -1) {
|
|
||||||
if (mnc != 0) {
|
|
||||||
ret.append("-mnc");
|
|
||||||
if (size <= 32) {
|
|
||||||
if (mnc > 0 && mnc < 10) {
|
|
||||||
ret.append(String.format("%02d", mnc));
|
|
||||||
} else {
|
|
||||||
ret.append(String.format("%03d", mnc));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret.append(mnc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret.append("-mnc00");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mnc != 0) {
|
|
||||||
ret.append("-mnc").append(mnc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret.toString();
|
|
||||||
}
|
|
||||||
private static void encodeSmallestScreenWidthDp(ResConfig resConfig, String[] split){
|
private static void encodeSmallestScreenWidthDp(ResConfig resConfig, String[] split){
|
||||||
int val=0;
|
int val=0;
|
||||||
for(int i=0;i<split.length;i++){
|
for(int i=0;i<split.length;i++){
|
||||||
@ -516,16 +337,6 @@ public class ResConfigHelper {
|
|||||||
}
|
}
|
||||||
resConfig.setSmallestScreenWidthDp((short)val);
|
resConfig.setSmallestScreenWidthDp((short)val);
|
||||||
}
|
}
|
||||||
private static String decodeSmallestScreenWidthDp(ResConfig resConfig){
|
|
||||||
int smallestScreenWidthDp=resConfig.getSmallestScreenWidthDp();
|
|
||||||
StringBuilder builder=new StringBuilder();
|
|
||||||
if(smallestScreenWidthDp!=0){
|
|
||||||
builder.append("-sw");
|
|
||||||
builder.append(smallestScreenWidthDp);
|
|
||||||
builder.append("dp");
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeScreenHeightDp(ResConfig resConfig, String[] split){
|
private static void encodeScreenHeightDp(ResConfig resConfig, String[] split){
|
||||||
int val=0;
|
int val=0;
|
||||||
for(int i=0;i<split.length;i++){
|
for(int i=0;i<split.length;i++){
|
||||||
@ -547,16 +358,6 @@ public class ResConfigHelper {
|
|||||||
}
|
}
|
||||||
resConfig.setScreenHeightDp((short)val);
|
resConfig.setScreenHeightDp((short)val);
|
||||||
}
|
}
|
||||||
private static String decodeScreenHeightDp(ResConfig resConfig){
|
|
||||||
int screenHeightDp=resConfig.getScreenHeightDp();
|
|
||||||
StringBuilder builder=new StringBuilder();
|
|
||||||
if(screenHeightDp!=0){
|
|
||||||
builder.append("-h");
|
|
||||||
builder.append(screenHeightDp);
|
|
||||||
builder.append("dp");
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeScreenWidthDp(ResConfig resConfig, String[] split){
|
private static void encodeScreenWidthDp(ResConfig resConfig, String[] split){
|
||||||
int val=0;
|
int val=0;
|
||||||
for(int i=0;i<split.length;i++){
|
for(int i=0;i<split.length;i++){
|
||||||
@ -578,16 +379,6 @@ public class ResConfigHelper {
|
|||||||
}
|
}
|
||||||
resConfig.setScreenWidthDp((short)val);
|
resConfig.setScreenWidthDp((short)val);
|
||||||
}
|
}
|
||||||
private static String decodeScreenWidthDp(ResConfig resConfig){
|
|
||||||
int screenWidthDp=resConfig.getScreenWidthDp();
|
|
||||||
StringBuilder builder=new StringBuilder();
|
|
||||||
if(screenWidthDp!=0){
|
|
||||||
builder.append("-w");
|
|
||||||
builder.append(screenWidthDp);
|
|
||||||
builder.append("dp");
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static void encodeSdkVersion(ResConfig resConfig, String[] split){
|
private static void encodeSdkVersion(ResConfig resConfig, String[] split){
|
||||||
int val=0;
|
int val=0;
|
||||||
for(int i=0;i<split.length;i++){
|
for(int i=0;i<split.length;i++){
|
||||||
@ -605,27 +396,6 @@ public class ResConfigHelper {
|
|||||||
}
|
}
|
||||||
resConfig.setSdkVersion((short)val);
|
resConfig.setSdkVersion((short)val);
|
||||||
}
|
}
|
||||||
private static String decodeSdkVersion(ResConfig resConfig){
|
|
||||||
int sdkVersion=resConfig.getSdkVersion();
|
|
||||||
StringBuilder builder=new StringBuilder();
|
|
||||||
if(sdkVersion!=0){
|
|
||||||
builder.append("-v");
|
|
||||||
builder.append(sdkVersion);
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
private static String decodeScreenSize(ResConfig resConfig){
|
|
||||||
int width=resConfig.getScreenWidth();
|
|
||||||
int height=resConfig.getScreenHeight();
|
|
||||||
if(width==0||height==0){
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (width > height) {
|
|
||||||
return String.format("%dx%d", width, height);
|
|
||||||
} else {
|
|
||||||
return String.format("%dx%d", height, width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static void encodeScreenSize(ResConfig resConfig, String[] split){
|
private static void encodeScreenSize(ResConfig resConfig, String[] split){
|
||||||
for(int i=0;i<split.length;i++){
|
for(int i=0;i<split.length;i++){
|
||||||
String s=split[i];
|
String s=split[i];
|
||||||
@ -703,13 +473,6 @@ public class ResConfigHelper {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private static boolean isDecimal(String str){
|
|
||||||
if(str==null){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Matcher matcher=PATTERN_NUMBER.matcher(str);
|
|
||||||
return matcher.find();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Pattern PATTERN_SDK_VERSION=Pattern.compile("^-?v([0-9]+)$");
|
private static final Pattern PATTERN_SDK_VERSION=Pattern.compile("^-?v([0-9]+)$");
|
||||||
|
|
||||||
@ -727,8 +490,6 @@ public class ResConfigHelper {
|
|||||||
|
|
||||||
private static final Pattern PATTERN_MCC_MNC=Pattern.compile("^(m[cn]c)([0-9]{2,3})$");
|
private static final Pattern PATTERN_MCC_MNC=Pattern.compile("^(m[cn]c)([0-9]{2,3})$");
|
||||||
|
|
||||||
private static final Pattern PATTERN_NUMBER=Pattern.compile("^[0-9]+$");
|
|
||||||
|
|
||||||
private static final Pattern PATTERN_SCREEN_SIZE=Pattern.compile("^-?([0-9]+)x([0-9]+)$");
|
private static final Pattern PATTERN_SCREEN_SIZE=Pattern.compile("^-?([0-9]+)x([0-9]+)$");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user